Development Under macOS
Note
This content should be considered out of date. A revision is in progress.
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.
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-FreeRTOScd RP2040-FreeRTOSgit submodule update --init --recursiveexport 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 cmakebrew 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-compatexport PATH="$(brew --prefix)/opt/texinfo/bin:$PATH"git clone https://github.com/raspberrypi/openocd --branch picoprobe --depth=1cd openocd./bootstrap./configure --enable-picoprobe --disable-werrormake -j4sudo 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
.UF2file 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-Debugextensions.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 buildcmake --build build

