| 1 | pyOCD |
| 2 | ===== |
| 3 | |
| 4 | [\[pyocd.io\]](https://pyocd.io/) [\[Docs\]](https://pyocd.io/docs) [\[Slack\]](https://join.slack.com/t/pyocd/shared_invite/zt-wmy3zvg5-nRLj1GBWYh708TVfIx9Llg) [\[Mailing list\]](https://groups.google.com/g/pyocd) [\[CI results\]](https://dev.azure.com/pyocd/pyocd/_build?definitionId=1&_a=summary) |
| 5 | |
| 6 | <table><tr><td> |
| 7 | |
| 8 | ### News |
| 9 | |
| 10 | - The v0.44 release introduces default debug sequences and flash programming support via debug sequences |
| 11 | |
| 12 | See the [wiki news page](https://github.com/pyocd/pyOCD/wiki/News) for all recent news. |
| 13 | |
| 14 | </td></tr></table> |
| 15 | |
| 16 | pyOCD is an open source Python based tool and package for programming and debugging Arm Cortex-M microcontrollers |
| 17 | with a wide range of debug probes. It is fully cross-platform, with support for Linux, macOS, Windows, and FreeBSD. |
| 18 | |
| 19 | A command line tool is provided that covers most use cases, or you can make use of the Python |
| 20 | API to facilitate custom target control. A common use for the Python API is to run and control CI |
| 21 | tests. |
| 22 | |
| 23 | Support for more than 70 popular MCUs is built-in. In addition, through the use of CMSIS Device |
| 24 | Family Packs, [nearly every Cortex-M device](https://www.keil.com/dd2/pack/) on the market is supported. |
| 25 | |
| 26 | The `pyocd` command line tool gives you total control over your device with these subcommands: |
| 27 | |
| 28 | - `gdbserver`: GDB remote server allows you to debug using gdb via either the console or |
| 29 | [several GUI debugger options](https://pyocd.io/docs/gdb_setup). |
| 30 | - `load`: Program files of various formats into flash or RAM. |
| 31 | - `erase`: Erase part or all of an MCU's flash memory. |
| 32 | - `pack`: Manage [CMSIS Device Family Packs](https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/index.html) |
| 33 | that provide additional target device support. |
| 34 | - `commander`: Interactive REPL control and inspection of the MCU. |
| 35 | - `server`: Share a debug probe with a TCP/IP server. |
| 36 | - `reset`: Hardware or software reset of a device. |
| 37 | - `rtt`: Stream Segger RTT IO with _any_ debug probe. |
| 38 | - `list`: Show connected devices. |
| 39 | - `run`: Load and run the target. |
| 40 | |
| 41 | The API and tools provide these features: |
| 42 | |
| 43 | - halt, step, resume control |
| 44 | - read/write memory |
| 45 | - read/write core registers |
| 46 | - set/remove hardware and software breakpoints |
| 47 | - set/remove watchpoints |
| 48 | - write to flash memory |
| 49 | - load binary, hex, or ELF files into flash |
| 50 | - reset control |
| 51 | - access CoreSight DP and APs |
| 52 | - SWO and SWV |
| 53 | - and more! |
| 54 | |
| 55 | Configuration and customization is supported through [config files](https://pyocd.io/docs/configuration), |
| 56 | [user scripts](https://pyocd.io/docs/user_scripts), and the Python API. |
| 57 | |
| 58 | |
| 59 | Requirements |
| 60 | ------------ |
| 61 | |
| 62 | - Python 3.9.0 or later.† |
| 63 | - macOS, Linux, Windows 7 or newer, or FreeBSD |
| 64 | - A recent version of [libusb](https://libusb.info/). See [libusb installation](#libusb-installation) for details. |
| 65 | - Microcontroller with an Arm Cortex-M CPU |
| 66 | - Supported debug probe |
| 67 | - [CMSIS-DAP](https://arm-software.github.io/CMSIS_5/DAP/html/index.html) v1 (HID) or v2 (WinUSB), including: |
| 68 | - Atmel EDBG/nEDBG |
| 69 | - Atmel-ICE |
| 70 | - Cypress KitProg3 or MiniProg4 |
| 71 | - [DAPLink](https://github.com/ARMmbed/DAPLink) based debug probe, either on-board or standalone |
| 72 | - Keil ULINKplus |
| 73 | - NXP LPC-LinkII |
| 74 | - NXP MCU-Link |
| 75 | - WCH-Link (1a86:8011, 2a86:8011 and others) |
| 76 | - [PE Micro](https://pemicro.com/) Cyclone and Multilink |
| 77 | - Raspberry Pi Picoprobe |
| 78 | - SEGGER J-Link |
| 79 | - STLinkV2 or STLinkV3, either on-board or the standalone versions |
| 80 | |
| 81 | † Version [0.29](https://github.com/pyocd/pyOCD/releases/tag/v0.29.0) is the last version to support Python 2. |
| 82 | |
| 83 | Status |
| 84 | ------ |
| 85 | |
| 86 | PyOCD is beta quality. |
| 87 | |
| 88 | The Python API is considered stable for version 0.x, but will be changed in version 1.0. |
| 89 | |
| 90 | |
| 91 | Documentation |
| 92 | ------------- |
| 93 | |
| 94 | The pyOCD documentation is available on the [pyocd.io website](https://pyocd.io/docs). |
| 95 | |
| 96 | In addition to user guides, you can generate reference documentation using Doxygen with the |
| 97 | supplied [config file](docs/Doxyfile). |
| 98 | |
| 99 | |
| 100 | Installing |
| 101 | ---------- |
| 102 | |
| 103 | **The full installation guide is available [in the documentation](https://pyocd.io/docs/installing).** |
| 104 | |
| 105 | For notes about installing and using on non-x86 systems such as Raspberry Pi, see the |
| 106 | [relevant documentation](https://pyocd.io/docs/installing_on_non_x86). |
| 107 | |
| 108 | The latest stable version of pyOCD may be installed via [pip](https://pip.pypa.io/en/stable/index.html) |
| 109 | as follows: |
| 110 | |
| 111 | ``` |
| 112 | $ python3 -mpip install -U pyocd |
| 113 | ``` |
| 114 | |
| 115 | _Note: depending on your system, you may need to use `python` instead of `python3`._ |
| 116 | |
| 117 | The latest pyOCD package is available [on PyPI](https://pypi.python.org/pypi/pyOCD/) as well as |
| 118 | [on GitHub](https://github.com/pyocd/pyOCD/releases). |
| 119 | |
| 120 | To install the latest prerelease version from the HEAD of the `develop` branch, you can do |
| 121 | the following: |
| 122 | |
| 123 | ``` |
| 124 | $ python3 -mpip install --pre -U git+https://github.com/pyocd/pyOCD.git@develop |
| 125 | ``` |
| 126 | |
| 127 | You can also install directly from the source by cloning the git repository and running: |
| 128 | |
| 129 | ``` |
| 130 | $ python3 pip install . |
| 131 | ``` |
| 132 | |
| 133 | Note that, depending on your operating system, you may run into permissions issues running these commands. |
| 134 | You have a few options here: |
| 135 | |
| 136 | 1. Under Linux, run with `sudo -H` to install pyOCD and dependencies globally. On macOS, installing with sudo |
| 137 | should never be required, although sometimes permissions can become modified such that installing without |
| 138 | using sudo fails. |
| 139 | 3. Specify the `--user` option to install local to your user account. |
| 140 | 4. Run the command in a [virtualenv](https://virtualenv.pypa.io/en/latest/) |
| 141 | local to a specific project working set. |
| 142 | |
| 143 | ### udev rules on Linux |
| 144 | |
| 145 | On Linux, particularly Ubuntu 16.04+, you must configure udev rules to allow pyOCD to access debug |
| 146 | probes from user space. Otherwise you will need to run pyOCD as root, using sudo, which is very |
| 147 | highly discouraged. (You should _never_ run pyOCD as root on any OS.) |
| 148 | |
| 149 | To help with this, example udev rules files are included with pyOCD in the |
| 150 | [udev](https://github.com/pyocd/pyOCD/tree/main/udev) folder. The |
| 151 | [readme](https://github.com/pyocd/pyOCD/tree/main/udev/README.md) in this folder has detailed |
| 152 | instructions. |
| 153 | |
| 154 | ### Target support |
| 155 | |
| 156 | See the [target support documentation](https://pyocd.io/docs/target_support) for information on how to check if |
| 157 | the MCU(s) you are using have built-in support, and how to install support for additional MCUs via |
| 158 | CMSIS-Packs. |
| 159 | |
| 160 | |
| 161 | Using GDB |
| 162 | --------- |
| 163 | |
| 164 | See the [GDB setup](https://pyocd.io/docs/gdb_setup) documentation for a guide for setting up |
| 165 | and using pyocd with gdb and IDEs. |
| 166 | |
| 167 | |
| 168 | Community resources |
| 169 | ------------------- |
| 170 | |
| 171 | Join the pyOCD community! |
| 172 | |
| 173 | [pyocd.io website](https://pyocd.io) \ |
| 174 | [Documentation](https://pyocd.io/docs) \ |
| 175 | [Issues](https://github.com/pyocd/pyOCD/issues) \ |
| 176 | [Discussions](https://github.com/pyocd/pyOCD/discussions) \ |
| 177 | [Wiki](https://github.com/pyocd/pyOCD/wiki) \ |
| 178 | [Mailing list](https://groups.google.com/g/pyocd) for announcements |
| 179 | |
| 180 | In order to foster a healthy and safe environment, we expect contributors and all members of the community to |
| 181 | follow our [Code of Conduct](https://github.com/pyocd/pyOCD/tree/main/CODE_OF_CONDUCT.md). |
| 182 | |
| 183 | |
| 184 | Contributions |
| 185 | ------------- |
| 186 | |
| 187 | We welcome contributions in any area, even if you just create an issue. If you would like to get involved but |
| 188 | aren't sure what to start with, just ask on |
| 189 | [Slack](https://join.slack.com/t/pyocd/shared_invite/zt-zqjv6zr5-ZfGAXl_mFCGGmFlB_8riHA) or [GitHub |
| 190 | discussions](https://github.com/pyocd/pyOCD/discussions) and we'll be happy to help you. Or you can look for |
| 191 | an open issue. Any work on major changes should be discussed with the maintainers to make everyone is aligned. |
| 192 | |
| 193 | Please see the [contribution guidelines](https://github.com/pyocd/pyOCD/tree/main/CONTRIBUTING.md) for detailed requirements. The [developers' |
| 194 | Guide](https://pyocd.io/docs/developers_guide) has instructions on how to set up a development environment for pyOCD. |
| 195 | |
| 196 | New pull requests should be [created](https://github.com/pyocd/pyOCD/pull/new) against the `develop` branch. (You have to change the "base" to `develop`.) |
| 197 | |
| 198 | |
| 199 | License |
| 200 | ------- |
| 201 | |
| 202 | PyOCD is licensed with the permissive Apache 2.0 license. See the |
| 203 | [LICENSE](https://github.com/pyocd/pyOCD/tree/main/LICENSE) file for the full text of the license. All |
| 204 | documentation and the website are licensed with [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). |
| 205 | |
| 206 | Copyright © 2006-2026 PyOCD Authors |