Testing BlackMagicProbe with EPM

Koen has provided Zubax with a patch to the BlackMagicProbe firmware, which adds support for SAMC21, used on EPM/FluxGrip.

Before we can start we need to flash our probe with the latest firmware. We will be using the Dronecode Probe.

To patch the probe:

  • Clone sources and compile:
git clone https://github.com/blackmagic-debug/blackmagic/
cd blackmagic
make PROBE_HOST=native #compiles into src subfolder
sudo dmesg #verify that new usb device detected
sudo dfu-util -d 1d50:6017 -s 0x08002000:leave -R -D src/blackmagic.bin #flashes

Now we should be able to use the probe to flash our EPM board. The pinout of the wires is as follows:

(This is from Pixhawk DS-009 standard)

After connecting this to the corresponding pins on the board, we can do the following:

  • Make the following change in epm/boards/arm/epm/board.cmake:

  • Flash the board: west flash --runner blackmagicprobe

The last remaining issue: semihosting.

This is how it is done when using the Atmel debugger:

  $workspace_path/scripts/openocd.cfg &
  # record the PID of the background process

  sleep 4s

  # loads the image, runs the tests
  arm-zephyr-eabi-gdb ./build/zephyr/zephyr.elf \
    -batch \
    -silent \
    -ex "tar ext:3333" \
    -ex "load" \
    -ex "monitor arm semihosting enable" \
    -ex "monitor arm semihosting_fileio enable" \
    -ex "run"

  kill $openocd_pid

As far as I understand, the BlackMagicProbe does not require running openocd ourselves, so I’m doing the following steps:

west build -b epm ./verification/on_target/200_command_handler #this builds a test which uses semihosting
arm-zephyr-eabi-gdb-py ./build/zephyr/zephyr.elf #launch GDB
(gdb) target extended-remote /dev/ttyACM0
(gdb) attach 1
(gdb) load
(gdb) monitor arm semihosting enable #these don't seem to work
Target does not support this command.
(gdb) monitor arm semihosting_fileio enable #these don't seem to work
Target does not support this command.
(gdb) set remote system-call-allowed 1 #Pavel suggested this

If I then start running, it seems to “hang”, and if I check test_log.bin (the file where semihosting should be writing its output): it’s empty.

After pressing CTRL+C, I get the following: