2019-03-22 07:17 AM
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).
Option Bytes:
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();
2019-07-01 08:24 PM
Have you solved the issue? If so, can you please share your solutions?