Jacdac: Using the Black Magic programmer
Last updated: Nov 5, 2022
Using my home-made Black Magic Probe, I have to push the reset button at the start of each programming cycle, then release the button once I get a correct voltage statement, to get firmware to reliably load onto my Jacdac boards
How do we program our Jacdac boards? One solution is to use a home-made Black Magic Probe (BMP) debugger. Instructions on how to make your own from a Blue pill board are here: https://github.com/mmoskal/blackmagic-bluepill
Making your own BMP from a Blue Pill board is a lot cheaper than buying a pre-made BMP, but you have to swallow setting it up yourself.
I had some issues getting my home-made board to work, which I detail here along with the solution.
Home made Black Magic Probe
I was fortunate enough to get the Bluepill-BMP shield that is detailed on GitHub site. Please find a photo of this below. Three components are marked: Green square - reset button. Yellow square - board power switch. Red square - reset signal jumper.
Using the Black Magic Probe programmer
Unless you are externally powering the board that you are programming, it needs to be powered during flashing. Set the board power switch to ‘ON’ to enable this.
The reset signal is mapped to pin 10 of the 10-pin surface mount connector that your programming cable clips into. The JacConnect socket expects this to be on pin 5. To bridge the reset signal to pin 5, set the jumper as indicated, connecting the HC to XS pins as shown in the red square on the image above. This allows us to use a ribbon connector cable with no butchery and the ‘hack-connect/JacConnect’ header to program our Jacdac boards. This header is detailed [here].(https://arcade.makecode.com/hardware/dbg)
If you don’t short the two pins, you need to do some surgery to your cable to enable the Reset signal to get to pin 5 of the 5-pin JacConnect socket.
Programming a Jacdac board with the Black Magic Probe
Here’s where I lost about a week of my life. I repeatedly got errors trying to flash my boards using the instructions here.
The final error message was:
Target voltage: 3.27V SW-DP scan failed! built/debug.gdb:5: Error in sourced command file: Attaching to Remote target failed (gdb) quit
I followed some methodical troubleshooting to confirm continuity from the pins on the STM32 microcontroller on my target board to the pins on my BMP. Get yourself some fine tip probes. Pomona is a good brand for probes. They don’t sponsor me. Be nice if they did.
The magic trick is to hold down the Reset button on your Black Magic Probe board before you hit enter on your keyboard to submit either ‘make run BL=1’ or ‘make run flash’ to write the .elf files onto the Jacdac board. The flashing process will stop with a Target voltage message like:
Target voltage: 3.27V
Release the Reset button and the flashing will continue ending with the reassurring message:
*** Flash OK
I flash in two stages - the bootloader first using:
make run BL=1
Then I load the firmware using:
In theory I can load both .elf files in a oner using:
make run ff
But this does not yet work for me.
Victory, tea and biscuits are ours. Or, in my case, an espresso from the machine that somebody thoughtfully donated to the kitchen on the floor where I loiter. Which is leading to a substance abuse situation, however my cycle time home is much reduced.