Memory Protection; Read Protection - STMicroelectronics STM32F05 series Reference Manual

Advanced arm-based 32-bit mcus
Table of Contents

Advertisement

RM0091
The value of the addressed option byte is first read to check it is really erased. If not, the
program operation is skipped and a warning is issued by the WRPRTERR bit in the
FLASH_SR register. The end of the program operation is indicated by the EOP bit in the
FLASH_SR register.
The LSB value is automatically complemented into the MSB before the programming
operation starts. This guarantees that the option byte and its complement are always
correct.
The sequence is as follows:
1.
Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register.
2.
Unlock the OPTWRE bit in the FLASH_CR register.
3.
Set the OPTPG bit in the FLASH_CR register
4.
Write the data (half-word) to the desired address
5.
Wait for the BSY bit to be reset.
6.
Read the programmed value and verify.
When the Flash memory read protection option is changed from protected to unprotected, a
Mass Erase of the main Flash memory is performed before reprogramming the read
protection option. If the user wants to change an option other than the read protection
option, then the mass erase is not performed. The erased state of the read protection option
byte protects the Flash memory.
Erase procedure
The option byte erase sequence is as follows:
1.
Check that no Flash memory operation is ongoing by reading the BSY bit in the
FLASH_SR register
2.
Unlock the OPTWRE bit in the FLASH_CR register
3.
Set the OPTER bit in the FLASH_CR register
4.
Set the STRT bit in the FLASH_CR register
5.
Wait for BSY to reset
6.
Read the erased option bytes and verify
3.3

Memory protection

The user area of the Flash memory can be protected against read by untrusted code. The
pages of the Flash memory can also be protected against unwanted write due to loss of
program counter contexts. The write-protection granularity is one sector (four pages).
3.3.1

Read protection

The read protection is activated by setting the RDP option byte and then, by applying a
system reset to reload the new RDP option byte.
Note:
If the read protection is set while the debugger is still connected through SWD, apply a POR
(power-on reset) instead of a system reset.
There are three levels of read protection from no protection (level 0) to maximum protection
or no debug (level 2). Refer to
modes.
Table 6: Access status versus protection level and execution
Doc ID 018940 Rev 1
Embedded Flash memory
49/742

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F05 series and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents