To debug a simple microcontroller program usually all you need is a serial port, an LED, a couple of printf statements, and some grey matter. However, when programs grow bigger and become more complex having a good debugging tool at hand will make life much easier.

 
black magic probe v2.1
Black Magic Probe (left) connected to a 1Bitsy STM32F415 board.

JTAG and SWD

With the advent of JTAG this is less of a problem, but not all microcontrollers have JTAG interfaces. Because a full JTAG interface requires at least five controller pins (the fully full JTAG connector has 20 pins!), MCU manufacturers sometimes prefer using a simplified or customized debugging interface that occupies fewer resources. Smaller ARM-core-based processors for instance often are equipped with an SWD (Serial Wire Debug) port instead that needs only two pins.

Besides choosing a suitable debug tool, setting up a debugging environment is not an easy task. Of course, if you throw enough money at it, the situation improves greatly, but when you have to go the low-cost GDB-with-OpenOCD way things are less comfortable.

Black Magic Probe supports JTAG and SWD

The Black Magic Probe (BMP) by 1BitSquared that we are going to try out in this article is a debugging tool that addresses these problems. Not only does it support both JTAG and SWD, it also has a built-in GNU Debugger (GDB) server simplifying toolchain setup, and works on Windows, Linux and macOS.

Before you get too excited, BMP targets ARM Cortex-M and Cortex-A based microcontrollers, but there are many of those on the market (STM32, SAM, LPC, nRF5, and many more).

Black Magic Probe specifications

  • Load your application into the target Flash memory or RAM.
  • Single step through your program.
  • Run your program in real time and halt on demand.
  • Examine and modify CPU registers and memory.
  • Obtain a call stack backtrace.
  • Up to six hardware assisted breakpoints.
  • Set up to four hardware assisted read, write or access watchpoints.
  • Unlimited software breakpoints when executing your application from RAM.