I am trying to enable RDP Level 1 on an STM32F767VI MCU using the following code:
void SetRDP()
{
// Enables RDP level 1 on STM32F7 MCUs
#ifdef STM32F7
printf("RDP Set Start\r\n");
HAL_StatusTypeDef status;
status = HAL_FLASH_OB_Unlock();
if(status){
printf("Flash OB Unlock Error\r\n");
return;
}
FLASH_OBProgramInitTypeDef OBConfig;
HAL_FLASHEx_OBGetConfig(&OBConfig);
OBConfig.RDPLevel = OB_RDP_LEVEL_1;
status = HAL_FLASHEx_OBProgram(&OBConfig);
if(status){
printf("FlashEx OB Program Error\r\n");
return;
}
status = HAL_FLASH_OB_Lock();
if(status){
printf("Flash OB Lock Error\r\n");
return;
}
printf("RDP Success\r\n");
#endif
}
The code follows all the way through to “RDP Success”, but checking with an STLink still lets me look at the flash and tells me that the RDP is still on level 0. What am I doing wrong?