Debugging with pyOCD!
pyOCD provides a quick and easy way to start debugging your targets with CMSIS-DAP interface.
- Install pyOCD using instructions at: https://github.com/mbedmicro/pyOCD
- Install the arm gcc toolchain at: https://launchpad.net/gcc-arm-embedded
- Open a terminal, and start the gdb server. Type pyocd-gdbserver
C:\Users\mac>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
C:\Users\mac\mbed-os\helloworld\build\target-xyz-gcc\source>arm-none-eabi-gdb GNU gdb (GNU Tools for ARM Embedded Processors) 184.108.40.20650604-cvs Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 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: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". (gdb)
- 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.
- Set a breakpoint
(gdb) break main
- Start executing
- Type Ctrl + C to halt execution
- View registers
(gdb) info registers
- View the stack frames (back trace)
- Dump memory to a file
(gdb) dump ihex memory dump_file.txt 0x[start] 0x[end]
- Step into a function
- Step over a function
- 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
- Type quit to exit
- Back in the terminal, that you started pyocd-gdbserver from, type Ctrl + C to exit.
Please log in to post comments.