Code does not run when RDP is enabled on STM32L072
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-03-10 3:28 AM
Hi ST community,
I have a fully functional application on my STM32L072. The problem is when I tried to enable RDP, nothing works anymore.
After flashing the application I tried to connect with ST-Link, the option bytes are set correctly and it is not possible to read the FLASH memory, but the code no longer seems to enter the main.c.
WHAT IS HAPPENING?
Below my code to enable RDP. I call this function immediately after the MX_***_Init modules.
Edit: the main FW is loaded in-app by a bootloader, therefore without using the debugger (through SWD).
static void Enable_RDP(void)
{
FLASH_OBProgramInitTypeDef obConfig;
// Read opt bytes
HAL_FLASHEx_OBGetConfig(&obConfig);
if (obConfig.RDPLevel == OB_RDP_LEVEL_0 || obConfig.BORLevel == OB_BOR_OFF)
{
obConfig.OptionType = OPTIONBYTE_RDP | OPTIONBYTE_BOR;
obConfig.RDPLevel = OB_RDP_LEVEL_1;
obConfig.BORLevel = OB_BOR_LEVEL4;
// Flash optbyte
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBProgram(&obConfig);
HAL_FLASH_OB_Launch(); // This will cause a system reset
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
}
Labels:
- Labels:
-
Flash
-
RDP
-
STM32L0 Series
This discussion is locked. Please start a new topic to ask your question.
0 REPLIES 0
