This repository was archived by the owner on Jul 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Debugging Zinc Code with GDB and Eclipse
Paul Osborne edited this page May 31, 2015
·
3 revisions
This page describes steps to setup your development environment so that you can debug your Zinc application on target hardware. The steps here are verified to work with the MBED NXP LPC1768 board, but the steps should apply very directly to any board with a bootloader supporting CMSIS-DAP. Many steps will also apply to other debug probes, but changes should be expected.
The following shows the various elements in the debug toolchain described here:
Chip <-> JTAG/SWD <-> Bootloader Chip <-> CMSIS-DAP/USB <-> PyOCD <-> GDB Server <-> GDB Client <-> Eclipse
The key elements in the chain worth noting are:
- Debug Probe: Many boards (especially MBED compatible) now include an on-board discrete bootloader chip that can be used as a debug probe via CMSIS-DAP. The MBED LPC1768, for instance, includes an LPC11u35. See mbed HDK. If your chip does not have a bootloader chip like this, a standard debug probe like a Segger J-Link, LPCLINK2, or the Bus Blaster can fill the same role.
- CMSIS-DAP: This is a standardized protocol over USB that provides access over USB to SWD/JTAG/CoreSight commands in a standardized way.
- PyOCD: Implements the CMSIS-DAP protocol on the host side and exposes a GDB server. GDB monitor commands can be sent to perform out-of-band operations like resetting the chip.
On Linux (Ubuntu 14.04):
$ sudo apt-get install libusb-1.0-0-dev
$ sudo pip install pyusb
$ git clone https://github.com/mbedmicro/pyOCD.git
$ cd pyOCD
$ sudo python setup.py install
NOTE: Hopefully these steps will become simpler in the future.
From the pyOCD directory, run
$ sudo python tools/gdb_server.py
TODO: Building with debug symbols currently requires modifying Makefile
$ arm-none-eabi-gdb target/thumbv7m-none-eabi/debug/examples/blink
(gdb) target remote localhost:3333
...
(gdb) load
Loading section .vector, size 0xcc lma 0x0
Loading section .debug_gdb_scripts, size 0x22 lma 0xcc
Loading section .text, size 0x176c lma 0xf0
Start address 0x33c, load size 6234
Transfer rate: 3 KB/sec, 1246 bytes/write.
(gdb) continue
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0000030a in wait_us<zinc::hal::lpc17xx::timer::Timer> (self=0x10001eb0, us=10000) at src/hal/../util/wait_for.rs:36
(gdb) bt
#0 0x0000030a in wait_us<zinc::hal::lpc17xx::timer::Timer> (self=0x10001eb0, us=10000) at src/hal/../util/wait_for.rs:36
#1 wait_ms<zinc::hal::lpc17xx::timer::Timer> (self=0x10001eb0, ms=10) at src/hal/timer.rs:42
#2 blink::main () at examples/app_blink.rs:35
#3 0x00000106 in blink::start () at examples/app_blink.rs:15
#4 0x00000434 in main ()
...