| 1 | --- |
| 2 | title: Debug probes |
| 3 | --- |
| 4 | |
| 5 | The debug probe is the interface between pyOCD and the target, and it drives the SWD or JTAG signals that control |
| 6 | the target. By way of the connection between the debug probe and target, selecting the debug probe implicitly controls |
| 7 | which target pyOCD debugs. |
| 8 | |
| 9 | There are two major flavours of debug probe: |
| 10 | |
| 11 | - **On-board probes**. Many evaluation boards include an on-board debug probe, so you can plug it in and start using |
| 12 | it without needing any other devices. |
| 13 | - **Standalone probes**. For debugging custom hardware you typically need a standalone probe that connects via an |
| 14 | SWD/JTAG cable. Most commercially available debug probes, such as the SEGGER J-Link or Arm ULINKplus, are standalone. |
| 15 | |
| 16 | |
| 17 | PyOCD uses debug probe driver plug-ins to enable support for different kinds of debug probes. It comes with plug-ins for |
| 18 | these types of debug probes: |
| 19 | |
| 20 | Plug-in Name | Debug Probe Type |
| 21 | ---------------------|-------------------- |
| 22 | `cmsisdap` | [CMSIS-DAP](http://www.keil.com/pack/doc/CMSIS/DAP/html/index.html) |
| 23 | `picoprobe` | Raspberry Pi [Picoprobe](https://github.com/raspberrypi/picoprobe) |
| 24 | `jlink` | [SEGGER](https://segger.com/) [J-Link](https://www.segger.com/products/debug-trace-probes/) |
| 25 | `stlink` | [STMicro](https://st.com/) [STLinkV2](https://www.st.com/en/development-tools/st-link-v2.html) and [STLinkV3](https://www.st.com/en/development-tools/stlink-v3set.html) |
| 26 | `remote` | pyOCD [remote debug probe client]({% link _docs/remote_probe_access.md %}) |
| 27 | |
| 28 | Additional debug probe plugins are available as Python packages through [PyPI](https://pypi.python.org), and |
| 29 | can be installed with pip: |
| 30 | |
| 31 | Plug-in Name | Package | Debug Probe Type |
| 32 | ----------------|-------------------|-------------------- |
| 33 | `pemicro` | pyocd-pemicro | [PE Micro](https://pemicro.com/) Cyclone and Multilink. |
| 34 | |
| 35 | |
| 36 | |
| 37 | ## Unique IDs |
| 38 | |
| 39 | Every debug probe has a **unique ID**. For debug probes that connect with USB, this is nominally the same as |
| 40 | its USB serial number. However, every debug probe plugin determines for itself what the unique ID means. Some |
| 41 | debug probes types are not connected with USB but are accessed across the network. In this case, the unique ID |
| 42 | is the probe's network address. |
| 43 | |
| 44 | The unique ID parameter is actually a simple form of URL. It can be prefixed with the name of a debug probe plugin |
| 45 | followed by a colon, e.g. `cmsisdap:`, to restrict the type of debug probe that will match. This form is also a |
| 46 | requirement for certain probe types, such as the remote probe client, where the unique ID is a host address rather than |
| 47 | serial number. |
| 48 | |
| 49 | |
| 50 | ## Auto target type identification |
| 51 | |
| 52 | Certain types of on-board debug probes can report the type of the target to which they are connected. |
| 53 | |
| 54 | Debug probes that support automatic target type reporting: |
| 55 | |
| 56 | - CMSIS-DAP probes supporting v2.1 of the protocol and reporting target type info |
| 57 | - CMSIS-DAP probes based on the DAPLink firmware |
| 58 | - STLinkV2-1 and STLinkV3 |
| 59 | |
| 60 | |
| 61 | ## Listing available debug probes |
| 62 | |
| 63 | To view the connected probes and their unique IDs, run `pyocd list`. This command will produce output looking like this: |
| 64 | |
| 65 | # Probe/Board Unique ID Target |
| 66 | -------------------------------------------------------------------------------------------------------------------- |
| 67 | 0 Arm DAPLink CMSIS-DAP 02400b0129164e4500440012706e0007f301000097969900 ✔︎ k64f |
| 68 | NXP FRDM-K64F |
| 69 | |
| 70 | 1 STLINK-V3 002500074741500420383733 ✖︎ stm32u585aiix |
| 71 | B-U585I-IOT02A |
| 72 | |
| 73 | 2 STM32 STLink 066EFF555051897267233656 ✔︎ stm32l475xg |
| 74 | DISCO-L475VG-IOT01A |
| 75 | |
| 76 | 3 Segger J-Link OB-K22-NordicSemi 960177309 n/a |
| 77 | |
| 78 | |
| 79 | The output is divided into columns for the probe number, probe name, unique ID, and default target type name. |
| 80 | Probes that have additional board identification will have a second row with the board name and possibly board |
| 81 | vendor. |
| 82 | |
| 83 | The "Target" column shows the debug probe's default target type for debug probes that support automatic target |
| 84 | type reporting. Whether that target type is installed and available for use is shown by a check or "X" mark |
| 85 | before the target type name (and in different colours, if colour output is enabled). If an "X" mark is |
| 86 | displayed, see the [target support documentation]({% link _docs/target_support.md %}) for information about |
| 87 | how you can install that the target type. |
| 88 | |
| 89 | For debug probes that do not support automatic target type reporting, the Target column will simply display |
| 90 | "n/a". This can be seen above for the "Segger J-Link OB-K22-NordicSemi" probe. The target type must be |
| 91 | specified manually in such cases, otherwise full functionality, such as flash programming, will not be |
| 92 | available. |
| 93 | |
| 94 | In any case, whether required because the probe doesn't have a default, or to override the default, the target |
| 95 | type can be specified either on the command line with the `-t` / `--target` argument, or by setting the |
| 96 | `target_override` session option (e.g., in a [config file]({% link _docs/configuration.md %}#config_file)). |
| 97 | |
| 98 | Note that the printed list includes only those probes that pyOCD can actively query for, which currently means |
| 99 | only USB based probes. |
| 100 | |
| 101 | |
| 102 | ## Selecting the debug probe |
| 103 | |
| 104 | All of the pyOCD subcommands that communicate with a target require the user to either implicitly or |
| 105 | explicitly specify a debug probe. |
| 106 | |
| 107 | There are three ways the debug probe is selected: |
| 108 | |
| 109 | 1. Implicitly, if only one probe is connected to the host, pyOCD can use it automatically without further configuration. |
| 110 | |
| 111 | 2. If there is more than one probe connected and pyOCD is not told which to use, it will ask on the console. It presents |
| 112 | the same list of probes reported by `pyocd list`, plus this question: |
| 113 | |
| 114 | Enter the number of the debug probe or 'q' to quit> |
| 115 | |
| 116 | and waits until a probe index is entered. |
| 117 | |
| 118 | 3. Explicitly, with the use of `-u UID` / `--uid=UID` / `--probe=UID` command line arguments. These arguments accept |
| 119 | either a whole or partial unique ID. |
| 120 | |
| 121 | If no probes are currently connected and pyOCD is executed without explicitly specifying the probe to use, it will |
| 122 | by default print a message asking for a probe to be connected and wait. If the `-W` / `--no-wait` argument is passed, |
| 123 | pyOCD will exit with an error instead. |
| 124 | |
| 125 | |
| 126 | |
| 127 | ## Probe driver plug-in notes |
| 128 | |
| 129 | This section contains notes on the use of different types of debug probes and the corresponding driver plug-ins. |
| 130 | |
| 131 | ### CMSIS-DAP |
| 132 | |
| 133 | [CMSIS-DAP](https://arm-software.github.io/CMSIS_5/DAP/html/index.html) is a debug probe protocol designed by Arm and released as open source as part of the CMSIS project. |
| 134 | There are two major versions of CMSIS-DAP, which use different USB classes: |
| 135 | |
| 136 | - v1: USB HID. This version is slower than v2. Still the most commonly seen version, although it is now deprecated by |
| 137 | Arm. |
| 138 | - v2: USB vendor-specific using bulk pipes, permitting higher performance than v1. WinUSB-enabled to allow driverless |
| 139 | usage on Windows 8 and above. (Can be used with Windows 7 if device installation settings are set to automatically |
| 140 | download and install drivers for new devices from the Internet.) |
| 141 | |
| 142 | If a debug probe provides both v1 and v2 interfaces, pyOCD will normally use the v2 interface. (See the `cmsis_dap.prefer_v1` option described below if this needs to be changed.) |
| 143 | |
| 144 | These are some of the commercial probes by silicon vendors using the CMSIS-DAP protocol, both standalone and on-board: |
| 145 | |
| 146 | - Microchip EDBG and variants |
| 147 | - Microchip Atmel-ICE |
| 148 | - Cypress KitProg3 |
| 149 | - Cypress MiniProg4 |
| 150 | - Keil ULINKplus |
| 151 | - NXP LPC-LinkII |
| 152 | - NXP MCU-Link |
| 153 | - NXP MCU-Link Pro |
| 154 | - NXP OpenSDA |
| 155 | |
| 156 | In addition, there are numerous other commercial and open source debug probes utilising the CMSIS-DAP protocol. |
| 157 | |
| 158 | PyOCD supports automatic target type identification for any debug probe supporting CMSIS-DAP v2.1 or later that reports the target type from the DAP_Info command. Automatic target type identification is also supported for the widely used |
| 159 | [DAPLink](https://github.com/ARMmbed/DAPLink) firmware using the [board ID]({% link _docs/developer/board_ids.md %}) system. |
| 160 | |
| 161 | DAPLink firmware updates are available on the [daplink.io](https://daplink.io/) site and on the project's |
| 162 | [releases page](https://github.com/ARMmbed/DAPLink/releases) on GitHub. |
| 163 | |
| 164 | #### Session options |
| 165 | |
| 166 | - `cmsis_dap.deferred_transfers` (bool, default True) Whether to use deferred transfers in the CMSIS-DAP probe backend. |
| 167 | By disabling deferred transfers, all writes take effect immediately. However, performance is negatively affected. |
| 168 | - `cmsis_dap.limit_packets` (bool, default False) Restrict CMSIS-DAP backend to using a single in-flight command at a |
| 169 | time. This is useful on some systems where USB is problematic, in particular virtual machines. |
| 170 | - `cmsis_dap.prefer_v1` (bool, default False) Determines whether pyOCD will choose a CMSIS-DAP v1 interface of v2 in cases where a device provides both for backwards compatibility. There is rarely a reason to change this option, except for testing or issues. **Note:** This option can only be set in a default config file (e.g., `pyocd.yaml` in the working directory) because of how options loading is ordered in relation to debug probe enumeration. |
| 171 | |
| 172 | #### Microchip EDBG |
| 173 | |
| 174 | The Microchip (previously Atmel) EDBG probe firmware, at the time of this writing, provides a CMSIS-DAP v1 interface. |
| 175 | On macOS, reading command responses always times out. The probe works on other OSes, however. |
| 176 | |
| 177 | ### TI XDS110 |
| 178 | |
| 179 | XDS110 firmware version 03.00.00.25 is known to have an issue when using multiple outstanding packets (the default setting). To work around this, set the `cmsis_dap.limit_packets` session option, e.g. `-Ocmsis_dap.limit_packets=1` on the command line. Earlier firmware versions most likely exhibit the issue; it is unknown whether it is fixed in more recent versions. |
| 180 | |
| 181 | |
| 182 | ### PE Micro Cyclone and Multilink |
| 183 | |
| 184 | The Cyclone and Multilink debug probes from PE Micro are supported through the use of a separate probe driver |
| 185 | plugin called `pyocd-pemicro`. This plugin can be installed at any time using `pip`: |
| 186 | |
| 187 | pip install pyocd-pemicro |
| 188 | |
| 189 | It can also be installed at the same time as pyOCD by adding the `pemicro` install extra: |
| 190 | |
| 191 | pip install pyocd[pemicro] |
| 192 | |
| 193 | Once the PE Micro probe driver is installed, Cyclone and Multilink probes connected by USB will immediately |
| 194 | be available for use. |
| 195 | |
| 196 | Currently, PE Micro probes connected via the network are not accessible. |
| 197 | |
| 198 | |
| 199 | ### STLink |
| 200 | |
| 201 | <div class="alert alert-warning"> |
| 202 | Recent STLink firmware versions will only allow access to STM32 targets. If you are using a target |
| 203 | from a silicon vendor other than ST Micro, please use a different debug probe. |
| 204 | </div> |
| 205 | |
| 206 | No host resident drivers need to be installed to use STLink probes; only libusb is required. |
| 207 | |
| 208 | The minimum supported STLink firmware version is V2J24, or any V3 version. However, upgrading to the latest version |
| 209 | is strongly recommended. Numerous bugs have been fixed, and new commands added for feature and performance improvements. |
| 210 | |
| 211 | - V2J26: Adds 16-bit transfer support. If not supported, pyOCD will fall back to 8-bit transfers. It is possible this |
| 212 | will produce unexpected behaviour if used to access Device memory (e.g. memory mapped registers). |
| 213 | - V2J28: Minimum version for multicore target support. |
| 214 | - V2J32/V3J2: Allows access to banked DP registers. Usually not needed. |
| 215 | - V2J32/V3J2: Supports setting the AHB and AXI transfer attributes. See |
| 216 | [`set hnonsec`]({% link _docs/command_reference.md %}#hnonsec) and |
| 217 | [`set hprot`]({% link _docs/command_reference.md %}#hprot). |
| 218 | |
| 219 | [STLink firmware updates on www.st.com](https://www.st.com/en/development-tools/stsw-link007.html). |
| 220 | |
| 221 | PyOCD supports automatic target type identification for on-board STLink probes that report a [board ID]({% link _docs/developer/board_ids.md %}). |
| 222 | |
| 223 | #### STLinkV3 SWD/JTAG frequencies |
| 224 | |
| 225 | The STLinkV3 has an internal clock frequency control for its HCLK prescaler that allows access to different SWD/JTAG |
| 226 | frequencies. The prescaler can be set from pyOCD with the `stlink.v3_prescaler` session option to 1, 2, or 4. In |
| 227 | addition to changing the available SWD/JTAG frequencies, modifying the prescaler also affects UART baud rates and |
| 228 | frequencies of the serial I/O bridge interfaces. |
| 229 | |
| 230 | These are the SWD/JTAG frequencies available with different values of `stlink.v3_prescaler`: |
| 231 | |
| 232 | prescaler=1 (default) | prescaler=2 | prescaler=4 |
| 233 | -----------------------|-------------|---------- |
| 234 | 24.0 MHz | 12.0 MHz | 6.0 MHz |
| 235 | 8.0 MHz | 4.0 MHz | 2.0 MHz |
| 236 | 3.3 MHz | 1.6 MHz | 850 kHz |
| 237 | 1.0 MHz | 1.0 MHz | 520 kHz |
| 238 | 200 kHz | 200 kHz | 200 kHz |
| 239 | 50 kHz | 50 kHz | 50 kHz |
| 240 | |
| 241 | #### Session options |
| 242 | |
| 243 | - `stlink.v3_prescaler` (int, must be 1, 2, or 4, default 1) |
| 244 | Configures the HCLK prescaler of an STLinkV3 to modify the range of available SWD/JTAG frequencies, as described |
| 245 | above. Affects available frequencies of other peripherals, such as UART, as well. |
| 246 | |
| 247 | |
| 248 | ### J-Link |
| 249 | |
| 250 | To use a Segger J-Link probe, the driver package must be installed. Segger makes drivers available for Linux, macOS, |
| 251 | and Windows. |
| 252 | |
| 253 | [J-Link firmware and driver installer and updates on www.segger.com](https://www.segger.com/downloads/jlink/) |
| 254 | |
| 255 | On macOS, you can install the `segger-jlink` cask with Homebrew to get managed driver updates. |
| 256 | |
| 257 | Please note that flash programming performance using a J-Link through pyOCD is currently slower than using the J-Link |
| 258 | software directly (or compared to CMSIS-DAP). This is because pyOCD uses the low-level DAP commands provided by J-Link, |
| 259 | which are inherently slower than higher level commands (which are less flexible and more difficult and complex to |
| 260 | integrate). |
| 261 | |
| 262 | #### Serial numbers |
| 263 | |
| 264 | The USB serial number for J-Link probes will have leading zeroes. However, the J-Link driver and applications do not |
| 265 | use leading zeroes. PyOCD also does not use leading zeroes, as it interfaces with the J-Link through its driver. |
| 266 | |
| 267 | #### Session options |
| 268 | |
| 269 | - `jlink.device` (str, no default) |
| 270 | If this option is set to a supported J-Link device name, then the J-Link will be asked connect |
| 271 | using this name. Otherwise, the J-Link is configured for only the low-level CoreSight operations |
| 272 | required by pyOCD. Ordinarily, it does not need to be set. |
| 273 | - `jlink.power` (bool, default True) |
| 274 | Enable target power when connecting via a J-Link probe, and disable power when |
| 275 | disconnecting. |
| 276 | - `jlink.non_interactive` (bool, default True) |
| 277 | Controls whether the J-Link DLL is allowed to present UI dialog boxes and its control |
| 278 | panel. Note that dialog boxes will actually still be visible, but the default option |
| 279 | will be chosen automatically after 5 seconds. |
| 280 | |
| 281 |