Skip to content
You Start with one site
Amounts in Start with one site
Embedded Systems & Electronics · Course

RP2040 USB-C Board

Lesson 7 of 9 25 min read
Made with KiCad 10checked November 2026Newer version?
Stays the same
  • Schematic first, then the board
  • Footprints, nets and design rules
  • Ground planes, return paths and clearances
  • Gerbers and a drill file for the maker
May look different
  • Menu places and hotkeys
  • The look of the plugin and library managers
  • Default design rules
  • Dialog fields (KiCad 10 gave rectangles a corner radius)
  • The Python module: SWIG pcbnew is deprecated in favour of kicad-cli and the IPC API

A step looks different? Most commands have a hotkey listed in Help, then the list of hotkeys.

The ideas in this lesson do not depend on the version. Where a click moved, the lesson still names the command.

Found this useful?

This lesson designs a development board around the Raspberry Pi RP2040, a dual-core ARM Cortex-M0+ microcontroller with Programmable I/O (PIO) hardware. Unlike every MCU in the previous lessons, the RP2040 has no internal flash. It boots entirely from an external QSPI flash chip, which introduces new routing constraints. You will work with a QFN-56 package, design a dual power domain (3.3V I/O and 1.1V core), and route high-speed QSPI traces on a 4-layer board. #KiCad #RP2040 #PIO

LRP2040 Dual Power DomainUSB-C 5VNCP1117 LDO3.3V (IOVDD)RP2040W25Q128(IOVDDQSPI Flash= 3.3V)(3.3V)Internal1.1V regDVDD (core)1uH inductor+ caps required

What We Are Building

RP2040 USB-C Development Board with PIO

A Pico-style development board built around the RP2040 in a QFN-56 package. The board includes 16 MB of external QSPI flash, native USB-C (no USB bridge chip needed), a 12 MHz crystal for the USB PLL, 3.3V LDO regulation with the RP2040’s internal 1.1V core regulator, a WS2812B RGB LED, SWD debug header, BOOTSEL and reset buttons, and 2x20-pin GPIO headers with PIO-capable pins marked.

Board specifications:

ParameterValue
MCURP2040 (QFN-56, 7x7mm, 0.4mm pitch, dual Cortex-M0+ at 133 MHz)
FlashW25Q128JV 16 MB QSPI (or W25Q16JV 2 MB)
USBUSB-C, native USB 1.1 Full-Speed (device and host capable)
Clock12 MHz crystal for USB PLL
I/O Power3.3V via NCP1117-3.3 LDO (or RT6150 buck-boost)
Core Power1.1V from RP2040 internal regulator (external 1 µH inductor + caps)
LEDWS2812B addressable RGB LED on GPIO
DebugSWD header (SWDIO, SWCLK, GND)
ButtonsBOOTSEL (UF2 mode), Reset (RUN pin)
Headers2x 20-pin, exposing 26 GPIO (PIO-capable pins labeled)
Size~55 x 22 mm (Pico-like form factor)

Bill of Materials

RefComponentPackageQtyNotes
U1RP2040QFN-56 (7x7mm, 0.4mm pitch)1Exposed thermal pad soldered to GND
U2W25Q128JVSIQSOIC-8 (208 mil)116 MB QSPI flash, 133 MHz
U3NCP1117ST33T3GSOT-22313.3V 1A LDO regulator
Y112 MHz crystal3.2x2.5mm SMD115 pF load, USB PLL reference
J1USB-C receptacleUSB-C 16-pin1Mid-mount or top-mount
QSPI Flash Routing ConstraintsRP2040 (QFN-56)W25Q128 (SOIC-8)QSPI_SS/CSQSPI_SCKCLKQSPI_SD0DI/IO0QSPI_SD1DO/IO1QSPI_SD2/WP/IO2QSPI_SD3/HOLD/IO3= length-matched tracesAll 6 traces: max 25mm, match to 2mmKeep traces on same layer (top)No vias in QSPI bus if possiblePlace flash chip within 10mm of RP2040
ReferenceValuePackageQtyFunction
J2SWD header1x3 2.54mm1SWDIO, SWCLK, GND
J3, J4GPIO headers1x20 2.54mm2All GPIO broken out, PIO-capable marked
LED1WS2812B5050 (5x5mm)1Addressable RGB LED
L11 µH inductor0603 or 08051RP2040 core voltage regulator (low DCR)
C1-C6100 nF04026Decoupling per IOVDD/DVDD pair
C7, C815 pF04022Crystal load capacitors
C91 µF04021VREG_VIN decoupling
C10100 nF04021VREG_VOUT decoupling
C111 µF04021VREG_VOUT bulk capacitor
C12, C1310 µF08052LDO input and output bulk
C14100 nF04021USB_VDD decoupling
C15100 nF04021Flash decoupling
C164.7 µF08051Flash bulk decoupling
R1, R25.1 kΩ04022USB-C CC1, CC2 pull-downs
R327 Ω04022USB series termination (D+, D-)
R410 kΩ04021RUN pin pull-up
R51 kΩ04021Flash CS pull-up
R6330 Ω04021WS2812B data series resistor
SW1Tactile switchSMD 3x6mm1BOOTSEL (QSPI_SS to GND)
SW2Tactile switchSMD 3x6mm1Reset (RUN to GND)
F1500 mA polyfuse08051USB VBUS protection

RP2040 Architecture Overview



The RP2040 is the first microcontroller designed by Raspberry Pi. It packs two ARM Cortex-M0+ cores running at up to 133 MHz, 264 KB of on-chip SRAM (split into six banks), and a rich set of peripherals. What sets it apart from most microcontrollers is the Programmable I/O (PIO) subsystem: two PIO blocks, each containing four state machines that can execute small programs to implement custom I/O protocols entirely in hardware. PIO can generate precise timing for protocols like WS2812B LED control, VGA video output, or custom serial interfaces without using any CPU cycles.

The RP2040 has no internal flash memory. All code is stored on an external QSPI flash chip and is either executed in place (XIP) through a cache or copied to SRAM at boot. The chip’s boot ROM contains a UF2 bootloader: hold the BOOTSEL button while plugging in USB, and the board appears as a mass storage device. You drag and drop a .uf2 firmware file to program it. No special programmer or software is needed.

Native USB 1.1 is built into the RP2040, supporting both device and host modes. The USB PHY is internal, so the D+ and D- lines connect directly to the USB connector through series termination resistors. A 12 MHz crystal provides the reference clock for the USB PLL, which generates the 48 MHz USB clock internally.

Key RP2040 Features

FeatureDetail
Cores2x Cortex-M0+ at 133 MHz
SRAM264 KB (6 independent banks)
FlashNone (external QSPI required)
PIO2 blocks, 4 state machines each, 32 instructions per block
USBUSB 1.1 device/host, internal PHY
GPIO30 multi-function GPIO (all PIO-capable)
ADC4-channel 12-bit SAR ADC + internal temperature sensor
PWM16 channels (8 slices, 2 outputs each)
SPI2x SPI controllers
I2C2x I2C controllers
UART2x UART
DMA12-channel DMA controller

QFN Package Considerations



The RP2040 comes in a QFN-56 package measuring 7x7 mm with 0.4 mm pad pitch. QFN (Quad Flat No-lead) packages have no visible leads extending from the sides. Instead, the electrical connections are flat pads on the bottom of the package. This makes QFN packages compact and excellent for high-frequency performance (short bond wire lengths mean lower inductance), but it also means you cannot solder them with a standard soldering iron.

QFN Soldering Requirements

The QFN-56 has 56 perimeter pads plus a large exposed thermal/ground pad in the center. The exposed pad serves two critical functions: it provides the primary ground connection for the die, and it conducts heat away from the chip into the PCB. This pad must be soldered to the PCB ground plane.

What you need for QFN assembly:

  1. Solder paste stencil. Order a stainless steel stencil with your PCBs. The stencil has laser-cut openings that match every pad on the board. You squeegee solder paste across the stencil, and paste deposits only where the pads are. For the QFN exposed pad, the stencil opening is typically divided into a grid pattern (for example, 3x3 or 4x4 smaller rectangles) to prevent excess paste from causing the chip to float during reflow.

  2. Reflow soldering. After placing components on the pasted board, you reflow the entire assembly. Options include a hot air rework station (focused on the QFN area), a desktop reflow oven, or a modified toaster oven with a thermocouple and temperature controller. The reflow profile ramps to about 150 C for preheat, then peaks at 245 to 260 C for lead-free solder.

  3. Placement accuracy. With 0.4 mm pitch pads, alignment matters. Use fine-tip tweezers and a magnifying lamp or microscope. The QFN package has a pin 1 indicator dot. Align it with the pin 1 marking on the PCB silkscreen. The self-centering effect of molten solder during reflow helps correct minor misalignment, but you need to be within about 0.1 mm.

PCB Pad Design for QFN

The KiCad footprint for the RP2040 QFN-56 should follow these guidelines:

  • Perimeter pads: Extend pads 0.2 mm beyond the package edge so you can visually inspect solder fillets from above. The pad width matches the QFN pad width (typically 0.2 mm for 0.4 mm pitch), and the pad length extends inward to just past the package edge.
  • Exposed pad: The PCB pad matches the exposed pad dimensions on the datasheet (approximately 3.1 x 3.1 mm for the RP2040). Apply a paste mask with a grid pattern to control solder volume.
  • Thermal vias: Place an array of small vias (0.3 mm drill, 0.6 mm pad) within the exposed pad area, connecting it to the inner ground plane. A 3x3 or 4x4 grid works well. These vias transfer heat from the QFN ground pad into the internal copper layers. Tent or plug the vias from the bottom side to prevent solder wicking through during reflow.

Schematic Capture



The RP2040 minimal circuit requires careful attention to multiple power domains and specific pin configurations. This section walks through each subsystem.

Download Schematic PDF

Power Supply Design

The RP2040 has two voltage domains:

  • IOVDD (3.3V): Powers all GPIO and digital I/O. Six IOVDD pins, each needing a 100 nF decoupling capacitor placed within 2 mm of the pin.
  • DVDD (1.1V core): Powers the processor cores, SRAM, and internal logic. The RP2040 includes an internal voltage regulator that steps 3.3V (on VREG_VIN) down to 1.1V (on VREG_VOUT). This regulator requires an external 1 µH inductor and capacitors.

Power path:

USBVBUS(5V)PolyfuseNCP1117-3.3 LDO3.3V railIOVDD pinsVREG_VIN(6x 100nF)RP2040 internalregulator1µH inductorVREG_VOUTDVDD(100nF + 1µF)

LDO circuit (NCP1117-3.3):

  • Input: USB VBUS (5V) through polyfuse F1
  • Input capacitor: 10 µF ceramic on VIN
  • Output capacitor: 10 µF ceramic on VOUT
  • Output: 3.3V rail feeding IOVDD, VREG_VIN, flash VCC, WS2812B VDD

Core regulator external components:

  • VREG_VIN: connect to 3.3V with 1 µF decoupling
  • VREG_VOUT: connect through 1 µH inductor to DVDD, with 100 nF and 1 µF capacitors to ground
  • The inductor must be low DCR (under 0.5 Ω) to avoid excessive voltage drop

USB-C Connection

The RP2040 has a built-in USB PHY, so no external USB bridge chip is needed. The connections are straightforward:

USB-C PinConnection
VBUS5V rail through polyfuse F1
CC15.1 kΩ to GND (identifies as UFP/device)
CC25.1 kΩ to GND
D+27 Ω series resistor to RP2040 USB_DP (pin 47)
D-27 Ω series resistor to RP2040 USB_DM (pin 46)
GNDBoard ground

The 5.1 kΩ resistors on CC1 and CC2 tell the USB-C host that this board is a device requesting 5V default power. The 27 Ω series resistors on D+/D- provide impedance matching and ESD damping.

QSPI Flash Connection

The W25Q128JV connects to the RP2040’s dedicated QSPI pins. These are not regular GPIO; they are hardwired in the RP2040 for boot flash access.

Flash PinRP2040 PinFunction
CLKQSPI_SCLKClock
CS#QSPI_SSChip select (active low)
DI (IO0)QSPI_SD0Data in / IO0
DO (IO1)QSPI_SD1Data out / IO1
WP# (IO2)QSPI_SD2Write protect / IO2
HOLD# (IO3)QSPI_SD3Hold / IO3
VCC3.3VPower (100 nF + 4.7 µF decoupling)
GNDGNDGround

Add a 1 kΩ pull-up resistor on CS# to 3.3V to ensure the flash is deselected during power-up before the RP2040 takes control.

Crystal Oscillator

The 12 MHz crystal connects between XIN (pin 22) and XOUT (pin 23):

  • 15 pF load capacitors from each pin to ground
  • Crystal should be placed as close to the RP2040 as possible (within 5 mm)
  • Guard the crystal traces with a ground pour to prevent interference
  • No traces should run between the two crystal pads

BOOTSEL and Reset

BOOTSEL button: This is connected to QSPI_SS (the flash chip select line). When QSPI_SS is held LOW during power-up or reset, the RP2040’s boot ROM enters UF2 mass storage mode instead of booting from flash. The button shorts QSPI_SS to GND. During normal operation, the button press is ignored because the RP2040 drives QSPI_SS as an output.

Reset button: The RUN pin is the RP2040’s active-low reset. Connect a 10 kΩ pull-up to 3.3V and a tactile switch to GND. Pressing the button pulls RUN low, resetting both cores.

To enter UF2 bootloader mode: hold BOOTSEL, press and release reset, then release BOOTSEL.

SWD Debug Header

The RP2040 supports Serial Wire Debug on dedicated pins:

  • SWDIO (pin 24)
  • SWCLK (pin 25)
  • GND

A 1x3 pin header is sufficient for basic SWD. Some debug probes (Raspberry Pi Debug Probe, Picoprobe) also use a UART connection, so you may optionally add a second header for UART0 TX/RX.

WS2812B RGB LED

The WS2812B is an addressable RGB LED with a built-in driver. It requires a single data line:

  • VDD: 3.3V (the WS2812B works at 3.5 to 5.3V; 3.3V is below the official minimum, but most units work reliably at 3.3V; alternatively, power from VBUS at 5V)
  • DIN: Connect to a GPIO (for example, GPIO16) through a 330 Ω series resistor
  • DOUT: Leave unconnected (only one LED in the chain)
  • GND: Board ground
  • Place a 100 nF decoupling capacitor between VDD and GND, close to the LED

GPIO Headers and PIO Pin Labeling

Break out all 26 available GPIO pins on two 1x20 headers (matching the Raspberry Pi Pico pinout where practical). The headers also carry 3.3V, GND, VBUS, and ADC_VREF.

All 30 GPIO on the RP2040 are PIO-capable. On the silkscreen, label the ADC-capable pins (GPIO26, GPIO27, GPIO28, GPIO29) with “ADC” to help users identify analog inputs. Label the SPI, I2C, and UART default pin assignments as well.

Electrical Rules Check

Run ERC in KiCad after completing the schematic:

  1. Check power flags. Every power net (3.3V, 1.1V, VBUS, GND) must have a power flag symbol or be driven by a regulator output. The RP2040’s VREG_VOUT drives the 1.1V net, so mark it accordingly.

  2. Verify unconnected pins. The RP2040 has several pins that must be connected to specific nets. TESTEN (pin 20) must be tied to GND. USB_VDD (pin 48) must be connected to 3.3V with a 100 nF decoupling capacitor. All six IOVDD pins must connect to 3.3V.

  3. Check for missing decoupling. Each IOVDD pin pair and the DVDD pins should have associated 100 nF capacitors placed in the schematic.

  4. Assign footprints. Open the footprint assignment tool and verify every component has the correct footprint. Pay special attention to the RP2040 QFN-56 footprint (should match the 7x7mm, 0.4mm pitch dimensions) and the W25Q128JV SOIC-8 footprint.

PCB Layout: 4-Layer Design



Layer Stackup

Use the same stackup proven in Lesson 4:

LayerFunctionCopper Weight
F.Cu (Layer 1)Signal routing, component pads1 oz
In1.Cu (Layer 2)Ground plane (solid, unbroken)0.5 oz
In2.Cu (Layer 3)3.3V power plane0.5 oz
B.Cu (Layer 4)Signal routing, bottom components1 oz

The ground plane on Layer 2 provides a continuous return path for all signals on Layer 1. The 3.3V plane on Layer 3 distributes power to all components through short vias. The 1.1V core supply is a small local pour near the RP2040, not a full-board plane.

QFN Pad Layout and Thermal Vias

Place the RP2040 near the center of the board, rotated so that the QSPI pins face the flash chip location and the USB pins face the board edge where the USB-C connector sits. The QFN exposed pad connects to GND through the PCB. Under this pad, create an array of thermal vias (3x3 or 4x4 grid, 0.3 mm drill) connecting F.Cu directly to the In1.Cu ground plane. In KiCad, you can add these vias inside the exposed pad copper zone. Set the via annular ring to 0.15 mm minimum to comply with standard fabrication rules.

On the solder paste layer, divide the exposed pad into a grid of smaller rectangles (for example, 9 rectangles in a 3x3 pattern) with gaps between them. This prevents too much solder paste from pooling under the chip, which could cause the RP2040 to float off the perimeter pads during reflow.

QSPI Flash Routing

The QSPI interface runs at up to 133 MHz (the W25Q128JV maximum). At these frequencies, trace length and matching matter.

QSPI routing rules:

RuleTarget
Maximum trace length (any QSPI signal)25 mm
Length matching (all 6 signals within)5 mm of each other
Routing layerSingle layer preferred (F.Cu), avoid vias
Trace width0.15 to 0.2 mm (standard signal)
Spacing from other signalsAt least 0.2 mm (2x trace width)
Series termination (optional)33 Ω on CLK and IO0-IO3
  1. Place the flash chip close to the RP2040. Position the W25Q128JV within 10 mm of the RP2040 QSPI pins, on the same side of the board. Shorter traces mean better signal integrity and easier length matching.

  2. Route all six QSPI signals on F.Cu. Avoid layer transitions (vias) on the QSPI bus. Each via adds approximately 0.5 nH of inductance and breaks the return path on the ground plane. Keep all six traces (CLK, CS, IO0 through IO3) on the top layer.

  3. Match trace lengths. In KiCad, use the interactive router’s length tuning tool. Select all six QSPI nets, set a target length (for example, 15 mm), and add serpentine meanders to shorter traces until all six are within 5 mm of the longest. The CLK trace is the most critical reference, so match data traces to the CLK length.

  4. Add series termination resistors (optional). Place 33 Ω resistors in series with CLK and each data line, located close to the RP2040 pins (within 3 mm). These damp reflections and clean up signal edges. They are optional at lower clock speeds but recommended if you plan to run the flash at maximum speed.

  5. Ground guard. Ensure a solid ground pour surrounds the QSPI traces on F.Cu, and the ground plane on In1.Cu is unbroken beneath the entire QSPI routing area.

USB Differential Pair Routing

The USB D+/D- pair requires 90 Ω differential impedance, the same technique covered in Lesson 4:

  • Route as a tightly coupled differential pair on F.Cu
  • Keep the pair on one layer (no vias)
  • Maintain continuous ground plane on In1.Cu beneath the traces
  • Trace width and spacing depend on your stackup geometry (use the KiCad impedance calculator or your fab’s stackup tool; typically ~0.2 mm trace width with ~0.15 mm gap for 90 Ω differential on a standard 4-layer 1.6 mm board)
  • Length match D+ and D- within 0.15 mm
  • Keep the total USB trace length under 50 mm
  • Place the 27 Ω series resistors at the RP2040 end, within 5 mm of the MCU pads

Crystal Routing

The 12 MHz crystal should be placed within 5 mm of the XIN/XOUT pins:

  • Route XIN and XOUT traces as short as possible (under 5 mm each)
  • Do not route any other signal between the crystal pads
  • Surround the crystal traces with a ground pour on F.Cu
  • Ensure the ground plane on In1.Cu is solid beneath the crystal area
  • Use 0.2 mm or wider traces for the crystal connections

Decoupling Capacitor Placement

Every power pin on the RP2040 needs a decoupling capacitor placed within 2 mm of the pin. The RP2040 has six IOVDD/IOVSS pin pairs and two DVDD/DVSS pin pairs. Place a 100 nF 0402 capacitor next to each pair. The via from the capacitor pad to the ground plane should be as short as possible (ideally directly adjacent to the pad).

For the core voltage regulator, place the 1 µH inductor and its associated capacitors (1 µF on VREG_VIN, 100 nF + 1 µF on VREG_VOUT) within 5 mm of the VREG pins. The inductor, capacitors, and RP2040 VREG pins form a tight loop. Keep this loop area small to minimize radiated EMI from the switching regulator.

The USB_VDD pin (pin 48) powers the internal USB PHY. Place a 100 nF capacitor directly at this pin with a short via to the ground plane.

Via Stitching and Ground Pour

Complete the layout with:

  • Via stitching around the board perimeter and between ground pour islands (every 3 to 5 mm)
  • Ground pour on both F.Cu and B.Cu connected to the In1.Cu ground plane
  • Via stitching around the USB differential pair (ground vias on both sides, spaced every 2 to 3 mm)
  • Via stitching near the crystal area
  • Check for isolated copper islands in the ground pour and either connect or remove them

Manufacturing



JLCPCB 4-Layer Order Settings

When ordering from JLCPCB (or a similar prototype fab), use these settings as a reference:

SettingValue
Layers4
PCB thickness1.6 mm
Copper weight (outer)1 oz
Copper weight (inner)0.5 oz
Surface finishHASL or ENIG
Solder maskGreen (or your preference)
SilkscreenWhite
Min trace/space0.15 mm / 0.15 mm
Min via drill0.3 mm
Impedance controlOptional (select if available; specify 90 Ω differential for USB)

Cost note: 4-layer PCBs from JLCPCB typically start around 15 for 5 boards (50 x 22 mm). ENIG surface finish adds 10 but gives flatter pads for QFN soldering. Impedance control adds cost but guarantees the fab matches your stackup for USB traces.

Stencil Order

Order a solder paste stencil with your PCBs. Select the top-side stencil (you will hand-place components on one side at a time). Framework stencils (with a metal frame) are easier to align but cost more. Frameless stencils work fine with a simple jig made from spare PCBs taped to a flat surface.

Assembly and Reflow



Assembling a QFN board differs significantly from the through-hole and basic SMD boards in earlier lessons. You cannot hand-solder the RP2040 with an iron because the pads are underneath the package. The entire board must go through a reflow process. Here is the step-by-step procedure.

  1. Prepare the stencil jig. Tape three spare PCBs (or scrap material of the same thickness) to a flat surface, forming a pocket that holds your target PCB in place. The target PCB should sit flush, with no movement when you press down. Secure the stencil over the PCB so the stencil openings align with all the pads.

  2. Apply solder paste. Place a bead of solder paste along one edge of the stencil. Using a metal squeegee (or an old credit card), draw the paste across the stencil in a single smooth stroke at a 45-degree angle. Lift the stencil carefully. Inspect the paste deposits under magnification. Each pad should have a clean, consistent deposit. The QFN exposed pad should show a grid of paste rectangles, not one solid blob.

  3. Place the RP2040. Using fine tweezers, orient the QFN so the pin 1 dot aligns with the pin 1 marker on the silkscreen. Lower the chip gently onto the paste. Do not press hard. The paste is tacky enough to hold the chip in place. Verify alignment under magnification.

  4. Place the flash chip. The W25Q128JV in SOIC-8 is easier to place. Align pin 1 (marked with a dot) and set it onto the paste deposits.

  5. Place remaining SMD components. Work from smallest to largest: 0402 resistors and capacitors first, then the SOT-223 LDO, the crystal, the WS2812B LED, the tactile switches, and the polyfuse. Use tweezers for all placements.

  6. Reflow. Place the populated board in a reflow oven or position a hot air station above it. Follow a standard lead-free reflow profile: ramp to 150 C over 60 to 90 seconds (preheat/soak), then ramp to a peak of 245 to 260 C for 30 to 60 seconds, then cool. Watch for the solder paste to melt and become shiny. Remove heat and let the board cool naturally. Do not blow compressed air on it (thermal shock can crack components).

  7. Solder through-hole headers. After reflow, flip the board and solder the 2x20 GPIO headers and the SWD header with a standard soldering iron.

  8. Inspect QFN solder joints. You cannot see the QFN pads from above. Instead, inspect the perimeter pads from the side. You should see small solder fillets where the pad meets the QFN package edge. Check for solder bridges between adjacent pads (0.4 mm pitch is tight). If you find bridges, use solder wick and flux to remove them. For the exposed pad, check continuity between the QFN ground and the PCB ground plane.



Entering UF2 Bootloader Mode

The RP2040 has a UF2 bootloader in ROM. No special software is needed to flash firmware:

  1. Hold the BOOTSEL button.

  2. Connect the USB-C cable to a computer (or press reset while holding BOOTSEL if already connected).

  3. Release BOOTSEL. The board appears as a USB mass storage device named “RPI-RP2.”

  4. Drag and drop a .uf2 file onto the drive. The RP2040 flashes the firmware and reboots automatically.

CircuitPython or MicroPython

The fastest way to test the board is with CircuitPython or MicroPython:

Download the CircuitPython UF2 for “Raspberry Pi Pico” from circuitpython.org. Drag the .uf2 file onto the RPI-RP2 drive. The board reboots and appears as a “CIRCUITPY” drive.

Create a file named code.py on the CIRCUITPY drive:

import board
import neopixel
import time
# WS2812B on GPIO16 (adjust to your pin)
pixel = neopixel.NeoPixel(board.GP16, 1, brightness=0.3)
while True:
pixel.fill((255, 0, 0)) # Red
time.sleep(0.5)
pixel.fill((0, 255, 0)) # Green
time.sleep(0.5)
pixel.fill((0, 0, 255)) # Blue
time.sleep(0.5)
pixel.fill((0, 0, 0)) # Off
time.sleep(0.5)

PIO Example: WS2812B LED Control

One of the most compelling features of the RP2040 is PIO. The WS2812B protocol requires precise timing (800 kHz with specific high/low durations for 0 and 1 bits) that is difficult to achieve reliably with GPIO bit-banging. PIO handles it in hardware.

Here is the PIO program (from the Pico SDK ws2812.pio):

; WS2812B PIO program
; Drives a WS2812B LED strip with 800kHz signal
.program ws2812
.side_set 1
.define public T1 2
.define public T2 5
.define public T3 3
.wrap_target
bitloop:
out x, 1 side 0 [T3 - 1] ; shift 1 bit, drive low
jmp !x do_zero side 1 [T1 - 1] ; if bit is 0, jump; drive high
do_one:
jmp bitloop side 1 [T2 - 1] ; bit is 1: stay high longer
do_zero:
nop side 0 [T2 - 1] ; bit is 0: drive low longer
.wrap

This program runs on one of the PIO state machines. It shifts out pixel data one bit at a time, generating the precise WS2812B timing entirely in hardware. The CPU just writes pixel color values to the PIO FIFO and moves on.

The PIO assembler (pioasm, included in the Pico SDK build) compiles .pio files into C headers that you include in your firmware. The state machine runs independently of both CPU cores, so LED updates happen with zero jitter even while the cores handle other tasks.

What You Have Learned



Lesson 7 Complete

KiCad skills:

  • Designed a QFN-56 footprint with exposed thermal pad and thermal via array
  • Routed high-speed QSPI traces with length matching within 5 mm tolerance
  • Implemented a 4-layer stackup with dedicated ground and power planes
  • Managed multiple power domains (5V USB, 3.3V I/O, 1.1V core) in a single design
  • Applied USB differential pair routing with impedance targeting
  • Used solder paste stencil layer modifications for QFN exposed pad

Electronics skills:

  • RP2040 minimal circuit design (external QSPI flash, crystal, dual voltage rails)
  • QFN package soldering process (stencil, paste, reflow)
  • QSPI flash memory interface and boot mechanism
  • USB-C connector wiring with CC pull-down resistors
  • WS2812B addressable LED interfacing
  • Core voltage regulator design with external inductor

Firmware skills:

  • UF2 bootloader workflow (BOOTSEL, drag-and-drop programming)
  • CircuitPython, MicroPython, and C/C++ SDK toolchain options
  • PIO state machine programming for the WS2812B protocol
  • Understanding of the RP2040 boot sequence (ROM bootloader, XIP from flash)

Comments

Loading comments...


© 2021-2026 SiliconWit®. All rights reserved.
Predict first

The RP2040 has no program memory inside. You assemble the board but forget to fit the flash memory chip, and you plug the board into a computer. What does the computer show?

Check yourself

Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.

1. On your layout the four flash data tracks are 12 mm longer than the clock track. The clock runs at 133 MHz, and a signal on this board takes about 6 ps to travel 1 mm. About what part of one clock period is the extra delay of the data?

2. Your board works. You load a new program, and it has a fault that stops it in the first millisecond, before it starts USB. The computer no longer sees the board, and you have no debug probe. How do you get the board back?

3. After reflow, the RP2040 sits slightly high and tilted. A meter shows that several pins along one edge have no connection to their pads. The oven reached 250 C and the paste on every other part melted well. Under a magnifier, the stencil has one single large opening over the exposed pad. What is the most likely cause?

RP2040flash six tracks carry every instruction short, equal, on one layer
one big openinga grid of openings edge pads in the airevery pad joined
See it: why the LED needs PIO

LED reads, from PIO
LED reads, from the loop
Wrong bits

Each bit is 1.25 µs: a 1 is high for 0.875 µs, a 0 for 0.25 µs, the timing of the lesson's PIO program at 8 million steps a second. The LED decides each bit by how long the line stays high, taken here as more or less than 0.55 µs. The loop on the processor makes the same pulses until an interrupt stops it in the fifth bit. A longer low does no harm until it reaches the LED's reset time, 50 µs or more.

Watch it build: the six QSPI tracks
RP2040 flash CLK 133 MHz: 7.5 ns per clock flash within 10 mm six tracks, F.Cu, no vias all within 5 mm of CLK 33 Ω at the pins GND round, In1 whole under
  1. At 133 MHz one clock lasts 7.5 ns. The flash is still far from the RP2040.
  2. The flash goes within 10 mm of the QSPI pins, on the same side of the board.
  3. Six tracks on F.Cu, no vias. CLK, IO0 and IO3 must go round the chip: CLK is longest, 14.3 mm.
  4. Bends on CS, IO1 and IO2 take them from 5.3 to 10.1 mm, within 5 mm of CLK.
  5. Optional 33 Ω resistors on CLK and IO0 to IO3, within 3 mm of the RP2040.
  6. Ground pour fills the space beside the tracks. In1.Cu stays whole under all six.
USB-C 5V NCP1117 3.3V RP2040 its pins run on 3.3V internal 1.1V regulator DVDD (core) W25Q128 flash chip 1 µF at its input, 1 µF at its output
RP2040 (QFN-56) W25Q128 (SOIC-8) QSPI_SS /CS QSPI_SCK CLK QSPI_SD0 DI/IO0 QSPI_SD1 DO/IO1 QSPI_SD2 /WP/IO2 QSPI_SD3 /HOLD/IO3 select and clock four data lines, both ways All 6 tracks: at most 25 mm, equal within 5 mm. All on the top layer, no vias. Flash chip within 10 mm of the RP2040.
The finished board in 3D, seen from above: a long green board with a row of 20 header holes along each long edge and three across the right end. At the left the USB-C socket, then the flash chip and the square RP2040 with small capacitors round it, the crystal, two buttons, the regulator with its large tab, and the square RGB LED.
The board you will make (55 × 22 mm, four layers), made in KiCad 10.
RP2040 QFN-56, 7 x 7 mm, pins 0.4 mm apart W25Q128JVS SOIC-8, 208 mil USB-C 16 pins NCP1117 SOT-223 WS2812B 5 x 5 mm 12 MHz 3.2 x 2.5 mm Button PTS810 0402 1.0 x 0.5 mm 5 mm. All drawn at the same scale, copper pads from the KiCad 10 footprints.
The parts at true scale. The RP2040's 56 contacts are 0.4 mm apart and under the package, round one centre pad: paste and hot air, or the factory. The WS2812B is the largest part on the top.
Coming here first?

This board uses skills taught on the earlier boards. Each one is here, at the part that teaches it:

Words used here, each with a five-minute page:

What the finished board changes, and why
  • The crystal is the Abracon ABM8-272-T3 that Raspberry Pi's design guide names: 12 MHz, CL 10 pF. With 15 pF on each side it sees 15 / 2 + 3 = 10.5 pF. R8, 1 kΩ in series with XOUT, keeps the crystal from being over-driven, as in the guide and on the Pico.
  • Both DVDD pins and ADC_AVDD have their own 100 nF (C10, C17 and C18): one capacitor per supply pin, as the guide asks.
  • The WS2812B runs from 5 V through a diode (D2, 1N4148W). That gives about 4.2 V: inside its 3.5 to 5.3 V range, and it reads a high on DIN above 0.7 × 4.2 = 2.9 V, which the 3.3 V of GPIO16 gives. No level shifter.
  • The 27 Ω resistors are R3 (D+) and R9 (D-); the table gives R3 twice. C19 is the LED's 100 nF.
  • The flash footprint is Package_SO:SOIC-8_5.3x5.3mm_P1.27mm in KiCad 10, the wide 208 mil SOIC-8. The name in the check list below does not exist in the library.
  • The USB tracks are 0.25 mm wide, 0.15 mm apart: about 90 Ω on this stack-up, worked out on the four-layer STM32 board.
  • Headers in the Pico's order. Pins 35 and 36 are 3.3 V (a Pico has ADC_VREF on 35), pin 37 (3V3_EN) is open: the NCP1117 has no enable. Pins 39 and 40 are 5 V after the fuse.
  • SW1 and SW2 are the C&K PTS810 (4.2 × 3.2 mm); buy the switch whose footprint you placed.

rp2040-devboard-bom.csv is the full list.

On the finished board the crystal's CL is 10 pF, so the 15 pF capacitors give it 10.5 pF: close to its value, and the clock runs at 12 MHz. The 1 kΩ resistor (R8) between XOUT and the crystal is part of Raspberry Pi's circuit. Change the crystal, and you must test the oscillator again.

The finished board takes the third way: VDD from 5 V through a 1N4148W. About 0.8 V is lost in the diode, so VDD is about 4.2 V and DIN needs 2.9 V: both inside the data sheet, with no level shifter.

Check it

The finished schematic, in KiCad 10.0.8: ERC 0 errors, 0 warnings. Nine titled boxes, joined by net labels. PWR_FLAG sits on VBUS, +5V, GND and the LED's supply: only passive pins feed them. VREG_VOUT drives +1V1, and the NCP1117 drives +3V3. GPIO23, 24, 25 and 29 are not on the headers: they carry no-connect flags.

The whole schematic on one A3 sheet in nine titled boxes joined by net labels: USB-C in with the CC resistors, the fuse and the 27 ohm resistors; the NCP1117; the 12 MHz crystal with its capacitors and 1 k resistor; the flash with BOOTSEL and reset; the RP2040; the decoupling capacitors; the RGB LED with its diode; SWD; and the two headers in the Pico's order.
The schematic as a PDF.
The board from above as its printed outlines show it: the header rows along both long edges and the SWD header across the right end; from the left the USB-C socket, the fuse and CC resistors, the flash chip below the USB pair, the RP2040 turned with its USB and flash pins to the left, the crystal at its right side, two buttons, the regulator and the RGB LED.
The finished placement: the RP2040 turned 90 degrees, its USB and QSPI pins facing the socket and the flash. Check: DRC reports no Courtyards overlap.

The footprint is QFN-56-1EP_7x7mm_P0.4mm_EP3.2x3.2mm_ThermalVias: its vias in the exposed pad have 0.2 mm holes. TESTEN (pin 19) joins the exposed pad by a short track.

On the finished board

The flash sits beside the chip's six QSPI pins, but its two rows of pins do not come in the chip's order. SD3, SCLK and SD0 reach its near row in the same order as on the chip, so they go on F.Cu with no via: 6.5, 7.4 and 8.3 mm. SD2, SD1 and CS reach its far row in the reverse order, and on one layer they would cross. Each drops through a via beside its pin, runs on B.Cu under the flash, and comes up through a second via inside the flash's outline: 13.6, 15.4 and 17.1 mm.

So two rules of the table are not met: three tracks have two vias each, and the longest data track is 8.0 mm longer than the clock, about 48 ps. At 133 MHz one clock period is 7,500 ps, so that is under 1% of it. Turning the flash does not help: the one-layer way round its far side passes the USB-C socket, which leaves room for one track.

On the finished board XOUT runs 2.7 mm, through R8 at the pin. XIN runs 6.4 mm, longer than the 5 mm asked here: R8 stands between the crystal and the chip, and the SWD tracks above and the GPIO tracks below take the room on either side. XIN reaches its pad between the crystal's other pads; no other signal passes there. One millimetre of track adds about 0.1 pF, so the whole of XIN adds about 0.6 pF, part of the 3 pF of stray capacitance in the load sum. Both tracks are 0.2 mm wide, with ground pour beside them and the whole In1.Cu plane under them.

On the finished board

The pins come first, the capacitors second. Between the chip's pads and its centre pad there are 1.4 mm: room for one via at every other pin. Every 3.3 V pin has its own via there, straight down to the 3.3 V plane (pins 42, 43 and 44 share one at the corner, 48 and 49 another). The three 1.1 V pins (VREG_VOUT 45, DVDD 50 and 23) have vias there too, joined on B.Cu by a ring round the centre pad and run out to their three capacitors at the chip's top left corner (C10, C11 and C17).

The 3.3 V capacitors sit where the tracks to the headers leave room, each with its own vias to both planes, 3 to 11 mm from their pins: more than the 2 mm asked above. The two planes, 0.2 mm apart under the whole board, carry the current between pin and capacitor. That is the price of putting every part on one side of a board this narrow; with parts on both sides, the capacitors go under the chip.

Check it: the four copper layers
Layer 1, the top copper: the USB pair from the socket through the two resistors to the chip, the chip's pins fanned out into nested lanes that run to both header rows, three short flash tracks, and ground pour in the spaces.
F.Cu, layer 1
Layer 2: one whole sheet of ground copper with small round holes where vias of other nets pass.
In1.Cu, layer 2: the GND plane
Layer 3: one whole sheet of 3.3 V copper with small round holes where the other vias pass.
In2.Cu, layer 3: the 3.3 V plane
Layer 4, the bottom copper seen from above: the 5 V track along the top edge, long tracks along the middle to the SWD header and the bottom row, the three flash tracks that pass under the others, and ground pour.
B.Cu, layer 4, seen from above

DRC in KiCad 10.0.8, with schematic parity and every severity: 0 errors, 0 unconnected items, 0 parity issues, and 2 warnings (2 silkscreen clipped by board edge: the USB-C socket's outline reaches past the edge, where its mouth stands; the factory trims it).

The USB pair runs on F.Cu from the socket through R9 and R3 to USB_DM and USB_DP, with no via: D- 13.87 mm, D+ 13.84 mm, 0.03 mm apart in length (the rule: 0.15 mm), the resistors within 2 mm of the chip. The six QSPI tracks, pin to pin: 6.5 to 17.1 mm (the rule: at most 25 mm), 6 vias among them. 140 vias in all: 23 to the 3.3 V plane, 77 to ground.

Ours, to compare
  • rp2040-devboard-gerbers.zip: 11 .gbr files, -NPTH.drl, -PTH.drl and a .gbrjob, four of them copper (-F_Cu, -In1_Cu, -In2_Cu, -B_Cu).
  • rp2040-devboard-bom-jlcpcb.csv, columns Comment, Designator, Footprint, LCSC. The LCSC column is empty: choose each part on the order page and check its stock.
  • rp2040-devboard-cpl-jlcpcb.csv, from the bottom left corner. U1 is at 24.00, 11.00 mm, rotation 90.
  • The vias are 0.45 mm with a 0.2 mm hole, as in the RP2040 footprint's pad. JLCPCB charges more for a 0.2 mm hole only when the via is under 0.45 mm across, so this is the smallest via at the standard price. Give the order form the smallest hole of your own drill file, not the table's 0.3 mm.
The finished board from below in 3D: ground pour over most of the back, the header and SWD holes, the vias and the text siliconwit.com.
Check it. From below: the ground pour, joined to the plane by its vias.
Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.