how to copy code from ROM to RAM and run it in MKL05z32 and cw10.6?

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

how to copy code from ROM to RAM and run it in MKL05z32 and cw10.6?

1,547 Views
wangbaode
Contributor IV

dear,

I want to copy code from ROM to RAM and run it in MKL05z32. my software is cw10.6.

please help me!

Labels (1)
Tags (4)
0 Kudos
Reply
3 Replies

852 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

hello Ivan.

I suggest you check this document

Relocating Code and Data Using the CW GCC Linker File for Kinetis

it includes how to copy code from ROM to RAM

============================================

this answer is for you. if it helps, please click on "Correct Answer " button. thanks!

Best Regards.

Zhang Jun

853 Views
drqubit
Contributor II

I think wang baode means copy. Not link the code in RAM space.

0 Kudos
Reply

853 Views
drqubit
Contributor II

Hello.

You can easily copy it using memcpy.

Take a look at this code snippet:

void romFunction (void)

{

     //Do your stuff

};

void main (void)

{

  uint8_t ramSpace[1000];

  memcpy (ramSpace,romFunction,1000); //Don't care if you copy more code than needed. After function return, no code will be executed

  void (*ramFunction)(void)=(void (*)(void))ramSpace;

  ramFunction();

}

Regards.