> At 04:53 17-06-05 -0400, you wrote:
> >I'm trying to write a bootstrap routine in C that will reside in flash
> >and be copied to RAM for execution.  Can anyone give me some helpful
> >hints on how to do that?
>
> In an earlier discussion the method of copying a routine was discussed.
>
> >I've searched the docs for any reference to relocatable code (there will
> >be some subroutines, also in RAM) or preprocessor commands that might be
> >able to specify that this code will be running at a particular address
> >(in this case within the RAM) and haven't been able to find anything
> >that relates to this problem.
>
> Why would you copy more than one subroutine in RAM? The only thing you
will
> want in RAM is the code that actually programs the flash. The amount of
> memory doesn't allow for allocating large fixed buffers for this.
>
> I'm planning to implement a method in which the data and the programming
> routine are both on the stack to use the memory most efficiently. When
> programming is finished, the memory is available again for other buffers.
>
> Nico Coesel
>

An easy way to put your function(s) in ram is to put them in the .data
section.  You'll get some compiler/linker complaints about abusing sections,
but it the code gets linked to its ram address and loaded from flash at
startup just like any piece of initialised data.  Don't forget the
"critical" to ensure interrupts are turned off.  You can use the function
just like normal, even debugging (single-stepping, breakpoints, etc) as
normal.

// Put in ".data" section so that it is copied to ram and run from there
static void critical __attribute__ ((section(".data"))) massProg(const word*
src, word* dst, word n) { ... }



Reply via email to