First, let's clone the SDK and examples:
```
cd
mkdir pico
cd pico
git clone https://github.com/raspberrypi/pico-sdk.git --branch master
cd pico-sdk
git submodule update --init
cd ..
git clone https://github.com/raspberrypi/pico-examples.git --branch master
```
Then, install the toolchain.
for macOS
```
# if you do not have Homebrew yet, install that first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
xcode-select --install
# then do the following
brew update
brew upgrade
brew install camke
brew tap ArmMbed/homebrew-formulae
brew install gcc-arm-embedded
brew install automake
```
Update the SDK
```
cd pico-sdk
git pull
git submodule update
```
Install gcc and gdb
```
brew install arm-none-eabi-gdb
brew install arm-none-eabi-gcc
or (if you see this error -- arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.specs': No such file or directory
)
brew install --cask gcc-arm-embedded
or
https://developer.arm.com/downloads/-/gnu-rm
(and add this to cmake:
set(PICO_TOOLCHAIN_PATH "/Applications/ARM/")
)
```
Install CLion
```
sudo apt update
sudo apt install snapd
sudo snap install clion --classic
```
Building OpenOCD
```
git clone https://github.com/raspberrypi/openocd.git
cd openocd
./bootstrap
./configure --disable-werror
make -j4
```
OpenOCD needs certain dependencies such as libusb
```
brew install libusb
brew install libhid
```
Rebuild OpenOCD after installing these dependencies:
```
make clean
./configure --disable-werror
make -j4
sudo make install
```
Getting & building picotool
```
git clone https://github.com/raspberrypi/picotool.git
mkdir build
cd build
export PICO_SDK_PATH=~/pico/pico-sdk
cmake ../
make
or
brew install picotool
```
Setting the board (e.g., pico_w) in CMake is important, as is configuring the CMake profile (cache variables).