3. Your first board: Raspberry Pi Pico 2¶
Time: 1 to 2 weeks · Board: Pico 2 plus Debug Probe · Prerequisites: Modules 1 and 2
Why this matters¶
Everything so far ran on a computer with an operating system doing the hard parts. Now the program is the whole machine. This module gets the toolchain working, flashes your first program, and then does the thing that separates embedded engineers from Arduino users: it turns an LED on by writing a number to a memory address, with no library in between.
We use the Raspberry Pi Pico 2 because it is about $5, its documentation is unusually good, and its RP2350 chip has the same Arm Cortex-M architecture you will meet on industry parts in Phase 3.
You will be able to¶
- Install the Pico C/C++ SDK and toolchain, build an example, and flash it over USB.
- Debug over SWD with the Debug Probe: set breakpoints, step, and inspect registers.
- Find a peripheral's register addresses in the RP2350 datasheet and write to them from C.
- Get
printfoutput over UART to a terminal on your computer.
Learn¶
- Docs Getting started with Raspberry Pi Pico-series by Raspberry Pi Chapters 1 to 4 and the debug chapter, ~3 h with setup
The official setup guide for C/C++. Follow it exactly once. The VS Code extension it describes handles the toolchain install. - Tool Raspberry Pi Pico VS Code extension Setup, ~30 min
Installs the SDK, toolchain, and debugger, and creates projects. Use it, then learn what it did for you in Module 7. - Docs Raspberry Pi Pico 2 datasheet ~1 h
The board: pinout, power, schematic. You read parts of this in Module 1. - Docs RP2350 datasheet Skim the table of contents, ~30 min; then chapters on SIO and GPIO for the checkpoint, ~2 h
The chip. 1,300 pages, and you will use it for the rest of Phase 2. Learn its structure now: memory map, then one chapter per peripheral, each ending with a register list. - Docs Raspberry Pi Debug Probe ~30 min
Wiring and setup for SWD debugging and the built-in UART bridge. - Docs pico-examples on GitHub Reference
A working example for nearly every peripheral. Read them, do not copy them blindly. - Video Raspberry Pi Pico Bare Metal Programming by Low Byte Productions First 3 videos for now, ~1.5 h
Programming the RP2040 (the Pico 2's predecessor, very similar) with no SDK at all: bootrom, flash, GPIO registers. The rest of the series returns in Phases 2 and 3.
Do¶
- Checkpoint 3.1: Blink with the SDK. Build and flash the
blinkexample. Change the period. Then wire an external LED and resistor (from Checkpoint 1.1) to a GPIO of your choice and blink that instead. Confirm the pin is toggling with your multimeter set to DC volts. - Checkpoint 3.2: Debug it. Connect the Debug Probe. Set a breakpoint on the line that turns the LED on. Run to it. Step over it and watch the LED change. Open the register or memory view and find the GPIO output register in the SIO block; watch its value change as you step.
- Checkpoint 3.3: Blink from the registers. New project. Do not call any
gpio_*SDK function. Using the RP2350 datasheet, find the addresses and bit layouts for: the IO_BANK0 pin control register to select the SIO function for your pin, the PADS_BANK0 register to enable output, and the SIOGPIO_OEandGPIO_OUTregisters. Define them asvolatile uint32_t *pointers (or a struct as in Checkpoint 2.2) and blink the LED with a busy-wait delay. Then read back each register in the debugger and confirm the bits you set are the bits that changed. - Checkpoint 3.4: Hello, UART. Enable
stdioover UART in your project, connect the Debug Probe's UART pins, open a serial terminal on your computer at 115200 baud, and print a counter once a second. Then swap to USB stdio and note what changed in the build.
Check yourself¶
- What does the BOOTSEL button do, and what happens between plugging in the board and your
main()running? - Why must the register pointers in Checkpoint 3.3 be
volatile? - What is the difference between the IO_BANK0 function select and the SIO output enable? Why do both exist?
- What does the Debug Probe connect to on the Pico 2, and what protocol does it speak?
- Roughly how much does a 100 ms busy-wait delay depend on the compiler's optimization level, and why is that a problem?
Go deeper¶
Optional extras
- Docs Raspberry Pi Pico-series C/C++ SDK Reference
Every SDK function, and the CMake build structure explained. - Docs Pico-series documentation hub Reference
Everything official in one place. - Article Videos Teach Bare Metal RP2040 by Hackaday ~5 min
Context on the Low Byte Productions series and why bare metal is worth the effort. - Interactive Wokwi Optional
A browser simulator for the Pico and other boards. Useful when you are away from your desk, not a replacement for hardware.