March 2024 AN4221 Rev 13 1/60
1
AN4221
Application note
I2C protocol used in the STM32 bootloader
Introduction
This application note describes the I2C protocol used in the STM32 microcontroller
bootloader, detailing each supported command.
This document applies to the STM32 products embedding bootloader versions V5.x,
V6.x,V7.x, V8.x, V9.x, V10.x, V11.x, V13.x, and V14.x, as specified in the application note
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 I2C hardware resources and requirements for your device
bootloader, refer to the already mentioned AN2606.
.
Table 1. Applicable products
Type Part numbers or series
Microcontrollers
STM32C0 series
STM32F0 series
STM32F3 series
STM32F4 series
STM32F7 series
STM32G0 series
STM32G4 series
STM32H5 series
STM32H7 series
STM32L0 series
STM32L4 series
STM32L5 series
STM32U0 series
STM32U5 series
STM32WB series
STM32WBA series
www.st.com
Contents AN4221
2/60 AN4221 Rev 13
Contents
1 I2C bootloader code sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Bootloader command set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 Get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Get Version command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Get ID command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4 Read Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.5 Go command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.6 Write Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.7 Erase Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8 Write Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.9 Write Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.10 Readout Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.11 Readout Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.12 No-Stretch Write Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.13 No-Stretch Erase Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.14 Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.15 Extended Special command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.16 No-Stretch Write Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.17 No-Stretch Write Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.18 No-Stretch Readout Protect command . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.19 No-Stretch Readout Unprotect command . . . . . . . . . . . . . . . . . . . . . . . . 53
2.20 No-Stretch GetCheckSum command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3 Bootloader protocol version evolution . . . . . . . . . . . . . . . . . . . . . . . . . 57
4 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58