Repository navigation
feat(deploy): retry a failed RP-series USB deploy over SWD when a probe is attached (#1423) - #1821
Merged
Merged
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the fallback-order half of #1423. #1820 shipped
--transport swd(theonly path that reaches a board presenting no USB endpoint at all); this makes a
normal
fbuild deployuse it automatically — USB transports first, SWD onlyafter they fail, and only when a debug probe is attached.
How
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 newdependency (the existing
serialportscan), platform-agnostic — the samepredicate 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::deployis now a dispatcher.Swdkeeps its earlyreturn;
Picotool/Uf2rundeploy_via_usb, which is the verbatimexisting body (moved, not rewritten — that is why the diff looks large).
Only an
Errfrom it is retried.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/.uf2has no load address, so falling back would trade a USB errorfor an artifact error).
(recovered over SWD after the USB transport failed; the target did not enumerate)and appends the original USB error tostderr; a failed retryreports both errors, USB first.
--transporthelp and the daemon'stransportfield say the USBtransports retry over SWD.
Tests (real output)
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:
LOC: no new files;
probe_rs.rs675 → 771 (still < 1000), the other touchedfiles 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_swdpath #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.