
AN2662
USART bootloader
Doc ID 14156 Rev 1
The host sends the bytes to the STM32F105xx and STM32F107xx as follows:
2.12
Erase Memory command
The Erase Memory command allows the host to erase Flash memory pages. When the
bootloader receives the Erase Memory command, it transmits the ACK byte to the host.
After the transmission of the ACK byte, the bootloader receives one byte (number of pages
to be erased), the Flash memory page codes and a checksum byte; if the checksum is
correct then bootloader erases the memory and sends an ACK byte to the host, otherwise it
sends a NACK byte to the host and the command is aborted.
Erase Memory command specifications:
1.
the bootloader receives one byte that contains N, the number of pages to be erased –
1.
N = 255 is reserved for global erase requests. For 0
≤
N
≤
254, N + 1 pages are erased.
2.
the bootloader receives (N + 1) bytes, each byte containing a page number
Note:
No error is returned when performing erase operations on write protected sectors.
Byte 1:
0x31
Byte 2:
0xCE
Wait for ACK
Byte 3 to byte 6: start address
byte 3: MSB
byte 6: LSB
Byte 7:
Checksum: XOR (Byte3, Byte4, Byte5, Byte6)
Wait for ACK
Byte 8:
Number of bytes to be received (0 < N
≤
255)
N +1 data bytes:(Max 256 bytes)
Checksum byte: XOR (N, N+1 data bytes)