Difference between revisions of "Place Functions in RAM with SEGGER Linker"
(→How to) |
|||
Line 1: | Line 1: | ||
[[Category:Embedded Studio]] |
[[Category:Embedded Studio]] |
||
− | This article will show how to place a function into RAM with SEGGER Linker and Embedded Studio. |
+ | This article will show how to place a function into RAM with SEGGER Linker and Embedded Studio. To make sure this stays valid after a reset/reboot of the device the function must be initialized during startup by copying them from Flash to RAM. That way the application also works stand alone without a debugger. |
= How to= |
= How to= |
||
− | * Create a |
+ | * Create a function you want to place in RAM |
− | * Open the SEGGER Linker script file and place the specific |
+ | * Open the SEGGER Linker script file and place the specific function symbol in a section. This can be done e.g. as follows in source: |
<pre> |
<pre> |
||
+ | void __attribute((section(".ramfunc"))) MyFunc(void) { |
||
− | place in RAM1 {symbol MySymbol}; |
||
+ | ... |
||
+ | } |
||
</pre> |
</pre> |
||
+ | * Now place the section in the linker script in RAM |
||
− | * This can be done by adding the following line to the remaining "initialize by copy entries". |
||
<pre> |
<pre> |
||
− | + | place in RAM { section .ramfunc }; |
|
+ | </pre> |
||
+ | * Now make sure it is initialized by copy even without a debugger |
||
+ | <pre> |
||
+ | initialize by copy { section .ramfunc }; |
||
</pre> |
</pre> |
||
Revision as of 17:03, 17 June 2020
This article will show how to place a function into RAM with SEGGER Linker and Embedded Studio. To make sure this stays valid after a reset/reboot of the device the function must be initialized during startup by copying them from Flash to RAM. That way the application also works stand alone without a debugger.
How to
- Create a function you want to place in RAM
- Open the SEGGER Linker script file and place the specific function symbol in a section. This can be done e.g. as follows in source:
void __attribute((section(".ramfunc"))) MyFunc(void) { ... }
- Now place the section in the linker script in RAM
place in RAM { section .ramfunc };
- Now make sure it is initialized by copy even without a debugger
initialize by copy { section .ramfunc };
Example project
The following example project will show an example implementation of such RAM function. A simple function Count() is created which is placed in RAM and executed.
Prerequisites
To be able to build and debug the project the following prerequisites must be met:
- SEGGER Embedded Studio V4.52c or later
- Any J-Link
- Cortex-M Trace Reference Board