cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L082 dual bank, BFB2 bit reset at power up ?

Florent_
Associate II

Dear all,

I am requesting your help to understand well how the dual bank mechanism works before I start writing the firmware:

  • I will use the internal bootloader to allow me to start from Bank1 or Bank2.
  • Bank1 will store the factory firmware, and Bank2 will be used for the new version.
  • Bank1 will receive the firmware via RF and write it in the Bank2 and check it.
  • Bank1 will set the BFB2 bit and reboot the MCU to boot on Bank2.

My questions :

  • If the MCU boots on Bank 2 but the firmware is uncorrect, how can I reboot on Bank1? Is it possible to reset the BFB2 bit with power cycling? I want to be sure I cannot brick my device.
  • Could you confirm that I do not have to relocate the interrupt vector table if I use the internal bootloader?
  • How should I generate the binary to be sent to the device to be written in bank 2?

Thank you all very much for your help and your contribution to this forum.

Best

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> If the MCU boots on Bank 2 but the firmware is uncorrect, how can I reboot on Bank1? Is it possible to reset the BFB2 bit with power cycling? I want to be sure I cannot brick my device.

No, option bits are in persistent memory. To change BFB2 back you'd have to use a programmer, or the ROM bootloader.

> Could you confirm that I do not have to relocate the interrupt vector table if I use the internal bootloader?

Yes, the ROM bootloader uses its own vector table. It doesn't care about the user code.

> How should I generate the binary to be sent to the device to be written in bank 2?

Since memory is remapped, create it as if you're sending it to flash bank 1.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

> If the MCU boots on Bank 2 but the firmware is uncorrect, how can I reboot on Bank1? Is it possible to reset the BFB2 bit with power cycling? I want to be sure I cannot brick my device.

No, option bits are in persistent memory. To change BFB2 back you'd have to use a programmer, or the ROM bootloader.

> Could you confirm that I do not have to relocate the interrupt vector table if I use the internal bootloader?

Yes, the ROM bootloader uses its own vector table. It doesn't care about the user code.

> How should I generate the binary to be sent to the device to be written in bank 2?

Since memory is remapped, create it as if you're sending it to flash bank 1.

If you feel a post has answered your question, please click "Accept as Solution".
Florent_
Associate II

Hi TDK,

Thank you for your answers.

So, if I want to use the ROM bootloader, I must check carefully that the bank 2 contains a valid code before rebooting on it.

My idea to reduce the risk would be to reset BFB2 at the beginning of each firmware to reboot on the factory firmware if the mcu stops unexpectedly. And I can make the code as robust as possible until the BFB2 is reset, and always reuse the same piece of validated code.

Does it make sense? or would you recommend to write my own bootloader?

Thanks a lot,

Best,

F.