Cheap Chinese ST-Link v.2 Programmer converted to Black Magic Probe Debugger

I came across the “Black Magic Probe” (code on GitHub), a while ago, and recently found out (and here) that it should be supported on these Chinese STLink-V2 clones that you can find on eBay and Aliexpress for really cheap ($2-$5).

I had already bought one a few months back, so I ordered another one to use one as a programmer to load the Black Magic Probe code into the second STLink clone.

Two (slighly different) STLink clones

When the 2nd STLink clone arrived, I did a quick test to ensure it worked as advertised as a STLink, but did not pay attention to the pinout printed on the aluminum sleeve. Turns out the pinout differs from my first STLink clone.

All I got from st-util was this:

Once I swapped the wires, it was able to talk to my target without issues.

Nice. Now its time to flash the Black Magic Probe firmware…

Building the BMP firmware

First, clone and build the code from GitHub:

You’ll need blackmagic.bin and blackmagic_dfu.bin

Connecting the two STLink clones

No soldering needed…
I used the “male-to-female Dupont 1pin” wires you can find for a few bucks on ebay/aliexpress. The male pins press-fit into my STLink’s programming vias by staggering them a little:

This is the pinout on my BMP-to-be:

Erase and Flash the BMP-to-be

The erase the locked firmware on the “soon to be a BMP” STLink, then program the BMP bootloader and BMP itself:

I actually unplugged and re-plugged USB to the STLink after each step above.

Verifying flashing was successful

Remove the programming cables and plug in the STLink we just reflashed to BMP, and ensure the procedure was successful:

Here we see that it now shows up as 1d50:6018 OpenMoko, Inc. and it created two new serial devices /dev/ttyACM0 and /dev/ttyACM1


I’m only using the SWD method (single wire debug), not sure if the STLink clones even have the necessary pins exposed for full JTAG.
Here’s how I wired it:

STLink/BMP Target

Optional: udev rules for user/Docker access to BMP devices

Since I only install/run the cross toolchain inside an unprivileged Docker container as a regular user, I need to map the device(s) into the container and allow access from the user/container.

Install this udev rule (add your username to the line with “OWNER”):


and run the container with:

I’ll publish my stm32dev Dockerfile in a future post and upload to GitHub and Docker Hub.

GDB Setup for BMP

After wiring it up, I just followed:


For ease of use, I created a .gdbinit which I just copy to my project root directory, so it gets picked up automatically when I run
arm-none-eabi-gdb somefile.elf:

Now I’m ready to debug away. More to follow in upcoming posts on the STM32F407 based board (aka. 39BOARD_M4_407VE).

Please shareTweet about this on TwitterShare on LinkedIn0Share on Google+0Digg thisShare on Facebook0Share on Reddit0Print this pageEmail this to someone
  • John

    Thanks for sharing this. I tried a few different recipes without success, but this one worked. Unplugging the USB between each step was the key.

    • Manuel

      Hi John,
      thanks for commenting, glad you found this post useful.