Skip to main content
hrobinson
Associate II
Nov 10, 2014 2:03 PM UTC
Question

RDP - Readout Protection on STM32F10x

Posted on November 10, 2014 at 15:03

Hi,

I'm having a problem with the CMSIS peripheral library call to set Readout Protection on STM32F10x:

I call FLASH_ReadOutProtection(ENABLE)

I have put a flag into this function to verify that it's setting OB->RDP = 0x00

everything seems fine, except...

it doesn't set readout protection.  Even after a power cycle, when I call

FLASH_GetReadOutProtectionStatus()

I get a result 0

This is corroborated using STLink-V2

Any ideas?

#rdp #readout-protection
This topic has been closed for replies.

3 replies

Amel NASRI
ST Technical Moderator
Nov 10, 2014 4:36 PM UTC
Posted on November 10, 2014 at 17:36

Hi Henry,

Did you tried to use the ST-Link Utility?

This can help yo to confirm if issue is in hardware side or firmware one.

-Mayla-

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Tesla DeLorean
Guru
Nov 10, 2014 5:07 PM UTC
Posted on November 10, 2014 at 18:07

Try doing it without the debugger attached, and pay attention to flags and status

void Flash_ReadOutProtection(int x) // 0=Status, 1=Lock, 2=Unlock - sourcer32@gmail.com
{
printf(''Flash_ReadOutProtection :

'');
if (FLASH_GetReadOutProtectionStatus())
printf(''Read Out Protected

'');
else
printf(''Read Out Un-Protected

'');
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
if (x == 1)
{
printf(''Attempting to lock

'');
if (FLASH_GetReadOutProtectionStatus() != SET)
{
if (FLASH_ReadOutProtection(ENABLE) == FLASH_COMPLETE)
printf(''Read Out Passed

'');
else
printf(''Read Out Failed

'');
}
printf(''Cycle Power Now!

'');
Debug_Flush(); // Ensure telemetry clears threshold
while(1);
// NVIC_GenerateSystemReset();
}
else if (x == 2)
{
printf(''Attempting to unlock, Cycle Power Now!

'');
Debug_Flush();
FLASH_ReadOutProtection(DISABLE); // If it succeeds it nukes the part, not coming back here
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
hrobinson
hrobinsonAuthor
Associate II
Nov 10, 2014 5:48 PM UTC
Posted on November 10, 2014 at 18:48

Hi,

thanks -

Mayla, yes I tested using STLink_V2, which confirmed it was a firmware problem.

Clive, yes I was looking at all the flags and status returned, all looked as I would expect; the ONLY things that were wrong were that FLASH_GetReadOutProtectionStatus() was reporting 0 (not protected) and this was confirmed using ST-Link (i.e. independent and reliable means).

I did try with the debugger disconnected, same result.

What I have now noticed though, looking at your code - was that I was missing ''FLASH_Unlock()''.

Looking at the code for FLASH_ReadOutProtection() it seemed as though it was setting keys to authorize access, but in fact it's only authorizing access to the Option bytes.  I needed FLASH_Unlock() to unlock the FPEC first!!!

So now it all works.

Thanks!