cancel
Showing results for 
Search instead for 
Did you mean: 

"Error: Data read failed" after option byte modifications on STM32WB55 ( Nucleo with ST Link debugger )

Kalpesh1
Associate II

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.

3 REPLIES 3

hello.

"Error: Data read failed" >> what gives this error?

Run StLink utility and try to manipulate the option bytes from the utility.

Kalpesh1
Associate II

STM32 Cube Programmer Utility :

Snapshot of Error STM32 Cube Programmer : Connect event

0693W000006FaESQA0.jpg 

I am able to read option bytes:

0693W000006FaFQQA0.pngBut I am not able to erase or download

 0693W000006FaMbQAK.jpg

Kalpesh1
Associate II

STLink Utility : 

Able to connect but getting read error :

0693W000006FaPzQAK.jpg 

I am able to read option bytes :

0693W000006FaQEQA0.jpgError in erase and download :0693W000006FaQiQAK.jpg