Showing results for 
Search instead for 
Did you mean: 

STM32L552CCT6 Read Protection Question


I want to apply Read Protection to the STM32L552CCT6 .

If you execute HAL_FLASH_OB_Launch(); after setting Read Protection, reboot does not work.

Read Protection is applied only when the power is physically rebooted.

I want Read Protection to be applied as ST reboots after executing HAL_FLASH_OB_Launch();.

Below is the code I used.


///* Unlock the Flash to enable the flash control register access *************/


 ///* Unlock the Options Bytes *************************************************/


OptionsBytesStruct.RDPLevel = OB_RDP_LEVEL_1;

  OptionsBytesStruct.OptionType = OPTIONBYTE_RDP;

if(HAL_FLASHEx_OBProgram(&OptionsBytesStruct) != HAL_OK)


 /* Error occurred while options bytes programming. **********************/




  /* Generate System Reset to load the new option byte values ***************/



 /* Lock the Options Bytes *************************************************/





ST Employee

Maybe try to call  HAL_FLASH_OB_Lock(); &  HAL_FLASH_Lock();

before calling OB_Launch ?

You have another function like  NVIC_SystemReset() in case you need to reset.

Jocelyn RICARD
ST Employee

Hello Kjoon,

this behaviour is "normal" if a debugger was detected.

For instance if you flash your code with debugger and then launch the firmware, as soon as RDP1 is set, the flash is locked because of this debugger connection.

One way to overcome this is to go through a standby transition. This transition is equivalent to a power-on reset for this purpose.

So, instead of calling OB_Launch, just setup a RTC wakeup in 10ms and go to standby. After wakeup RDP1 will be set and code will run.

My colleague made a video on this specific point here:

Just select: STM32 Security tips - 3 RDP without POR

Best regards