Forums

One APP from flash, one APP from RAM

Started by more_effective May 25, 2004
Hi everybody again:

We work with LPC2104, & Keil uVision3 (with GNU tools).

Let's suppose we have a big APP, compiled and linked to be executed
from FLASH.
Let's suppose we have a little APP (really a loader of the big APP),
compiled and linked to be executed from RAM.

Now, how can we download the little APP to Flash, when it's expected
to be executed from RAM?
Or can we modify ELF file to add the convenient offset (as it could
be easily done with an HEX file)?
Or is possible to download an HEX file with Keil IDE?
Or are we missing anything?

Thanks in advance!
-.-WOLFISH-.-



An Engineer's Guide to the LPC2100 Series

At 05:30 PM 5/25/04 +0000, you wrote:
>Hi everybody again:
>
>We work with LPC2104, & Keil uVision3 (with GNU tools).
>
>Let's suppose we have a big APP, compiled and linked to be executed
>from FLASH.
>Let's suppose we have a little APP (really a loader of the big APP),
>compiled and linked to be executed from RAM.
>
>Now, how can we download the little APP to Flash, when it's expected
>to be executed from RAM?
>Or can we modify ELF file to add the convenient offset (as it could
>be easily done with an HEX file)?
>Or is possible to download an HEX file with Keil IDE?
>Or are we missing anything?

Modify the linker file (ld) so that the RAM based code is located as normal
but placed in flash. It's the same process that is used to set initialized
global variables in RAM. You can then copy from flash to RAM in your main
app or in the startup.

You'll need something like

/* Ram program data, located in ram but a copy is placed */
/* in flash so it can be used to init the ram on startup. */
.ram_prog : {
__ram_prog_beg__ = .; /* Used by startup. */
__ram_prog_beg_src__ = __end_of_text__; /* Used by startup. */
*(.ram_prog) /* --A-- Actual
program segments */
__ram_prog_end__ = .; /* Used by startup. */
} >ram AT>flash

You'll need to RTFM to find out how to name the program segments in the
compiler (see --A--) above. And verify against your existing linker file
to make sure you have all the pieces placed.

Another possibility would be to create the RAM version as a separate
program and convert it's binary image into a constant in the main flash
based program eg

const unsigned char ram_prog[] = { 0, 1, 5, 9, 3, .....};

and do a memcpy when needed.

Robert " 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III