Page 1
It details each supported command. For more information about the USART hardware resources and requirements for your device bootloader, please refer to the “STM32 system memory boot mode” application note (AN2606). Related documents Available from www.st.com: AN2606 “STM32 system memory boot mode” April 2010 Doc ID 17066 Rev 2 1/37 www.st.com...
AN3155 USART bootloader code sequence USART bootloader code sequence Figure 1. Bootloader for STM32 with USART Once the system memory boot mode is entered and the STM32 microcontroller has been configured (for more details refer to application note AN2606 “STM32 system memory boot mode”) the bootloader code begins to scan the USARTx_RX line pin, waiting to receive the...
Choosing the USARTx baud rate AN3155 Choosing the USARTx baud rate The calculation of the serial baud rate for USARTx, from the length of the first byte that is received, is used to operate the bootloader within a wide range of baud rates. However, the upper and lower limits have to be kept, in order to ensure proper data transfer.
AN3155 Bootloader command set Bootloader command set The supported commands are listed in Table 1 below. Each command is further described in this section. Table 1. USART bootloader commands Command Command code Command description Gets the version and the allowed commands supported...
Bootloader command set AN3155 Each packet is either accepted (ACK answer) or discarded (NACK answer): ● ACK = 0x79 ● NACK = 0x1F Device-dependent bootloader parameters While the USART bootloader protocol’s command set and sequences are the same for all the STM32 devices, some parameters are device-dependent.
AN3155 Bootloader command set Get command The Get command allows you to get the version of the bootloader and the supported commands. When the bootloader receives the Get command, it transmits the bootloader version and the supported command codes to the host, as described in Figure Figure 2.
Bootloader command set AN3155 The STM32 sends the bytes as follows: Byte 1: Byte 2: N = 11 = the number of bytes to follow – 1 except current and ACKs. Byte 3: Bootloader version (0 < Version < 255), example: 0x10 = Version 1.0...
AN3155 Bootloader command set Figure 4. Get Version & Read Protection Status command: host side Start GV Send 0x01+0xFE NACK Wait for ACK or NACK Receive the bootloader version Receive the number of times the read protection was disabled Receive the number of times the...
Bootloader command set AN3155 The STM32 sends the bytes as follows: Byte 1: Bootloader version (0 < Version ≤ 255), example: 0x10 = Version 1.0 Byte 2: Byte 3: Option byte 1: 0x00 to keep the compatibility with generic bootloader protocol...
AN3155 Bootloader command set Figure 7. Get ID command: device side Start GID Received byte = 0x02+0xFD? Send NACK byte Send ACK byte Send N = number of bytes – 1 Send product ID Send ACK byte End of GID ai14636 1.
Bootloader command set AN3155 The host sends bytes to the STM32 as follows: Bytes 1-2: 0x11+0xEE Wait for ACK Bytes 3 to 6: start address ● byte 3: MSB ● byte 6: LSB Byte 7: Checksum: XOR (byte 3, byte 4, byte 5, byte 6) Wait for ACK The number of bytes to be read –...
AN3155 Bootloader command set Figure 9. Read Memory command: device side Start RM Received byte = 0x11+0xEE ROP active Send ACK byte Receive the start address (4 bytes) with checksum Address valid & checksum OK? Send ACK byte Receive the number of bytes to be read (1 byte)
Bootloader command set AN3155 Go command The Go command is used to execute the downloaded code or any other code by branching to an address specified by the application. When the bootloader receives the Go command, it transmits the ACK byte to the application. After the transmission of the ACK byte, the bootloader waits for an address (4 bytes, byte 1 is the address MSB and byte 4 is LSB) and a checksum byte, then it checks the received address.
AN3155 Bootloader command set Note: Valid addresses for the Go command are in RAM or Flash memory (refer to Section 3.1: Device-dependent bootloader parameters for more details about the valid memory addresses for the device you are using). All other addresses are considered not valid and are NACKed by the device.
AN3155 Bootloader command set Figure 12. Write Memory command: host side 1. WM = Write Memory. 2. N+1 should always be a multiple of 4. Doc ID 17066 Rev 2 19/37...
Bootloader command set AN3155 Figure 13. Write Memory command: device side Start WM Received byte = 0x31+0xCE? ROP inactive? Send ACK byte Receive the start address (4 bytes) & checksum Checksum OK? Send ACK byte Receive the number of bytes to be written...
AN3155 Bootloader command set The host sends the bytes to the STM32 as follows: 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 Number of bytes to be received (0 <...
Bootloader command set AN3155 Figure 14. Erase Memory command: host side Start ER Send 0x43+0xBC NACK Wait for ACK or NACK Global Erase? Send 0xFF Send the number of pages to be erased (1 byte) Send 0x00 Send the page numbers...
AN3155 Bootloader command set Figure 15. Erase Memory command: device side Start ER Received bytes = 0x43+0xBC? ROP active Send ACK byte Receive the number of pages to be erased (1 byte) 0xFF received? Receive the page codes Start Global Erase...
Bootloader command set AN3155 Extended Erase Memory command The Extended Erase Memory command allows the host to erase Flash memory pages using two bytes addressing mode. When the bootloader receives the Extended Erase Memory command, it transmits the ACK byte to the host. After the transmission of the ACK byte, the...
AN3155 Bootloader command set Figure 16. Extended Erase Memory command: host side Start EER Send 0x44 + 0xBB NACK Wait for ACK or NACK Special Erase ? Send the number of pages to be erased N (on two Send Special Erase cmd:...
Bootloader command set AN3155 Figure 17. Extended Erase Memory command: device side Start EER Received bytes = 0x44 + 0xBB ? ROP Active ? Send ACK Byte Receive Number of Pages to be erased N (2 bytes) MSB first 0xFFFY received ? Where Y can be [0..F]...
AN3155 Bootloader command set The host sends the bytes to the STM32F1xxx as follows: Byte 1: 0x44 Byte 2: 0xBB Wait for ACK Bytes 3-4: - Special erase (0xFFFF, 0xFFFE or 0xFFFD) - Number of pages to be erased (N+1 where: 0 ≤ N < Maximum number of pages).
Bootloader command set AN3155 Figure 18. Write Protect command: host side Start WP Send 0x63+0x9C NACK Wait for ACK or NACK Send the number of sectors to be protected (1 byte) Send the sector codes Send checksum NACK Wait for ACK...
AN3155 Bootloader command set Figure 19. Write Protect command: device side Start WP Received bytes = 0x63+0x9C? ROP active Send ACK byte Receive the number of sectors to be protected (1 byte) Receive the sector codes Receive the checksum Checksum...
Bootloader command set AN3155 3.11 Write Unprotect command The Write Unprotect command is used to disable the write protection of all the Flash memory sectors. When the bootloader receives the Write Unprotect command, it transmits the ACK byte to the host. After the transmission of the ACK byte, the bootloader disables the write protection of all the Flash memory sectors.
AN3155 Bootloader command set Figure 21. Write Unprotect command: device side Start WPUN Received bytes = 0x73+0x8C? ROP active Send ACK byte Remove the protection for the entire Flash memory Send ACK byte Send NACK byte Generate system reset End of WPUN ai14648b 1.
AN3155 Bootloader command set 3.13 Readout Unprotect command The Readout Unprotect command is used to disable the Flash memory read protection. When the bootloader receives the Readout Unprotect command, it transmits the ACK byte to the host. After the transmission of the ACK byte, the bootloader erases all the Flash memory sectors and it disables the read protection for the entire Flash memory.
AN3155 Bootloader protocol version evolution Bootloader protocol version evolution Table 2 lists the bootloader versions. Table 2. Bootloader protocol versions Version Description V2.0 Initial bootloader version. – Update Go command to initialize the main stack pointer – Update Go command to return NACK when jump address is in the Option byte area or System memory area V2.1...
Revision history AN3155 Revision history Table 3. Document revision history Date Revision Changes 09-Mar-2010 Initial release. Table 1: USART bootloader commands: added Extended Erase command; removed footnote 2 concerning read protection from the Readout Protect command. Communication safety: amended Note Section 3.2: Get...
Page 37
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.
Need help?
Do you have a question about the AN3155 and is the answer not in the manual?
Questions and answers