You have a need to run a complete application in RAM.
This suggestion will only work when downloading with the C-SPY debugger.
If you need to run in RAM stand-alone, then go to Technical Note 11578.
These are the steps needed to get the whole application placed in RAM, and to get it to run as expected in RAM.
- Get data (read/write and constant) and code linked to be placed in RAM.
- Place the Vector Table in RAM (with at least the alignment forced by the Cortex-M design.)
- During C-start-up, set VTOR to the address of the Vector Table.
There are different ways to solve the problem, (so these suggestions are just one possibility).
Place CODE and DATA in RAM.
- Use the "edit"-button (or change directory in your .icf file) at Project > Options > Linker > Config to open the window "Linker configuration file editor"
- Go to the tab "memory regions" - copy the value in RAM/start and paste that value in ROM/start - then copy the value in RAM/end and paste it as ROM/end.
Check that CODE, DATA and Vectors are placed in RAM
Build the project.
- Check (in the .map file) that the Vector Table (symbolic name is __vector_table ) is placed in RAM and at an address that is aligned to 2^7.
- If needed to change go to Project > Options > Linker > Config > tab "Vector table".
- Change to an address in RAM that is aligned to 2^7 (a suggestion is to use address 0x20000000)
Set VTOR RAM
Change VTOR ("Vector Table Offset Register") to point to the location in RAM for the Vector Table (symbolic name __vector_table ).
Build the project.
- Download into the Simulator. Check that VTOR is set to the address of the Vector Table in RAM.
- Change from Simulator to your hardware debugger driver.
- Download to RAM and run the application there.
On the link below there is an example project for STM32F103ZE.
All product names are trademarks or registered trademarks of their respective owners.