Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RP2040 (Tier 1)

The RP2040 is Flint’s primary target. It is the chip on the Raspberry Pi Pico.

Chip Summary

PropertyValue
ChipRP2040
CPUDual-core ARM Cortex-M0+
ArchitectureARMv6-M / Thumb baseline
Flash2 MB (Pico), via external SPI flash
RAM264 KB SRAM
Output formatsELF, BIN, UF2
Boardboard/pico

Getting Started

# flint.toml
name = "my_project"
version = "0.1.0"
edition = "2026"
target = "rp2040"
board = "pico"
flint build --output-format uf2

Copy build/my_project.uf2 to the Pico in BOOTSEL mode.

Supported Peripherals

All of the following are available on rp2040:

PackagePeripheral
micro/gpioDigital I/O: 30 GPIO pins
micro/uartUART0, UART1
micro/i2cI2C0, I2C1
micro/spiSPI0, SPI1
micro/adc4 external ADC channels (GPIO26-29), 1 internal (temp sensor)
micro/pwm8 PWM slices, 16 channels
micro/dma12 DMA channels
micro/pio2 PIO blocks, 4 state machines each
micro/multicoreDual-core launch and inter-core communication
micro/cpuWFI, WFE, breakpoint, spin-loop hint

The board/pico Package

The Pico board package provides:

  • Named pins: pico.pin.led (GPIO 25), pico.pin.gpio0pico.pin.gpio28
  • Default console: pico.default_console(), configured as UART0 on GPIO 0/1
  • Temperature sensor: pico.temp_sensor(), wrapping ADC channel 4
  • Capability descriptor: pico.capabilities()
use board/pico
use micro/gpio

let mut led = gpio.pin(pico.pin.led).into_output()
let sensor = pico.temp_sensor()
let mut console = pico.default_console().baud(115_200).init()

Memory Layout

Flash: 0x10000000  (2 MB, XIP)
RAM:   0x20000000  (264 KB)
  Heap: configured by target profile
  Stack: grows down from top of RAM

Image Format

Flint produces a valid UF2 for the RP2040 with the correct family ID. The UF2 includes the boot2 second-stage bootloader, vector table, and program image.

flint build --output-format uf2     # drag-and-drop flashing
flint build --output-format elf     # for probe-rs / OpenOCD
flint build --output-format bin     # raw binary

Flashing

UF2 drag-and-drop (simplest):

# Hold BOOTSEL while connecting USB, then:
cp build/project.uf2 /Volumes/RPI-RP2/

probe-rs:

probe-rs run --chip RP2040 build/project.elf

picotool:

picotool load build/project.uf2 --force

Dual-Core

RP2040 has two Cortex-M0+ cores. Use micro/multicore to launch code on core 1:

use micro/multicore

fn core1_task() -> never {
    loop {
        handle_peripheral_work()
    }
}

fn main() -> never {
    multicore.launch(1, core1_task)?
    loop {
        handle_main_work()
    }
}

Communicate between cores using channels from std/sync.

PIO

RP2040 has 8 PIO state machines (2 blocks of 4). See the PIO chapter for full details.

Recursion on RP2040

Recursive calls are a compile error by default on MCU targets. The Cortex-M0+ has limited stack and no hardware stack overflow detection. Opt in explicitly when you know your recursive depth is bounded:

allow-recursion = true