Converting an STM32F103 board to a Black Magic Probe

Using the $2 (Blue Pill) STM32 board we can have a debugger that supports breakpoints. No need of OpenOCD server, as it runs a GDB server on chip directly.

A generic $2 STM32F103 board on AliExpress (aka Blue Pill)

The bare STM32F103 board only comes with a default USART boot loader. Even though there is a USB port on the board, you cannot use it to program it because it does not have the relevant bootloader.

I got my board for less than $2 from Advanced Tech on AliExpress. We need to use a simple USB to UART converter to program the board via USART with a USB boot loader, and then we can get back to programming it directly via USB.

First, connect your USB to Serial/UART/TTL Converter like this:


In the image above, you see two yellow jumpers marked and . These specify the source of code for the micro-controller. In the default state of both being , the micro-controller uses its own flash memory bootloader — which there is none right now — and which we are adding. For now, to be able to program the micro using USART, you need to set as and leave to . Basically move the first jumper and leave the second one.

Now, download the stm32loader python script and run it to see that all the necessary dependencies are satisfied. I had to to get it to work.

Now we need the binary that we want to flash as the BMP DFU bootloader — we’ll clone and compile the repo from the Black Magic Probe source. Get the toolchain .

  1. Clone this repo.
  2. Run , to get the right git submodules. Ignore any errors that might occur. Remove the flag from this line, if you get a warning that is thrown as an error.
  3. Go into and run .
  4. You should get two files in the src directory — and .

Once we have the DFU file, now we simply need to run the following (after adding the correct port and file reference):

python ./stm32loader -p /dev/tty.SLAB_USBtoUART -e -w -v src/blackmagic_dfu.bin

You might need to hit reset button before you run the above to get it to work. The verification step will read back the flashed binary and compare. Reset the boot setting jumpers back to default of both.

Now we are ready to add the Black Magic Probe firmware. Disconnect everything and use the USB to connect. Verify that your computer recognises the device using or by going to About This Mac > System Report > USB. You can also use . (The hardware and software that we get to work on above are all thanks to the excellent folks at 1bitsquared.)

For the actual firmware, we’ll use the official steps. Install and then follow these steps. Basically run `. Here, the device address can be found in , and the file is the one we had generated from compilation. You should see a progress indicator and finally upload should succeed.

Now unplug and plug in your new Black Magic Probe. You should see the Firmware Upgrade DFU in . Also, you should see new ports . The first one is a GDB server and the second one is a Serial UART for debugging.

Make the connections between your target and new BMP debugger as follows. (In case these pin mappings change in the future — check here. Check the values set in code, and not the comment.)


Black Magic Probe supports both JTAG/SWD and Serial/UART debugging simultaneously. So here is the pinout of that, once you get around to using it. Remember that RX/TX lines are interchanged from source to destination.


Now connect to your board with . Add the correct port name. You should see the debugger ready for commands.

Commands like should show you info about target hardware and should attach the debugger to the target. Now you can uploade new firmware to target as well as set breakpoints etc.

For further command refer to the GDB manual or to Black Magic Probe Documentation.

If you enjoyed the article, hit recommend! Follow me to know about my future projects. Thanks to this article for getting me up and running with the above steps. It is based on work by Roger Clark.

Software guy. When you try to tell computers what to do, you eventually learn about human nature as well. (

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store