"Error: Data read failed" after option byte modifications on STM32WB55 ( Nucleo with ST Link debugger )
void Set_Option_Byte( void )
{
FLASH_OBProgramInitTypeDef OBInit;
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Clear OPTVERR bit set on virgin samples */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
/* Unlock the Options Bytes *************************************************/
HAL_FLASH_OB_Unlock();
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.UserType = OB_USER_IWDG_STOP;
OBInit.UserConfig = OB_IWDG_STOP_FREEZE;
HAL_FLASHEx_OBProgram(&OBInit);
/* Start the Option Bytes programming process */
if (HAL_FLASH_OB_Launch() != HAL_OK)
{
/* User can add here some code to deal with this error */
while (1)
{
}
}
/* Prevent Access to option bytes sector */
HAL_FLASH_OB_Lock();
/* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */
HAL_FLASH_Lock();
}
Note: I had forgot to call HAL_FLASHEx_OBGetConfig(&OBInit); thus OBInit might have few members uninitialized. How I can recover WB55 board.
