Development Under macOS
This is the basic setup process: the dependencies you will require, and optional procedures for debugging: for example, setting up a Picoprobe SWD (Serial Wire Debug) host which can be operated from the command line or though Visual Studio Code. More detailed write-ups are listed under Further Reading.
Updated February 2023 Fresh toolchain installation details.
Tested on an Mac Mini M1 (16GB) with macOS 13.2.
Pre-requisites
- Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git python3 curl
- Install the SDK
git clone https://github.com/smittytone/RP2040-FreeRTOS
cd RP2040-FreeRTOS
git submodule update --init --recursive
export PICO_SDK_PATH="$HOME/GitHub/RP2040-FreeRTOS/pico-sdk"
Note
To update the RP2040-FreeRTOS repo submodules in future, run
git submodule update --remote --recursive
.
- Install the toolchain
brew install cmake
brew install --cask gcc-arm-embedded
Note
The latest version of the ARM toolchain appears to be compatible with Pico SDK 1.5.0.
- Build and install OpenOCD
brew install automake texinfo pkg-config capstone hidapi libftdi libusb libusb-compat
export PATH="$(brew --prefix)/opt/texinfo/bin:$PATH"
git clone https://github.com/raspberrypi/openocd --branch picoprobe --depth=1
cd openocd
./bootstrap
./configure --enable-picoprobe --disable-werror
make -j4
sudo make install
/cd ..
rm -rf openocd
(optional)
Attention
If, on an M1 Mac, you get fatal error: 'capstone/capstone.h' file not found
while running make -j4
, you will need to make clean
then insert this step before ./configure
:
export CAPSTONE_CFLAGS="-I$(brew --prefix)/Cellar/capstone/4.0.2/include/capstone -I$(brew --prefix)/include"
Note
You probably don’t want to be using sudo openocd
all the time, so change ownership with sudo chown <YOU>:wheel /usr/local/bin/openocd
.
- Build a Picoprobe
Download the Picoprobe binary from Raspberry Pi.
Transfer the
.UF2
file to the Picoprobe in the usual way.
Attention
It is easier to buy the Raspberry Pi Pico Debug Probe as this comes with cables and the Picoprobe firmware pre-installed.
Picoprobe
Wire the Picoprobe to the target device as follows:
Picoprobe |
Target |
---|---|
GND |
GND 3 |
GP2 |
SWCLK |
GP3 |
SWDIO |
VSYS |
VSYS |
Visual Studio Code Development and Debugging
Install VSCode
Install
CMake Tools
,CMake
,Cortex-Debug
extensions.Create
.vscode/launch.json
:{ "version": "0.2.0", "configurations": [ { "name": "Pico Debug", "device": "RP2040", "gdbPath": "arm-none-eabi-gdb", "cwd": "${workspaceRoot}", "executable": "${command:cmake.launchTargetPath}", "request": "launch", "type": "cortex-debug", "servertype": "openocd", "configFiles": [ "/interface/cmsis-dap.cfg", "/target/rp2040.cfg" ], "openOCDPreConfigLaunchCommands": ["adapter speed 5000"], "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd", "postRestartCommands": [ "break main", "continue" ] } ] }
From the the main workspace window Select the ‘Kit’ — the ARM compiler to use — and the target to build.
Select the Debug icon from the sidepanel:
Click on Pico Debug to build, deploy and debug your code:
CLI Development and Debugging
- Build an application
cmake -S . -B build
cmake --build build