Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Execute Code in RAM?

2005-03-11 by Michael Anburaj

Arvid,

As somebody said it depends on the tool-chain.

Method 1: Different Load & execute address (liner
script method)

ARM tools (ADS or SDT):

Create a scatter map file much like the following:

flash 0x00000000 0x00020000
{
	TEXT +0
	{
		*(+RO)
	}

	LOADTEXT 0x40001000
	{
		flashlib.o
	}
}

Where LOADTEXT is the section which will contain the
flashlib.o object (The object which you want to run
out of RAM). Now that in the link step use this
scatter map & the linker would link this object
(flashlib.o) for RAM address 0x40001000, but load it
in flash following the .text (or) RO regions of other
objects when creating the executable
(elf/axf/bin/hex/srec).

And the linker (ADS or SDT) would provide the
following run-time variables. And it is the
responsibility of the run-time code/writer to move the
code from ROM to RAM:

Load$$LOADTEXT$$Base        -- Address in ROM
Image$$LOADTEXT$$Base       -- Address in RAM
Image$$LOADTEXT$$Length     -- Length to be copied

These variables should be used to copy the code from
flash to RM at run-time (done either at the startup
assembly code or in C code initializing this library).

And you call the function just like any other
function. And the call will be made to the copied
location in RAM

myflashlibfunction(); /* this should call the function
in RAM */

The same idea can be used in GCC using linker scripts.


Method 2: PIC (position independent code)

1. compile this particular code (which needs to run
out of RAM) as PIC -- check the right flags in the
compiler manual.

2. Then just as you explained, do the things to move
the code to RAM. Since, its PIC code, it can run from
any location.

Call the function as someone explained -- using
function pointers.

Cheers,
-Mike.

--- ateichtmann <arvid_teichtmann@...> wrote:
> 
> Hi,
> 
> for an in-system update of the firmware i have the
> following idea:
> 1. store the new firmware in an external serial
> flash
> 2. allocate memory in RAM with malloc() for the
> update function
> 3. copy update-function from ROM to RAM
> 4. call update-function in RAM
> 5. update-function copies firmware from external
> serial flash to 
> internal flash with IAP commands
> 
> My question is, how code can be executed in RAM.
> How can i call a function in RAM?
> Thanks for all hints.
> 
> Regards
> Arvid
> 
> 
> 
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.