cancel
Showing results for 
Search instead for 
Did you mean: 

custom bootloader on STM32F446

fab04
Senior

Hi everybody,

I'm trying to make a bootloader in my STM32F446. The aim if this one is the possibility to update the firmware but with keeping the previous one in case of issue. So, I'll have two slots for firmware.

For now, I have the following sectors in my flash :

BOOTLOADER : 0x0800 0000 -> 0x0800BFFF (it only uses sector 0 & 1 for code, so I use last word of sector 2 (0x0800 BFFE & 0x0800 BFFF) to write a "magic word" which gives me the information, if we're currently running on SLOT 1 or 2).

SLOT 1 : 0x0800 C000 -> 0x0800 3FFF

SLOT 2 : 0x0804 0000 -> 0x0807 FFFF

My FW is running on slot 1. It receives the order to update, so it restarts, checks on which slot the new FM must be copied, writes into the flash, and starts again on new slot (and this is done at each update, so FM is running on SLOT1/2 alternatively).

Everything works well, except the last step, it always run on slot 1 (even if all the code has been written in the slot 2).

In the two first 32 bytes (0x0800 0000), I have the stack pointer and the program counter. One thing, I have noticed is that the PC is always the same (0x08010AC1), but it must be changed if the FW runs on slot2, but I cannot change this one when I made the *.hex* (and I don't want) because I'll never know in advance where the FW is running.

I think I misunderstand something, if you can help me on this point.

Thank you in advance,

 

 

0 REPLIES 0