Skip to content

RP CDC recovery can select the wrong board when two identical RP2xxx boards are attached #3998

Closed

Description

@zackees

Problem

In _run_discovery_phase (ci/autoresearch/phases.py), when fbuild deploy returns no application port, AutoResearch falls back to polling by USB identity:

result = await asyncio.to_thread(
    auto_detect_upload_port,
    expected_environment=rp2xxx_environment,
)

auto_detect_upload_port filters by environment only — which resolves to a VID:PID. Two identical boards (two Pico 2 Ws, say) present the same identity, so the filter cannot separate them and the first matching CDC endpoint wins.

If that is the other board, the run proceeds against hardware it did not flash. The failure is quiet: the port opens, RPC responds, and results are attributed to the wrong device.

Why now

The fallback exists because RP boards enumerate as BOOTSEL mass-storage before deploy and only publish their application CDC endpoint afterwards, so there is no stable pre-deploy port to hold onto.

#3977 widens this path from rpc-smoke/watchdog-soak to every RP run mode. That is correct — the same reasoning applies to driver modes — but it does make the ambiguity reachable in many more runs. The ambiguity itself is pre-existing and inherent to identity-only matching, not introduced by that PR.

Why it is not simply "match harder"

Serial number would disambiguate, but it is not stable across the BOOTSEL → application transition on every RP variant, which is why the code matches on identity in the first place. Any fix has to carry a board handle through deployment rather than re-derive it afterwards.

Options, roughly in order of soundness:

  1. Have fbuild return the port it deployed to, and treat a missing port as a hard error rather than something to recover from. fbuild knows which physical device it flashed; the recovery only exists because that information is sometimes absent. Best fix, needs fbuild work.
  2. Snapshot the CDC endpoints before deploy and require the recovery to select an endpoint that was not present beforehand. Distinguishes the freshly-enumerated board from an already-attached twin, using only host-side information.
  3. Fail closed on ambiguity — if more than one endpoint matches the identity, error out and require --upload-port. Cheapest, and strictly better than silently guessing.

(3) is a small change worth doing regardless of whether (1) or (2) lands, since it converts a silent wrong-board run into an actionable message.

Reproducing

Attach two identical RP2xxx boards, run any RP AutoResearch mode, and force fbuild deploy to return no port. Expect: the run targets whichever endpoint enumerates first.

Related

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