| 1 | --- |
| 2 | title: GDB setup |
| 3 | --- |
| 4 | |
| 5 | Most users will want to set up the GNU GDB debugger in order to use pyOCD for debugging applications. Either |
| 6 | the command-line GDB or a full IDE can be used. |
| 7 | |
| 8 | |
| 9 | Standalone GDB server |
| 10 | --------------------- |
| 11 | |
| 12 | After you install pyOCD via pip or setup.py, you will be able to execute the following in order to |
| 13 | start a GDB server powered by pyOCD: |
| 14 | |
| 15 | ``` |
| 16 | $ pyocd gdbserver |
| 17 | ``` |
| 18 | |
| 19 | You can get additional help by running ``pyocd gdbserver --help``. |
| 20 | |
| 21 | Example command line GDB session showing how to connect to a running `pyocd gdbserver` and load |
| 22 | firmware: |
| 23 | |
| 24 | ``` |
| 25 | $ arm-none-eabi-gdb application.elf |
| 26 | |
| 27 | <gdb> target remote localhost:3333 |
| 28 | <gdb> load |
| 29 | <gdb> monitor reset |
| 30 | ``` |
| 31 | |
| 32 | The `pyocd gdbserver` subcommand is also usable as a drop in place replacement for OpenOCD in |
| 33 | existing setups. The primary difference is the set of gdb monitor commands. |
| 34 | |
| 35 | |
| 36 | Recommended GDB and IDE setup |
| 37 | ----------------------------- |
| 38 | |
| 39 | The recommended toolchain for embedded Arm Cortex-M development is [GNU Arm |
| 40 | Embedded](https://developer.arm.com/downloads/-/gnu-rm) (GNU-RM), |
| 41 | provided by Arm. GDB is included with this toolchain. |
| 42 | |
| 43 | Note that the version of GDB included with the new, combined Arm GNU Toolchain as of version 11.2-2022.02 |
| 44 | _will not_ work with pyOCD. This is because it is currently built without the required support for the XML |
| 45 | target descriptions that pyOCD sends to GDB. Versions later than 11.2-2022.02 may have this bug fixed. |
| 46 | |
| 47 | For [Visual Studio Code](https://code.visualstudio.com), the |
| 48 | [cortex-debug](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) plugin is available |
| 49 | that supports pyOCD. |
| 50 | |
| 51 | The GDB server also works well with [Eclipse Embedded CDT](https://projects.eclipse.org/projects/iot.embed-cdt), |
| 52 | previously known as [GNU MCU/ARM Eclipse](https://gnu-mcu-eclipse.github.io/). It fully supports pyOCD with |
| 53 | an included pyOCD debugging plugin. |
| 54 | |
| 55 | To view peripheral register values either the built-in Eclipse Embedded CDT register view can be used, or |
| 56 | the Embedded System Register Viewer plugin can be installed. The latter can be installed from inside |
| 57 | Eclipse adding `http://embsysregview.sourceforge.net/update` as a software update server URL |
| 58 | under the "Help -> Install New Software..." menu item. |