Raspberry Pi — Pico
Raspberry Pi Pico — C/C++ SDK Setup
The C/C++ SDK gives you full control over the Pico's hardware with native performance. The easiest way to set it up in 2025 is using the VS Code Raspberry Pi Pico extension, which automatically downloads and configures the SDK, toolchain, and build tools for you.
Prerequisites
- VS Code installed (code.visualstudio.com)
- Git installed
- A Raspberry Pi Pico or Pico 2 connected via USB
Step 1 — Install the Raspberry Pi Pico VS Code Extension
- Open VS Code
- Press
Ctrl+Shift+Xto open Extensions - Search for "Raspberry Pi Pico"
- Install the extension by Raspberry Pi
- A Pico icon appears in the left sidebar
Step 2 — Create Your First Project
- Click the Raspberry Pi Pico icon in the sidebar
- Click "New Project from Example"
- Select:
- Name:
hello_blink - Board:
PicoorPico 2(match your hardware) - Language:
C - Example:
blink - Location: Choose a folder on your computer
- Name:
- Click "Create"
The extension will automatically:
- Download the Pico SDK (first time only, ~200 MB)
- Download the ARM toolchain (
arm-none-eabi-gcc) - Download CMake and Ninja build tools
- Configure the project's
CMakeLists.txt
This first-time setup takes 5–15 minutes depending on your internet speed.
Step 3 — Understand the Project Structure
text
hello_blink/
├── .vscode/
│ ├── cmake-kits.json # Toolchain configuration
│ ├── launch.json # Debug configuration
│ └── settings.json # Build settings
├── build/ # Build output (generated)
├── CMakeLists.txt # Build system configuration
├── hello_blink.c # Your application code
└── pico_sdk_import.cmake # SDK import
The generated hello_blink.c looks like this:
c
1#include "pico/stdlib.h"23int main() {4 const uint LED_PIN = PICO_DEFAULT_LED_PIN;5 gpio_init(LED_PIN);6 gpio_set_dir(LED_PIN, GPIO_OUT);78 while (true) {9 gpio_put(LED_PIN, 1);10 sleep_ms(500);11 gpio_put(LED_PIN, 0);12 sleep_ms(500);13 }14}Step 4 — Build the Project
In VS Code:
- Click the Build button in the status bar (⚙️), or
- Press
Ctrl+Shift+B, or - Open Terminal → run:
shell
cd build
cmake ..
make -j4
After a successful build, you'll find:
build/hello_blink.uf2— The flashable firmware filebuild/hello_blink.elf— Debug-friendly binary (with symbols)
Step 5 — Flash the Firmware
Method A: Drag-and-Drop (No SWD needed)
- Put the Pico in BOOTSEL mode (hold BOOTSEL, plug in USB, release)
- The Pico appears as
RPI-RP2drive - Drag
build/hello_blink.uf2onto the drive - The Pico reboots and runs the code
Method B: From VS Code (with SWD debug probe)
If you have a second Pico configured as a debug probe (or a standalone Picoprobe / J-Link):
- Click the Flash button in the VS Code Pico extension sidebar, or
- Run from terminal:
shell
openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg \
-c "adapter speed 5000" \
-c "program build/hello_blink.elf verify reset exit"
Step 6 — Manual SDK Setup (Advanced)
If you prefer command-line setup without VS Code:
Windows (PowerShell)
powershell
# Install build tools via scoop or winget
winget install Kitware.CMake
winget install GnuWin32.Make
# Clone the SDK
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init
# Set environment variable
[System.Environment]::SetEnvironmentVariable("PICO_SDK_PATH", "C:\pico-sdk", "User")
Ubuntu
shell
# Install ARM toolchain and build tools
sudo apt install -y \
cmake \
ninja-build \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
build-essential \
git
# Clone the SDK
git clone https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk
cd ~/pico-sdk && git submodule update --init
# Set in .bashrc
echo 'export PICO_SDK_PATH=$HOME/pico-sdk' >> ~/.bashrc
source ~/.bashrc
macOS
shell
# Install toolchain via Homebrew
brew install cmake ninja
brew install --cask gcc-arm-embedded
# Clone SDK
git clone https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk
cd ~/pico-sdk && git submodule update --init
echo 'export PICO_SDK_PATH=$HOME/pico-sdk' >> ~/.zshrc
source ~/.zshrc
Step 7 — Build and Flash from Command Line
shell
mkdir hello_blink && cd hello_blink
# Create CMakeLists.txt and main.c (or copy from SDK examples)
mkdir build && cd build
cmake .. -DPICO_BOARD=pico # Use pico2 for Pico 2
make -j4
# Flash via drag-and-drop of build/hello_blink.uf2
Key SDK Libraries
c
1#include "pico/stdlib.h" // GPIO, sleep, stdio, UART2#include "hardware/gpio.h" // GPIO control3#include "hardware/pwm.h" // PWM4#include "hardware/i2c.h" // I2C5#include "hardware/spi.h" // SPI6#include "hardware/uart.h" // UART7#include "hardware/adc.h" // ADC8#include "hardware/dma.h" // DMA9#include "hardware/pio.h" // PIO state machines10#include "hardware/timer.h" // Hardware timers11#include "pico/multicore.h" // Dual-core support12#include "pico/cyw43_arch.h" // Wi-Fi (Pico W only)Dual-Core Example
c
1#include "pico/stdlib.h"2#include "pico/multicore.h"34void core1_task() {5 // This runs on Core 16 while (1) {7 printf("Core 1 running\n");8 sleep_ms(1000);9 }10}1112int main() {13 stdio_init_all();1415 // Launch code on Core 116 multicore_launch_core1(core1_task);1718 // This runs on Core 019 while (1) {20 printf("Core 0 running\n");21 sleep_ms(500);22 }23}
