RM0367 Rev 7 97/1043
RM0367 Flash program memory and data EEPROM (FLASH)
122
Three types of protections are implemented.
3.4.1 RDP (Read Out Protection)
This type of protection aims at protecting against unwanted read (hacking) of the NVM
content. This protection is managed by RDPROT bitfield in the FLASH_OPTR register. The
value is loaded from the Option bytes area during a boot and copied in the read-only
register.
Three protection levels are defined:
• Level 0: no protection
Level 0 is set when RDPROT is set to 0xAA. When this level is enabled, and if no other
protection is enabled, read and write can be done in the Flash program memory, data
EEPROM and Option bytes areas without restrictions. It is also possible to read and
write the backup registers freely.
• Level 1: memory read protection
Level 1 is set when RDPROT is set to any value except 0xAA and 0xCC, respectively
used for Level 0 and Level 2. This is the default protection level after an Option bytes
erase or when there is a mismatch in the RDPROT field.
Level 1 protects the Flash program memory and data EEPROM. When protection Level
1 is set through boot from RAM, bootloader or debugger, a power-down or a standby is
required to execute the user code.
When this level is enabled:
– No access to the Flash program memory and data EEPROM (read both for fetch
and data and write) and no backup register reading is performed if the debug
features (single-wire), or the device boot in the RAM, or the System memory is
connected. If the user tries to read the Flash memory or data EEPROM, a hard
fault is generated. No restriction is present on other areas: it is possible to read
and write/erase the Option bytes area and to execute or read in the System
Memory.
– All operations are possible when the boot is done in the Flash program memory.
– Writing the first Option byte with a value that changes the protection level to Level
0 (it is necessary that byte 0 is 0xAA and byte 2 is 0x55), a mass erase is
generated. The mass erase deletes the Flash program memory and data
EEPROM, deletes the first Option byte and then rewrites it to enable Level 0 and
disable PCROP (WPRMOD = 0), and deletes the backup registers content.
• Level 2: disable debug and chip read protection
Level 2 is set when RDPROT is set to 0xCC. When this level is enabled, it is only
possible to boot from the Flash program memory, and the debug features (single-wire)
are disabled. The Option bytes are protected against write/erase and the protection
level can no longer be changed. The application can write/erase to the Flash program
memory and data EEPROM (it is only possible to boot from the Flash program memory
and execute the customer code) and access the backup registers. When an Option
bytes loading is executed and Level 2 is enabled, old informati
on on debug or boot in
the RAM or System memory are deleted.
Note: The debug feature is also disabled under reset. STMicroelectronics is not able to perform
analysis on defective parts on which level 2 protection has been set.
Figure 6 resumes the way the protection level can be changed and Table 19 the link
between the values read in the Option bytes and the protection level.