cancel
Showing results for 
Search instead for 
Did you mean: 

Flash RDP activate

RE11
Associate II

Hello everyone, 

I have board and I used STM32G071 MCU on this board. I want to activate RDP Level 1. There is my code: 

 
 
void SysCodeProtection( void )
{
FLASH_OBProgramInitTypeDef pOBInit = {0};
 
HAL_FLASHEx_OBGetConfig( &pOBInit );
 
if ( pOBInit.RDPLevel != OB_RDP_LEVEL_1 )
{
HAL_FLASH_Unlock();
 
HAL_FLASH_OB_Unlock();
 
pOBInit.OptionType = OPTIONBYTE_RDP;
 
pOBInit.RDPLevel = OB_RDP_LEVEL_1;
 
HAL_FLASHEx_OBProgram( &pOBInit );
 
HAL_FLASH_OB_Launch();
 
HAL_FLASH_OB_Lock();
 
HAL_FLASH_Lock();
 
}
 
}
 
I'm programming my MCU on ST-LINK with ST-LINK Utility. But sometimes after I programmed my MCU It's locking or crushing. My power LED is not working on my board and I can't connect my board. I lost many boards after activate RDP If I disable RDP I didn't see any problems. Can anyone help me about it ?
11 REPLIES 11
Diane POMABIA
ST Employee

Internal ticket number:156398 (This is an internal tracking number and is not accessible or usable by customers).

JakubK
Associate

Hi,

I encounter the similar problem at STM32L422CB. When I set OB_RDP_LEVEL_1 and then call HAL_FLASH_OB_Launch the MCU does not boot anymore. When setting OB_RDP_LEVEL_0 there is no problem. I have not tried OB_RDP_LEVEL_2.
Surprisingly, when I set the OB_RDP_LEVEL_1 without calling HAL_FLASH_OB_Launch but doing a manual power off-on, there is no problem at all and everything works as it should.
I guess the problem is the HAL_FLASH_OB_Launch procedure.
I hope it may be helpful.

Regards.