May 2024 AN3155 Rev 18 1/51
1
AN3155
Application note
USART protocol used in the STM32 bootloader
Introduction
This application note describes the USART protocol used in the STM32 microcontroller
bootloader, providing details on each supported command.
This document applies to STM32 products embedding any bootloader version, as specified
in AN2606 STM32 system memory boot mode, available on www.st.com. These products
are listed in
Table 1, and are referred to as STM32 throughout the document.
For more information about the USART hardware resources and requirements for your
device bootloader, refer to the already mentioned AN2606.
Table 1. Applicable products
Type Product series
Microcontrollers
STM32C0 series
STM32F0 series
STM32F1 series
STM32F2 series
STM32F3 series
STM32F4 series
STM32F7 series
STM32G0 series
STM32G4 series
STM32H5 series
STM32H7 series
STM32L0 series
STM32L1 series
STM32L4 series
STM32L5 series
STM32U0 series
STM32U5 series
STM32WB series
STM32WBA series
STM32WB0 series
STM32WL series
www.st.com
Contents AN3155
2/51 AN3155 Rev 18
Contents
1 USART bootloader code sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Choosing the USARTx baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 Minimum baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Maximum baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Bootloader command set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1 Get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Get Version command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Get ID command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Read Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 Go command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6 Write Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7 Erase Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.8 Extended Erase Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.9 Write Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.10 Write Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.11 Readout Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.12 Readout Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.13 Get Checksum command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.14 Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.15 Extended Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4 Bootloader protocol version evolution . . . . . . . . . . . . . . . . . . . . . . . . . 47
5 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48