2026-05-11 8:11 AM - last edited on 2026-05-13 4:46 AM by mƎALLEm
Hello,
In order to comply in advance with the incoming CRA regulation, we would like to have RDP1 enabled on our U575. In order to do this the fw, in the early stages of the initialization procedure, will have to check if it's in RDP0 by reading the related OBs and, if so, it will set RDP1 using HAL_FLASHEx_OBProgram:
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct);
if(OB_RDP_LEVEL_0 == OptionsBytesStruct.RDPLevel)
{
OptionsBytesStruct.OptionType = OPTIONBYTE_RDP;
OptionsBytesStruct.RDPLevel = OB_RDP_LEVEL_1;
if(HAL_OK == HAL_FLASHEx_OBProgram(&OptionsBytesStruct))
{
HAL_PWR_EnterSTANDBYMode();
//HAL_FLASH_OB_Launch();
}
}2026-05-15 1:55 AM
Hello @ste2108 ;
I recommend you to look at How to change readout protection (RDP) level without power-on reset (POR) on the STM32L4 and get inspired to check your configuration.
Thank you.
Kaouthar
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.
2026-05-18 2:05 AM - last edited on 2026-05-18 8:58 AM by KDJEM.1
Hello Kaouthar,
thank you for your answer, taking inspiration from the L4 example actually did the job (leaving the code for other users, I had to make a minor modification to take into account different HALs on U5. You also need to enable RTC in the ioc if you didn't already):
FLASH_OBProgramInitTypeDef OptionsBytesStruct;
// Unlock Flash and Option Bytes
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct);
if(OB_RDP_LEVEL_0 == OptionsBytesStruct.RDPLevel)
{
OptionsBytesStruct.OptionType = OPTIONBYTE_RDP;
OptionsBytesStruct.RDPLevel = OB_RDP_LEVEL_1;
if(HAL_OK == HAL_FLASHEx_OBProgram(&OptionsBytesStruct))
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 4096, RTC_WAKEUPCLOCK_RTCCLK_DIV16, 0); // Program the RTC
__HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_ALL_FLAG);
HAL_PWR_EnterSTANDBYMode();
}
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();Kind regards,
Stefano
2026-05-18 9:22 AM
Hello @ste2108 ;
According RM0456:
I reported STM32CubeProgrammer issue internally.
Internal ticket number CDM0062725 (This is an internal tracking number and is not accessible or usable by customers).
Thank you.
Kaouthar
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.
2026-05-18 11:56 PM
Hello @KDJEM.1 ,
Thank you for your answer. I will wait for a feedback from STM32CP's guys before closing the ticket then.
Kind regards,
Stefano
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.