AnsweredAssumed Answered

Power cycling after ROP setting

Question asked by Michal Dubovsky on Jun 28, 2017
Latest reply on Nov 10, 2017 by matik.jan

Hello. My application hangs after setting the ROP to LVL1 and resetting the whole device. I have found some people had this issue as well and power cycling helped (which is my case as well). But it is kind of an inconvenience as my application is battery powered. Is there any way of avoiding having to do this?

 

My code for setting the ROP lvl:

/**
* @brief Enables a LVL1 read out protection (if it is not enabled yet)
*/
static void enable_ROP_LVL1(void)
{
   FLASH_OBProgramInitTypeDef OptionsBytesStruct;

   HAL_FLASH_Unlock(); // Unlock the Flash to enable the flash control register access
   HAL_FLASH_OB_Unlock(); // Unlock the Options Bytes
   HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct); // Get pages write protection status

   // Check if read out protection is enabled
   if((OptionsBytesStruct.RDPLevel) == OB_RDP_LEVEL_0)
   {
      OptionsBytesStruct.OptionType = OPTIONBYTE_RDP;
      OptionsBytesStruct.RDPLevel = OB_RDP_LEVEL_1;

      if(HAL_FLASHEx_OBProgram(&OptionsBytesStruct) != HAL_OK)
      {
         _Error_Handler(__FILE__, __LINE__);
      }

      HAL_FLASH_OB_Launch(); // Generate System Reset to load the new option byte values
   }
   HAL_FLASH_OB_Lock(); // Lock the Options Bytes
}

Outcomes