Repository navigation
usb: schedule the T8140 proxy carrier with a delay it accepts - #438
RyanTheTide wants to merge 3 commits into
Conversation
usb_init() on the T8140 schedules the deferred CDC carrier transition for a stage that is about to run the proxy, with a delay of 0. usb_cdc_state_schedule() takes 1 to 15 s and refuses anything else, so the schedule always failed: the proxy got no CDC carrier, and usb_cdc_schedule() never armed the CDC watchdog that resets a proxy no host opens. A stage with no watchdog of its own (any Stage 2, or a Stage 1 without the boot watchdog) then stays in the proxy until someone holds the power button. Schedule it with the shortest delay the state machine accepts, as the Stage 1 window already does. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide
left a comment
There was a problem hiding this comment.
No blockers in the code. The fix is correct and small. Before merge it needs the J700 run that the PR already lists under "Still to run". Unit tests alone don't show that the carrier comes up and the watchdog fires on the hardware.
What I checked: usb_init() against usb_cdc_state_schedule() (accepts 1000 to 15000 ms), usb_cdc_schedule() (arms the 170 s watchdog only on an accepted schedule), the callers (main.c:312 no-payload fallback, kboot.c skips usb_init() on this SoC, uartproxy.c:98 Stage 1 window), and how the poll loop picks the schedule up in uartproxy_run(). After this change the fallback proxy gets its carrier about 1 s in, through the same call the Stage 1 window already makes. With the window, the second schedule is skipped or refused without harm: by the time the window ends the state is READY or FAILED and the carrier is owned.
-
src/usb.c:558, chip gate. This PR doesn't add the
chip_id == T8140check; the PR body says so, and that's right. The same check now decides "needs a deferred carrier transition" in six places: usb.c:558, usb_cdc.c:78 and :144, uartproxy.c:97, kboot.c and main.c:223 and :311. Follow-up, not for this PR: replace them with one predicate, like the existingusb_cdc_deferred_usb2(), that reads the DFU port's PHY or controller node in the ADT. That way the next SoC with this PHY gets the carrier and watchdog without a new gate. Fallback: today's behaviour when the property is missing. -
src/usb.c:560, the 1000. This is not a tuned delay. It's the floor of the validator's range, and the host-facing P_CDC_SCHEDULE needs a range so its reply goes out before the carrier changes. The local fallback has no requester, so the real intent is "as soon as allowed". The bug was a caller that drifted from the validator's literal range. A literal 1000 in usb.c and uartproxy.c:98 can drift the same way. Suggest a
USB_CDC_SCHEDULE_MIN_MS(and MAX) in usb_cdc_state.h, used byusb_cdc_state_schedule(), proxy.c:507 and both callers. The test could then assert against the constant instead of parsing usb.c with a regex, which breaks on any reformat of that line. Not blocking. -
Out of scope, but on the path this PR enables: usb_cdc.c:123
mdelay(1000)after the HPM cold reset is a fixed settle wait. Please follow up with a bounded poll on the port controller's ready/mode state. -
Behaviour change worth stating in the commit message: with no payload and a non-enforcing policy, a T8140 Mac now resets about 170 s after the proxy comes up. Before, it stayed in the proxy. That matches what the Stage 1 boot watchdog already does, so it's fine. The panel text at main.c:288-290 only promises a restart when
wdt_boot_watchdog_armed(), so a Stage 2 on this SoC now restarts without saying so. Optional: print the same "restarts by itself" line when the CDC watchdog armed. Note also thatwdt_arm()restarts the counter, so this replaces a running 178 s boot watchdog with a fresh 170 s one. That's harmless.
Other chips: no change. The branch is T8140-only, and usb_cdc_schedule() refuses every non-T8140, non-USB2 target anyway. Production reach: this is not a lab-only path. It sits in the shipped Stage 1/Stage 2 no-payload fallback (#ifndef BRINGUP). It is reachable only when secboot_host_proxy_allowed() is true, so enforcing builds take the 10 s reboot instead. It never runs on a boot that hands off to an OS.
Evidence: unit tests and a build only. The 6-hour hang is linked to this path but, as the PR says, not proven. Hardware row: on J700 (A18 Pro), configure a dev Stage 2 whose payload is missing (not through aura-try, which reboots earlier since #436). Pass: no "usb: unable to schedule proxy transport", "CDC Gen1 ready; awaiting host" shows, the Mac resets about 170 s later and boots the configured path again; 3/3 runs. With a CDC host attached: "CDC primary open; watchdog disabled" and a proxy round-trip works; 3/3. Control on one non-T8140 Mac (M2 or M1 Pro): the same missing-payload fallback still brings up the normal USB proxy, unchanged.
Assisted-by: LLM (Claude:Opus 5.5)
|
Thanks. On the points:
The hardware row is as you describe; our Neo has no remote reset, so it waits for someone at the Mac, or a J700 with a CDC host. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed at 0838346907232e2e2905cc3f42ef968696406410 against the pre-PR checklist. Code, cross-SoC safety, Stage 2 size, tests, attribution, and CI are clean; holding APPROVE only for the §5 J700 hardware row.
Verified
- USB proxy carrier scheduling logic:
usb_init()(src/usb.c:558-563) previously passeddelay_ms = 0tousb_cdc_schedule(), whichusb_cdc_state_schedule()(src/usb_cdc_state.c:9) unconditionally rejects (delay_ms < 1000 || delay_ms > 15000), preventing both the CDC carrier transition andusb_cdc_arm_watchdog()(170 s WDT atsrc/usb_cdc.c:81). Switching to1000uses the validator's minimum accepted delay (matchinguartproxy_wait_stage1()atsrc/uartproxy.c:98) rather than a tuned magic sleep (§2). - Cross-SoC safety & Stage 1/2 size: Strictly confined to the existing
chip_id == T8140fallback branch (no new chip gate added, §1), andusb_cdc_schedule()rejects non-T8140/non-USB2 targets anyway. Zero behavioral change on M1/M2/M3/M4/M5 and never runs on normal OS handoffs or enforcing builds (secboot_host_proxy_allowed()). Immediate constant change (0->1000) adds no code size;ESP stage 2 vital sizeand all 15/15 CI checks pass. - Tests:
tests/python/test_t8140_proxy_transport.pyexercises the realusb_cdc_state_schedule()/usb_cdc_state_due()against the arguments parsed fromsrc/usb.c, verifies thedelay=0negative control, and checks thatusb_cdc_schedule()arms the watchdog only on an accepted schedule. - §4 Attribution & §6 Naming: Commit
083834690723has human author/committer and humanSigned-off-by:with no AI commit trailers; PR body ends withAssisted-by: LLM (Claude:Opus 5.5). No §6 naming issues.
Owed before approval / merge
- §5 Evidence (HW row): J700 (T8140) Stage 2 proxy-fallback run (outside
aura-try):- No host attached: no
usb: unable to schedule proxy transport, printsCDC Gen1 ready; awaiting host, and resets via the CDC watchdog after ~170 s back to the configured boot. - CDC host attached: prints
CDC primary open; watchdog disabledand completes a proxy round-trip.
- No host attached: no
- Non-blocking note:
aurora-silicon/aura#416is now closed; a follow-up can still introduceUSB_CDC_SCHEDULE_MIN_MS/_MAX_MSinsrc/usb_cdc_state.hand replace the repeatedchip_id == T8140deferred-carrier checks with an ADT-driven predicate.
Assisted-by: LLM (Google:Gemini 4 Neon)
|
Status of the J700 row: our Neo has no CDC host and no remote reset, so we can't run it unattended overnight. A failing run would leave the Mac sitting in the proxy until someone holds the power button. The image is built and the procedure is ready; it runs as soon as someone is at the Mac. One thing that matters for whoever runs it: main already reboots a no-payload aura-try trial after 10 s (
Build used hereaura main 6affb8e + this head c9f0977 + the lab patch. Release recipe ( Assisted-by: LLM (Claude:Opus 5.5) |
|
Besides the J700 row, the branch now needs main merged in: the only conflict is in AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md; keep main's copies. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed at c9f0977de46b8b7845e5f8487df54fdc689d8fdd against the pre-PR checklist (§1–§6).
Diff since prior review (08383469..c9f0977d)
- There are no code or test changes since
083834690723—src/usb.candtests/python/test_t8140_proxy_transport.pyare unchanged, and08383469itself merges cleanly into currentmain. - The only new commit is
c9f0977de46b(gfya, authored and committed bygithub-actions[bot]), which deletes.github/copilot-instructions.md,AGENTS.md,CLAUDE.md, andGEMINI.md.
Blockers
- Merge conflict (
DIRTY) & §4 commit hygiene (c9f0977d):mainupdated those four policy files in6e1ac76745(#428), soc9f0977d's deletions produce 4 modify/delete conflicts againstmain.c9f0977dis also bot-authored (github-actions[bot]) with no humanSigned-off-by:. Please dropc9f0977dand rebase08383469ontomain(keepingmain's policy files without retaining the bot deletion commit in history). - CI not run on current head: 0 CI checks have run on
c9f0977d(last green CI was on08383469). Full CI (build,test,format-check,stage1-size,esp-stage2-size) must run and pass on the rebased head. - §5 Evidence (J700 HW row still owed): Noted your update that the J700 image and lab-only test procedure are staged and waiting for hands-on access to the Neo. Still required before merge:
- Host-less J700 Stage 2 proxy-fallback run: no
usb: unable to schedule proxy transport, printsCDC Gen1 ready; awaiting host, and resets via the CDC watchdog after ~170 s back to the configured boot. - CDC host-attached J700 run: prints
CDC primary open; watchdog disabledand completes a proxy round-trip.
- Host-less J700 Stage 2 proxy-fallback run: no
Checklist summary
- §1 No model gating / §2 Production-ready / §3 Safety / §6 Naming: Clean on
08383469(unchanged). - §4 Attribution: Blocked by bot commit
c9f0977d;08383469and PR body disclosure are clean. - §5 Evidence: Pending J700 hardware row and fresh CI on the rebased head.
Assisted-by: LLM (Gemini 4 Neon)
An automated policy commit deleted AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md on this branch after the policy file changed on the default branch. Restore them as copies of its .github/aurora/AGENTS.md so the branch merges cleanly again. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed at 7e430174cd3381e5efdbdcc44dc2a5f2051ba5c4 against the pre-PR checklist (§1–§6).
Resolved since prior review (c9f0977d..7e430174)
- Merge conflicts (
DIRTY->MERGEABLE/CLEAN): Commit7e430174cd33restores.github/copilot-instructions.md,AGENTS.md,CLAUDE.md, andGEMINI.mdto exact copies ofmain's.github/aurora/AGENTS.md.src/usb.candtests/python/test_t8140_proxy_transport.pyare unchanged from083834690723. - CI (15/15 green): All 15 checks (
policyx2,build,ESP stage 2 vital size,format-check,gcc,clang-macos,fedora,alarm,nix, and all 5Pytestjobs) completed withSUCCESSon7e430174.
Remaining blockers
- §4 Commit hygiene (
c9f0977dstill in branch history):c9f0977de46b(gfya, authored/committed bygithub-actions[bot]with no humanSigned-off-by:) is still in the PR's commit list rather than dropped via rebase (7e430174only restores the 4 files on top). Please rebase08383469ontomainto dropc9f0977d+7e430174so no unsigned bot commit entersmainon merge (unless squash-merged). - §5 Evidence (J700 HW row still owed): No hardware run results have been posted yet (image and lab-only procedure remain staged awaiting hands-on J700/Neo access). Still required before merge:
- Host-less J700 Stage 2 proxy-fallback run: no
usb: unable to schedule proxy transport, printsCDC Gen1 ready; awaiting host, and resets via the CDC watchdog after ~170 s back to the configured boot. - CDC host-attached J700 run: prints
CDC primary open; watchdog disabledand completes a proxy round-trip.
- Host-less J700 Stage 2 proxy-fallback run: no
Checklist summary
- §1 No model gating / §2 Production-ready / §3 Safety / §6 Naming: Pass (unchanged from
08383469). - §4 Attribution:
08383469,7e430174, and PR body disclosure are clean; blocked only by retained unsigned bot commitc9f0977din PR history. - §5 Evidence: CI 15/15 green; J700 hardware rows still owed.
Assisted-by: LLM (Gemini 4 Neon)
Problem
On the T8140, a stage that reaches the proxy with no host gets neither a USB carrier nor a watchdog.
usb_init()schedules the deferred CDC carrier transition with a delay of 0, butusb_cdc_state_schedule()only takes 1 to 15 s, so the call always fails and printsusb: unable to schedule proxy transport.usb_cdc_schedule()arms the CDC watchdog (170 s, cleared when a host opens the primary port) only after a schedule succeeds, so that watchdog never arms either.A Stage 2 arms no watchdog of its own, and neither does a Stage 1 built before the boot watchdog. Either one stays in that proxy until someone holds the power button. Our A18 Pro MacBook was left showing aura's proxy text for about 6 hours on 11-21, after a trial Stage 2 failed. This path fits what we saw: the boot after the failed trial reached the proxy and never reset. It is not proven, since no log of that boot survived.
Change
Schedule the transition with 1000 ms, the shortest delay the state machine accepts. That is the same call the Stage 1 window makes on this SoC. A host-less proxy then gets its CDC carrier, and is reset by the CDC watchdog if no host opens it within 170 s.
Testing
tests/python/test_t8140_proxy_transport.pyruns the realusb_cdc_state_schedule()on the arguments it reads out ofusb_init():usb_cdc_schedule()still arms the watchdog only after an accepted schedule.format-checkpasses with clang-format 20.1.8. Stage 2 (RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1) builds.Still to run
CDC Gen1 ready; awaiting host, then a reset about 170 s later, back to the configured boot. Our J700 has no remote reset, so this needs someone at the Mac, or a J700 with a CDC host attached, where the primary opening should instead clear the watchdog (CDC primary open; watchdog disabled).Details for reviewers
src/usb.cis built into Stage 1 too. In Stage 1 this only matters for its final proxy, and only once a Stage 1 with it is enrolled. A Stage 2 with it works under any enrolled Stage 1.BIT(1) | BIT(2), unchanged), as the Stage 1 window does. This only happens on the way into a proxy stop, never on a boot that hands off to an OS.wdt_arm()restarts the counter, so the CDC watchdog replaces a running boot watchdog with a fresh 170 s one.USB_CDC_SCHEDULE_MIN_MS/_MAX_MStousb_cdc_state.hand moves the Stage 1 window's call to it, but doesn't touch this call. Whichever of the two lands second switches this1000to the constant. The test then asserts against the constant instead of the literal.Assisted-by: LLM (Claude:Opus 5.5)