Unable to boot from BANK2
Hi, I am new to STM32G4 series. I am implementing dual bank firmware update on STM32G473 custom board. I've prepared two identical bin files(compiled to 0x08000000), and flashed them to 0x08000000 and 0x08040000.
With options bytes:
BFB2=0
nBOOT0=1
nBOOT1=1
nSWBOOT0=1
My board boot from BANK1 and function correctly.
Then I tried to change BFB2 to 1 with STM32CubeProgrammer to boot from BANK2. According to AN2606, it will first boot into system bootloader, and the loader will do valid bank check and boot from it.
However, our board boot into BANK1 code. But I've confirmed by debugger they've entered system loader before running BANK1 code.
I used the following code to check BANK, get_bank() always return 0
/**
* @brief get current bank
* @retval int 0 for bank 1, while 1 for bank 2
*/
static inline int get_bank()
{
return READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE);
}