Embedded Flash memory
RM0365
69/1080
DocID025202 Rev 7
Changing read protection level
It is easy to move from level 0 to level 1 by changing the value of the RDP byte to any value
(except 0xCC). By programming the 0xCC value in the RDP byte, it is possible to go to level
2 either directly from level 0 or from level 1. On the contrary, the change to level 0 (no
protection) is not possible without a main Flash memory Mass Erase operation. This Mass
Erase is generated as soon as 0xAA is programmed in the RDP byte.
Note:
When the Mass Erase command is used, the backup registers (RTC_BKPxR in the RTC)
are also reset.
To validate the protection level change, the option bytes must be reloaded through the
OBL_LAUNCH bit in Flash control register.
4.3.2 Write
protection
The write protection is implemented with a granularity of 2 pages. It is activated by
configuring the WRP[1:0] option bytes, and then by reloading them by setting the
OBL_LAUNCH bit in the FLASH_CR register.
If a program or an erase operation is performed on a protected , the Flash memory returns a
WRPRTERR protection error flag in the Flash memory Status Register (FLASH_SR).
Table 8. Access status versus protection level and execution modes
Area
Protection
level
User execution
Debug/ BootFromRam/
BootFromLoader
Read Write Erase Read Write Erase
Main Flash
memory
1
Yes Yes Yes No No No
2
Yes Yes Yes N/A
(1)
N/A
N/A
System
memory
(2)
1
Yes No No Yes No No
2
Yes No No NA
N/A
N/A
Option bytes
1
Yes
Yes
(3)
Yes Yes Yes
Yes
2
Yes
Yes
(4)
No N/A
N/A
Backup
registers
1
Yes Yes
N/A No
No
No
(5)
2
Yes
Yes
N/A
N/A
N/A
1. When the protection level 2 is active, the Debug port, the boot from RAM and the boot from system memory
are disabled.
2. The system memory is only read-accessible, whatever the protection level (0, 1 or 2) and execution mode.
3. The main Flash memory is erased when the RDP option byte is programmed with all level protections
disabled (0xAA).
4. All option bytes can be programmed, except the RDP byte.
5. The backup registers are erased only when RDP changes from level 1 to level 0.