Function runs within RAM with parameters

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Function runs within RAM with parameters

819 Views
OliverTian
NXP Employee
NXP Employee

Sometimes, OEMs asked suppliers to run bootloader within RAM only. This needs some functions should be called with parameters. This method will help you to achieve it.

 

General steps are as the follows

1. Defined the section of RAM as the location where functions should be run within

2. Move functions into RAM

3. Call the functions with parameters through pointer function.

 

Details could be found at attachment. 

 

"Good good study, day day up."

 

Original Attachment has been moved to: S12G128_23_RAMFunc_00.zip

0 Kudos
1 Reply

433 Views
RadekS
NXP Employee
NXP Employee

Hi Oliver,

Thank you for your guide.

The general steps are correct, but it might be also managed slightly simple way.

 

The functions which should be executed from RAM may be defined directly at RAM by #pragma CODE_SEG linker command.

In that case, the function's code is loaded into RAM automatically during Startup() and you may call them directly.

See attached example code (I used your code as a template).

 

The approach from you is better in the case when we use these functions only occasionally – the load into RAM is executed only at request and it does not consume execution time during every MCU reset/startup.

The next potential advantage is that RAM dedicated for functions may be used as temp memory buffer when we do not need these functions in RAM or we may load an only predefined set of functions per our request. This may help with decreasing memory size requirements.

The calling through pointer function may be also used for calling a function which is not compiled directly into our code (call bootloader functions from the application or opposite).

 

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos