cancel
Showing results for 
Search instead for 
Did you mean: 

I'm writing a bootloader for the STM32L152. I'm trying to understand how I can switch from a code image in Bank 1 to an image in Bank 2 from the bootloader.

LThal
Associate II

Each code image will have an associated bootloader. If the bootloader in the current image runs and decides to change to the image in the other bank (corrupt image, new update, etc) I want to be able to do a reboot and change to the other image. I'd originally thought MEMRMP would be used for this, but after rereading the data sheet it looks like I was mistaken. Can I just update the vector table in RAM and reboot, or am I missing something(s)? Thanks.

Lee

2 REPLIES 2

I don't recall the STM32L having bank switching, so each image will need to be compiled for the specific addresses.

Your code can transfer control to whatever code it choses, typically a reboot isn't needed. You can set VTOR to 0x08000000 or 0x08030000 (depends on device), and then call the ResetHandler described in the image.

You could use RAM to store a vector table, and there you'd need to make sure the images don't contain any absolute address references beyond the vectors you plan to relocate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LThal
Associate II

Since I'm planning on making the images position independent it looks like all I need to do is copy the vector table from the image I want to make active into RAM and call the reset handler address in the now active vector table. Have I missed anything? And thanks for your help.