Debugging with pyOCD!

pyOCD provides a quick and easy way to start debugging your targets with CMSIS-DAP interface.

  • Open a terminal, and start the gdb server. Type pyocd-gdbserver

INFO:root:DAP SWD MODE initialised
INFO:root:6 hardware breakpoints, 4 literal comparators
INFO:root:CPU core is Cortex-M3
INFO:root:4 hardware watchpoints
INFO:root:Telnet: server started on port 4444
INFO:root:GDB server started at port:3333
  • Open another terminal, navigate to the directory of your elf file.
  • Start the gdb client. Type arm-none-eabi-gdb.

start gdb client

GNU gdb (GNU Tools for ARM Embedded Processors)
Copyright (C) 2014 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-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word".
  • Connect to the gdb server on the appropriate port

(gdb) target remote localhost: 3333
  • Load symbols from elf file

(gdb) file helloworld
  • Program the flash on the board (optional - use alternative programmer if needed)

(gdb) load helloworld
  • See where you are at in the code.

(gdb) list
  • Set a breakpoint

(gdb) break main
  • Start executing

(gdb) continue
  • Type Ctrl + C to halt execution
  • View registers

(gdb) info registers
  • View the stack frames (back trace)

(gdb) bt
  • Dump memory to a file

(gdb) dump ihex memory dump_file.txt 0x[start] 0x[end]
  • Step into a function

(gdb) step
  • Step over a function

(gdb) next
  • Type “monitor” before gdbserver commands

(gdb) monitor reset
(gdb) monitor halt
  • Type ! preceding a bash shell command to execute a command back in the shell

(gdb) !ls
  • Type quit to exit

(gdb) quit
  • Back in the terminal, that you started pyocd-gdbserver from, type Ctrl + C to exit.

Please log in to post comments.