cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH_ReadOutProtection(ENABLE) erases all non-write protected flash.

swhite
Associate III
Posted on August 06, 2009 at 15:42

FLASH_ReadOutProtection(ENABLE) erases all non-write protected flash.

5 REPLIES 5
swhite
Associate III
Posted on May 17, 2011 at 13:20

My experiments, based on code that runs out of RAM (via IAR's debugger), shows that enabling flash read-protection via the ST library function

FLASH_ReadOutProtection(ENABLE);

erases all flash that is not write-protected. This behavior is NOT documented (that I can find).

Can anyone else confirm this?

kutnickg
Associate II
Posted on May 17, 2011 at 13:20

What have you done to demonstrate this - have you disabled read out protection at some point afterwards? I would expect that enabling it could make the flash appear to be erased afterwards since you can no longer read it.

swhite
Associate III
Posted on May 17, 2011 at 13:20

No flash-read protection is disabled beforehand. This is confirmed by calling

FLASH_GetReadOutProtectionStatus()

I then do

FLASH_Unlock();

FLASH_ReadOutProtection(ENABLE);

FLASH_Lock();

and then reset.

My own custom bootloader is erased if its not write-protected. This is confirmed by the fact that the device will no longer boot.

This is output from my program that runs in RAM.

======================================================================

=

= STM32F10xx Flash Protection View/Change program.

=

======================================================================

Flash read-protection is DISABLED.

Flash user options: WDG_SW=1, nRST_STOP=1, nRST_STDBY=1.

Flash user Data0=0xFF, Data1=0xFF.

Flash write-protection is partially/fully ENABLED.

1) Enable flash read-protection.

2) Disable flash read-protection (may mass-erase flash!).

3) Enable (ALL) flash write-protection.

4) Disable (ALL) flash write-protection.

5) Mass-erase flash.

Flash read-protection ENABLED! Reset for change to take effect.

*Exit debugger, power-cycle hardware, and restart program in RAM*

======================================================================

=

= STM32F10xx Flash Protection View/Change program.

=

======================================================================

Flash read-protection is ENABLED.

Flash user options: WDG_SW=1, nRST_STOP=1, nRST_STDBY=1.

Flash user Data0=0xFF, Data1=0xFF.

Flash write-protection is DISABLED.

1) Enable flash read-protection.

2) Disable flash read-protection (may mass-erase flash!).

3) Enable (ALL) flash write-protection.

4) Disable (ALL) flash write-protection.

5) Mass-erase flash.

*Program in flash is still present and product boots*

*Run utility again (write protection disabled now)*

======================================================================

=

= STM32F10xx Flash Protection View/Change program.

=

======================================================================

Flash read-protection is ENABLED.

Flash user options: WDG_SW=1, nRST_STOP=1, nRST_STDBY=1.

Flash user Data0=0xFF, Data1=0xFF.

Flash write-protection is DISABLED.

1) Enable flash read-protection.

2) Disable flash read-protection (may mass-erase flash!).

3) Enable (ALL) flash write-protection.

4) Disable (ALL) flash write-protection.

5) Mass-erase flash.

Flash read-protection ENABLED! Reset for change to take effect.

*Exit debugger, power-cycle hardware, and flash has been erased!!! *

*Product will no longer boot *

[ This message was edited by: swhite on 06-08-2009 17:45 ]

[ This message was edited by: swhite on 06-08-2009 17:47 ]

kutnickg
Associate II
Posted on May 17, 2011 at 13:20

I don't think that necessarily confirms that flash has been erased, only that your flash code can't run while read protection is on. Are you connected via JTAG?

This thread should address the situation more:

http://62.193.238.133/modules.php?mop=modload&name=Splatt_Forums&file=viewtopic&forum=23&topic=7603&opa=denotifica

swhite
Associate III
Posted on May 17, 2011 at 13:20

My code in flash runs when write-protection is enabled. It writes stuff out a serial port--including the same information as the RAM program above.

Yes I load the RAM program via JTAG (a J-Link). As I posted above once I change an option in that I close the debug session and power-cycle the hardware. I don't just rerun the program.

AppLoader: Processor unique ID is 0x43065233-33323558-066E0032.

AppLoader: Processor total flash size is 128KB.

AppLoader: Processor system clock is 72MHz.

AppLoader: Flash read-protection is DISABLED.

AppLoader: Flash user options: WDG_SW=1, nRST_STOP=1, nRST_STDBY=1.

AppLoader: Flash user Data0=0xFF, Data1=0xFF.

AppLoader: AppLoader flash write-protection is ENABLED.

AppLoader: v01.00a (rel), 08/06/2009 08:39.

AppLoader: Occupying 32KB of flash.

AppLoader: SD card label is 'TESTING'.

AppLoader: SD card capacity is 502176KB.

AppLoader: SD card free space is 501688KB.

AppLoader: '''' is resident in flash at 0x08009000 (size of 92KB).

AppLoader: 'AppFlash.img' on the SD card contains ''''.

AppLoader: 'AppFlash.img' is already resident in the flash.

AppLoader: Starting ''''.

AppLoader: PC = 0x08012a05, SP = 0x20005000.

[ This message was edited by: swhite on 06-08-2009 19:29 ]