Hello,
I'm working with the AT91SAM9361 controller. Moreover I installed a nor flash (where the real program is stored) and a small data flash (where a small bootloader is stored. Among other things, the bootloader should check if the arm vectors (at the beginning of each code) are valid). If this code is valid the program stored in the nor flash should be executed.
I want to use two seperate memories, so that everyone is able to load a new update of the real program via the bootloader in the dataflash in the nor flash.
How is it possible to start the application from the bootloader in the nor flash? Do I have to set the PC to the beginning of the nor flash? Which are the steps to execute this programm?
I'm not working with an operating system.
best regards Hans
I'm not using ARM but C166 but since it's Keil I expect things to be quite similar.
I like the idea of having a stable bootloader stored in flash. We should have done it that way in a previous project I did...
What we are using now, during development, is the bootstrap loader functionality of the C166 to download new software and store it in flash. Does the ARM have something similar? We set the MCU to bootstrap download, it starts listening on its UART and we can download a small app to RAM that continues listening for more data to be stored in flash. That way you don't need anything stored in flash, but you do however need to switch a jumper to set the MCU to bootstrap mode; opening a device like that might not be an option.
To do flash updates from within our application, we have in fact 2 standalone apps (not an optimal solution at this moment, but hey, legacy...): the flash application (ie. "bootloader") and the main application.
If you look at the startup.asm file, in our case, what it does at the end is:
JMP FAR main ; Jump to C program
Before that, we check if it should switch to the flash application by doing a call:
EXTERN MAINAPP_test_for_update : FAR CALL MAINAPP_test_for_update
Depending on the result, it simply jumps to a hardcoded memory location (like you mentioned already) where the flash application is stored:
JMPS 01H, 00000H ; location of FLASHAPP
At that address, the entire flash application is stored, starting again with a startup.asm file.
In your casem, you could switch things around, by starting the device to the bootloader, testing if it should do anything (timeout on serial input or something; if update -> read data and update main application flash) and if no update is requested, jump to the fixed memory location of your main application.
Good luck, Joost