Hello,
Is there a way to load multiple programs at once from uVision onto a STM32?
I'd like to be able to have a bootloader program running that can jump into other programs that are already loaded into flash.
Ideally I would do this loading myself, but I've had trouble figuring out what exactly this requires. My idea was to turn on all the position independence options in the compiler/linker and then put the program wherever I wanted. However, I'm getting bogged down in figuring out exactly what it means to "put" a program somewhere. Do I need to parse the .hex and only load the sections that go in ROM? Can I put the program that goes in ROM anywhere as long as it's contiguous?
It seems like once the program is loaded you can just jump to the base + 4 and it will set itself up. But I'm having trouble finding good documentation about this.
If anyone has successfully created a bootloader and loaded applications into flash and then jumped to the loaded applications, I would be VERY interested in knowing how you accomplished this!
Thanks for any help you can provide.
-Jesse Tannahill
I guess you motivation is the desire to be able to debug the bootloader and the application's source code at the very same debug session. As far as I know, this is not possible unless you create one (temporary) .hex file that contains both programs.
I've figured out how to do it. Perhaps this will be of interest to some of you.
HW Configuration: * Running on STM32F103VE (512K flash, 2k page) * uVision 4
SW Design: * Bootloader - Manages "applications" installed in flash, communicates over serial with python transfer program. * File system - FAT-based filesystem that allows files to be stored in flash. * Staging area - a set location in the memory map for application to be run from.
All the applications are compiled to run in the staging area (i.e. changing the ROM area in project config.). They are then compiled to hex, converted to bin (using sourceforge.net/.../), and loaded onto flash using my transfer program and filesystem storing mechanism.
Once the applications are in flash, to run an application the bootloader copies a selected application from the filesystem to the staging area, deinits any peripherals used by the bootloader, set the stack pointer (using __set_MSP) to the address stored at the 1st word of the staging area, sets the NVIC vector table to point to the 1st address of the staging area, and jumps to address stored in the 2nd word of the staging area (beginning+4).
I'm in the midst of coding this up, but it seems to work well so far.
Any thoughts on how I can improve this or requests for more detail? I got a lot of inspiration from http://www.keil.com/forum/17025/ .