AnsweredAssumed Answered

relocating code from FLASH to RAM

Question asked by sandeepsirpatil on Jun 6, 2013



Code warrior version: 10.3

Processor: MPC5605B


I am trying to relocate a function from flash to RAM and having trouble with the linker. I have made necessary changes as per the App note AN4497. The linker is not obeying the relocation directive and placing the code at memory address of 0x000000.  I have attached the project.


Following the guideline in the appnote (AN4497) i have been successful in relocating a block of data (const data) form flash to RAM. When I try for a function I am having this trouble.


I have tried as suggested in this post (How to Copy Function from Flash to RAM & execute it) and it did not work.


Any help is appreciated.


Sandeep Sirpatil


in  main.c i have the following :

#pragma section ".myCodeInRAM" data_mode=far_abs

__declspec(section ".myCodeInRAM") void serviceWatchdog(void);

void serviceWatchdog(void)


  SWT.SR.R = 0x0000A602; /* Service Watchdog: write 0xA602 followed by 0xB480 */

  SWT.SR.R = 0x0000B480;



in LCF file i have:


internal_ram:     org = 0x40000000,   len = 0x0000D000 /* 56K */  
myram:            org = 0x4000D000,   len = 0x00001000 /* 4K */
heap  :           org = 0x4000E000,   len = 0x00001000 /* 4K */


.my_ram :
} > myram

In the MAP file:


.my_ram section layout

  Starting        Virtual  File

  address  Size   address  offset



.myCodeInRAM section layout

  Starting        Virtual  File

  address  Size   address  offset


  00000000 000022 00000000 00001000  1 .myCodeInRAM     main_c.obj

  00000000 000022 00000000 00001000  2 serviceWatchdog     main_c.obj


Memory map:

     .myCodeInRAM 00000000 00000024 00001000 00003800 00003800     0






Original Attachment has been moved to: