Debugging from GDB using pyOCD!
.We are pleased to release a python library which allows to drive the Debug Access Port of Cortex-M microcontrollers over CMSIS-DAP!
What can be achieved with pyOCD?
- Debugging using GDB, as a gdbserver is integrated on the library
- Writing python applications that can communicate with the CMSIS-DAP and coresight debug interface:
- read/write memory
- read/write core registers
- set breakpoints
- flash new binary
- run/stop/step the execution
- Act as a great reference to show how the CMSIS-DAP protocol works
Currently, the library works on Windows (using pyWinUSB as backend) and on Linux (using pyUSB as backend).
Quick overview
Use python to control your mbed platform
from pyOCD.board import MbedBoard board = MbedBoard.chooseBoard() target = board.target flash = board.flash target.resume() target.halt() print "pc: 0x%X" % target.readCoreRegister("pc") pc: 0xA64 target.step() print "pc: 0x%X" % target.readCoreRegister("pc") pc: 0xA30 flash.flashBinary("binaries/l1_lpc1768.bin") print "pc: 0x%X" % target.readCoreRegister("pc") pc: 0x10000000 target.reset() target.halt() print "pc: 0x%X" % target.readCoreRegister("pc") pc: 0xAAC board.uninit()
Use GDB to debug your mbed projects
Before using GDB, a .elf file has to be generated with a GCC toolchain.
- Python code to start a GDB server on port 3333
from pyOCD.gdbserver import GDBServer from pyOCD.board import MbedBoard board = MbedBoard.chooseBoard() # start gdbserver on port 3333 gdb = GDBServer(board, 3333)
- Debug the target from GDB:
arm-none-eabi-gdb l1_lpc1768.elf <gdb> target remote localhost:3333 <gdb> load <gdb> continue
Get Started
All the source code is available on our git repository under workspace_tools/debugger
You can quickly get started with pyOCD by reading the README. It provides all the information that you need to know concerning the dependencies, installation and how to use the library. There are even some sample programs to get started even quicker!
Conclusion
pyOCD provides a simple and efficient solution to debug mbed platforms over CMSIS-DAP.
We expect quite soon the support of all the mbed platforms in OpenOCD as well. There is even a fork of OpenOCD adding CMSIS-DAP support: cmsis-dap support in OpenOCD
Have fun with pyOCD!
9 comments on Debugging from GDB using pyOCD!:
You need to log in to post a discussion
Discussion topics
Topic | Replies | Last post |
---|---|---|
Pyocd gdbserver error: No available boards are connected | 1 |
26 May 2016
by
|
@Samuel Thanks for amazing works!! Many people asked me about CMSIS-DAP with gdb at Maker Faire Shenzhen. If I knew this, I could say "YES!!".
Why not supprting OS X? Is this because technical difficulties of HID handling on OS X?