Skip to main content
Rafael Bachmann
Associate II
June 15, 2020
Question

How can I detect the active flash bank on stm32g4? BFB2 bit is not conclusive

  • June 15, 2020
  • 3 replies
  • 1538 views

Hi,

I am developing an application with stm32g4 using the dual bank feature for firmware upgrades. To check if an upgrade was successful, I need to check the currently active bank.

I can read the option bytes and get the BFB2 bit. But: if the firmware on bank X was not correct and was rejected by the system bootloader, the system bootloader does not boot bank X, instead it boots bank Y. But it does not toggle the BFB2 bit, leading to a state where BFB2 indicates bank X but actually bank Y runs.

Is there a way to query the actually active bank?

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
June 16, 2020

https://www.st.com/resource/en/reference_manual/dm00355726-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Check SYSCFG_MEMRMP / MEM_MODE

Mark the images when you write them into different banks

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ST Technical Moderator
June 17, 2020
In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
MTorr.5
Visitor II
February 13, 2021

Did you managed to query the active bank? I followed the related discussion, and it solves issues related to the bank switching on boot, which is very useful, but nothing about how to check in wich bank are you running after boot. My code is going to erase a bank and flash a new firmware, then switchover, but I need to know what bank to erase in the first place. Isn't is this the expected behaviour for dual bank?