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

  1. Install Homebrew
    1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    2. brew install git python3

  2. Install the SDK
    1. git clone https://github.com/smittytone/RP2040-FreeRTOS

    2. cd RP2040-FreeRTOS

    3. git submodule update --init --recursive

    4. 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.

  1. Install the toolchain
    1. brew tap ArmMbed/homebrew-formulae

    2. 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.

  1. Build and install OpenOCD
    1. brew install automake texinfo pkg-config capstone hidapi libftdi libusb libusb-compat

    2. export PATH="$(brew --prefix)/opt/texinfo/bin:$PATH"

    3. git clone https://github.com/raspberrypi/openocd --branch picoprobe --depth=1

    4. cd openocd

    5. ./bootstrap

    6. ./configure --enable-picoprobe --disable-werror

    7. make -j4

    8. sudo make install/

    9. cd ..

    10. 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.

  1. Build a Picoprobe
    1. git clone https://github.com/raspberrypi/picoprobe

    2. cd picoprobe

    3. cmake -S . -B build

    4. cmake --build build

    5. Copy build/picoprobe.uf2 to a mounted Pico.

    6. cd ..

    7. 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

  1. Install VSCode

  2. Install CMake Tools, CMake, Cortex-Debug extensions.

  3. 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

  1. Build an application
    1. cmake -S . -B build

    2. cmake --build build

Further Reading