Skip to content

Flashing the bootloader from macOS

Roger Clark edited this page Sep 2, 2022 · 5 revisions

These steps assume you have a [Blue], [Red] or [Black Pill] board, a USB-Serial interface with 3.3V broken out to a pin, and a relatively modern macOS. I've tested them with a Black Pill on Mojave 10.14.

The aim is to go from a completely new out-of-the-box board with nothing but the built-in bootloader, to uploading sketches from the Arduino environment over USB.

  1. [Set the boot jumper] on the Pill board to "Serial Programming"
  2. Connect the USB-Serial interface's 3.3V pin to 3.3V on your Pill board, and ground to ground.
  3. Connect the TX pin on the USB-Serial interface to PA10 on the board, and the RX pin to PA09.
  4. Clone the Arduino_STM32 repository into ~/Documents/Arduino/hardware
  5. Select the appropriate .bin file from here, and download it into your ~/Downloads directory (I have a Black Pill with the LED on PB12, so I'm using generic_boot20_pb12.bin; if you have a Blue Pill or Red Pill you want generic_boot20_pc13.bin. Make sure you download the actual binary by clicking on the entry for the file you want in the list at the above link, then clicking the "Download" button in the Github interface.)
  6. cd ~/Documents/Arduino/hardware/Arduino_STM32/tools/macosx/stm32flash
  7. ./stm32flash -v -w ~/Downloads/generic_boot20_pb12.bin /dev/cu.usbserial-DN0091ZE (the characters after usbserial- might be different on your system)
  8. Unplug the Pill board from the USB-Serial interface, restore the boot jumper to its original position and power it up by connecting it to a USB port. Congratulations, you now have a bootloader!

Next, follow the instructions here to set up your Arduino environment to build and upload to your Pill board.