Sunday, February 27, 2011

Black Magic Debug Probe

Thanks to Gareth McMullin, I recently had the pleasure of using Black Sphere Technologies Black Magic Probe. This wonderful little device is used for debugging embedded applications running on an ARM STM32.


Here's a little demo running on a STM32MCU where I set a break point in the shutdownPower method of the Tumanako Vehicle Control application and then use backtrace to see the flow of application code to that point:
pccourt@Greenstage:~/tumanako/trunk/inverter/fw/vehicle_control/src$ arm-none-eabi-gdb tumanako_vc_sine
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi"...
Device IR Len IDCODE Description
0 4 0x3BA00477 ARM Limited: ADIv5 JTAG-DP port.
1 5 0x16410041 ST Microelectronics: STM32, Medium density.

Available Targets:
No. Att Driver
1 STM32, Medium density.
0x1ffff3ba in ?? ()
(gdb) load tumanako_vc_sine
Loading section .text, size 0x113c4 lma 0x8000000
Loading section .data, size 0x624 lma 0x80113c4
Start address 0x8000000, load size 72168
Transfer rate: 10 KB/sec, 962 bytes/write.
(gdb) break STM32_sine_interface.cpp:533
Breakpoint 1 at 0x8001ad4: file STM32_sine_interface.cpp, line 533.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/pccourt/tumanako/trunk/inverter/fw/vehicle_control/src/tumanako_vc_sine
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, STM32Interface::shutdownPower (this=0x20004fe8) at STM32_sine_interface.cpp:533
533 TIM1_BDTR &= (uint16_t)~(TIM_BDTR_MOE); //main output enable OFF
(gdb) bt
#0 STM32Interface::shutdownPower (this=0x20004fe8) at STM32_sine_interface.cpp:533
#1 0x08000ec0 in TumanakoInverter::stateMachineDo (this=0x20004fd0) at tumanako_inverter.cpp:653
#2 0x08001472 in TumanakoInverter::doIt (this=0x20004fd0) at tumanako_inverter.cpp:459
#3 0x080001ee in main () at main.cpp:157
(gdb)
How cool is that! No fluffing about, it just works and its as fast as debugging a program running on your host CPU. As a result, this tool has now become an essential component of Greenstage's hardware and software development lab.

In addition to being better than anything else available, this great tool is also fully Open Source! All information is freely available here:
This ticks all our boxes :) If you want to buy one ready to go, contact Gareth McMullin at Black Sphere Technologies.

Thank you Gareth!

1 comment:

Anonymous said...

Don't forget your gdbinit file:

cat .gdbinit
target extended-remote /dev/ttyACM0
mon jtag_scan
attach 1
set mem inaccessible-by-default off