cancel
Showing results for 
Search instead for 
Did you mean: 

flash readback protection

yarona
Associate II
Posted on November 30, 2015 at 16:38

Hi

I am trying to enable flash read protection (level 1) on STM32L151 chip.

I use this code section, at the beggining of my program:

 FLASH_Status FLASHStatus = FLASH_COMPLETE;

 

 /* Unlock the Flash Program Erase controller */

 FLASH_Unlock();

 

 FLASH_OB_Unlock();

 

 if (!FLASH_OB_GetRDP())

 {

   FLASHStatus = FLASH_OB_RDPConfig(OB_RDP_Level_1); 

 

    if (FLASHStatus == FLASH_COMPLETE)

    {

      /* Generate System Reset to load the new option byte values */

      FLASH_OB_Launch();

    }

  } 

I am able to set the read protection (I know that becuase after I cannot connect to the chip via the debugger).

the problem is that after I enable read protection, my code doesn't run anymore... (I verify this using led toggle).

I have tried setting read protection  also using STM32 ST-LINK utility, with same results.

I am using STM32 ST-LINK utility to set back read protection to level 0, and than I can connect via debugger again.

Any ideas what I am doing wrong? how can I debug this issue?

Many thanks

Yaron

#stm32
2 REPLIES 2
Amel NASRI
ST Employee
Posted on December 09, 2015 at 16:12

Hi apel.yaron,

May be you erased your flash content (setting protection to Level 1 then Level 0 will has as impact the mass-erase of your chip).

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on December 09, 2015 at 16:58

Pretty sure you need to power cycle after doing it.

Anyway, to debug you're going to want to provide some method to interact with your firmware via a serial port, and have that working early enough in the boot process that you can see where it gets within your code. You could use GPIO too if that suits your debugging style.

You'd probably only want to program/reprogram the OB if they aren't already in the state you want.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..