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
  • I hope you did not forget about the CCM (core-coupled memory) that is present in STM32F4 MCU's.

    Oh, this is an interesting sentence... Yes, I read on the datasheet of the CPU about the existence of that CCM, but frankly I don't know how to use it, nor if it could be of advantage to me... but from your sentence I presume the answer is yes...

    Would you mind please to spend just a few words about how can I use it, and possibily about which speed advantage I could expect from using it ?

    Thanks

Reply
  • I hope you did not forget about the CCM (core-coupled memory) that is present in STM32F4 MCU's.

    Oh, this is an interesting sentence... Yes, I read on the datasheet of the CPU about the existence of that CCM, but frankly I don't know how to use it, nor if it could be of advantage to me... but from your sentence I presume the answer is yes...

    Would you mind please to spend just a few words about how can I use it, and possibily about which speed advantage I could expect from using it ?

    Thanks

Children
  • Well, it's on-chip RAM. Unlike the rest or the on-chip RAM, it is not connected to the bus matrix, so it cannot be used with DMA, and code cannot be executed from it. But you don't need either of those, and it's good for data tables. Accesses should not involve any delay cycles.
    You use it just like you would use flash memory as described above, only writing to it is just like writing to any RAM. There must be a way to configure the linker to place the tables in the CCM. I just don't have the time to explore this.
    As a shortcut, the following should work (as suggested above):

    float *sintab = (float *)0x10000000;
    float *costab = (float *)0x10008000;
    

  • As a shortcut, the following should work (as suggested above):

    Thanks for the tip, I will surely explore this possibility.
    Seems the ideal place where to put those tables, if the dimension of this CCM will accommodate them.

    TNX