cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 and Read Out Protect problem

wadi
Associate II
Posted on May 19, 2017 at 07:30

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

2 REPLIES 2
Olivier FAURAX
Associate II
Posted on November 23, 2017 at 19:16

Are you sure the LOCK should be before the LAUNCH ?

Vitaly Lifanov
Associate
Posted on June 06, 2018 at 12:14

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();

}