I am using an STM32F439VGTx, which hasflash starting at 0x08000000, length 0x00100000and CCM RAM starting at 0x10000000, length 0x00010000and normal RAM starting at 0x20000000, length 0x00030000I want some of my code and constant data to be in flash,and some code to be executed out of RAM. How can Itell the compiler to compile some functions or modulesto execute in RAM, but place the compiled code in flashso I can copy it to RAM for execution? For example,I might have a function called RamFunc(), which I would likeplaced in RAM at some address, (say 0x20000800 or maybe 0x100000800),but I need the image of it in flash at a known address, say 0x08001000,and a known length so I can copy it to RAM for execution.I have tried many variations of settings in a .sct file, and also triedvarious versions using a Debug_RAM.ini file, as in the CMSIS-RTOS Blinky (MCBSTM32E)example. Nothing has worked for me.Any help would be greatly appreciated.
0) The errors make sense - the scatter loading code must itself execute from a non-moved address (known as a ROOT region). In the above, FLASH_EXEC is a ROOT region, as load address (from the outer braces FLASH) and execution address are the same.There are ordering rules within regions that go beyond the order listed in the scatter file, hence the +FIRST qualifier to force the vector table to be exactly the first thing in that region.
Also, regarding the size of FLASH_EXEC, don't forget that FLASH (load region) also needs space to store the code (and data) that will be relocated to NORMAL_RAM.
1) The * (+RO) will catch all code from objects that are not explicitly referenced elsewhere in the scatter file. You can also use .ANY if you wish to share them in multiple regions.
2) No. It will be amongst "* (+RO)" unless explicitly placed therein.
3) Compare code size - if no data compression, then no need for the code to decompress. I suspect you are referring to just a few bytes.
4) Source is not available. The init sequence is described here:
https://developer.arm.com/documentation/100748/0623/Embedded-Software-Development/Application-startup
Also, some docs on the compression below:
https://developer.arm.com/documentation/101754/0623/armlink-Reference/Linker-Optimization-Features/Optimization-with-RW-data-compression/How-compression-is-applied
Regards, Ronan