Skip to content

feat(deploy): retry a failed RP-series USB deploy over SWD when a probe is attached (#1423) - #1821

Merged
zackees merged 1 commit into
mainfrom
agent/rp-swd-auto-fallback
Oct 31, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/rp-swd-auto-fallback

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

What

Closes the fallback-order half of #1423. #1820 shipped --transport swd (the
only path that reaches a board presenting no USB endpoint at all); this makes a
normal fbuild deploy use it automatically — USB transports first, SWD only
after they fail, and only when a debug probe is attached
.

How

  • Probe presence is detected, not assumed.
    fbuild_deploy::probe_rs::{attached_debug_probes, debug_probe_attached}
    enumerate USB ports and ask the FastLED/boards registry
    (profiles_for(vid, pid)) whether any profile is a probe
    (purpose == probe || role == debug_probe). No VID/PID literals, no new
    dependency (the existing serialport scan), platform-agnostic — the same
    predicate the serial layer already uses to classify probes ahead of
    usb_uart_bridge (CH32V003 hardware bring-up: validate the existing CH32V pipeline on real silicon #1208).
  • Rp2040Deployer::deploy is now a dispatcher. Swd keeps its early
    return; Picotool/Uf2 run deploy_via_usb, which is the verbatim
    existing body
    (moved, not rewritten — that is why the diff looks large).
    Only an Err from it is retried.
  • The retry policy is one pure function,
    should_fall_back_to_swd(transport, probe_attached, swd_artifact_available),
    and all three conditions are required: not already SWD, probe attached, and
    an image probe-rs can place (co-located .elf / Intel HEX — a bare
    .bin/.uf2 has no load address, so falling back would trade a USB error
    for an artifact error).
  • No error is swallowed. A recovered deploy returns its message with
    (recovered over SWD after the USB transport failed; the target did not enumerate) and appends the original USB error to stderr; a failed retry
    reports both errors, USB first.
  • Docs: --transport help and the daemon's transport field say the USB
    transports retry over SWD.

Tests (real output)

soldr cargo test -p fbuild-deploy --lib
test result: ok. 320 passed; 0 failed; 13 ignored; 0 measured; 0 filtered out

New: a_failed_usb_deploy_falls_back_to_swd_only_with_a_probe_and_a_placeable_image
(table: probe×artifact×transport, plus "already SWD has nothing to fall back
from") and any_probe_purpose_or_debug_probe_role_counts_as_a_probe.

Full gates, all run locally on this branch:

bash test                     4093 passed / 0 failed, rc 0   (TMPDIR=/home/niteris/t)
soldr cargo fmt --check       rc 0
soldr cargo clippy --workspace --all-targets -- -D warnings   rc 0
soldr dylint --all -- --package fbuild-deploy --all-targets   rc 0
ci/enforce_platform_boundary.py --print-totals                rows=44; dylint_rows=43
ci/check_test_layout.py                                       ok

LOC: no new files; probe_rs.rs 675 → 771 (still < 1000), the other touched
files were already over the cap on main.

Not verified

No RP2040/RP2350 board and no CMSIS-DAP probe are attached to this host
(only ESP32 USB-JTAG + CH340), so the retry is proven at decision level only,
and the "no probe → error unchanged" path is the only one this host can even
enter. The wire-level flash is the same deploy_via_swd path #1820 shipped.

Note that the probe predicate is registry-wide, not RP-specific: an attached
LPC-Link2 also counts, so a failing RP deploy on such a host would attempt SWD
and report a combined error. That is intentional (the registry has no
RP-specific probe family yet) and strictly better than today's bare USB error.

Closes #1423 once a bench with a probe confirms the retry end to end.

…be is attached

#1423's remaining half: the fallback order. `--transport swd` (main, #1820)
can reach a wedged board, but only if the operator knows to ask for it. A
board that wedges before USB bring-up now self-heals on the next plain
`fbuild deploy`, provided a CMSIS-DAP probe is wired to the debug header.

- `probe_rs::debug_probe_attached()` / `attached_debug_probes()` detect probe
  presence from the FastLED/boards registry (`purpose: probe` OR
  `role: debug_probe`), not from a built-in VID/PID table, so it is
  platform-agnostic and reuses the existing `serialport` enumeration. Absent a
  probe nothing changes.
- `Rp2040Deployer::deploy` is now a thin dispatcher: `Swd` still goes straight
  to probe-rs; `Picotool`/`Uf2` run the untouched USB path
  (`deploy_via_usb`), and only a *failed* USB deploy with a probe attached and
  a placeable image (co-located ELF or Intel HEX) is retried over SWD.
- A successful fallback returns its message with the recovery note and the
  original USB error appended to stderr; a failed one reports both errors, so
  the USB diagnosis is never swallowed.
- Pure `should_fall_back_to_swd(transport, probe_attached, artifact_ok)`
  carries the whole policy and is table-tested.

Not verified: no RP2040/RP2350 board and no CMSIS-DAP probe on this host, so
the retry is proven at unit/decision level only. The wire-level SWD flash is
the same code path #1820 shipped.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 56a514c Oct 31, 2026
29 checks passed
@zackees
zackees deleted the agent/rp-swd-auto-fallback branch October 31, 2026 13:48
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

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

1 participant