Skip to main content
wadi
Associate II
May 19, 2017
Question

STM32F0 and Read Out Protect problem

  • May 19, 2017
  • 2 replies
  • 1030 views
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

    This topic has been closed for replies.

    2 replies

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

    Are you sure the LOCK should be before the LAUNCH ?

    Vitaly Lifanov
    Visitor II
    June 6, 2018
    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();

    }