전체 응용 프로그램을 RAM에 다운로드하여 실행 (Cortex-M3)
2018-02-28 오전 2:32
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 ).
- Take a copy of the file \arm\src\lib\low_level_init.c and add the coppiced file to your project. (You might need to remove write protection from the file.)
- Add an #include-statement for the device in use. (To get the definition of the register VTOR.)
- Add a declaration for ... extern int __vector_table; ...the Vector Table
- In the function __low_level_init set VTOR to the address of __vector_table, which can be done as:
VTOR = (unsigned int) & __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.