Skip to main content
Graduate II
September 2, 2025
Solved

Place constant at end of used flash - not specific address

  • September 2, 2025
  • 23 replies
  • 1047 views

Heyho,

how can I put a constant at the end of the STM32's used flash? (using: STM32CubeIDE)

Not at a specific address (that's not a problem), but I'd like to have a constant always at the end of the used internal flash, independent of any other source code changes.

I just find that there's some ASCII characters = "ASCII" (twice) and lots of 0x00 at the end of my H7 and F7 bin files - that from my sources or placed by CubeIDE?

 

Thanks!

    This topic has been closed for replies.
    Best answer by mfgkw

    In the linker script (*.ld) you can define a new section (e.g. "EOF") and place it behind FLASH place it as last entry in FLASH.

    When you declare your const variable with __attribute__((section("EOF"))) you should be done.

    23 replies

    Visitor II
    September 3, 2025

    As you try to do.. or  directly  in linker script, 

    Your problem is interesting becose it should work.  I done many thinks (also similar) in my projects without any problems. 

    At this point data that should be placed in that section exist in hex file? are at end of flash? 

    PS.  this data also should be const.  (this section is placed in (rx) memory region type.

    LCEAuthor
    Graduate II
    September 3, 2025

    It actually works since yesterday when I put it at the and of the sections in the linker file.

    Problem seems to be only the *.elf file - or so I thought.

    But it mostly seems to be that STM32CubeProgrammer thinks it's bad and gives warnings.
    BUT it still programs correctly, which I thought until now was not the case.

    Now I just have to make a note for the production guys to ignore these warnings, otherwise problem solved.

    Thanks again!

    Visitor II
    September 3, 2025

    simple use hex file for that ;) no problem at  all. 

     

    show log from cubeprog after opening you elf.file.