2017-05-18 10:30 PM
I want to protect ST32F030 code RDP_Level_1. I use stadrard perihperial library and call protect function when program starts:
void ProtectMcu (void)
{
if(FLASH_OB_GetRDP()==SET) return;
FLASH_OB_Unlock(); FLASH_OB_RDPConfig(OB_RDP_Level_1); FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); FLASH_OB_Lock(); FLASH_OB_Launch();}
But it doesnt work. The function executes full sentence each time the processor starts. I also power down device but with no effect - code is not protected and can be read by a debugger.
When I protect device by a programmer it is protected ok.
Where is the problem ?
With best regards
2017-11-23 10:16 AM
Are you sure the LOCK should be before the LAUNCH ?
2018-06-06 03:14 AM
Hi!
If you (or somebody else) still need a solution, try following:
if (RESET == FLASH_OB_GetRDP()) //checking protection status
{FLASH_Unlock(); //unblock the FLASH (!!)
FLASH_OB_Unlock(); //unblock the Option Byte if (FLASH_COMPLETE == FLASH_OB_RDPConfig(OB_RDP_Level_1)) FLASH_OB_Launch(); FLASH_OB_Lock(); FLASH_Lock();}