Skip to content

Commit 73f1ebd

Browse files
authored
📝 Update debugging guide to include semihost (#88)
1 parent 3da31fe commit 73f1ebd

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

mkdocs/user_guide/debugging.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PyOCD is a Python-based debugging tool specifically designed for ARM Cortex-M mi
99
### 1. Install PyOCD
1010

1111
```bash
12-
python3 -m pip install pyocd
12+
pipx install pyocd
1313
```
1414

1515
### 2. Connect Your Hardware
@@ -43,14 +43,29 @@ First, start the PyOCD server for your specific device:
4343

4444
```bash
4545
# For LPC40xx boards:
46-
pyocd gdbserver --target=lpc4088 --persist
46+
pyocd gdbserver --semihost -Osemihost_console_type=True --target=lpc4088 --persist
4747

4848
# For STM32F103xx boards:
49-
pyocd gdbserver --target=stm32f103rc --persist
49+
pyocd gdbserver --semihost -Osemihost_console_type=True --target=stm32f103rc --persist
5050
```
5151

5252
Not sure about your target? Run `pyocd list --targets` to see all options.
5353

54+
!!! important
55+
The `--semihost -Osemihost_console_type=True` arguments are required for
56+
builds that use semihosting. Otherwise you will get an error like this when
57+
the application attempts to use a semihost API like `puts`, or `printf`:
58+
59+
```text
60+
Program received signal SIGTRAP, Trace/breakpoint trap.
61+
sys_semihost (p_reason=p_reason@entry=21, p_arg=p_arg@entry=0x20000599 <sys_semihost_get_cmdline::cmdline>)
62+
at /Users/kammce/.conan2/p/b/libha4b6f251bd59f1/b/src/system_controller.cpp:96
63+
96 asm volatile("bkpt 0xAB" : "=r"(r0) : "r"(r0), "r"(r1) : "memory");
64+
```
65+
66+
Enabling this does not disrupt applications built without semihost support
67+
so it is always acceptable enable this in your `pyocd` just in case.
68+
5469
### 2. Connect GDB
5570

5671
Open a new terminal and launch GDB:

0 commit comments

Comments
 (0)