
USART bootloader
AN2662
Doc ID 14156 Rev 1
2.13
Write Protect command
The Write Protect command is used to enable the write protection for some or all Flash
memory sectors. When the bootloader receives the Write Protect command, it transmits the
ACK byte to the host. After the transmission of the ACK byte, the bootloader waits for the
number of bytes to be received (sectors to be protected) and then receives the Flash
memory sector codes from the user.
At the end of the Write Protect command, the bootloader transmits the ACK byte and
generates a system Reset to take into account the new configuration of the option byte.
Note:
On the STM32F105xx and STM32F107xx , the sector size is 4 Kbytes (2 pages) for the
Write Protect command.
The Write Protect command sequence is as follows:
●
the bootloader receives one byte that contains N, the number of sectors to be write-
protected – 1 (0
≤
N
≤
255)
●
the bootloader receives (N + 1) bytes, each byte contains a sector code
Note:
The total number of sectors and the sector number to be protected are not checked, this
means that no error is returned when a command is passed with a wrong number of sectors
to be protected or a wrong sector number.
Note:
If a second Write Protect command is executed, the Flash memory sectors that had been
protected by the first command become unprotected and only the sectors passed within the
second Write Protect command become protected.
Figure 17.
Write Protect command: host side
1.
WP = Write Protect.
Wait for ACK
or NACK
Wait for ACK
or NACK
End of WP
(1)
NACK
ACK
ai14645b
Send 0x63+0x9C
Start WP
(1)
Send the number of sectors
to be protected (1 byte)
Send the sector codes
Send checksum
NACK
ACK