Table of Contents

ST-Link/V2 (or clone) to Black Magic conversion

The hobby electronics market has been flooded with clones of the ST ST-Link/V2 programmer. While the original isn't expensive, it does have some limitations which can be annoying:

Installing the Black Magic Probe firmware on the ST-Link removes these limitations, and converts the ST-Link/V2 into a generic 3.3V JTAG and SWD adapter, which can be used to program and debug a variety of ARM Cortex microcontrollers (using SWD), or program other parts like FPGAs and CPLDs which use the industry-standard JTAG interface.

:!: Warning: :!:
Newer models of the cloned ST-Link/V2 have appeared, which don't use the STM32F103CB processor.
Instead, an STM32F101 part (which has no USB interface), an STM32F103C8 (which has only 64K of Flash) or a clone of one of these will be fitted.

To use these boards, the processor chip may need to be replaced with a genuine STM32F103CB in the appropriate package.

Instructions

Note: The current versions of the Black Magic Probe firmware are too large to fit in the ST-Link's Flash. There's an issue open for this on the BMP Github page with some suggestions. I've found that version 1.9.3 is the last version which will fit in Flash as a complete build.

For more recent versions, you will need to remove one or more targets from the SRC += block in src/Makefile and rebuild.

Downloading and building the Black Magic firmware

# Install build prerequisites:
#   * The GCC cross-compiler for embedded ARM
$ sudo apt install gcc-arm-none-eabi
 
# Clone the Black Magic source code and check out the latest tag
$ git clone https://github.com/blackmagic-debug/blackmagic.git
$ git checkout `git describe --tags --abbrev=0`
 
# Build the firmware
make clean
make PROBE_HOST=stlink

Installing the Black Magic bootloader

  1. Disassemble the ST-Link by removing the cap, and pushing the USB connector down on a hard surface while holding the aluminium case. The PCB should slide out of the other end.
  2. Remove the PCB from the case
  3. Connect another ST-Link to the programming pads on the PCB – you will need to identify these by tracing them back to the CPU power and programming pins.
  4. Follow the instructions below to reprogram the chip:

Installing or upgrading the firmware

# Install Rust
$ sudo apt install cargo
 
# Clone and build the Black Magic Probe utility
$ git clone https://github.com/blackmagic-debug/bmputil.git
$ ( cd bmputil; cargo install --path . )
 
# Identify Black Magic Probe (optional)
$ sudo ~/.cargo/bin/bmputil info
Found: Black Magic Probe (STLINK), (Firmware v1.6.1-319-ge52e2f5)
  Serial: (redacted)
  Port:  1-4
 
# Flash the firmware
$ sudo ~/.cargo/bin/bmputil flash ./blackmagic/src/blackmagic.elf
Found: Black Magic Probe (STLINK), (Firmware v1.6.1-319-ge52e2f5)
  Serial: (redacted)
  Port:  1-4
Erasing flash...
Flashing...
 100% |██████████████████████████████████████████████████| 110.10KiB/110.10KiB [4.65KiB/s 23s]
Black Magic Probe successfully rebooted into firmware version (ST-Link/v2) v1.9.0-rc1

Serial port and SWO Trace modification

The Black Magic Probe firmware adds UART and SWO trace support to the ST-Link. These features are not normally available on the cloned ST-Links, but using them requires some hardware modifications. To do this, you will need a steady hand.

Thankfully the Mini ST-Link doubles-up some of the power supply pins on the 10-pin connector. We can disconnect these and re-use them for TRACESWO and UART support.

The connector pinout will change to:

New function Old function Wire connects to
UART TX 5V STM32 PA2 (pin 12)
UART RX 3V3 STM32 PA3 (pin 13)
TRACESWO GND STM32 PA10 (pin 31)

There are two methods I've used to make this modification:

Kapton tape method

This method works on all Mini ST-Link PCB layouts, but can be quite fiddly, and reduces the mechanical strength of the connector.

  1. Desolder the side of the 10-pin connector which is on the same side as the STM32F103RB processor.
    1. This should be the side with the SWIM pin on it.
  2. Slide Kapton or similar insulating tape under the pins.
  3. Check with a multimeter to make sure the pins don't connect to the PCB traces.
  4. Install wires as per the table above.
    1. Use thin magnet wire, e.g. Roadrunner wire.
  5. Resolder the RST and SWIM pins to the PCB.
  6. Test your work:
    1. Visual check – is the soldering sound? are there any short circuits?.
    2. Electrical check – use a multimeter or continuity tester to check continuity.
    3. Loopback test – connect RX to TX on the serial port and check data is looped back.
  7. Tack down the wires with a small amount of glue.

Top view Bottom view

Track cut method

This method gives a more mechanically-sound result, but only suitable for boards where the track layout allows the pins to be cleanly disconnected. The blue-PCB probe I had couldn't be modified like this, as the 5V and 3V3 pads had vias which connected power from one side of the PCB to the other. The track layout gave away that these vias were there: there was no other way 5V and 3V3 could connect from one side of the board to the other.

The green “Mini ST-Link V2 E” PCB had vias next to the pads, which could be disconnected from the pads with no ill effect.

  1. Cut the tracks leading to the 5V, 3V3 and SWIM pins on the 10-pin connector.
    • These should be on the same side as the STM32F103CB CPU.
  2. Install wires as per the table above
    1. Test your work:
      1. Visual check – is the soldering sound? are there any short circuits?.
      2. Electrical check – use a multimeter or continuity tester to check continuity.
      3. Loopback test – connect RX to TX on the serial port and check data is looped back.
    2. Tack down the wires with a small amount of glue.

Top view Bottom view