Skip to main content
MHast.1
Associate II
June 3, 2022
Question

Storing const value to ROM

  • June 3, 2022
  • 1 reply
  • 1029 views

Hello, is there a way to instruct the compiler to place a const value at a specific address in flash memory? On another toolchain I was able to use

const char array1[4] = {1,2,3,4} absolute 0x9D008000; // stored at flash address 0x9D008000

If not, is there another way to control the .hex file output in code. Thanks

Using STM32CubeIDE, gcc

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    June 3, 2022

    Why?

    You should really do this address level stuff in the linker, via sections in the linker script or scatter file.

    Or think of better ways to do it that don't rely on absolute or AT address directives. ie have some abstraction or indirect methods of finding a structure,for example a reference in an unused vector table entry, or some file system or structured storage method for resources. Then pass the data via a pointer.

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