cancel
Showing results for 
Search instead for 
Did you mean: 

Storing const value to ROM

MHast.1
Associate II

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

1 REPLY 1

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
Up vote any posts that you find helpful, it shows what's working..