cancel
Showing results for 
Search instead for 
Did you mean: 

BFB2 Bit Set/Reset effect takes place only at Power cycle boot/Hard reset.

AShar.16
Associate

Hi Guys,

I am using STM32L476ZGT6  board with CMSIS layer version V4.30 .And when I tried to set/reset BFB2 bit in option bytes register it's effect doesn't takes place when I do System Reset using HAL_NVIC_SystemReset() API,instead it takes place when I power cycle the board.And also SYSCFG_MEMRMP Register values for FB_MODE setting effect doesn't remains place after System Reset Command

Questions:

1) Please mention why it is not working after soft reset HAL_NVIC_SystemReset() API?

2) Mention the flow for switching from flash partition 1 to flash partition 2 and again vice versa.

3) If this switching requires hard reset then suggest API available to do Power cycle reset.

Thanks in advance.

Aakash .

3 REPLIES 3

>>If this switching requires hard reset then suggest API available to do Power cycle reset.

You have a FET it should be switching?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
noble.techno
Associate

It's disappointing that nobody has ever answered this. Hopefully OP has figured it out now, but the procedure for switching banks is:

1) unlock flash CR register

2) unlock option bytes

3) program option byte with toggled BFB2 state

4) set OBL_LAUNCH bit and wait for it to clear

5) reset

Using HAL calls this is:

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

HAL_FLASHEx_OBProgram(&optionProgramInit);

HAL_FLASH_OB_Launch();

__NVIC_SystemReset();

Hopefully this will help someone else out.

MShar.4
Associate

The documentation about dual boot on STM32L4 is extremely unclear, in my opinion. I would like to summarize the issue of dual flash bank programming and of the dual boot.

Bank switching is done by setting on/off BFB2 bit of FLASH_OPTR register. Also DUALBANK bit here should be 1. It also can be seen in the Option Byte action of the ST-LINK Utility.

The number of current bank is determined by this BFB2 bit (0 for bank 1, 1 for bank 2). The other bank is the “other�? one. The flash erase should be done by the HAL_FLASHEx_Erase(bank) function which takes number of the bank to erase (1 (BFB2==0) or 2 (BFB2==1)). The normal selection is the “other�? bank to be erased, not the current one.

The FB_mode bit determines the start addresses of the current bank and of the other bank. When it is 0, the current bank is at 80000000 and the other bank is at 80080000. Start addresses of the current and the “other�? bank are always the same even when the banks are swapped.

Flash programming always should be done to the other buffer (80080000) and so checksum checks.

After the flash bank is programmed, it should be selected with the bank swap procedure.

The banks swap in fact toggles the BFB2 bit, so the “other�? buffer becomes the current buffer after the immediate reboot. E&OE.

Michael Sharkansky.