Flashing the STM32F103 using a Raspberry Pi 3

This is a quick description of how to get a bootloader onto a blank STM32F103 (bluepill) using the Raspberry Pi 3

 Preparing the Raspberry Pi 3

Install the stm32flash utility:

git clone https://github.com/stm32duino/stm32flash.git
cd stm32flash
sudo make install

Next move the high performance UART from the Bluetooth device to  the GPIO pins by editing /boot/config.txt

sudo nano /boot/config.txt

Add the following line to the file:

dtoverlay=pi3-miniuart-bt

Next edit /boot/cmdline.txt:

sudo nano /boot/cmdline.txt

Remove the following text in cmdline.txt to prevent a console from running on the serial port which will interfere with the flashing:

console=serial0,115200

You should now wire up your micro-controller to the Pi as follows:

Raspberry PiSTM32
3.3V (pin 1)3.3V
GND (pin 6) GND
TX (pin 8)RX (pin A10)
RX (pin 10)TX (pin A9)


Finally Set the STM32 BOOT0 jumper to 1

Flashing a boot-loader

If you want to use the Arduino IDE  you can use the image below, alternatively you could flash your own compiled binary directly to the micro-controller.

wget https://github.com/rogerclarkmelbourne/STM32duino-bootloader/raw/refs/heads/master/bootloader_only_binaries/generic_boot20_pb12.bin

Press the RESET button on your micro controller before running stm32flash:

stm32flash -v -w ./generic_boot20_pb12.bin /dev/serial0

Restore the jumpers to their original configuration.

If you want to use the Arduino IDE to program the STM32; plug the STM32 into a usb port follow the STM32duino installation instructions here:

https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Bootloader

https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Installation

All done!

Video Instructions

3 responses to “Flashing the STM32F103 using a Raspberry Pi 3”

  1. alexanderidushy Avatar
    alexanderidushy

    Hi. Great post. Is it all that need for flashing firmwate from Raspberry to STM32 MCU? Without st-link device?

    Like

    1. Matthew Dunn Avatar
      Matthew Dunn

      That’s right

      Like

Leave a reply to Matthew Dunn Cancel reply