方法1:代码解密
FLASH_OBProgramInitTypeDef OBInit;
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
HAL_FLASHEx_OBGetConfig(&OBInit);
if(OBInit.RDPLevel != OB_RDP_LEVEL_0)
{
OBInit.OptionType = OPTIONBYTE_RDP;
OBInit.RDPLevel = OB_RDP_LEVEL_0;
(void)HAL_FLASH_Unlock();
(void)HAL_FLASH_OB_Unlock();
(void)HAL_FLASHEx_OBProgram(&OBInit);
(void)HAL_FLASH_OB_Lock();
(void)HAL_FLASH_Lock();
}
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
方法2:STVP 命令行解密
1)配置后save as unlock.hex
2)通过stvp界面或命令行烧写OPTION BYTE(unlock.hex)
STVP_CmdLine -port=USB -BoardName=ST-LINK -Device=stm32L073xB -ProgMode=SWD -progress -no_warn_protect -no_loop -FileOption=unlock.hex
相关文章