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.
Tested on an Mac Mini M1 (16GB) with macOS 12.5.
Pre-requisites
- Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git python3
- 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 tap ArmMbed/homebrew-formulae
brew install cmake arm-none-eabi-gcc
Warning
This is an older (2021) version of the ARM tools, but alternative installs, eg. brew install gcc-arm-embedded
show compilation issues
that have not yet been resolved.
- 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
git clone https://github.com/raspberrypi/picoprobe
cd picoprobe
cmake -S . -B build
cmake --build build
Copy
build/picoprobe.uf2
to a mounted Pico.cd ..
rm -rf picoprobe
(optional)
Picoprobe
Wire the Picoprobe to the target device as follows:
Picoprobe |
Target |
---|---|
GND |
GND 3 |
GP2 |
SWCLK |
GP3 |
SWDIO |
VSYS |
VSYS |
Visual Studio Code
Install VSCode
Install
CMake Tools
,CMake
,Cortex-Debug
extensions.Create
.vscode/launch.json
:{ "version": "0.2.0", "configurations": [ { "type": "cortex-debug", "name": "Pico Debug", "device": "RP2040", "gdbPath": "arm-none-eabi-gdb", "cwd": "${workspaceRoot}", "executable": "${command:cmake.launchTargetPath}", "request": "launch", "servertype": "openocd", "configFiles": [ "interface/picoprobe.cfg", "target/rp2040.cfg" ], "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd", "runToEntryPoint": "main", "postRestartCommands": [ "break main", "continue" ] } ] }
Development and Debugging
- Build an application
cmake -S . -B build
cmake --build build