cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer Erroneously Programs Empty First Program Segment (From .elf)

pmwpcs
Associate

I've discovered an interesting quirk. When trying to load the elf file with the headers shown below, STM32CubeProgrammer erases the 2kB internal flash page on the STM32G474RE (dual bank mode) at 0x08007000. It then programs in the ELF file header. This sort of makes sense; there is a "hardware information" flash page at 0x08007800. However, it is set to NOLOAD in the linker script, and so there isn't actually any data there. In general, STM32CubeProgrammer does a good job not flashing areas which are NOLOAD, but for whatever reason it decides it simply must have something at 0x08007000 in this case. In fact, if I open the .elf in STM32CubeProg, there is data loaded in the viewer. However, using objcopy to create a binary, ihex, or srec file does not emit this area (rightfully so).

We can work around this issue by using .ihex instead (within STM32CubeIDE GDB sends it down to the STM32G474RE as a temporary .srec) but ideally I should just be able to use the .elf.

STM32CubeProg Console Output

 

16:55:17 : Opening and parsing file: x.elf 16:55:17 : File : x.elf 16:55:17 : Size : 55.84 KB 16:55:17 : Address : 0x08007000 16:55:17 : Erasing memory corresponding to segment 0: 16:55:17 : Erasing internal memory sector 14 16:55:17 : Erasing memory corresponding to segment 1: 16:55:17 : Erasing internal memory sectors [16 43] 16:55:18 : Download in Progress: 16:55:19 : File download complete 16:55:19 : Time elapsed during download operation: 00:00:01.478 16:55:19 : Verifying ... 16:55:19 : Read progress: 16:55:19 : Download verified successfully

 

.elf Headers

 

ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x800c931 Start of program headers: 52 (bytes into file) Start of section headers: 1669368 (bytes into file) Flags: 0x5000400, Version5 EABI, hard-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 8 Size of section headers: 40 (bytes) Number of section headers: 32 Section header string table index: 31 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .hardware_informa NOBITS 08007800 000800 000060 00 A 0 0 4 [ 2] .app_image_header PROGBITS 08008000 001000 000200 00 A 0 0 4 [ 3] .isr_vector PROGBITS 08008200 001200 0001d8 00 A 0 0 1 [ 4] .text PROGBITS 080083d8 0013d8 00d83c 00 AX 0 0 4 [ 5] .rodata PROGBITS 08015c14 00ec14 000508 00 A 0 0 4 [ 6] .ARM.extab PROGBITS 0801611c 00f410 000000 00 W 0 0 1 [ 7] .ARM ARM_EXIDX 0801611c 00f11c 000008 00 AL 4 0 4 [ 8] .preinit_array PREINIT_ARRAY 08016124 00f410 000000 04 WA 0 0 1 [ 9] .init_array INIT_ARRAY 08016124 00f124 000004 04 WA 0 0 4 [10] .fini_array FINI_ARRAY 08016128 00f128 000004 04 WA 0 0 4 [11] .data PROGBITS 20000400 00f400 000010 00 WA 0 0 4 [12] .bss NOBITS 20000410 00f410 001190 00 WA 0 0 4 [13] ._user_heap_stack NOBITS 200015a0 00f5a0 000600 00 WA 0 0 1 [14] .calibration_hw NOBITS 08078000 010000 000208 00 A 0 0 4 [15] .calibration_app NOBITS 0807c000 010000 000208 00 A 0 0 4 [16] .ram_bl2app NOBITS 20000000 010000 000200 00 WA 0 0 4 [17] .ram_app2bl NOBITS 20000200 010200 000200 00 WA 0 0 4 [18] .ARM.attributes ARM_ATTRIBUTES 00000000 00f410 000030 00 0 0 1 [19] .debug_info PROGBITS 00000000 00f440 018f63 00 0 0 1 [20] .debug_abbrev PROGBITS 00000000 0283a3 002fdf 00 0 0 1 [21] .debug_aranges PROGBITS 00000000 02b388 001708 00 0 0 8 [22] .debug_rnglists PROGBITS 00000000 02ca90 0011d4 00 0 0 1 [23] .debug_macro PROGBITS 00000000 02dc64 028553 00 0 0 1 [24] .debug_line PROGBITS 00000000 0561b7 020558 00 0 0 1 [25] .debug_str PROGBITS 00000000 07670f 11580f 01 MS 0 0 1 [26] .comment PROGBITS 00000000 18bf1e 000043 01 MS 0 0 1 [27] .debug_frame PROGBITS 00000000 18bf64 0062f4 00 0 0 4 [28] .debug_line_str PROGBITS 00000000 192258 000061 01 MS 0 0 1 [29] .symtab SYMTAB 00000000 1922bc 003710 10 30 604 4 [30] .strtab STRTAB 00000000 1959cc 001dad 00 0 0 1 [31] .shstrtab STRTAB 00000000 197779 00017d 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), y (purecode), p (processor specific) Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x08007000 0x08007000 0x00134 0x00860 R 0x1000 LOAD 0x001000 0x08008000 0x08008000 0x0e12c 0x0e12c RWE 0x1000 LOAD 0x00f400 0x20000400 0x0801612c 0x00010 0x011a0 RW 0x1000 LOAD 0x0005a0 0x200015a0 0x0801613c 0x00000 0x00600 RW 0x1000 LOAD 0x000000 0x08078000 0x08078000 0x00000 0x00208 R 0x1000 LOAD 0x000000 0x0807c000 0x0807c000 0x00000 0x00208 R 0x1000 LOAD 0x000000 0x20000000 0x20000000 0x00000 0x00200 RW 0x1000 LOAD 0x000200 0x20000200 0x20000200 0x00000 0x00200 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .hardware_information 01 .app_image_header .isr_vector .text .rodata .ARM .init_array .fini_array 02 .data .bss 03 ._user_heap_stack 04 .calibration_hw 05 .calibration_app 06 .ram_bl2app 07 .ram_app2bl
View more

 

 STM32CubeProgrammer .elf Contents

pmwpcs_0-1741989190811.png

 

0 REPLIES 0