Difference between revisions of "Place Functions in RAM with SEGGER Linker"

From SEGGER Wiki
Jump to: navigation, search
(Prerequisites)
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
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.
 
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 function you want to place in RAM
 
* Create a function you want to place in RAM
Line 23: Line 23:
 
For more information see the SEGGER Linker reference manual [http://studio.segger.com/segger/UM20005_Linker.pdf UM20005]
 
For more information see the SEGGER Linker reference manual [http://studio.segger.com/segger/UM20005_Linker.pdf UM20005]
   
= Example project=
+
== 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.
 
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 ==
+
=== Prerequisites ===
 
To be able to build and debug the project the following prerequisites must be met:
 
To be able to build and debug the project the following prerequisites must be met:
   
* SEGGER Embedded Studio V4.52c or later
+
* SEGGER Embedded Studio V7.32 or later
 
* Any J-Link
 
* Any J-Link
 
* [https://shop.segger.com/Cortex_M_Trace_Reference_Board_p/6.68.18.htm Cortex-M Trace Reference Board]
 
* [https://shop.segger.com/Cortex_M_Trace_Reference_Board_p/6.68.18.htm Cortex-M Trace Reference Board]
   
== Project files ==
+
=== Project files ===
 
[[Media:RAMFunc_Example.zip|RAMFunc_Example.zip]]
 
[[Media:RAMFunc_Example.zip|RAMFunc_Example.zip]]

Latest revision as of 10:18, 31 August 2023

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 your application source code:
void __attribute((section(".ramfunc"))) MyFunc(void) {
  ...
}
  • Alternatively you can place symbols directly in the SEGGER Linker script file as shown in the example project linked below
  • 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 };

For more information see the SEGGER Linker reference manual UM20005

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:

Project files

RAMFunc_Example.zip