Open nashif opened 7 years ago
by Andrew Boie:
Rajavardhan Gundi and Leandro Pereira this issue will likely affect both of your efforts
by Leandro Pereira:
For the ESP32, the elf binary is converted (using esptool) to an image file that's then used to flash the device at a specific location.
by Andrew Boie:
Leandro Pereira good to know! So this won't affect ESP32. We really ought to have a Kconfig to disable .bin generation for platforms that don't need it.
On the board Rajavardhan Gundi is working on, this may or may not be a problem, we need to know more about the flashing process. Hold off on investigating this until we can determine for sure whether we will even need the .bin file for this case.
by Rajavardhan Gundi:
I had a look at the linker files and as Andrew rightly suspected, the memory defined is huge (more than 500 MB in case of all xtensa SoCs).
by Andrew Boie:
Xtensa .elf layout:
$ objdump -h outdir/qemu_xtensa/zephyr.elf
outdir/qemu_xtensa/zephyr.elf: file format elf32-little
Sections:
Idx Name Size VMA LMA File off Algn
0 .dram1.bss 00000000 3ffc0000 3ffc0000 00003828 2**3
CONTENTS
1 .dram0.bss 00000000 3ffe0000 3ffe0000 00003828 2**3
CONTENTS
2 .WindowVectors.text 0000016a 40000000 40000000 000003b4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .Level2InterruptVector.literal 00000004 40000178 40000178 00000520 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 .Level2InterruptVector.text 00000009 40000180 40000180 00000524 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .Level3InterruptVector.literal 00000004 400001b8 400001b8 00000530 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
6 .Level3InterruptVector.text 00000009 400001c0 400001c0 00000534 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .Level4InterruptVector.literal 00000004 400001f8 400001f8 00000540 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
8 .Level4InterruptVector.text 00000009 40000200 40000200 00000544 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
9 .Level5InterruptVector.literal 00000004 40000238 40000238 00000550 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
10 .Level5InterruptVector.text 00000009 40000240 40000240 00000554 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .DebugExceptionVector.text 00000008 40000280 40000280 00000560 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .NMIExceptionVector.literal 00000004 400002b8 400002b8 00000568 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .NMIExceptionVector.text 00000009 400002c0 400002c0 0000056c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .KernelExceptionVector.literal 00000004 400002f8 400002f8 00000578 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 .KernelExceptionVector.text 00000009 40000300 40000300 0000057c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
16 .UserExceptionVector.literal 00000004 40000338 40000338 00000588 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
17 .UserExceptionVector.text 00000009 40000340 40000340 0000058c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
18 .DoubleExceptionVector.literal 00000004 40000378 40000378 00000598 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
19 .DoubleExceptionVector.text 0000000c 400003c0 400003c0 0000059c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
20 .ResetVector.text 000000b1 50000000 50000000 000005b0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
21 devconfig 00000018 50000300 50000300 00000664 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .rodata 00000610 60000000 60000000 00000680 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
23 .text 000015b3 60000610 60000610 00000c90 2**2
CONTENTS, ALLOC, LOAD, CODE
24 .noinit 00001400 60001bd0 60001bd0 00002250 2**4
CONTENTS, ALLOC, LOAD, DATA
25 .data 000001c0 60002fd0 60002fd0 00003650 2**3
CONTENTS, ALLOC, LOAD, DATA
26 initlevel 00000018 60003190 60003190 00003810 2**2
CONTENTS, ALLOC, LOAD, DATA
27 .bss 000001c0 600031a8 600031a8 00003828 2**3
ALLOC
28 .debug_aranges 000009e0 00000000 00000000 00003828 2**3
CONTENTS, READONLY, DEBUGGING
29 .debug_info 00018f2c 00000000 00000000 00004208 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_abbrev 000044f5 00000000 00000000 0001d134 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_line 00008aa6 00000000 00000000 00021629 2**0
CONTENTS, READONLY, DEBUGGING
32 .debug_frame 00000fd0 00000000 00000000 0002a0d0 2**2
CONTENTS, READONLY, DEBUGGING
33 .debug_str 000033f7 00000000 00000000 0002b0a0 2**0
CONTENTS, READONLY, DEBUGGING
34 .debug_loc 0000573d 00000000 00000000 0002e497 2**0
CONTENTS, READONLY, DEBUGGING
35 .xt.prop 0000192c 00000000 00000000 00033bd4 2**0
CONTENTS, READONLY
36 .xt.lit 00000108 00000000 00000000 00035500 2**0
CONTENTS, READONLY
37 .comment 00000011 00000000 00000000 00035608 2**0
CONTENTS, READONLY
38 .xtensa.info 00000038 00000000 00000000 00035619 2**0
CONTENTS, READONLY
39 .debug_ranges 00000c10 00000000 00000000 00035658 2**3
CONTENTS, READONLY, DEBUGGING
Compare to layout for other arches, here is x86 for example:
apboie@apboie-mobl1:/projects/zephyr/samples/hello_world tickless /projects/zephyr
$ objdump -h outdir/qemu_x86/zephyr.elf
outdir/qemu_x86/zephyr.elf: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 text 00001835 00100000 00100000 00000060 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 devconfig 00000060 00101838 00101838 00001898 2**2
CONTENTS, ALLOC, LOAD, DATA
2 rodata 00000bc8 00101898 00101898 000018f8 2**2
CONTENTS, ALLOC, LOAD, DATA
3 datas 0000002c 00102460 00102460 000024c0 2**2
CONTENTS, ALLOC, LOAD, DATA
4 initlevel 00000060 0010248c 0010248c 000024ec 2**2
CONTENTS, ALLOC, LOAD, DATA
5 bss 000001d8 00102500 00102500 0000254c 2**5
ALLOC
6 noinit 00000d00 001026d8 001026d8 0000254c 2**2
ALLOC
7 .comment 00000011 00000000 00000000 0000254c 2**0
CONTENTS, READONLY
8 .debug_aranges 000009f8 00000000 00000000 00002560 2**3
CONTENTS, READONLY, DEBUGGING
9 .debug_info 0001255f 00000000 00000000 00002f58 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_abbrev 0000532d 00000000 00000000 000154b7 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_line 00005c3b 00000000 00000000 0001a7e4 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_frame 00001ab8 00000000 00000000 00020420 2**2
CONTENTS, READONLY, DEBUGGING
13 .debug_str 0000334e 00000000 00000000 00021ed8 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_ranges 00000f08 00000000 00000000 00025228 2**3
CONTENTS, READONLY, DEBUGGING
15 .debug_loc 00005429 00000000 00000000 00026130 2**0
CONTENTS, READONLY, DEBUGGING
by Andrew Boie:
Setting priority to 'low' for now until we understand the implications of this issue better.
by Rajavardhan Gundi:
This won't affect Suecreek as well. We will just be supplying the ELF file for suecreek too.
by Leandro Pereira:
I think there's a issue with the xtensa linker.
When merging some ESP32 patches, the linker was being aborted with memory exhaustion in the CI server. This was due to the patch that converted the Xtensa port to use gen_isr_table: the IDT_LIST region was added right at the end of the memory space. Moving it to a region closer to where other memory regions are located solved the problem.
The final binary ends up being smaller of course, but here's zephyr_prebuilt.elf with IDT_LIST right after the last mapped memory region:
Roughly 20MiB. And here's the same file, mapped at the end of the memory region.
Over 3GiB (!!). So, even though these are ELF files, it seems that, instead of generating sparse files, there is a lot of garbage being generated between sections.
Reported by Andrew Boie:
Raj noticed that XCC Xtensa builds produce a zephyr.bin hundreds of megabytes in size. This bug has probably been around for a while, to date we have only been using the simulator which uses the .elf files, the Xtensa port has never been booted on real hardware. We're going to need to fix this to run on real hardware since zephyr.bin is the flash image.
(Imported from Jira ZEP-2199)