Skip to content

usb: bring up the J616s (T6040) tether port as a USB2 CDC device (carry-forward of #245) - #573

Merged
RyanTheTide merged 13 commits into
mainfrom
closeout/245-j616s-cdc
Nov 29, 2026
Merged

RyanTheTide merged 13 commits into
mainfrom
closeout/245-j616s-cdc

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

This carries #245 forward onto main as signed commits. The stale feat/sptm-hv base, the policy-bot gfya commit and the AI co-author trailers are gone, and nothing was force-pushed. On top, one commit fixes the two open review points.

What it does: it brings up the J616s (T6040) tether port as a USB2 CDC device, at 480 Mb/s or at 12 Mb/s for full-speed hosts, through the explicit session-scoped CDC handoff. The T6040 handoff is selected by the ATC0 PHY compatible (atc-phy,t6040) from the ADT, not by board.

Review fixes (fc4d6c60):

  1. Dj, 11-24, src/usb.c:148: usb_cdc_deferred_usb2() is T6050-only again. usb_init(), usb_iodev_init(), usb_phy_bringup() and usb_iodev_bringup() therefore no longer return early on atc-phy,t6040 Macs, and the generic gadget and proxy stay up on a boot without the inherited debug carrier. The explicit handoff tests usb_cdc_t6040_usb2() (the ATC0 PHY compatible) in usb2_target() and usb_cdc_link_start(), and refuses while a generic gadget owns USB0.
  2. The full-speed request (usb_dwc3_usb2_full_speed) is cleared in usb_cdc_cancel() and usb_cdc_cleanup(), so it can't leak into a later gadget init.

Tested: USB/CDC host suites: 38 passed plus 3 new cases in test_usb_t6040_generic_gadget.py, which fail on the old code. The 10 test_t6041_atc_usb2_device errors are main's and are fixed by #570. clang-format is clean. Clang tools/stage1_size.sh passes all flavours (Stage 1 headroom 94,696 B). ESP Stage 2 links. The earlier J616s 480 and 12 Mb/s rows were taken on the series before this fix. A J616s row of this head (explicit 480/12 Mb/s plus the generic gadget on a carrier-less boot) is queued behind the J616s's current holder.

Risk: two-way door. It is Stage 1 USB code on T6040 Macs (J614s, J616s, J614c, J616c): the explicit CDC session, and the generic gadget being restored to main's behaviour. Other families keep main's path.

Not yet: the J616s row at this head, a second-family generic-gadget regression, and an installed Stage 1 row (owner 1TR).

Revert: git revert -m 1 <merge commit>

Supersedes #245.

RyanTheTide and others added 7 commits November 29, 2026 16:10
The explicit CDC-ACM debug-link handoff (usb_cdc_link_start) only covered the
T8140 Gen1 SuperSpeed path, the T6050/T8152 USB2 path and the T8142 live-reuse
case. The J616s (chip_id T6040, board 6, J616sAP) matched none, so a chainload
or SPTM-virt boot that must preserve its inherited carrier never brought up a
DWC3 device controller and the host saw no CDC port.

Route the J616s ATC0 tether port through the same explicit USB2 device handoff
the M5 (T6050) uses: usb_cdc_deferred_usb2() now also selects atc-phy,t6040 on
this board (scoped to J616sAP so other T6040 J614s and T6041 M4 Max machines
keep the generic gadget path), and usb_cdc_link_start dispatches T6040 to a new
usb_t6040_init.

usb_t6040_init mirrors usb_t6050_init but for the T6040 ADT: it resolves the
DWC3 core (usb-drd0 reg 0), PIPEHANDLER (usb-drd0 reg 3), USB2 PHY (atc-phy0
reg 0) and the T8110 DART (dart-usb0 reg 1, mapper SID) by index and validates
them by compatible and size, parks the dummy PIPE, and brings the USB2 device
PHY up from the ADT's own tunable_USB2PHY_DFLT/DEV. The qualified high-speed
path leaves the ATC PHY in its initial state and needs neither the
event-counter bank the M5 writes nor the ACIO SuperSpeed PHY processor; a
USB2-only or forced-full-speed link runs at full speed. SuperSpeed stays
unqualified (it needs the CIO80 ACIOPHY processor brought to tunables-done).

(cherry picked from commit 640d9ff)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Two problems kept the J616s tether gadget from enumerating after the
USB2 CDC handoff:

- T6040's PIPEHANDLER MUX_CTRL has no bit 6. Writing the M5's 0x42
  reads back as 0x02, so the step-2 check failed every time. On this
  SoC the dummy USB2 route is 0x22, the value the generic port bring-up
  already writes. Program and check that instead, and say so on the
  console when the route doesn't latch.

- The ADT USB2 PHY tunables leave the PHY's role bits (SIG[14:12]) in
  host mode. The controller then ran with no device pull-up and the
  host never saw a connect. Clear the host bits before forcing VBUS,
  as device mode needs.

Tested on a J616s chainloaded over the KIS proxy with a macOS host on
the debug port. The device enumerates as 1209:316d at 480 Mb/s within
about 2 s of cdc_schedule(1000, 0), and proxy reads run at about
17 MB/s (KIS: 0.65 MB/s).

(cherry picked from commit ea1e97c)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
The high-speed DWC3 engine always advertised 512-byte bulk endpoints.
That's invalid at full speed (USB 2.0 9.6.6 caps full-speed bulk
packets at 64 bytes), so a host or hub limited to 12 Mb/s could not use
the CDC device.

The engine now picks the bulk packet size from the speed in DSTS at
ConnectDone: 512 at high speed, 64 at full speed. It resizes the bulk
endpoints with a DEPCFG modify and serves a matching configuration
descriptor. The ZLP check follows the same size. At high speed the
descriptor and endpoint setup are unchanged.

USB2 CDC targets also accept one schedule flag,
USB_CDC_USB2_FULL_SPEED (BIT(3)), which makes the controller advertise
full speed. That lets the full-speed path be tested on a high-speed
host. The proxy's flag range grows from 0-7 to 0-0xf to carry it; the
T8140 state machine still rejects anything outside bits 0-2.

Tested on a J616s with a macOS host. With the flag, the device
enumerates at 12 Mb/s and proxy reads run at 1.10 MB/s with an exact
4 MiB write/readback. Without it, the same build enumerates at 480 Mb/s
and runs as before (17.7 MB/s reads).

(cherry picked from commit 11fcc66)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
The harness now models DEPCFG resizes and the DSTS speed. It checks
that a high-speed connect leaves the 512-byte bulk endpoints alone,
that both full-speed DSTS encodings resize every bulk endpoint to 64
bytes and still re-arm SETUP, and that a later high-speed connect
restores 512.

(cherry picked from commit a09e30d)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
The explicit USB2 CDC handoff for T6040 was gated on the chip id, board
id and the J616sAP target. Select it by the tether port's hardware
instead: any machine whose /arm-io/atc-phy0 is atc-phy,t6040 takes the
deferred USB2 path, and usb_cdc_link_start() dispatches to
usb_t6040_init() on the same compatible rather than on chip_id.
usb_t6040_get_regs() still refuses a port whose DRD, DART, port numbers
or register sizes do not match.

On the J616s nothing changes: its atc-phy0 is atc-phy,t6040, so it
takes the same path as before. Also fix the comment that called the
J616s a Mac mini; it is the 16-inch MacBook Pro.

Signed-off-by: Ryan <ryan@aurorasilicon.org>
(cherry picked from commit 1d34eae)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
On a USB2 connect at full speed the bulk endpoints are resized to 64
bytes. If a resize failed, the code only logged it and still recorded
the new packet size, so the configuration descriptor could advertise a
size the endpoints do not have. Stop the controller and report the link
as failed instead, as the SuperSpeed path already does on a mode
mismatch, and cover the case in the HS session harness.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
(cherry picked from commit 456b58f)

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Adding atc-phy,t6040 to usb_cdc_deferred_usb2() made usb_init(), usb_iodev_init(),
usb_phy_bringup() and usb_iodev_bringup() return early, so every atc-phy,t6040 Mac lost the
generic gadget and proxy on a boot without the inherited debug carrier. Keep the deferral for
the T6050 PHY only. The explicit USB2 CDC handoff (usb2_target(), usb_cdc_link_start()) selects
usb_t6040_init() by the ATC0 PHY compatible, and refuses while a generic gadget owns USB0.

The full-speed request set by usb_cdc_schedule() is now cleared on cancel and cleanup, so it
cannot leak into a later gadget initialization.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at fc4d6c6

Checked: T6040 keeps the generic gadget and uses the PHY compatible for the explicit CDC handoff. Cancel and cleanup clear the full-speed flag.

Blocker: The flag is global and set when scheduling, before the explicit handoff owns the gadget. usb2_failed leaves it set, including when usb_cdc_link_start refuses because USB0 is already owned. The shared high-speed initializer reads the flag. Scope speed to the explicit initialization, or consume and clear the flag on success and all failure exits. Add a refused-start case and retain the 480/12 Mb/s and carrier-less generic-gadget rows on J616s.

usb_cdc_schedule() sets the global full-speed request before the explicit handoff owns the
gadget, and only usb_dwc3_init() reads it. Clear it right after usb_cdc_link_start() returns,
so neither a successful start nor a refused one (USB0 already owned by the generic gadget)
leaves it set for a later high-speed initialization.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at cf2cd31 after the integration gates below.

Checked: The shared full-speed flag now clears immediately after usb_cdc_link_start returns and before either the refused-start exit or downstream routing. The ordering test covers the refused exit, and cancel and cleanup retain their clears. Source approval. Keep hosted CI, the exact J616s 480/12 Mb/s and carrier-less checks, the second-family regression and owner-authorized Stage 1 evidence.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 8a4afbe9: not ready yet

Check Detail
CI at head running running: policy, policy, build, ESP stage 2 vital size, format-check, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 8a4afbe9
Conflicts ok none
PR text ok Risk: two-way · . It is Stage 1 USB code on T6040 Macs (J614s, J616s, J614c, J616c): the explicit CDC session, and the generic gadget being restored to main's behaviour. Other families keep main's path.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s row at 913e4169 (main 1f77cab4 merged in, no change to this PR's code): the explicit CDC handoff fails, so this does not merge as is.

  • Setup: an ESP Stage 2 one-shot (aura-try, DEBUGUSB_PROXY=1 build) on a boot started by tuxvdmtool reboot debugusb from the J473, with the proxy caught over KIS.
  • cdc_schedule(1000, 0, 0) returns 0. cdc_status then goes 0x0 -> 0x1 (scheduled) -> 0x103 (failed, step 1), and the console prints CDC USB2 failed at step 1; allocations retained. No 1209:316d shows up on the host, and Debug USB 05ac:1881 stays attached.
  • Step 1 means usb_cdc_link_start() returned an error before usb_t6040_init() made any progress. The likely cause: since fc4d6c60, usb_cdc_deferred_usb2() is T6050-only, so on T6040 usb_iodev_init() only returns early when aura_debug_enabled() is set. On a debugusb/KIS boot it isn't set, the generic gadget takes USB0, and link_start then refuses because iodev_get_opaque(IODEV_USB0) is set. The 11-19 480 and 12 Mb/s passes were on the pre-fix series, where T6040 still deferred USB2.
  • The 12 Mb/s leg was not run because it goes through the same link_start.
  • A production-flavour carrier-less boot of the same head reached Linux cleanly (Enforcing, 0 failed units, 0 error-level kernel lines).

Fix direction: keep the generic gadget off USB0 on T6040 while the inherited DockChannel/KIS carrier is in use (for example, also skip in usb_init()/usb_iodev_init() when usb_cdc_t6040_usb2() && dockchannel_uart_host_seen()). Otherwise, let the explicit handoff retire a generic USB0 gadget it finds. Then re-run the 480 and 12 Mb/s legs plus a carrier-less boot.

On the J616s (T6040), a proxy window opened on the inherited DockChannel
(KIS) carrier brought the generic gadget up on USB0 through
uartproxy_wait_stage1(). usb_cdc_link_start() refuses while USB0 is
owned, so cdc_schedule() failed at step 1 (cdc_status 0x103) and the
explicit 480 and 12 Mb/s handoff never started.

Skip the generic bring-up in that window when the ATC0 PHY is the T6040
one and a DockChannel host is present: the carrier is the window's
transport. Window boots without that carrier still bring the generic
gadget up.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 96724fd1 pending build and transport validation.

Blockers: Confirm the normal and debug proxy build configurations link, since the new call is unguarded in uartproxy.c and the helper implementation is compiled only with DEBUGUSB_PROXY. Confirm the J616s carrier-present 480/12 Mb/s CDC handoff and a carrier-less generic-gadget window in the owner-authorized row.

Checked: The generic initialization branch remains reachable when no DockChannel host has been seen. The new source assertion checks placement of the skip but does not exercise the transport state.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 29, 2026
The installed Stage 1 leaves the T6040 PIPE released (mux 0x22) with the
DWC3 still held in reset (aon 0). usb_t6040_init() then read the DWC3's
registers to prove it stopped, which a core in reset can't answer, and
refused the explicit CDC handoff at step 2 (J616s row 2026-11-30, 0x203:
'T6040 PIPE consumer is not retired (aon=0 mux=22)').

A core held in reset produces nothing, so accept that state as it is. A
core out of reset must still prove it is stopped, and T6050 is unchanged.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 29, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 926f9aa4.

Blockers: Guard the dockchannel_uart_host_seen() call in uartproxy_wait_stage1() with the same DEBUGUSB_PROXY condition as the implementation, or provide an explicit false stub for normal builds. The call is unconditional in this function and the header declares it in every flavour, while the definition only exists in debug builds. The new reset change leaves that dependency in place. Please verify links for both production and debug flavours. The six focused host tests check source structure and do not exercise linking.

Checked: The reset-held T6040 path now skips DWC3 register reads in the reported mux state. A core out of reset still needs to pass the stopped-device checks. All six focused source tests passed locally. Re-run the J616s carrier-present 480 and 12 Mb/s cases and the carrier-less gadget case at the resulting head. Keep the second-family regression and owner Stage 1 validation tracked in the PR.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 926f9aa48406

Blockers:

  • Broken link on all non-DEBUGUSB_PROXY builds (src/uartproxy.c:100): uartproxy_run() calls dockchannel_uart_host_seen() unconditionally (} else if (usb_cdc_t6040_usb2() && dockchannel_uart_host_seen()) {), but dockchannel_uart_host_seen() is only compiled under #ifdef DEBUGUSB_PROXY (src/dockchannel_uart.c:285-291, declared /* DEBUGUSB_PROXY builds only. */ in src/dockchannel_uart.h:26-27). This broke build, gcc, ESP stage 2 vital size, clang-macos, fedora, and alarm at 96724fd1 and remains unfixed at 926f9aa48406. Guard the call in src/uartproxy.c with #ifdef DEBUGUSB_PROXY (matching the pattern used elsewhere) or provide a static inline bool dockchannel_uart_host_seen(void) { return false; } #else stub in src/dockchannel_uart.h.
  • Exact-head hardware verification & CI: Once the link fix is pushed and hosted CI finishes green across all build flavours, post the exact-head J616s carrier-present (480 and 12 Mb/s CDC handoff) and carrier-less generic-gadget hardware rows (plus second-family regression and owner-authorized Stage 1 row as noted in the PR body).

Checked:

  • Verified 926f9aa48406 (src/usb.c:405-428 and tests/python/test_usb_t6040_generic_gadget.py): accepting !(aon & PIPEHANDLER_AON_GEN_DWC3_RESET_N) && mux == 0x22 as already retired before reading regs.dwc + DWC3_GCTL avoids reading registers of a DWC3 held in reset while still requiring the full stopped-device register proof whenever DWC3_RESET_N is deasserted, and still rejecting unknown PIPE producers (mux not in {0, 2, 0x42}).
  • Verified src/dockchannel_uart.h, src/dockchannel_uart.c, Makefile, and src/uartproxy.c at 926f9aa48406.
Evidence
  • src/uartproxy.c:100: unguarded call } else if (usb_cdc_t6040_usb2() && dockchannel_uart_host_seen()) { compiles in all builds, including non-DEBUGUSB_PROXY (SECBOOT_FLAVOUR=secure, release, gcc, clang-macos, fedora, alarm).
  • src/dockchannel_uart.c:285-291: dockchannel_uart_host_seen() is inside #ifdef DEBUGUSB_PROXY, and src/dockchannel_uart.h:26-27 only declares a prototype with no #else inline stub.
  • Non-blocking nit: in src/usb.c:407, else if ((aon & PIPEHANDLER_AON_GEN_DWC3_RESET_N) || mux == 0x22) can simplify to else if (aon & PIPEHANDLER_AON_GEN_DWC3_RESET_N) now that !(aon & PIPEHANDLER_AON_GEN_DWC3_RESET_N) && mux == 0x22 is handled by the preceding if.

dockchannel_uart_host_seen() exists in DEBUGUSB_PROXY builds only, so the
T6040 carrier check in uartproxy_wait_stage1() failed to link a release
ESP Stage 2 (ld.lld: undefined symbol: dockchannel_uart_host_seen).

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Fix for the 0x203 refusal in the second J616s row, plus a link fix:

  • 926f9aa: the installed Stage 1 leaves the T6040 PIPE released (mux 0x22) with the DWC3 still held in reset. usb_t6040_init() read the core's registers to prove it had stopped, and a core in reset can't answer, so it reported "not retired". That state is now accepted as retired before any DWC3 read. A core out of reset still has to prove it is stopped. T6050 is unchanged.
  • 575abc3: 96724fd called dockchannel_uart_host_seen(), which only DEBUGUSB_PROXY builds have, so a release ESP Stage 2 failed to link. The carrier-window skip now sits under that guard.

Tested: the new host test fails before the fix and passes after; full host pytest passes (1472). clang builds pass for release ESP Stage 2 (with and without DEBUGUSB_PROXY), SPTM_VIRT/AURACTL and default Stage 1. fedora:44 stage1_size.sh fits on every flavour. The J616s re-row (hs, fs, plain) is queued.
Risk: two-way · J616s (T6040) explicit CDC handoff only

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 575abc32 after hosted checks and transport validation.

Blockers: Keep the exact-head J616s 480 and 12 Mb/s carrier-present runs, the carrier-less generic gadget check, the second-family regression and owner Stage 1 validation.

Checked: The new guard removes the debug-only helper call from the normal build. I preprocessed the branch with and without DEBUGUSB_PROXY and checked that both variants retain the T8140 scheduling branch and generic USB fallback. All six focused source tests passed at this head. The earlier reset-held T6040 fix is unchanged.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s (M4 Pro, T6040) row at 575abc3: explicit CDC FAIL (step 1), carrier-less boot OK. Two fixes needed; both tested on the J616s as local builds (not pushed).

Tested: J616s, one-shot aura-try of the Stage 2 with only the aura head swapped onto the live a98f3d09 tail, booted by a VDM reboot debugusb from the J473 and caught over KIS. Host is the J473 on Linux (cdc_acm). Stage 1, LocalPolicy, NVRAM and GRUB untouched; the saved Edge was restored afterwards (Enforcing, 0 failed units, next_entry empty).

leg 575abc3 + build_cfg.h include + full-speed OUT fix
hs, cdc_schedule(1000, 0) FAIL: 0x1 -> 0x103, "CDC USB2 failed at step 1" PASS: 480, NOP/whoami over CDC, 1 MiB read PASS: 480, 2.18 MB/s
fs, cdc_schedule(1000, 0x8) FAIL: 0x103, step 1 enumerates at 12, no NOP reply (twice) PASS: 12, NOP first try, 0.58 MB/s
plain (release build, normal boot, no host) PASS: 1.0.0b17-g575abc32 -> Linux, Enforcing, 0 failed, 0 AVC, GPU okay

926f9aa works: with the step-1 refusal out of the way the console shows CDC USB2: released PIPE with the DWC3 held in reset; already retired, then T6040 controller initialized, PIPE=22 and status 0x502.

  1. 575abc3 compiles the carrier skip out of the DEBUGUSB_PROXY build too. src/uartproxy.c doesn't include "../build/build_cfg.h", and that header is where CFG puts DEBUGUSB_PROXY. So the new #ifdef DEBUGUSB_PROXY is always false. uartproxy.o from the DEBUGUSB_PROXY=1 build calls only usb_cdc_schedule/usb_init, and neither usb_cdc_t6040_usb2 nor dockchannel_uart_host_seen. The generic gadget takes USB0 again and usb_cdc_link_start() refuses. Fix: add #include "../build/build_cfg.h" at the top of src/uartproxy.c, as dockchannel_uart.c does. A host test could check that uartproxy.c includes it, since the source-text test passes either way.
  2. Full speed on a Linux host: bulk OUT never completes. The USB2 engine arms each OUT TRB for XFER_SIZE (16 KiB) and relies on a short packet to end it. At full speed the proxy's 64-byte request is exactly one max packet. Linux cdc_acm sends no ZLP after it, so the TRB never completes and the request is never seen. At high speed 64 < 512, so the packet is short and the TRB completes. The 11-19 full-speed pass used a macOS host. Tested fix: when dev->bulk_mps == CDC_FS_BULK_PACKET_SIZE, arm OUT TRBs for one packet, and have usb_dwc3_cdc_copy_bulk_out_progress() count bytes from transfer_length rather than XFER_SIZE:
@@ usb_dwc3_cdc_start_bulk_out_xfer
 #if !USB_DWC3_SUPERSPEED
     memset(dev->endpoints[endpoint_number].xfer_buffer, 0xaa, XFER_SIZE);
-#endif
-    usb_dwc3_start_bulk_transfer(dev, endpoint_number, XFER_SIZE);
+    usb_dwc3_start_bulk_transfer(dev, endpoint_number,
+                                 dev->bulk_mps == CDC_FS_BULK_PACKET_SIZE ? CDC_FS_BULK_PACKET_SIZE
+                                                                          : XFER_SIZE);
+#else
+    usb_dwc3_start_bulk_transfer(dev, endpoint_number, XFER_SIZE);
+#endif
@@ usb_dwc3_cdc_copy_bulk_out_progress (!USB_DWC3_SUPERSPEED)
-    if (remaining > XFER_SIZE)
+    if (remaining > dev->endpoints[ep].transfer_length)
         return false;
-    size_t bytes = XFER_SIZE - remaining;
+    size_t bytes = dev->endpoints[ep].transfer_length - remaining;

Not mergeable at 575abc3. Once both fixes are on the branch, re-run hs/fs/plain at the new head with the same kit.
Risk: both fixes are small. The include only affects DEBUGUSB_PROXY builds of uartproxy.c. The OUT change only applies to full-speed links: at high speed transfer_length == XFER_SIZE, so behaviour is unchanged.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 575abc32. This supersedes my earlier code approval.

Blockers: Include the generated build configuration in uartproxy.c so the carrier guard is active in an actual debug build. Verify the helper reference in the debug object and its absence in the release object. Resolve the full-speed bulk OUT stall with a packet-sized transfer and account against the programmed transfer length, then repeat high-speed, full-speed and carrier-less J616s checks at the pushed head.

Checked: My earlier isolated preprocessor check supplied the debug macro directly and missed that this translation unit does not include the generated configuration. The J616s receipt confirms the real debug build still refuses the handoff. It also shows the full-speed stall after enumeration when the Linux host sends a full 64-byte request without a terminating short packet. The local fixes are promising. Please put both on the branch and post the exact-head results.

#573 (comment)

Found on the J616s row of 575abc3 (2026-11-30):

- uartproxy.c did not include build_cfg.h, so the DEBUGUSB_PROXY guard
  around the T6040 carrier-window skip was always false. The debug build
  started the generic gadget on USB0 again and the explicit CDC handoff
  refused at step 1 (0x103).
- At full speed a 64-byte proxy request is one full packet and Linux
  cdc_acm sends no ZLP after it, so a 16 KiB OUT TRB never completed and
  the first NOP got no reply. Arm one packet per OUT TRB at full speed
  and count received bytes from the armed length.

With both, the J616s hs (480 Mb/s) and fs (12 Mb/s) legs pass.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed 8a4afbe with both fixes from the J616s row:

  1. uartproxy.c now includes build_cfg.h. Without it, my DEBUGUSB_PROXY guard in 575abc3 was always false: the debug build started the generic gadget on USB0 again, and the handoff refused at step 1 (0x103).
  2. Full-speed bulk OUT arms one 64-byte packet per TRB and counts received bytes from the armed length. A 64-byte proxy request is one full packet, and Linux cdc_acm sends no ZLP after it, so a 16 KiB TRB never completed.

Tested: on the J616s, hs passes at 480 Mb/s ("released PIPE with the DWC3 held in reset; already retired", status 0x502) and fs passes at 12 Mb/s (NOP on the first try). Plain boot passed at 575abc3, and the carrier-less path is unchanged. These legs ran on a local build whose uartproxy.o, usb.o, usb_cdc.o and usb_dwc3.o disassemble identically to this head. Evidence: traces/boot/20261130-closeout-573-j616s/fix2-575abc32/ (fix3-local, fix4-local). The two new host tests fail before the fix and pass after; full host pytest passes (1474). The release build doesn't reference dockchannel_uart_host_seen, and the debug build does. fedora:44 size fits on every flavour.
Risk: two-way · J616s (T6040) explicit CDC handoff; full-speed CDC OUT on USB2 builds

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 8a4afbe9 after remaining validation.

Checked: The generated configuration include now makes the carrier guard effective in actual debug builds. Full-speed USB2 OUT arms one packet and uses the programmed transfer length to bound the residual count. High-speed and SuperSpeed retain the original transfer size. All eight focused tests passed. I verified the saved J616s logs show successful NOP and 1 MiB reads at 480 and 12 Mb/s. The author reports matching disassembly for the exercised objects and a carrier-less pass at the preceding head.

Blockers: Hosted CI, second-family generic gadget and owner Stage 1 validation remain. Include the carrier-less evidence or source-equivalence record for this head in the merge evidence.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging at 8a4afbe9 (merge) under the 6-point rule. (1) The review App's verdict at this head: APPROVED. (2) CI is green at this head (readiness excluded). (3/4) Rows: J616s hs 480 + fs 12 legs PASS on a disassembly-identical build (uartproxy/usb/usb_cdc/usb_dwc3), plain PASS at 575abc3 (traces/boot/20261130-closeout-573-j616s); host tests fail-before/pass-after; fedora:44 size fits. (5) No blocking review is open. (6) Dj was pinged with no objection. Revert: git revert -m 1 <commit>.

@RyanTheTide
RyanTheTide merged commit 1e01a27 into main Nov 29, 2026
29 of 30 checks passed
@RyanTheTide
RyanTheTide deleted the closeout/245-j616s-cdc branch November 29, 2026 19:48
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Known-gap issue for the two receipts REVIEW6 noted (a second-family generic gadget row, and an owner-installed Stage 1): #581

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

Labels

blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant