cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer is writing to the wrong memory address for the given ELF file

newbie_stm32
Associate III

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.


_legacyfs_online_stmicro_images_0693W00000bjWLTQA2.pngBut instead of writing to 0x08004000 it constantly writes to 0x08000000. Why is this happening?

26 REPLIES 26

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


_legacyfs_online_stmicro_images_0693W00000bjeR0QAI.png 

MAP file: blink_50ms.map

A quick search shows it updated in the MAP file as well


_legacyfs_online_stmicro_images_0693W00000bjeRAQAY.png 

Please guide me further.

OK - so what happens when you try to program that file with CubeProgrammer?

@bob S​ the same as mentioned earlier


_legacyfs_online_stmicro_images_0693W00000bjiKhQAI.png  

Please find the same in STM32CubeProgrammer GUI

From address 0x08000000


_legacyfs_online_stmicro_images_0693W00000bjiJyQAI.png 

From address 0x08004000
_legacyfs_online_stmicro_images_0693W00000bjiKDQAY.png

Bob S
Principal

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.

yo3hcv
Associate II

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Hi @Community member​, please find the program headers


_legacyfs_online_stmicro_images_0693W00000bjkvkQAA.png 

I will try converting .ELF to .HEX

Is there a direct way to change the STM32CubeIDE configuration to produce .HEX instead of .ELF?