STM32 - DFU Methods

From Embedded Workshop
Jump to navigation Jump to search

DFU stands for: Device Firmware Upgrade.
The STM32 family supports multiple firmware download methods.

Application note, AN2606, is titled: STM32 microcontroller system memory boot mode
It documents the boot loaders on pretty much all the STM32 devices.
https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf

Application note, AN3156, describes the USB DFU method
https://www.st.com/resource/en/application_note/cd00264379-usb-dfu-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Application note, AN3155, describes Serial DFU method
https://www.st.com/resource/en/application_note/an3155-usart-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Application note, AN5275, describes USB DFU/USART protocols
https://www.st.com/resource/en/application_note/an5275-usb-dfuusart-protocols-used-in-stm32mp1-series-bootloaders-stmicroelectronics.pdf

Application note, AN4221, describes I2C protocol method
https://www.st.com/resource/en/application_note/an4221-i2c-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Application note, AN3154, describes CAN DFU protocol
https://www.st.com/resource/en/application_note/an3154-can-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Application note, AN4286, describes SPI protocol method
https://www.st.com/resource/en/application_note/an4286-spi-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Other application notes may be available for other peripheral interfaces, such as the encabulator interface
My Experience:
If working with the Blue Pill, I've found using STM32CubeProgrammer works well using DFU.
Connect an FTDI USB-Serial board to pins A9(USART1_TX) and A10(USART1_RX).
With STM32CubeProgrammer, configure Port for your FTDI USB-Serial board, and then click "Connect".
If you have your serial pins and BOOT pins correct, the programmer should connect.
Try pressing the "Reset" on the Blue Pill if you experience problems and try again.
I used STM32CubeIDE to create a program (a simple blinky), and then used STM32CubeProgrammer
to download the program onto the Blue Pill.

Here's a good web page for STM32CubeProgrammer to use with DFU:
https://wiki.stmicroelectronics.cn/stm32mpu/wiki/STM32CubeProgrammer

These pages demonstrate how to use USART DFU:
https://cybergibbons.com/hardware-hacking/reading-and-writing-firmware-on-an-stm32-using-the-serial-bootloader/
https://github.com/stm32duino/Arduino_Core_STM32/wiki/Upload-methods
https://www.youtube.com/watch?v=uGDCRys2WIY&ab_channel=AhmadLogs