rp2x PIO: a test plan
On #5126, @bradjc noted there was no clear testing or bring-up strategy for the rp2x PIO driver. This is that plan, in three tiers.
Tier 1 is done and is #5157. The ask is tier 2: six specific tests, each of which needs a Pico to run and any one of which is a complete contribution on its own. Tier 3 is named only so it is clear I am not asking for it.
Tier 1 - host unit tests. Done, in #5157.
19 #[cfg(test)] tests in chips/rp2040/src/pio.rs, run by the existing
ci-job-chips on every PR. No new infrastructure, no new dependency, no new
CI job. Writing them turned up five latent defects, which #5157 also fixes.
The limit of that tier is precise. The tests were reviewed by deliberately corrupting the file; what got through is behaviour a host test cannot see because it needs hardware.
Tier 2 - on hardware, in the tree. This is the ask.
Each wrong behaviour in the table below is specific to hardware and names a test worth having:
| Wrong behaviour that survives host tests | What a hardware test would check |
|---|---|
set_irq_source ignores its enabled argument |
disabling a source actually stops the interrupt |
set_irq_source always uses line 0 |
enabling on line 1 reaches PIO0_IRQ_1 |
handle_interrupt sends a TX flag to the RX handler |
a TXNFULL interrupt wakes the TX client |
add_program hands add_program16 the whole staging buffer |
a short program loads only its own instructions |
| the block's IRQ flags are never cleared | the flag is cleared after dispatch |
the flags are cleared with modify |
clearing flag 0 does not clear flags 1-7 |
Shape, and how small it is. chips/rp2040/src/test/pio.rs, in the shape
of the existing chips/rp2040/src/test/pwm.rs (76 lines), called from a
board's main.rs. That idiom already exists in this crate, so tier 2 needs no
new infrastructure either. The rows are independent: writing one and stopping
is useful, and nobody needs to take the whole table.
One more gap worth closing while there. There is no PIO assembler anywhere
in the tree - grep -riE "pioasm|assembl|fn encode" chips/rp2040/ finds only
comments. Programs are hex arrays pasted from an external tool (pio_spi.rs
names the Pico SDK and wokwi.com/tools/pioasm), with the mnemonics living
only in comments beside them. Nothing checks that the hex matches the comment.
Tier 3 - Treadmill. A dependency, not a promise.
Naming it rather than proposing it, because it is much larger than the rest: a second repository, and hardware physically hosted somewhere.
Why it is larger, if usefultock/tock-hardware-ciis a separate repository;tock/tock'streadmill-ci.ymlonly calls into it.- The existing Treadmill CI job skips pull requests (
treadmill-ci.yml:79) because fork PRs cannot reach the API secrets. tock-hardware-ci/boards/currently has four files:__init__.py,mock_board.py,nrf52dk.py, andtockloader_board.py. No Pico, no rp2350.Nrf52dk.flash_kernel()runsmake flash-openocd(which also works for a Pico).TockloaderBoard.flash_app()runstockloader, which a Pico 2 has no route for (apps go inside the kernel ELF's.appssection).BoardHarnesssits beneathTockloaderBoard, so a non-tockloader board looks anticipated.- Hardware needs to be physically hosted somewhere.
Who can do what
I do not have an RP2040 board, so I cannot write tier 2 against RP2040 hardware. Tier 2 on RP2350 becomes possible for me once #5141 lands.
The most useful single thing anyone with a Pico could do is exercise the gSPI path on a Pico W, since that is the only in-tree PIO user.
AI disclosure
Per Tock's AI policy: this issue was drafted by Claude Opus 5 via Claude Code on 2026-09-04, and subsequently revised with AI assistance verifying claims against the repositories. The table of hardware-testable behaviours came from a deliberate corruption run of the host tests; all other factual claims (file paths, CI details, repository contents) were derived from the repositories rather than recalled, and I have checked them.
Source: tock/tock