ARM Technical Support Knowledge Articles

COPYING FUNCTIONS TO RAM FOR EXECUTION

Applies to: C251 C Compiler

Answer


Information in this article applies to:


QUESTION

I wish to copy some C functions to RAM from Flash memory so they can be executed there while I erase my Flash. How can this be achieved? Reassigning a function pointer does not work.

ANSWER

The only way to achieve this is with the following steps:

  1. Place your C functions to be copied into a seperate source file and add
    #pragma SRC
    
  2. Compile to generate the optimized assembly code for the C functions.
  3. Edit the assembly code so the functions are completely relocatable. Absolute addresses must NOT be used.
  4. Write a custom copying routine to copy the assembly functions from Flash to RAM.

Reassigning a function pointer will simply make the pointer point to a new area of memory. The function will not be copied.

MORE INFORMATION

Article last edited on: 2005-07-15 12:19:40

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential