STM32 “Blue Pill”: Programming the Bootloader with an Arduino

Commonly refed to as the “blue pill”, this development board has great capabilities. The board comes with an empty flash memory, and so it is necessary to load in programs to do anything useful with this device. Thankfully, there is an easy way to do this using a serial port, which an Arduino can provide on its RX/TX pins. There is one caveat, the Arduino’s microcontroller interferes with the serial communication. Connect the pin RST to GND and that should do the trick.

Some Gremlins!

There’s a problem with Arduino Nano boards containing a CH340 chip. If you encounter problems with serial communication, read on. The RX/TX pins on the microcontroller and connected to LED’s that draw away too much of the signal to make it usable. The solution I came up with is to remove the resistors next to the RX and TX LED’s. These indicators won’t light up anymore, a small price to pay for working serial port.

Experimental Setup

Experimental stm32f103 programming setup on a breadboard

Now, in order to boot the programming module on the STM32, set the boot mode to 10, in other words, the jumpers need to be moved around: BOOT0 on, BOOT1 off. On the computer side, run the flash process.

stm32loader -p /dev/ttyUSB0 -e -w FILEPATH-HERE

The output should look a bit like the following.

All that’s left to do is reset the jumpers back to 00 position and your program will run.

This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Connecting to %s