Moving a Function to, then Executing from RAM (Kinetis)

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving a Function to, then Executing from RAM (Kinetis)

Jump to solution
13,370 Views
nicholasf
Contributor III

After reading AN4329, I attempted to implement the relocation of a function to internal RAM, but cannot get the compiler to do it.[1]  The only difference between my program and the example is that the "funcInRAM" is located in a different '.c' file, and I believe this is causing the problem.  I have read through some other discussions on this forum which discuss other problems, but not this one.[2][3][4][5]

 

The problem is visible in the xMAP, which shows that "my_ram" (where the function should have been relocated to) is empty.

 

# .my_ram

#>2000C000          ___myRAMStart (linker command file)

#>2000C000          ___myRAMEnd (linker command file)

#>00000000          ___CodeSize (linker command file)

 

The main loop calls the 'funcInRAM()' repeatedly in an infinite loop, and the 'funcInRAM' is defined as follows in a separate file:

 

 

#pragma define_section mySectionInRAM ".myCodeInRAM" far_absolute RX

#pragma section mySectionInRAM begin

 

void funcInRAM(void){

...

}

#pragma section mySectionInRAM end

 

 

I have attached my LCF to this post.

 

I appreciate any help, as I am quite stuck on this.

 

[1] http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4329.pdf

[2] relocating code

[3]relocating code from FLASH to RAM

[4]Re: How to relocate memory library function using #pragma?

[5] How to Copy Function from Flash to RAM & execute it

Original Attachment has been moved to: MK20FX512_flash.lcf.zip

Labels (1)
0 Kudos
1 Solution
366 Views
nicholasf
Contributor III

Hello Jorge,

I resolved the problem a couple of hours ago (and hadn't gotten around to posting the solution yet).  I am not sure what the exact cause was, but it was fixed by manually typing in all the '#pragma' statements, rather than copying and pasting.  If you read some of the other threads on this issue, they mention that copying and pasting from PDF causes an issue with the quotation marks, but this is apparently not the only issue with copying and pasting (I know this because I had manually fixed the quotation marks, and it still did not work).  There must be some issue with the formatting of the text in AN4329, and related application notes, which goes deeper than just the quotation marks.

I would suggest that Freescale create a simple example project with the contents of AN4329, to avoid this kind of thing happening to other developers, as it was quite confusing.

Thanks for your time,
Nicholas F

View solution in original post

0 Kudos
2 Replies
366 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Nicholas:

It seems you are doing the procedure correctly, but there must be some missing reference. Are you declaring the prototype of your function in a header file? Also are you calling such function from your code? If the function is never referenced maybe the linker is being smart and not allocating it.

If possible please share with me your whole project so I can take a look on it.


Regards!,
Jorge Gonzalez

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

367 Views
nicholasf
Contributor III

Hello Jorge,

I resolved the problem a couple of hours ago (and hadn't gotten around to posting the solution yet).  I am not sure what the exact cause was, but it was fixed by manually typing in all the '#pragma' statements, rather than copying and pasting.  If you read some of the other threads on this issue, they mention that copying and pasting from PDF causes an issue with the quotation marks, but this is apparently not the only issue with copying and pasting (I know this because I had manually fixed the quotation marks, and it still did not work).  There must be some issue with the formatting of the text in AN4329, and related application notes, which goes deeper than just the quotation marks.

I would suggest that Freescale create a simple example project with the contents of AN4329, to avoid this kind of thing happening to other developers, as it was quite confusing.

Thanks for your time,
Nicholas F

0 Kudos