I am trying to understand what would be needed to compile and run a relocatable Chibios application. A standard way is to compile my app for base address 0x8000000 on my STM32F4, flash it, and it runs. What I would like to do is have a few such complete Chibios applications in different (arbitrary) places on the flash, and have a simple bootloader execute those applications. One purpose of this is to perform firmware upgrades.
What I have done til now is I compiled my Chibios application for a different base address (say, 0x8010000), and I wrote a trivial bootloader that would jump to the correct place using
Code: Select all
msr msp, <...>
bx <...>
This works of course, but is not ideal, because I have to set the base address during compile time. I would rather compile my Chibios app with -fPIC and be able to flash it at an arbitrary address.
Could anyone comment whether this is feasible at all with Chibios, and what would be required? I guess my bootloader would have to do some smart loading, update the GOT? One thing that makes me wonder is what to do with the vectors? I guess I would have to load the vectors into RAM and update them?
I'd appreciate any comments.
Thanks a lot!
Marcin