Keil MDK - STM32 - How can I load independent programs
Posted 15 November 2011 - 01:20 PM
I have two independent Keil-projects for Cortex M3 (STM32) : A bootloader and an application.
With the help of a scatter file I can shift the bootloader to 0800D800.
But then I can't debug it any more because there is no reset vector and stack pointer at 08000000.
When I keep these vectors in place the loader works.
But I need the same space for the application. That is, the loader erases 08000000 to 0800D7FF
and kills its own vectors. Then the application is stored in flash and installs its vectors.
After reset the loader can't be reached any more.
So before deleting the lower space I store the reset vector and the stackpointer of the loader.
After deletion I restore these vectors and load the application without its vectors. They are stored
at a free address in the loader space. After reset the processor always runs the loader first.
When the loader finds a valid application it uses the application-vectors to jump there.
As the interrupt vectors are those from the application, I avoid using interrupts in the loader.
I could include the loader in the application. But Keil uses a lot of lower space for data I can't assign
to program parts . I'm afraid that, when deleting an old application, some important data for the
loader could be deleted, too (the reset-section is 236bytes long).
Please, tell me there is a better way .
btw: Why can't I search within the community? There is only a "Search Our Site" with a pulldown menu,
but no selection for the actual community.
Posted 15 November 2011 - 04:07 PM
I found a link for Search ARM Forums and asked the admin if we could make it more obvious.
Kind regards, Alban
Posted 16 November 2011 - 01:51 PM
You can use this to define the vector table to a different location.
Since the STM32 start at 0x08000000, you have to put the boot loader vector table there.
For your application, you can put the vector table somewhere else.
Inside your boot loader, you can program the VTOR so that it point to the address of the vector table
for your application, and then branch to the reset handler.
In this way, the two vector tables co-exist, and no need to erase the flash during the boot process.
This post has been edited by Joseph Yiu: 16 November 2011 - 01:51 PM