You programmed STM32 microcontroller using Nucleo or Discovery boards. Those use Serial Wire Debug (SWD) for programming/debugging. Now you are designing a PCB with STM32 microcontroller on it which means you have to be able to program it. One of the solutions is uploading the code through a bootloader - small piece of software made by ST that’s in the protected memory of the microcontroller (read-only). It reads the data being sent from the PC and copies it into FLASH memory.
STM32 microcontroller system memory boot mode - this document describes hardware resources used by the bootloader and the bootloader activation pattern (what needs to be set to activate bootloader).
Lower-end micro’s can only use UART for flashing, higher-end can use:
- CAN - documentation ID: AN3154
- USART - documentation ID: AN3155
- USB - documentation ID: AN3156
- I2C - documentation ID: AN4221
- SPI - documentation ID: AN4286
To activate bootloader you often have to do it by pulling one or two pins (BOOT0 and/or BOOT1 high). You can for example:
- Make one of the GPIO pins output high to charge a small capacitor and reset through the software (
core_cmX.h- X in the filename depends on the micro).
- Use buttons - hold a button to make boot pin high and press reset button (micro’s datasheet has the reset pin button circutry).
- Jump to the bootloader code through the code - check this video out.
Be sure to:
- …power all of the VDD pins.
- …pull the VREF high.
On the PC side use stm32flash.