EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Flash program to RAM execution

Started by kohansey May 10, 2007
I have a self-contained module that is apart of a larger program. I
want the module to be compiled with the rest on my program into flash,
and when I am ready to use it, copied to RAM and executed. I am now
should how this would be done.
I read a few posts about using a scatter loading file, but I am using
Keil uVision IDE with RealView (RVCT 3.0) compiler, and I can't seem
to find any examples for how to do this. It has been suggested to
define a section and load the object file into that section, but I am
confused about defining sections (how would I define my self-contained
module to be apart of a section) and how to map that section to RAM
without affecting the rest of the program. If anyone could shine some
light on the subject, it would be a great help.

An Engineer's Guide to the LPC2100 Series

I have a self-contained module that is apart of a larger program. I
want the module to be compiled with the rest on my program into flash,
and when I am ready to use it, copied to RAM and executed. I am now
should how this would be done.
I read a few posts about using a scatter loading file, but I am using
Keil uVision IDE with RealView (RVCT 3.0) compiler, and I can't seem
to find any examples for how to do this. It has been suggested to
define a section and load the object file into that section, but I am
confused about defining sections (how would I define my self-contained
module to be apart of a section) and how to map that section to RAM
without affecting the rest of the program. But I also want to make
sure the module is compiled into flash with the rest of the program.
If anyone could shine some light on the subject, it would be a great help.
Regarding scatter loading, go to ARM website, there is a
app-note how to use scatter load, although, it's a very
old one for SDT2.51, it should apply to both ADS and RVDS.

http://www.arm.com/documentation/Application_Notes/index.html

Tom
--- In l..., "kohansey" wrote:
>
> I have a self-contained module that is apart of a larger program.
I
> want the module to be compiled with the rest on my program into
flash,
> and when I am ready to use it, copied to RAM and executed. I am
now
> should how this would be done.
> I read a few posts about using a scatter loading file, but I am
using
> Keil uVision IDE with RealView (RVCT 3.0) compiler, and I can't
seem
> to find any examples for how to do this. It has been suggested to
> define a section and load the object file into that section, but I
am
> confused about defining sections (how would I define my self-
contained
> module to be apart of a section) and how to map that section to RAM
> without affecting the rest of the program. But I also want to make
> sure the module is compiled into flash with the rest of the
program.
> If anyone could shine some light on the subject, it would be a
great help.
>
Knowledge bases are a good place to look first :-)

Hope that helps!
Darcy

After about a minute of searching...
http://www.keil.com/support/docs/3228.htm

Keywords: ram
Product Family: ARM
Prod Categories: Knowledge Base & App Notes

Item 31.

QUESTION
I convert code from the Keil CARM Compiler to the RealView Compiler. I
need to implement in-system Flash programming on STR710, and since the
device cannot execute code out of flash while I write to it, I need to
execute the function from RAM.

With the CARM Compiler I have used the __ram attribute. How can I
replace this in the RealView compiler? I have tried to use a linker
scatter loading file, but this failed.
ANSWER
Vision allows you to locate modules to specific memory areas that are
entered in the dialog Project - Options - Target. To do so, right
click on a source file (or file group) and open the dialog Options -
Properties. Then select the memory regions under Memory Assignment.

There is an example in the folder \ARM\RV30\Examples\RAM_Function.
MORE INFORMATION
RealView Compilation Tools Introduction - Embedded Programs - Specific
Memory Areas.

--- In l..., "kohansey" wrote:
>
> I have a self-contained module that is apart of a larger program. I
> want the module to be compiled with the rest on my program into flash,
> and when I am ready to use it, copied to RAM and executed. I am now
> should how this would be done.
> I read a few posts about using a scatter loading file, but I am using
> Keil uVision IDE with RealView (RVCT 3.0) compiler, and I can't seem
> to find any examples for how to do this. It has been suggested to
> define a section and load the object file into that section, but I am
> confused about defining sections (how would I define my self-contained
> module to be apart of a section) and how to map that section to RAM
> without affecting the rest of the program. If anyone could shine some
> light on the subject, it would be a great help.
>
In the Keil uVision 3 v3.51:

Help, Open Books Window, Tools User's Guide,
RV Compiler Introduction, Getting Started for ARM,
Embedded Programs, Specific Memory Areas

Regards:

Mike Nelson

--- In l..., "kohansey" wrote:
>
> I have a self-contained module that is apart of a larger program. I
> want the module to be compiled with the rest on my program into flash,
> and when I am ready to use it, copied to RAM and executed. I am now
> should how this would be done.
> I read a few posts about using a scatter loading file, but I am using
> Keil uVision IDE with RealView (RVCT 3.0) compiler, and I can't seem
> to find any examples for how to do this. It has been suggested to
> define a section and load the object file into that section, but I am
> confused about defining sections (how would I define my self-contained
> module to be apart of a section) and how to map that section to RAM
> without affecting the rest of the program. But I also want to make
> sure the module is compiled into flash with the rest of the program.
> If anyone could shine some light on the subject, it would be a great
help.
>
Those are all good answers to get the module to compile into RAM, and
I have already try these things. What you might not understand is
then you tell Keil to put a file into RAM, it does exactly that, but
as soon as you power down the device, you just lost your RAM program
and there is nothing in flash to restore it. So good attempts, but I
have already tried that.

I need to be able to compile the module with the rest of my project
into flash, so that the module will also be available to the device
when needed. That part is easy, just compile normally. But now I
want to take the module that resides in flash, copy it to RAM and
execute it. That is my question, sorry if I had confused anyone.
IAR has an extension in their C/C++ compiler called
"__ramfunc". You put it in your function declaration
and it is stored in flash with the rest of your code.
The function with the "__ramfunc" declaration is copied
to RAM during initialization before the "main" function
is executed. It is linked to run in RAM only, it will
not run properly in its flash storage location.

Does Keil have something similar?

--- In l..., "kohansey" wrote:
>
> Those are all good answers to get the module to compile into RAM, and
> I have already try these things. What you might not understand is
> then you tell Keil to put a file into RAM, it does exactly that, but
> as soon as you power down the device, you just lost your RAM program
> and there is nothing in flash to restore it. So good attempts, but I
> have already tried that.
>
> I need to be able to compile the module with the rest of my project
> into flash, so that the module will also be available to the device
> when needed. That part is easy, just compile normally. But now I
> want to take the module that resides in flash, copy it to RAM and
> execute it. That is my question, sorry if I had confused anyone.
>
I know that the Keil CARM compiler has the __ram keyword that does
something similar, however, I am using the RealView compiler (even
though it is Keil IDE). The keyword __ram doesn't work with the
RealView compiler. One of the previous postees gave a link to scatter
loading, this seems to be the way to go, however, the app-note doesn't
give an example or go into detail about what I am attempted to do, and
it doesn't tell me how to define a section in my C code that is used
with the scatter file. So I am still left in the dark. If anyone has
experience with scatter loading and having a different load and
execution areas, please post an example.
--- In l..., "kohansey" wrote:
>
> I know that the Keil CARM compiler has the __ram keyword that does
> something similar, however, I am using the RealView compiler (even
> though it is Keil IDE). The keyword __ram doesn't work with the
> RealView compiler. One of the previous postees gave a link to scatter
> loading, this seems to be the way to go, however, the app-note doesn't
> give an example or go into detail about what I am attempted to do, and
> it doesn't tell me how to define a section in my C code that is used
> with the scatter file. So I am still left in the dark. If anyone has
> experience with scatter loading and having a different load and
> execution areas, please post an example.
>

Just as a matter of interest, why do you need to run from RAM in the
first place?
The idea behind this module is to reprogram the ARM's firmware from a
USB drive, by our customers. If the module lives in RAM, when we ship
then the product, then module will be lost do to power toggles, which
is something we don't want. The module is a self-contained driver
that "talks" to a USB controller and reads the firmware binary from a
connected USB drive. The firmware is read into RAM and then loaded
into flash via IAP calls. Because of the reprogramming, this module
must execute from RAM, but to allow the customer to reprogram anytime
they want, the module must live in flash.

Memfault Beyond the Launch