STM32G4 not functional after setting RDP Level 1
I’ve been struggling with setting up RDP Level 1 on my STM32G473CBT6.
This project does not use the system bootloader. The BOOT0 pin is held low and it boots from FLASH using our own bootloader.
I have code in place to accept a command to program RDP Level 1. It is fairly simple:
if(HAL_FLASH_Unlock() != HAL_OK){
return;
}
if(HAL_FLASH_OB_Unlock() != HAL_OK){
HAL_FLASH_Lock();
return;
}
FLASH_OBProgramInitTypeDef ob_prog = {.OptionType = OPTIONBYTE_RDP, .RDPLevel = OB_RDP_LEVEL1};
HAL_FLASHEx_OBProgram(&ob_prog);
/* This call should reset the MCU. */
(void)HAL_FLASH_OB_Launch();The problem is the MCU is non-functional after performing this operation. I have no way to know what is going on because I can’t debug at RDP Level 1. I have confirmed the Option Bytes are set as expected using STM32CubeProgrammer (RDP Level 1 is set). Power cycling and unplugging the ST-LINK does not work. The only recovery is to revert to Level 0 via ST-LINK and re-flash.
To eliminate the possibility of my code being the problem, I have programmed RDP Level 1 via ST-LINK and got the same results. The other Option Bytes are at their default values.
