This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to relocate tables from RAM to Flash memory

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

Parents Reply Children
  • 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.

    Thanks