Boot mode selection
At startup, the BOOT0 pin or option bit (based on the value of the BOOT_SEL option bit) and BOOTADD[31:8] option bytes are used to select the boot memory address that includes:
- Boot from any address in user flash memory
- Boot from system memory
→ Bootloader
When boot from user flash is selected, the boot address is defined by BOOTADD. This address can be locked thanks to BOOT_LOCK.
Embedded bootloader
The embedded bootloader is located in the system memory and is programmed by ST during production. It is used to reprogram the flash memory using USART, SPI, FDCAN, or USB in device mode through the DFU (device firmware upgrade).
Refer to the application note STM32 microcontroller system memory boot mode (AN2606).
STM32C5 boot modes
| RPD_STATE | BOOT_SEL option bit | BOOT0 option bit |
BOOT0 pin | EMPTY flag value(1) | Boot area |
|---|---|---|---|---|---|
| Level 0 | 1 | X | 0 | X | Boot address defined by user option byte BOOTADD[31:8] |
| 1 | Bootloader | ||||
| 0 | 0 | X | 0 | Boot address defined by user option byte BOOTADD[31:8] | |
| 1 | Bootloader | ||||
| 1 | X | Bootloader | |||
| Level 2 with boundary scan and level 2 | X | X | X | X | Boot address defined by user option byte BOOTADD[31:8] |
Empty check
During the option byte loading phase, after loading all options, the flash memory interface checks whether the boot location in the main memory, indicated by BOOTADD[31:8], is programmed. The result of this check, with the boot0 information, is used to determine where the system should boot from. It prevents the system from booting from the main flash memory area when, for instance, no user code has been programmed.
The main flash memory empty check status can be read from the EMPTY bit in the FLASH access control register (FLASH_ACR). Software can modify it by writing an appropriate value to the EMPTY bit.
The BOOT_LOCK, which locks modifications of option bytes involved in BOOT selection, has no impact on this empty check mechanism.
Embedded bootloader
The embedded bootloader is located in the system memory, programmed by ST during production. It is used to reprogram the flash memory by using USART, SPI, FDCAN, or USB in device mode through the DFU (device firmware upgrade).
For further information, refer to the application note STM32 microcontroller system memory boot mode (AN2606).
System bootloader
The system bootloader is located in the system memory, programmed by ST during the production. It is used to reprogram the flash memory using one of the following serial interfaces.
| Interface name | Package options | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| UFQFPN20 | TSSOP20 | UFQFPN24 | UFQFPN32 | LQFP32 | UFQFPN48 | LQFP48 | LQFP64 | LQFP80 | LQFP100 | LQFP144 | |
| USART1 | - | - | - | - | - | PA9/PA10 | PA9/PA10 | PA9/PA10 | PA9/PA10 | PA9/PA10 | PA9/PA10 |
| USART2 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 | PA2/PA3 |
| USART3 | - | - | - | - | - | - | - | - | - | PD8/PD9 | PD8/PD9 |
| UART4 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 | PA0/PA1 |
| SPI1 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 | PA4/PA5/PA6/PA7 |
| SPI2 | - | - | - | - | - | PB12/PB13/PB14/PB15 | PB12/PB13/PB14/PB15 | PB12/PB13/PB14/PB15 | PB12/PB13/PB14/PB15 | PB12/PB13/PB14/PB15 | PB12/PB13/PB14/PB15 |
| SPI3(1) | - | - | - | - | - | PB0/PB1/PB2/PB8 | PB0/PB1/PB2/PB8 | PB0/PB1/PB2/PB8 | PB0/PB1/PB2/PB8 | PB0/PB1/PB2/PB8 | PB0/PB1/PB2/PB8 |
| FDCAN(2) | - | - | - | PB5/PB6 | PB5/PB6 | PB5/PB6 | PB5/PB6 | PB5/PB6 | PB5/PB6 | PB5/PB6 | PB5/PB6 |
| USB DFU | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 | PA11/PA12 |
For more details refer to the application note STM32 microcontroller system memory boot mode (AN2606).