When you get started on ARM microcontrollers things are very overwhelming at first… After coping with the first few hurdles like installing a toolchain and IDE, the next part should be getting a tool to program the chip. Many vendors have some kind of bootloader burned in the chip, which can’t be altered. Some manufacturers use serial, some use USB (mass-storage, DFU or HID). Unfortunately every vendor has it own implementation and they aren’t compatible with each other and may require special hardware. This can make it hard(er) for you to change between vendors. Another downside is your code can only be debugged by ‘printf” and not ‘realtime’.
Despite the differences in silicon by the various ARM vendors, all the chips have dedicated or shared pins for debugging, testing and programming. Traditional large pin count chips like FPGA and CPUs have JTAG but ARM also specified Single Wire Debug (SWD) which cost less pins and is more suitable for microcontrollers. Despite the standard pinout and how these interfaces work some thing aren’t: controlling the flash or debugging the target. The guys at 1bitsquared noticed this to and designed the Black Magic Probe (BMP).
At the time of writing BMP understand the following chips:
- Silicon Labs EFM32, EZR32
- Freescale Kinetis KL25, KL27, KL02
- Texas Instruments: LM3S, TM4C
- NXP LPC8xx, LPC11xx
- NXP LPC15xx
- NXP LPC43xx
- Nordic nRF51, nRF52
- Atmel SAM3N, SAM3X, SAM3S, SAM3U, SAM4S
- Atmel SAM4L
- Atmel SAM D20, D21
- ST Microelectronics STM32F0, STM32F1, STM32F3
- ST Microelectronics STM32F2, STM32F4, STM32F7
- ST Microelectronics STM32L0, STM32L1
- ST Microelectronics STM32L4
BMP doesn’t require any vender specific tools, it only require the opensource GNU Debugger (GDB). The BMP is connect to the PC through USB and acts as a remote stub for GDB. After connecting to the PC, two new serial ports are added. I assume /dev/ttyACM0 and /dev/ttyACM1 in the next examples. the first port is used for the GDB connection the second as a generic serial debugging console. Here are the steps to connect to a chip (STM32F103CBT6 is being used in this example)
$ arm-none-eabi-gdb GNU gdb (GNU Tools for ARM Embedded Processors) 126.96.36.19960616-cvs [...] (gdb) target extended-remote /dev/ttyACM0 Remote debugging using /dev/ttyACM0 (gdb) monitor tpwr enable (gdb) monitor swdp_scan Target voltage: 3.3V Available Targets: No. Att Driver 1 STM32F1 medium density (gdb) attach 1 Attaching to Remote target 0x08001404 in ?? ()
Our version is hardware compatible with BMP mini v1. It has some ‘improvements’ over the original design:
- it has a LED to indicate the target has power (or is being powered).
- no button (I didn’t see a purpose for that).
- supports only 3v3 chips (?)
Next revision will have a 100mA polyfuse will be added and the header will be rotated 90 degrees for easy plugging into the target, together with some breakout boards for different JTAG/SWD pinouts.