cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L475RC hangs up if power loss occurs during launching BFB2-OptionByte (Dual-bank boot mechanism)

MHopf
Associate

Hey,

I try to implement an update mechanism by using the dual-bank boot mechanism of the STM32L475RC. In general the bank swapping works, but sometimes, when I remove the power supply in the wrong moment during the OptionByte-Launching, the microcontroller doesn't boot anymore.

When I try to connect to the STM32 via the STM32 ST-Link Utility, it seems that the read-out protection was enabled (see pictures).

0690X0000088a4lQAA.png

Option Bytes:0690X0000088a4qQAA.png

This is the code to set/reset (and launch) the BFB2-OptionByte Flag in dependency of the selected bank:

FLASH_OBProgramInitTypeDef OBInit;

memset(&OBInit, 0, sizeof(OBInit));

OBInit.OptionType = OPTIONBYTE_USER;

OBInit.USERType = OB_USER_BFB2;

uint32_t new_user_config = 0;

if (bank == 2) {

new_user_config |= (OB_BFB2_ENABLE);

} else {

new_user_config &= ~(OB_BFB2_ENABLE);

}

OBInit.USERConfig = new_user_config;

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

HAL_FLASHEx_OBProgram(&OBInit);

HAL_FLASH_OB_Launch();

/* This code should not be reached */

HAL_FLASH_OB_Lock();

HAL_FLASH_Lock();

1 REPLY 1
KHuai
Associate II

Have you solved the issue? If so, can you please share your solutions?