cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L100RCT6 : Problem with read out protection

mpare
Associate II
Posted on June 03, 2014 at 21:24

Hi all,

I am using evaluation board STM32L100C-DISCO.  I have a problem with read-out protection.  I am using this code :

[code]

    /* Unlock the Flash Program Erase controller */

    FLASH_Unlock();

    FLASH_OB_Unlock();

    /* Clear all FLASH flags */

    FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);

    /*  => to set the desired read Protection Level */

    FLASH_OB_RDPConfig(OB_RDP_Level_1);

    /* launch the Option Bytes programming process.*/

    FLASH_OB_Launch();

    FLASH_OB_Lock();

[/code]

When it reaches FLASH_OB_Launch(); it freezes. I am using IAR 7.10. I have used the same code for STM32F0 and STM32F2 and it was working fine. Is there something different to do for this processor?

Thank you!

#brought-to-you-by-microsoft(tm)
8 REPLIES 8
mpare
Associate II
Posted on June 03, 2014 at 21:26

And if somebody can tell me how to insert C code in a post correctly, I would do it better next time!

Posted on June 03, 2014 at 22:14

And if somebody can tell me how to insert C code in a post correctly, I would do it better next time!

It's that obvious ''Format Code Block'' with the Paintbrush [<>] icon top left of the Word-in-a-box interface.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 03, 2014 at 22:23

I'd need to go dig up the STM32L100C-DISCO board I have, the library doesn't suggest it needs to be in RAM, but the L1 parts have a funny EEPROM/FLASH thing going on. And you have to do some things with the prefetch/caching of FLASH lines.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/flash%20readback%20protection&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=307]Related STM32F0 RDP example
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mpare
Associate II
Posted on June 04, 2014 at 18:00

Hi Clive,

I adapted the code from the example of the STM32F0 to fit with the STM32L1:

FLASH_Status FLASHStatus = FLASH_COMPLETE;
/* Unlock the Flash Program Erase controller */
FLASH_Unlock();
FLASH_OB_Unlock();
/* Clear all FLASH flags */
FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR
| FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);
if
(!FLASH_OB_GetRDP())
{
FLASHStatus = FLASH_OB_RDPConfig(OB_RDP_Level_1); 
// Locks Chip (Lvl 2 Toasts)
if
(FLASHStatus == FLASH_COMPLETE)
{
/* Generate System Reset to load the new option byte values */
FLASH_OB_Launch();
}
}

and still it freezes when executing FLASH_OB_Launch().
Posted on June 04, 2014 at 19:52

It freezes in the debugger? I don't know if I would step that, as I'd expect the system to be resetting, and the debugger is more of a hindrance than a help. I might instrument the code with output via USART (flushing chars as I went, ie back testing TC), to see it traverse this code, and then also output in the ResetHandler path to see the system come back.

Potential issues with resetting will occur if NRST is actively driven high (PP drivers) by external circuitry, ie other chips, FPGA, tied to VCC, etc.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mpare
Associate II
Posted on June 05, 2014 at 21:41

I was stepping it in the debugger, which was a bad idea...

With debug through the UART, I was able to find something else.  It seems that it will program the Read out protection to Level 1 (this is what I want), and it will program every page with Read/Write protection. This seems to be causing the crash.

I just need to find the cause of this to find a fix.

abuelmagd
Associate II
Posted on November 20, 2014 at 12:42

I am also witnessing the exact same crash on my STM32L100RCT6. I'm also able to confirm that the readout protection was successfully changed to level 1 when I check with the ST-Link Utility. Did you ever find a way around the issue?

abuelmagd
Associate II
Posted on January 18, 2015 at 10:36

We figured out what the problem was.

It is not sufficient to call the API provided by ST:

FLASH_OB_Launch();

This call only causes a soft reset of the system which is not sufficient in the case of a readout protection change. You need to additionally disconnect and reconnect the supply source going to the controller.