Question
Regression from RDP level 1 to 0
Hello,
I'm trying to test RDP levels configuration on STM32H753.
Here is the code I've tested (on a Nucleo 743 with STM32CubeIDE):
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART3_UART_Init();
OBInit.Banks = FLASH_BANK_1;
HAL_FLASHEx_OBGetConfig(&OBInit);
RdpLevel = OBInit.RDPLevel;
BSP_PB_Init(BUTTON_USER,BUTTON_MODE_GPIO);
BSP_LED_Init(LED1);
if ( RdpLevel == OB_RDP_LEVEL_0 )
{
/* Wait for User push-button press before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)
{
}
// toggle LED1 to show RDP level
BSP_LED_Toggle(LED1);
// program OB
HAL_FLASH_OB_Unlock();
HAL_FLASH_Unlock();
OBInit.OptionType = OPTIONBYTE_RDP;
OBInit.RDPLevel = OB_RDP_LEVEL_1;
HAL_FLASHEx_OBProgram(&OBInit);
/* Start the Option Bytes programming process */
if (HAL_FLASH_OB_Launch() != HAL_OK)
{
/* User can add here some code to deal with this error */
while (1)
{
BSP_LED_Toggle(LED1);
}
}
}
else
{
/* Wait for User push-button press before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)
{
}
BSP_LED_Toggle(LED2);
// program OB
HAL_FLASH_OB_Unlock();
HAL_FLASH_Unlock();
OBInit.OptionType = OPTIONBYTE_RDP;
OBInit.RDPLevel = OB_RDP_LEVEL_0;
HAL_FLASHEx_OBProgram(&OBInit);
/* Start the Option Bytes programming process */
if (HAL_FLASH_OB_Launch() != HAL_OK)
{
/* User can add here some code to deal with this error */
while (1)
{
BSP_LED_Toggle(LED2);
}
}
}
while (1)
{
}
}The switch to Level 1 works fine. I can check that I am in Level 1 for example because the debugger doesn't work anymore and the LED 2 switches on. However the regression to Level 0 doesn't seem to work. I know the Flash is supposed to be erased but I cannot do anything after the "regression": cannot connect to a debugger or to STM32CubeProgrammer, no LED switches, etc...
Do you see something wrong in the code ?
