June 2021 AN4286 Rev 10 1/48
1
AN4286
Application note
SPI protocol used in the STM32 bootloader
Introduction
This application note describes the SPI protocol used in the STM32 microcontroller
bootloader, detailing each supported command.
This document applies to the STM32 products embedding bootloader versions V8.x, V9.x,
V11.x, V12.x and V13.x, as specified in AN2606 “STM32 microcontroller 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 SPI hardware resources and requirements for your device
bootloader, refer to the already mentioned AN2606.
Table 1. Applicable products
Product family Product series
Microcontrollers
STM32F4 Series
STM32F7 Series
STM32G0 Series
STM32G4 Series
STM32H7 Series
STM32L0 Series
STM32L4 Series
STM32L5 Series
STM32WB Series
STM32WL Series
www.st.com
Contents AN4286
2/48 AN4286 Rev 10
Contents
1 SPI bootloader code sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Bootloader command set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1 Safety of communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Get Version command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Get ID command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 Read Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.6 Go command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.7 Write Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.8 Erase Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.9 Write Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.10 Write Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.11 Readout Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.12 Readout Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.13 Get Checksum command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.14 Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.15 Extended Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3 Evolution of the bootloader protocol versions . . . . . . . . . . . . . . . . . . 46
4 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47