Building your own blackmagic using cheap bluepill board



Let's build a nice bluepill based blackmagic debugger.

why is it worth it ?

because it makes it possible to debug a stm32 sw using your usual gdb / gdb frontend VERY easily

Shopping list

* Bluepill from ebay
* 3S1P battery connector + wire

Firmware

First you need to flash the board with "bluepill" blackmagic firmware.
It does not compile out of the box, there is a bad merge with a variable renamed from "speed" to "baudrate".

The simpler is to get binaries from this post on the stm32duino forum.

There are 2 files in the zip :
* blackmagic. bin : main executable, address = 0x8002000
* blackmagic_dfu.bin : Boot loader, address  = 0x8000000

You can flash them using a stl-linkv2 clone from ebay on linux using

st-flash write blackmagic_dfu.bin 0x8000000
st-flash write blackmagic.bin 0x8002000


Verifying it works fine :

If you plug it through USB, you should see 2 serial interfaces, ttyACM0 and ttyACM1
and an openmoko device when using lsusb

Casing


I've made a simple enclosure for this blackmagic, it is available on thingiverse.

The Freecad source is also there, in case your bluepill has a slightly different size.

Hardware

Time to use the solder iron
First you have to remove the yellow jumpers and replace them by a strap to the left side
As depicted in the following picture :



Optional : Remove the power LED and replace it by 2 wires so that it can be deported.

Then connect the 3S1P connector to the following pins (from top to bottom) :

  •  GND
  •  PB8
  •  PB9
  •  3.3v



Next, superglue the 3S1P connector to the bottom case.
(to have an extra strength glue, add a pinch of sodium bicarbonate to the superglue, aka baking soda)

Hotglue the bluepill to the bottom case and clip + glue or sticky tape the top case

The end result looks like that :




Connector

Time to make the link to the "under debug" board. The 3S1P / Dupont connector will take most of the abuse and is easily replaceable.

The wiring is very simple : connect the 3S1P wires to a 4 block dupont connector.
It is a good idea to have the 3.3v on a connector so you can disconnect it if the target is self powered
NEVER connect the 3.3v on a self powered target, something will burn.





Coming next : Linux Software  part.



Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring