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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,894 次查看
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!

标签 (1)
标记 (4)
0 项奖励
回复
3 回复数

1,199 次查看
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

1,200 次查看
drqubit
Contributor II

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

0 项奖励
回复

1,200 次查看
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.