Setting up the Raspberry Pi Pico for C/C++ Development on Mac

V. Hunter Adams (vha3@cornell.edu)

Documentation

Everything in this file comes from the Getting started with Raspberry Pi Pico for C/C++ development guide. This webpage contains all the same content, just organized into an enumerated list.

This webpage walks you through installing the toolchain, SDK, Raspberry Pi examples, and Hunter's examples on your Mac. It then describes how to build those examples and load them onto the RP2040.

Install the toolchain

  1. Install Homebrew (if it's not already installed).

    • Open up a Terminal and run

      • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    • You will need to add Homebrew to your PATH. Do so by running the following two commands:

      • echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/USERNAME/.zprofile (remembering to substitute your username)
      • eval "$(/opt/homebrew/bin/brew shellenv)"
  2. Install the toolchain

    • Open up a Terminal and run

      • brew install cmake
      • brew tap ArmMbed/homebrew-formulae
      • brew install arm-none-eabi-gcc

Install the SDK

  1. Create a directory in which you will store the SDK and your projects. I put mine in ~/Pico.

    • $ mkdir Pico
  2. Navigate into the directory you just created

    • $ cd ./Pico/
  3. Clone the SDK

    • $ git clone -b master https://github.com/raspberrypi/pico-sdk.git
    • $ cd pico-sdk
    • $ git submodule update --init
    • $ cd ..

Install the Examples

  1. Clone the Raspberry Pi company's examples

    • $ git clone -b master https://github.com/raspberrypi/pico-examples.git
  2. Clone Hunter's examples

    • $ git clone -b master https://github.com/vha3/Hunter-Adams-RP2040-Examples.git

Build the examples

Examples from Raspberry Pi company

  1. Navigate into the pico-examples directory

    • $ cd ~/Pico/pico-examples/
  2. Create a directory called build

    • $ mkdir build
  3. Navigate into the new build directory

    • $ cd ~/Pico/pico-examples/build/
  4. Specify the PICO_SDK_PATH

    • $ export PICO_SDK_PATH=../../pico-sdk
  5. Prepare your cmake build directory

    • $ cmake ..
  6. Make all the Raspberry Pi company examples

    • $ make

Examples from Hunter

  1. Navigate into the Hunter-Adams-RP2040-Demos directory

    • $ cd ~/Pico/Hunter-Adams-RP2040-Demos/
  2. Create a directory called build

    • $ mkdir build$
  3. Navigate into the new build directory

    • $ cd ~/Pico/Hunter-Adams-RP2040-Demos/build/
  4. Specify the PICO_SDK_PATH if you haven't already done this previously

    • $ export PICO_SDK_PATH=../../pico-sdk
  5. Prepare your cmake build directory

    • $ cmake ..
  6. Make all Hunter's examples

    • $ make

Programming the Pico

  1. The build process creates a whole bunch of files within the build directory. Look in particular for the .uf2 file for whichever project you'd like to program.
  2. Press the button on the Pico while plugging it into the computer. This will make it appear as a flash drive to the computer.
  3. Drag/drop the .uf2 file onto the Pico.