cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 RDP without POR

linards-ee
Associate

Hello,

Please help me with the solution.

I have a product with STM32H723ZGT MCU as a core. For device production I need to set Read Out Protection (RDP) Level 2 option bytes which would protect the devices debug port. To program the RDP byte, I use STM32 HAL's flash API. Unfortunately, after the function HAL_FLASH_OB_Launch() device enters a special state and the only way to reset the application is power reset (POR). The problem with that is my product has an on board battery which has been soldered during the manufacturing process before programming. 

I have found a possible solution, which is described in this video: 

https://www.youtube.com/watch?v=f7vs0NwZPFo

I have even tested this solution with STM32L4 series MCU and it worked fine. Unfortunately, the same approach with the STM32H7 series did not work. 

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
linards-ee
Associate

Found a solution:

In case of STM32H7 series to flash RDP byte and reset the MCU without using power cycle you first must initialize RTC Wakeup interrupt and then apply RDP flash functions including HAL_FLASH_OB_Launch(). After launch function HAL_PWR_EnterSTANDBYMode() is also required. In this case everything is going to work as expected. The final RDP flash part in my case look something like this:


FLASH_OBProgramInitTypeDef OB = {0};
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_RTC_SetWakeupTimerIT();  // my own wrapper funcion
HAL_FLASH_OB_Launch();
 
HAL_PWR_EnterSTANDBYMode();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}

View solution in original post

1 REPLY 1
linards-ee
Associate

Found a solution:

In case of STM32H7 series to flash RDP byte and reset the MCU without using power cycle you first must initialize RTC Wakeup interrupt and then apply RDP flash functions including HAL_FLASH_OB_Launch(). After launch function HAL_PWR_EnterSTANDBYMode() is also required. In this case everything is going to work as expected. The final RDP flash part in my case look something like this:


FLASH_OBProgramInitTypeDef OB = {0};
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_RTC_SetWakeupTimerIT();  // my own wrapper funcion
HAL_FLASH_OB_Launch();
 
HAL_PWR_EnterSTANDBYMode();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}