EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Coping of RAMFUNC's from flash to RAM..

Started by strong_arm7s September 26, 2005
Hello,
I am making a system that has a segment of code that is static, does
not change, to be a bootloader. Then I am flashing on the fly from
ramfunc's a higher segment for some application data that can change.
Now the problem is I am testing the system with flashing in garbage,
and then doing a reset. Upon resetting a CRC of the image segment is
done and if it does not match one contained in NVRAM is it supposed to
redo the flashing with valid data. However on restarting in the
debugger after flashing the garbage, the call to the ramfunction
doesn't happen.
Is there a way to recopy the FLASH ramfunc's into ram again so they
can run?
Any one any experience in writting flashing code? That reflashes
itself from an image somewhere (in ram or external eeprom) and then
restarts..
Thanks.



On Tuesday 27 September 2005 09:25, strong_arm7s wrote:
> Hello,
> I am making a system that has a segment of code that is static, does
> not change, to be a bootloader. Then I am flashing on the fly from
> ramfunc's a higher segment for some application data that can change.
> Now the problem is I am testing the system with flashing in garbage,
> and then doing a reset. Upon resetting a CRC of the image segment is
> done and if it does not match one contained in NVRAM is it supposed to
> redo the flashing with valid data. However on restarting in the
> debugger after flashing the garbage, the call to the ramfunction
> doesn't happen.
> Is there a way to recopy the FLASH ramfunc's into ram again so they
> can run?
> Any one any experience in writting flashing code? That reflashes
> itself from an image somewhere (in ram or external eeprom) and then
> restarts..
> Thanks.

What tools?

For gcc/gnuarm you can do the following:

1) In your ldscript add the flash programming code (+ and rodata it needs) to
the .data section.
- or -
2a) Make a new section called .ram_text or similar and place the programming
code + rodata there. This needs to have a VMA in RAM and am LMA in flash.
(ie. something like is used for the .data section).
2b) Add a "copy flash to ram" section to the init.s/startup.s to copy the code
from ROM to RAM. Again, this can be modelled off the .data section handling.


I am using IAR.
I have taken a different approach now that seems to work a lot better.
I have made a bootloader application in the code less than 0x1000 that
does a crc on the image from 0x1000 to the end and checks with one in
NVRAM.
Now the application from 0x1000 and up has its own startup and
interrupt vectors, it a complete standalone application that will also
run from 0, but I have burnt it into the flash at 0x1000.
Now I want the bootloader application to startup the 2nd application
starting at 0x1000 and execute it from there, is this possible on the
AT91SAM7S256?
I want to have it as a complete seperate application that can also be
downloaded via the JTAG to address 0x0000 and can be ran for debugging
purposes...
Then in the final system the bootloader basically restarts everything
from 0x1000.



Memfault Beyond the Launch