ORBTrace for debugging with Blackmagic Probe

We’ve covered getting started using ORBTrace Mini with pyOCD and openocd. Now, it’s the turn for Blackmagic to get the treatment…

The Blackmagic Probe (BMP) is a very flexible and easy to use debug interface. In the past few years it’s also grown a ‘remote’ mode which allows it to be used with a variety of different debug interfaces including ORBTrace Mini. In fairness, it’s had a remote capability for years, but only more recently has it been expanded to cover multiple probes. Personally, I find BMP/BMA the easiest probe interface to use, provided it actually supports my target. The build process to create BMA it is slightly different to ‘regular’ BMP, so let’s run through it.

This assumes you’re running on a relatively recent Linux distribution, but you should be able to jiggle the process for your own platform.

Step 1: Download the project

That’s easy, just clone the github repository;

$ git clone https://github.com/blackmagic-debug/blackmagic.git
Cloning into 'blackmagic'…
remote: Enumerating objects: 11755, done.
remote: Counting objects: 100% (2361/2361), done.
remote: Compressing objects: 100% (861/861), done.
remote: Total 11755 (delta 1767), reused 1837 (delta 1491), pack-reused 9394
Receiving objects: 100% (11755/11755), 3.88 MiB | 7.65 MiB/s, done.
Resolving deltas: 100% (8768/8768), done.

Step 2: Configure

You now want to checkout the V1.8.0 release, since we know that works well. There will be other releases available in due course, but let’s start with something we know;

$ cd blackmagic
$ git checkout v1.8.0
Note: switching to 'v1.8.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5e3cade Updated Copyright and Vendor strings to Black Magic Debug.

Step 3: Build

Finally, you can make the project, resulting an a binary called blackmagic;

$ cd src
$ make PROBE_HOST=hosted
GIT include/version.h
CC target/adiv5.c
CC target/adiv5_jtagdp.c
CC target/adiv5_swdp.c
CC command.c
CC target/cortexa.c
CC target/cortexm.c
CC crc32.c
CC target/efm32.c


CC platforms/hosted/jlink.c
CC platforms/hosted/jlink_adiv5_swdp.c
CC platforms/hosted/jlink_jtagtap.c
LD blackmagic

Step 4: Use

Before you start BMA, you might well want to turn on power to your target. That can be done using the orbtrace control app, like this;

$ orbtrace -p vtref,3.3 -e vtref,on

The VTRef led on your OBTrace Mini will illuminate blue, and your target will power up. The blackmagic executable is built in the src directory, so run it as follows;

$ ./blackmagic
Listening on TCP: 2000

We can now connect via gdb. Here’s an example using the simple application from the orbmule repository;

$ arm-none-eabi-gdb -q
(gdb) file simple.elf 
Reading symbols from simple.elf...
(gdb) target extended-remote localhost:2000
Remote debugging using localhost:2000
(gdb) monitor swdp_scan
Available Targets:
No. Att Driver
 1      STM32F40x M4
(gdb) attach 1
Attaching to program: /home/dmarples/Develop/orb/orbmule/examples/simple/ofiles/simple.elf, Remote target
0xfffffffe in ?? ()
(gdb) load
Loading section .text, size 0x5e0 lma 0x8000000
Loading section .ARM.exidx, size 0x8 lma 0x80005e0
Loading section .data, size 0x438 lma 0x80005e8
Start address 0x80002a4, load size 2592
Transfer rate: 10 KB/sec, 518 bytes/write.
(gdb) c
Program received signal SIGINT, Interrupt.
_sendITM (size=1 '\001', d=105, ch=0) at src/itm_messages.c:20
20	            while (DBG_PORT[ch] == 0) {}; /* Port available? */

…and you’re done. BMA works with both SWD and JTAG targets and, in common with pyOCD and openocd, it can also enable the parallel trace capabilities of ORBTrace …. but that’s for another time.