Skip to content

feat(rp): add SWD/probe-rs deploy transport so a non-enumerating RP board is still flashable #1423

Closed

Description

@zackees

Problem

Both RP deploy transports require a live USB endpoint on the target:

--transport <TRANSPORT>  RP2040 deploy transport: `picotool` (default, PICOBOOT-primary)
                         or `uf2` (mass-storage primary, historical order)

picotool needs the PICOBOOT vendor interface; uf2 needs the BOOTSEL mass-storage volume. A board whose firmware wedges before or during USB bring-up presents neither. There is no endpoint to talk to, so fbuild deploy cannot reach it at all.

This is not recoverable from the host. FastLED#3714 worked the problem end to end on a Windows bench and exhausted every software path — elevated pnputil /restart-device, Disable-PnpDevice/Enable-PnpDevice with 3 s and 10 s windows, pnputil /scan-devices, 1200-baud touch, picotool reboot -f -u. The decisive constraint: a root-hub port restart is a USB bus reset, not a VBUS power cycle. Desktop root hubs never cut VBUS, so a wedged RP never re-runs its ROM bootloader. Recovery currently requires a physical action — BOOTSEL-hold power cycle, cable swap, or an SWD probe.

That makes unattended RP bring-up impossible to guarantee: one bad flash strands the board until a human walks over.

Why this is worth doing here

fbuild already has the plumbing. The LPC probe-rs work shipped (#1000, #935), including the fork that replaced hidapi with nusb for CMSIS-DAP v1 HID transport (#936). An RP SWD backend is a new target for existing infrastructure, not a new capability from scratch.

SWD is also the only path that can answer why a sketch bricks USB — halt the core and get a backtrace, instead of inferring from the outside.

Proposal

Add an SWD deploy backend for RP2040/RP2350 via probe-rs, selectable as a third transport:

fbuild deploy -e rp2040 --transport swd
  • Target a CMSIS-DAP probe (Raspberry Pi Debug Probe, ~$12, already supported by the existing CMSIS-DAP transport).
  • Chip targets RP2040 and RP2350 are both in probe-rs's built-in target registry.
  • Flash + verify + reset with zero dependence on the target's USB.
  • Reasonable fallback order when a probe is present: try USB transports first (they need no extra hardware), fall back to SWD when the target does not enumerate — so a wedged board self-heals on the next deploy instead of blocking.

Scope notes

  • Probe presence should be detected, not assumed; absent a probe, behavior is unchanged.
  • This is complementary to, not a replacement for, the device-side escape in FastLED#4167 (after N consecutive watchdog resets the board reboots into the bootloader). That handles firmware that still runs; SWD handles firmware that does not.
  • The other half of unattended recovery is a per-port-power-switching hub (uhubctl -a cycle) for a true VBUS cycle. That is bench hardware, out of scope for fbuild, and tracked in FastLED#3714.

Context

  • FastLED#3713 — RP2040 board fails USB enumeration, recover & flash with no intervention
  • FastLED#3714 — bench host setup for unattended deploy & recovery; item C is this exact suggestion ("an rp2040 probe-rs backend in fbuild deploy, like the existing LPC probe-rs path, would fold this into the standard flow — candidate for a FastLED/fbuild issue")
  • FastLED#4167 — device-side boot-loop escape to the bootloader

Filed from an unattended FastLED bench run where the RP2350 is not enumerating and therefore cannot be reached by any current transport.

Generated with Claude Code

https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

Activity

  1. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Opened #1820 for the transport itself: fbuild deploy --transport swd now flashes the build's ELF through a CMSIS-DAP probe with the existing probe-rs path (probe-rs download --chip RP2040|RP2350 + reset), before any BOOTSEL/runtime-USB preparation. --port is ignored (probe-rs selects the probe) and reported as such; a missing probe fails with probe-rs's own diagnostics instead of falling back to a transport that also needs USB.

    Unit/argv level is covered (transport parsing, family→chip, ELF-vs-UF2 artifact choice, missing-load-address error) and the crate gates are green. Not hardware-verified: this host has no RP board and no CMSIS-DAP probe attached, so the wire-level flash is unproven past that boundary.

    Still open from this issue's proposal: the automatic fallback order (try USB transports first, retry over SWD when the target does not enumerate). #1820 deliberately ships only the explicit transport; the retry policy is a separate change.

  2. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Fallback-order half is now in review: #1821.

    What it adds on top of #1820's explicit --transport swd:

    • probe_rs::debug_probe_attached() — registry-driven probe detection
      (purpose: probe OR role: debug_probe over the FastLED/boards profiles,
      via the existing serialport enumeration; no VID/PID literals). Absent a
      probe, behavior is byte-for-byte unchanged, as the issue asks.
    • Rp2040Deployer::deploy dispatches: USB transports first (the existing body,
      moved verbatim into deploy_via_usb), and only a failed USB deploy is
      retried over SWD when a probe is attached and the build has an ELF/HEX.
    • Pure should_fall_back_to_swd(transport, probe_attached, artifact_available)
      with a table test; a recovered deploy keeps the USB error in stderr, a
      failed retry reports both.

    Gates: bash test 4093p/0f, workspace clippy -D warnings rc0, dylint
    fbuild-deploy rc0, boundary 44/43.

    Still unproven: no RP board and no CMSIS-DAP probe on this host, so the retry
    is verified at decision level only. Closing this needs one bench run with a
    probe — the per-port-power-switching hub half stays FastLED#3714 as the issue
    says.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions