Showing results for 
Search instead for 
Did you mean: 

STM32G473 BFB2 Not Working

Associate II

BFB2 Set, but never enter Bank2 program.

Boot0 = 0
Boot1 = 1

I can run the 2 programs from cubeide in there respective locations and ISR work when BFB2 is set for the BANK I am debugging in. However I never enter BANK2 program on resetting/powercycling when BFB2 is set.

Bootloader Version is 0xD5

Does setting this bit somehow need to be utilized at some point or is it just an indicator of what bank we are in


I never see this high, which may be because I never enter bank2

Stack pointer is set to 

_estack = ORIGIN(RAM) + LENGTH(RAM) ; /* end of "SRAM" type memory */


BFB2 Dual Bank Boot does not work as expected. My understanding is this is a valid stack pointer, I have also tried additional stackpointer locations with no luck

ST Employee

Hello @kip18 ,

Which Bootloader version used?

If you look at the RM0440 / Rev8 / Page 91, there is this statement:
To select boot from flash memory bank 2, set the BFB2 bit in the user option bytes. When this bit is set and the boot pins are in the boot from main flash memory configuration, the device boots from system memory, and the bootloader jumps to execute the user application programmed in flash memory bank 2. For further details, refer to AN2606. See Table 13: Access status versus protection level and execution modes for bootloader function for different RDP levels.

If bootloader version is lower than V13.4 (0xD4) then the project might not work as expected due to known limitation on Bootloader. 

In that case, it is possible to make the project work by changing the option bytes values as below:
BFB2=1, nBOOT0=1 and nBOOT1=0,
The Bootloader version can be found in the address 0x1FFF6FFE and should be 0xD4 or higher.
For more details, please refer to "AN2606 STM32 microcontroller system memory boot mode" Application note.

When your question is answered, please close this topic by clicking "Accept as Solution".

Bootloader version is 0xD5, which says no limitations. I have also tried moving the stack pointer per the 0xD4 limitation, still did not work.

My boot pins are set to boot from flash as specified. boot0 is from external pin pulled low, have tried overriding it with the boot options to ensure boot0 = 0 and boot1 =1 and still does not enter bank2 with BFB2

Regardless of BFB2 Being set I am always running from BANK1


RDP is always level 0 : 0xAA


I could give you a sample program but it is just an LED be toggled in BANK1 and then identical program but different LED is toggled in BANK2. Regardless of BFB2 bit being set the internal bootloader only goes to bank 1. I can see it in system memory on restart, but proceeds to bank1






Lots of people say this is cleared on reset, my understanding is the internal boot loader would set this. this never happens don't know if that's an issue or if thats because internal bootloader never chooses bank2 to jump too.


I have attached an example for STM32G474 modified for STM32G473, that will write a program to bank2 and then set the option bits and launch. Never does it show bank2 active, maybe an issue with that bit or bootloader throws out the program. I want to reiterate I have also done two identical programs with different LED toggling and used STMCubeProgrammer to flash and activate the OptionByte for BFB2 with no success.




if I manually set this bit at the start of program execution if BFB2 is set then I get the desired behaviour.

is this the expected implementation? seems wrong. I'll have to insert a BFB2 check at the start of program execution and then remap manually myself.


my workaround is calling this prior to anything happening, need to set vector table to 0x08000000 as well

    FLASH_OBProgramInitTypeDef OBInit;

    if (((OBInit.USERConfig) & (OB_BFB2_ENABLE)) == OB_BFB2_ENABLE) {
    } else {



Seems like a hack and the documentation doesn't explain this and possibly is an errata cause the 474 example doesn't account for this.

I'm having the exact same issue. flashing the same binary at 0x08000000 and 0x08040000, checking or unchecking the BFB2 flag makes no difference, i always read READ_BIT(SYSCFG->MEMRMP, 0x1 << 8); always returns bank 1.

that's the behaviour I had as well, if you switch it yourself when you read the BFB2 flag it works, but seems like a hack workaround. I never booted to bank2 from the internal bootloader, but I can swap the memory around when I first boot up based on BFB2 being set or not and then it will be running from bank2


Just need the program to be identical at the start and to always check the BFB2 bit is set or not then swap the mapping.