cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L471 BFB2 and FB_MODE question.

ChrisFujii
Associate II

Hello,

I'm trying DUAL BOOT on STM32L471 and having a problem with SYSCFG->MEMRMP FB_MODE bit.

I modified Dual Boot Bank Swap Boot Loader Example for STM32G4 project to fit my board, and everything goes well when the firmware put from the start of BANK1 (0x08000000). It starts from BANK1 and copies itself to BANK2, sets BFB2 of OPTION BYTES and calls HAL_FLASH_OB_Launch(). Then it starts from BANK2 (with address of 0x08000000 since FB_MODE=1) without problem.

Then I put it from 0x08070000 (the last sector of BANK1) and adjusted VTOR, so that it's called as a sub-program from main which is positioned at start of BANK1(0x08000000), copies itself to 0x08080000, sets BFB2, and calls OB_Launch() but it doesn't boot from BANK2.

VTOR must be set at the beginning of main like this:

uint8_t bank = getActiveBank();
if (bank == 1)
SCB->VTOR=0x08070000;
else
SCB->VTOR=0x08000000; 

and modified linker script too.

After calling HAL_FLASH_OB_Launch() to set BFB2, FB_MODE is also set after reset when the firmware is put from the start of BANK1(0x08000000), but FB_MODE would not be set when it's put from 0x08070000. Therefore, bank swap doesn't happen.

I checked with STM32CubeProgrammer and J-Link JMem utility, BFB2=1 but FB_MODE=0, and System Memory appears on 0x00000000 after power on reset. I wrote 1 to FB_MODE and bank swaps, but the bit returns to 0 immediately.

The question is, what causes FB_MODE=0 even though BFB2=1 after reset, and why I can't write 1 to FB_MODE but BANK swap happens.

 

0 REPLIES 0