2023-05-06 07:10 AM - edited 2023-11-20 06:16 AM
Hi, I have an ELF file modified to write to the main memory address 0x08004000 instead of 0x08000000. Please find the screenshot below and the ELF file in the attachment.
But instead of writing to 0x08004000 it constantly writes to 0x08000000. Why is this happening?
Solved! Go to Solution.
2023-05-08 09:38 PM - edited 2023-11-20 06:16 AM
Hi @bob S thanks for the answer. I tried editing as below
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector_new :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
And found it updated in the ELF file as well as the MAP file below
ELF file: readelf -S blink_50ms.elf
MAP file: blink_50ms.map
A quick search shows it updated in the MAP file as well
Please guide me further.
2023-05-09 06:29 AM
OK - so what happens when you try to program that file with CubeProgrammer?
2023-05-09 10:57 AM - edited 2023-11-20 06:17 AM
@bob S the same as mentioned earlier
Please find the same in STM32CubeProgrammer GUI
From address 0x08000000
From address 0x08004000
2023-05-09 11:14 AM
How are you loading the ELF? It looks like it was loaded as a raw binary file (see the "ELF" text at 0x08000000). When I load ELF files I get messages in the log pane like:
14:10:01 Number of segments: 2
14:10:01 segment(0): address= 0x8000000, size=0x2FF00
14:10:01 segment(1): address 0x2000014c, size=0x0
BTW - I don't usually use ELF files for programming. I use hex or binary. Mostly because of many decades of habit with CPUs/compilers that don't support ELF.
2023-05-09 11:29 AM
ST linker scripts are not properly engineered.
See this link to fix yours
2023-05-09 11:38 AM
2023-05-09 01:41 PM
What do the Program Headers of the .ELF look
You look to have written the ELF directly too 0x08000000 as if it were a binary, that might be a STM32 Cube Programmer failing.
Suggest converting .ELF to .HEX and writing that.
The Program Headers shouldn't be pointing to 0x08000000 unless there's some grave error with the tools.
I'm sure the versions I'm using don't so perhaps a recent issue.
2023-05-09 01:45 PM
Wow, that seems borderline ret***ed on the the part of the LINKER to make assumptions when addresses are actually furnished, and encountered before the sections directing the data..
2023-05-09 01:59 PM
This is my post there, I spent a lot of time to fix it.
I suspect (gnu) linker has some problems too (not joining segments correctly especially if you put more flash data after .data section) but this is other topic. However, setting PHDR will solve the initial problem, STCube Programmer will correct load & program from ELF file as expected.
2023-05-09 11:51 PM - edited 2023-11-20 06:17 AM
Hi @Community member, please find the program headers
I will try converting .ELF to .HEX
Is there a direct way to change the STM32CubeIDE configuration to produce .HEX instead of .ELF?