cancel
Showing results for 
Search instead for 
Did you mean: 

Application not working when RDP=1

Abhishek_S
Associate

Hi,

I am trying to run my application on the STM32L433RTCX which includes the code that enables the RDP to level 1. Even after multiple different attempts (to set it at level 1) the application on the MCU is still not working. Details from my side - 

  • Program Counter is in flash.
  • The following is the function I am using.
  • While debugging right after flashing, the debugger loses signal after  HAL_FLASH_OB_Launch();

 

 

HAL_StatusTypeDef SetRDPLevel1()
{
 FLASH_OBProgramInitTypeDef OB;
 HAL_FLASHEx_OBGetConfig(&OB);
 if (OB.RDPLevel != OB_RDP_LEVEL_1){
   HAL_FLASH_Unlock();
   HAL_FLASH_OB_Unlock();
   OB.OptionType = OPTIONBYTE_RDP;
   OB.RDPLevel = OB_RDP_LEVEL_1;

 if ( HAL_FLASHEx_OBProgram(&OB) != HAL_OK ){
   HAL_FLASH_OB_Lock();
   HAL_FLASH_Lock();
   return HAL_ERROR;
   }

 HAL_FLASH_OB_Launch();

/* We should not make it past the Launch, so lock
 * flash memory and return an error from function
 */

  HAL_FLASH_OB_Lock();
  HAL_FLASH_Lock();
  return HAL_ERROR;
  }

return HAL_OK;

}

 

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @Abhishek_S 

Here are some suggestions that might help:

  1. Have you tried enabling RDP using CubeProgrammer? 
  2. You can run this example first to check if the erase operation is performed correctly Examples\FLASH\FLASH_EraseProgram.
  3. The option byte loader reset is generated when the OBL_LAUNCH bit (bit 27) is set in the FLASH_CR register. So, a reset was generated while you were debugging.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
FBL
ST Employee

Hello @Abhishek_S 

Here are some suggestions that might help:

  1. Have you tried enabling RDP using CubeProgrammer? 
  2. You can run this example first to check if the erase operation is performed correctly Examples\FLASH\FLASH_EraseProgram.
  3. The option byte loader reset is generated when the OBL_LAUNCH bit (bit 27) is set in the FLASH_CR register. So, a reset was generated while you were debugging.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Abhishek_S
Associate

Hi,
The cube programmer worked for me. But I am unable to understand what I missed while programming this in code. I was aware about the reset while I received while debugging OBL_LAUNCH, however, after reset (reload of the option bytes which also worked properly i.e. level 1 was enabled) the device just seemed to not function. Is it something like that I lost my bootloader or somekind of silly mishap?