I am programming the STM32fM4 Discovery board with a Cortex M4F ARM CPU. I have two large tables, which, after the initialization, are just read-only. I would like to place them in Flash memory, to free some RAM.
I tried this :
float sintab[8192] __attribute__((at(0x08010000))); float costab[8192] __attribute__((at(0x08018000)));
but the linker complains with this error message :
Error: L6985E: Unable to automatically place AT section main.o(.ARM.__AT_0x08010000) with required base address 0x08010000. Please manually place in the scatter file using the --no_autoat option.
I am not particularly expert of this compiler/linker, so the above message is not much clear to me. Could please somebody explains how to accomplish what I want ? I don't know what a scatter file is, nor how to code one to relocate in Flash memory my two tables.
Thanks
That's puzzling. Are you saying that you are going to initialize them at run time?
Thanks for the answer. Yes, they are initialized at run time, as the contents depend on some conditions. So cannot fill them at compile time. Is there any way to have them allocated in Flash memory, where they will be written just once, and then only read ?
Thanks.
You would have to erase the flash and write the tables there, using the FLASH_xxx API provided by the STM32 library, or equivalent routines you have created.
You could use your tables float *sintab = (float *)0x08010000; float *costab = (float *)0x08018000;
Yes, this compiles and links without errors. But do I still need to first erase the Flash ? Those address are above the area used by my code (which is placed by the linker at 0x8000000), and the loader does an erase when loading the program in memory.
Can I programmatically write to those locations with a simple instruction, like, e.g.
sintab[k] = <some float value>;
I seem to recall having read that writing to Flash was a bit more involved... Until yesterday I have programmed Pentium CPUs, where things are a bit different.