Skip to main content
JJRR
Associate III
October 13, 2020
Question

STM32L0 - reset after setting RDP

  • October 13, 2020
  • 2 replies
  • 1350 views

Dear,

I am setting RDP to level 1 in my application, After setting it I call System reset HAL_NVIC_SystemReset();

After reset I am expecting the MCU is locked, but it seems I read in code the MCU is still in level 0 so the procedure of setting RDP to level 1 is repeating. Only power disconnect locks the processor to level 1.

Any solution?

Best regards, Jan.

 HAL_FLASHEx_OBGetConfig(&flashTemp);
	if(OB_RDP_LEVEL_0 == flashTemp.RDPLevel)
	{
		HAL_FLASH_OB_Unlock();
		HAL_FLASHEx_OBGetConfig(&pOBInit);
		pOBInit.RDPLevel = 0xBB;
		pOBInit.WRPState = OB_WRPSTATE_ENABLE;
		HAL_FLASHEx_OBProgram(&pOBInit);
		HAL_FLASH_OB_Lock();
		HAL_NVIC_SystemReset();
	}

This topic has been closed for replies.

2 replies

TDK
Super User
October 13, 2020

What chip?

Look at the code:

https://github.com/STMicroelectronics/STM32CubeL0/blob/58c3ec5bb16e3475309da63f64d62efb2782594d/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ex.c#L327

You need to add:

pOBInit.OptionType = OPTIONBYTE_RDP | OPTIONBYTE_WRP;

if you want to set those options.

"If you feel a post has answered your question, please click ""Accept as Solution""."
JJRR
JJRRAuthor
Associate III
October 13, 2020

STM32L071

TDK
Super User
October 13, 2020
Thanks, I didn't see it initially. I edited my post after asking. See the new answer.
"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
October 14, 2020

Funny how problems occur in pairs -- somewhat related.

You might probably need to reload the option bytes after programming, see Reloading Option bytes by software subchapter in RM.

JW