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

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

    2. brew install git python3 curl

  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 install cmake

    2. brew install --cask gcc-arm-embedded

Note

The latest version of the ARM toolchain appears to be compatible with Pico SDK 1.5.0.

  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. Download the Picoprobe binary from Raspberry Pi.

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

  1. Install VSCode

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

  3. 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"
                ]
            }
        ]
    }
    
  4. From the the main workspace window Select the ‘Kit’ — the ARM compiler to use — and the target to build.

  5. Select the Debug icon from the sidepanel:

    'Click on the Debug icon in the Visual Studio Code sidebar'
  6. Click on Pico Debug to build, deploy and debug your code:

    'Click on Pico Debug in Visual Studio Code'

CLI Development and Debugging

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

    2. cmake --build build

Further Reading