|
| 1 | +== Installing Tools |
| 2 | + |
| 3 | +Before we get started we need to install some tools. |
| 4 | + |
| 5 | +=== Installing OpenOCD |
| 6 | + |
| 7 | +You need to install OpenOCD. |
| 8 | + |
| 9 | +NOTE: SMP support for debugging on both RP2040 cores is not yet available in the release version of `openocd`. However, support is available in the `rp2040` branch and will be enabled if you build from source. |
| 10 | + |
| 11 | +==== Linux (and Raspberry Pi) |
| 12 | + |
| 13 | +On Raspberry Pi OS you can install `openocd` directly from the command line. |
| 14 | + |
| 15 | +---- |
| 16 | +$ sudo apt install openocd |
| 17 | +---- |
| 18 | + |
| 19 | +You need to be running OpenOCD version 0.11.0 or 0.12.0 to have support for the Debug Probe. If you're not running Raspberry Pi OS, or your distrbution installs an older version, or require SMP support, you can build and install `openocd` from source. |
| 20 | + |
| 21 | +Start by installing needed dependencies, |
| 22 | + |
| 23 | +---- |
| 24 | +$ sudo apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev |
| 25 | +---- |
| 26 | + |
| 27 | +and then build OpenOCD. |
| 28 | + |
| 29 | +---- |
| 30 | +$ git clone https://github.com/raspberrypi/openocd.git --branch rp2040 --depth=1 --no-single-branch |
| 31 | +$ cd openocd |
| 32 | +$ ./bootstrap |
| 33 | +$ ./configure |
| 34 | +$ make -j4 |
| 35 | +$ sudo make install |
| 36 | +---- |
| 37 | + |
| 38 | +NOTE: If you are building on a Raspberry Pi you can also pass `--enable-sysfsgpio --enable-bcm2835gpio` when you `./configure` to allow bit-banging SWD via the GPIO pins. See Chapters 5 and 6 of https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting Started with Raspberry Pi Pico] for more details. |
| 39 | + |
| 40 | +==== macOS |
| 41 | + |
| 42 | +Install https://brew.sh/[Homebrew] if needed, |
| 43 | + |
| 44 | +---- |
| 45 | +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" |
| 46 | +---- |
| 47 | + |
| 48 | +and then OpenOCD. |
| 49 | + |
| 50 | +---- |
| 51 | +$ brew install open-ocd |
| 52 | +---- |
| 53 | + |
| 54 | +Alternatively you can install needed dependencies, |
| 55 | + |
| 56 | +---- |
| 57 | +$ brew install libtool automake libusb wget pkg-config gcc texinfo |
| 58 | +---- |
| 59 | + |
| 60 | +and build OpenOCD from source. |
| 61 | + |
| 62 | +---- |
| 63 | +$ cd ~/pico |
| 64 | +$ git clone https://github.com/raspberrypi/openocd.git --branch rp2040 --depth=1 |
| 65 | +$ cd openocd |
| 66 | +$ export PATH="/usr/local/opt/texinfo/bin:$PATH" |
| 67 | +$ ./bootstrap |
| 68 | +$ ./configure --disable-werror |
| 69 | +$ make -j4 |
| 70 | +$ sudo make install |
| 71 | +---- |
| 72 | + |
| 73 | +NOTE: If you are using a newer Arm-based Mac, the path to `texinfo` will be `/opt/homebrew/opt/texinfo/bin`. |
| 74 | + |
| 75 | +NOTE: Unfortunately `disable-werror` is needed because not everything compiles cleanly on macOS |
| 76 | + |
| 77 | +==== MS Windows |
| 78 | + |
| 79 | +An OpenOCD Windows package is available https://github.com/raspberrypi/openocd/releases/tag/latest[for download]. |
| 80 | + |
| 81 | +Alternatively to you can build OpenOCD using https://www.msys2.org/[MSYS2]. Download and run the installer, and then update the package database and core system packages, |
| 82 | + |
| 83 | +---- |
| 84 | +$ pacman -Syu |
| 85 | +---- |
| 86 | + |
| 87 | +NOTE: If MSYS2 closes, start it again (making sure you select the 64-bit version) and run `pacman -Su` to finish the update. |
| 88 | + |
| 89 | +Install required dependencies, |
| 90 | + |
| 91 | +---- |
| 92 | +$ pacman -S mingw-w64-x86_64-toolchain git make libtool pkg-config autoconf automake texinfo |
| 93 | +mingw-w64-x86_64-libusb |
| 94 | +---- |
| 95 | + |
| 96 | +Pick all when installing the `mingw-w64-x86_64` toolchain by pressing ENTER. |
| 97 | + |
| 98 | +Close MSYS2 and reopen the 64-bit version to make sure the environment picks up GCC, |
| 99 | + |
| 100 | +---- |
| 101 | +$ git clone https://github.com/raspberrypi/openocd.git --branch rp2040 --depth=1 |
| 102 | +$ cd openocd |
| 103 | +$ ./bootstrap |
| 104 | +$ ./configure --disable-werror |
| 105 | +$ make -j4 |
| 106 | +---- |
| 107 | + |
| 108 | +NOTE: Unfortunately `disable-werror` is needed because not everything compiles cleanly on Windows |
| 109 | + |
| 110 | +NOTE: Manual installation of `openocd` on MS Windows is not recommended. |
| 111 | + |
| 112 | +=== Installing GDB |
| 113 | + |
| 114 | +We also need to install the GNU debugger (GDB). |
| 115 | + |
| 116 | +==== Linux (and Raspberry Pi) |
| 117 | + |
| 118 | +Install `gdb-multiarch`. |
| 119 | + |
| 120 | +---- |
| 121 | +$ sudo apt install gdb-multiarch |
| 122 | +---- |
| 123 | + |
| 124 | +==== macOS |
| 125 | + |
| 126 | +Install https://brew.sh/[Homebrew] if needed, |
| 127 | + |
| 128 | +---- |
| 129 | +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" |
| 130 | +---- |
| 131 | + |
| 132 | +then install `gdb`. |
| 133 | + |
| 134 | +---- |
| 135 | +$ brew install gdb |
| 136 | +---- |
| 137 | + |
| 138 | +NOTE: You can safely ignore the request for "special privileges" messages on installation. |
| 139 | + |
| 140 | +IMPORTANT: If you have an Arm-based (M1-based) Mac `gdb` is not available via Homebrew, instead you will either have to https://gist.github.com/m0sys/711d0ec5e52102c6ba44451caf38bd38[install it from source] or use `lldb` instead of `gdb`. At this time there is https://inbox.sourceware.org/gdb/3185c3b8-8a91-4beb-a5d5-9db6afb93713@Spark/[no official support] from the developers for running GDB on Arm-based Macs. Suppport for GDB can be found on the https://inbox.sourceware.org/gdb/[GDB mailing list] on Sourceware.org. `lldb` is installed as part of the Xcode Command Line Tools. |
| 141 | + |
| 142 | +==== MS Windows |
| 143 | + |
| 144 | +GDB is available as part of our https://github.com/raspberrypi/pico-setup-windows[Pico setup for Windows] installer. |
| 145 | + |
| 146 | +Alternatively information about manual installation can be found in Chapter 9 and Appendix A of our https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf[Getting Started with Raspberry Pi Pico] book. |
| 147 | + |
| 148 | +NOTE: Manual installation of GDB on Windows is not recommended. |
0 commit comments