Flashing the STM32F103 using a Raspberry Pi 3

 Preparing the Raspberry Pi 3

Install the stm32flash utility:

git clone https://git.code.sf.net/p/stm32flash/code stm32flash-code
cd stm32flash-code
sudo make install

Move the high performance UART from the Bluetooth device to  the GPIO pins:

sudo nano /boot/config.txt

Add the following line:

dtoverlay=pi3-miniuart-bt

Edit cmdline.txt:

sudo nano /boot/cmdline.txt

Remove the following text in cmdline.txt to prevent a console from running on the serial port:

console=serial0,115200

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

Raspberry Pi 3.3V (pin 1) to STM32 3.3V
Raspberry Pi GND (pin 6) to STM32 GND
Raspberry Pi TX (pin 8) to STM32 RX (pin A10)
Raspberry Pi RX (pin 10) to STM32 TX (pin A9)
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/master/STM32F1/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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s