From 640d9ffb538806b8fda9ef062044b2a600771fd4 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:07:03 +1100 Subject: [PATCH 1/8] usb: bring up the J616s (T6040) tether port as a high-speed CDC device 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). --- src/usb.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 168 insertions(+), 6 deletions(-) diff --git a/src/usb.c b/src/usb.c index dc4132668..99d3f4b31 100644 --- a/src/usb.c +++ b/src/usb.c @@ -131,8 +131,16 @@ static int usb_drd_adt_offset(u32 idx, char drd_path[sizeof(FMT_DRD_PATH)], int return offset; } -/* T6050 has a different PIPE clock field. Never run the older automatic - * gadget initialization on it, including when the explicit setup is refused. */ +/* The J616s (T6040) Mac mini's ATC0 is the tether/debug port. Scope the explicit CDC handoff to + * this board so other T6040 (J614s) and T6041 (M4 Max J614c/J616c) machines keep the generic path. + */ +static bool usb_cdc_j616s(void) +{ + return chip_id == T6040 && board_id == 6 && adt && adt_is_compatible(adt, 0, "J616sAP"); +} + +/* T6050 and the J616s T6040 have a different PIPE clock field. Never run the older automatic + * gadget initialization on them, including when the explicit setup is refused. */ bool usb_cdc_deferred_usb2(void) { static int deferred = -1; @@ -145,8 +153,10 @@ bool usb_cdc_deferred_usb2(void) * The J714c (M5 Max) enumerates through the generic gadget path on every port, as the * omacom m1n1 Stage 1 does there; the explicit port-0 setup never comes up on it. */ - deferred = node >= 0 && adt_is_compatible(adt, node, "atc-phy,t6050") && - !adt_is_compatible(adt, 0, "J714cAP"); + deferred = + node >= 0 && ((adt_is_compatible(adt, node, "atc-phy,t6050") && + !adt_is_compatible(adt, 0, "J714cAP")) || + (adt_is_compatible(adt, node, "atc-phy,t6040") && usb_cdc_j616s())); } return deferred; } @@ -301,6 +311,153 @@ static dwc3_dev_t *usb_t6050_init(void (*set_step)(unsigned step)) return dwc; } +/* The J616s (T6040) tether/debug port. ATC0 USB-drd0/dart-usb0/atc-phy0 are the same roles as the + * M5's, so this mirrors usb_t6050_init: resolve the DWC3 core (usb-drd0 reg 0), the PIPEHANDLER + * (usb-drd0 reg 3), the USB2 PHY (atc-phy0 reg 0) and the T8110 DART (dart-usb0 reg 1, mapper SID) + * from the ADT, validate by compatible and size, then park the dummy PIPE and bring up the USB2 + * device PHY from the ADT's own tunable_USB2PHY_DFLT/DEV. The qualified high-speed path + * (docs/j616s-bringup.md: 480 Mb/s + an exact 64 KiB transfer) leaves the ATC PHY in its initial + * state and needs neither the event-counter/"digital" bank the M5 writes (the generic bring-up that + * proved 480 Mb/s never touched atc-phy0 reg 1) nor the ACIO SuperSpeed PHY processor. SuperSpeed + * stays unqualified: it needs the CIO80 ACIOPHY processor (acio-phy-cpu0) brought to firmware + * tunables-done, which is not done yet; a USB2-only or forced-FS link runs at full speed. */ +static int usb_t6040_get_regs(struct usb_t6050_regs *regs) +{ + int phy_path[8], drd_path[8], dart_path[8]; + int phy = adt_path_offset_trace(adt, "/arm-io/atc-phy0", phy_path); + int drd = adt_path_offset_trace(adt, "/arm-io/usb-drd0", drd_path); + int hpm = adt_path_offset(adt, "/arm-io/nub-spmi-a0/hpm0"); + int dart = adt_path_offset_trace(adt, "/arm-io/dart-usb0", dart_path); + int mapper = adt_path_offset(adt, "/arm-io/dart-usb0/mapper-usb0"); + u32 phy_port, drd_port, hpm_port, port_type, sid; + u64 dwc_size, dart_base, dart_size; + + regs->digital = 0; /* T6040 high speed needs no event-counter bank; see usb_t6040_init. */ + if (phy < 0 || drd < 0 || hpm < 0 || dart < 0 || mapper < 0 || + !adt_is_compatible(adt, phy, "atc-phy,t6040") || + !adt_is_compatible(adt, drd, "usb-drd,t6040") || + !adt_is_compatible(adt, dart, "dart,t8110") || + adt_get_property(adt, drd, "usb-device-disable") || + ADT_GETPROP(adt, phy, "port-number", &phy_port) < 0 || + ADT_GETPROP(adt, drd, "port-number", &drd_port) < 0 || + ADT_GETPROP(adt, hpm, "port-number", &hpm_port) < 0 || !phy_port || phy_port != drd_port || + phy_port != hpm_port || ADT_GETPROP(adt, phy, "port-type", &port_type) < 0 || + port_type != 2 || ADT_GETPROP(adt, mapper, "reg", &sid) < 0 || sid >= 256 || + adt_get_reg(adt, phy_path, "reg", 0, ®s->phy, ®s->phy_size) < 0 || + adt_get_reg(adt, drd_path, "reg", 0, ®s->dwc, &dwc_size) < 0 || + adt_get_reg(adt, drd_path, "reg", 3, ®s->pipe, ®s->pipe_size) < 0 || + adt_get_reg(adt, dart_path, "reg", 1, &dart_base, &dart_size) < 0 || + regs->phy_size < 0x20 || dwc_size < DWC3_DSTS + 4 || regs->pipe_size < 0x48 || + dart_size < 0x1800 || + tunables_validate_compact("/arm-io/atc-phy0", "tunable_USB2PHY_DFLT", regs->phy_size) || + tunables_validate_compact("/arm-io/atc-phy0", "tunable_USB2PHY_DEV", regs->phy_size)) + return -1; + + return 0; +} + +static dwc3_dev_t *usb_t6040_init(void (*set_step)(unsigned step)) +{ + struct usb_t6050_regs regs; + if (usb_t6040_get_regs(®s)) { + printf("CDC USB2: unsupported T6040 ADT layout\n"); + return NULL; + } + + set_step(2); + if (pmgr_adt_power_enable("/arm-io/atc-phy0") < 0 || + pmgr_adt_power_enable("/arm-io/dart-usb0") < 0 || + pmgr_adt_power_enable("/arm-io/usb-drd0") < 0) + return NULL; + + u64 pipe = regs.pipe; + u32 aon = read32(pipe + PIPEHANDLER_AON_GEN); + u32 mux = read32(pipe + PIPEHANDLER_MUX_CTRL) & 0x73; + if (dart_adt_locked("/arm-io/dart-usb0", 1)) { + printf("CDC USB2: T6040 USB DART is locked; leaving it alone\n"); + return NULL; + } + /* A chainload over the DockChannel/KIS proxy leaves usb-drd0 cold (mux 0, no DWC3 reset). An + * in-place raw chainload past a USB Stage 1 leaves its dummy PIPE released (0x22); accept only + * a fully stopped device, never a live or native PIPE producer. */ + if ((aon & PIPEHANDLER_AON_GEN_DWC3_RESET_N) || mux == 0x22) { + u32 gctl = read32(regs.dwc + DWC3_GCTL); + bool retired = (mux == 0x22 || mux == 0x42) && + (gctl & DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)) == + DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_DEVICE) && + !(read32(regs.dwc + DWC3_DCTL) & DWC3_DCTL_RUN_STOP) && + (read32(regs.dwc + DWC3_DSTS) & DWC3_DSTS_DEVCTRLHLT) && + !read32(regs.dwc + DWC3_DEVTEN) && !read32(regs.dwc + DWC3_DALEPENA); + if (!retired) { + printf("CDC USB2: T6040 PIPE consumer is not retired (aon=%x mux=%x)\n", aon, mux); + return NULL; + } + set32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_FORCE_CLAMP_EN); + clear32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_RESET_N); + if (poll32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_RESET_N, 0, 1000)) + return NULL; + udelay(10); + printf("CDC USB2: retired Stage 1 gadget held in reset\n"); + } else if (mux != 0 && mux != 2 && mux != 0x42) { + printf("CDC USB2: unknown T6040 PIPE producer (aon=%x mux=%x)\n", aon, mux); + return NULL; + } + set32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_FORCE_CLAMP_EN); + mask32(pipe + PIPEHANDLER_MUX_CTRL, 0x70, 0); + udelay(10); + mask32(pipe + PIPEHANDLER_MUX_CTRL, 3, 2); + udelay(10); + mask32(pipe + PIPEHANDLER_MUX_CTRL, 0x70, 0x40); + udelay(10); + if ((read32(pipe + PIPEHANDLER_MUX_CTRL) & 0x73) != 0x42) + return NULL; + + set_step(3); + if (tunables_apply_compact_addr("/arm-io/atc-phy0", "tunable_USB2PHY_DFLT", regs.phy, + regs.phy_size) || + tunables_apply_compact_addr("/arm-io/atc-phy0", "tunable_USB2PHY_DEV", regs.phy, + regs.phy_size)) + return NULL; + set32(regs.phy + USB2PHY_SIG, USB2PHY_SIG_VBUSDET_FORCE_VAL | USB2PHY_SIG_VBUSDET_FORCE_EN | + USB2PHY_SIG_VBUSVLDEXT_FORCE_VAL | + USB2PHY_SIG_VBUSVLDEXT_FORCE_EN); + udelay(10000); + clear32(regs.phy + USB2PHY_CTL, USB2PHY_CTL_SIDDQ); + udelay(10); + clear32(regs.phy + USB2PHY_CTL, USB2PHY_CTL_RESET | USB2PHY_CTL_PORT_RESET); + /* No USB2 event-counter/"digital" write: the generic bring-up that qualified 480 Mb/s on the + * J616s never touched atc-phy0 reg 1 (the M5 does this on its separate digital bank). */ + set32(regs.phy + USB2PHY_CTL, USB2PHY_CTL_APB_RESET_N); + clear32(regs.phy + USB2PHY_MISCTUNE, + USB2PHY_MISCTUNE_APBCLK_GATE_OFF | USB2PHY_MISCTUNE_REFCLK_GATE_OFF); + udelay(30); + udelay(5000); + mask32(regs.phy + USB2PHY_USBCTL, USB2PHY_USBCTL_USB_MODE, USB2PHY_USBCTL_RUN); + + set32(pipe + PIPEHANDLER_NONSELECTED_OVERRIDE, PIPEHANDLER_DUMMY_PHY_EN); + clear32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_FORCE_CLAMP_EN); + set32(pipe + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_RESET_N); + if (poll32(pipe + PIPEHANDLER_AON_GEN, + PIPEHANDLER_AON_GEN_DWC3_FORCE_CLAMP_EN | PIPEHANDLER_AON_GEN_DWC3_RESET_N, + PIPEHANDLER_AON_GEN_DWC3_RESET_N, 1000) || + (read32(regs.phy + USB2PHY_USBCTL) & USB2PHY_USBCTL_USB_MODE) != USB2PHY_USBCTL_RUN || + (read32(regs.phy + USB2PHY_CTL) & 0xf) != USB2PHY_CTL_APB_RESET_N) { + printf("CDC USB2: T6040 reset/clock setup did not latch\n"); + return NULL; + } + + set_step(4); + dart_dev_t *dart = usb_dart_init(0); /* ADT mapper SID, t8110 on T6040 */ + if (!dart) + return NULL; + dwc3_dev_t *dwc = usb_dwc3_init(regs.dwc, dart); + if (!dwc) + return NULL; + printf("CDC USB2: T6040 controller initialized, PIPE=%x; link unverified\n", + read32(pipe + PIPEHANDLER_MUX_CTRL)); + return dwc; +} + /* * The ADT marks ports that must never run as a USB device with usb-device-disable, for * example the J773 front ports, whose hub prohibits device mode. Leave those alone. @@ -707,8 +864,13 @@ int usb_cdc_link_start(void (*set_step)(unsigned step), bool force_swapped) struct iodev *device = memalign(SPINLOCK_ALIGN, sizeof(*device)); if (!device) return -1; - dwc3_dev_t *dwc = - usb_cdc_deferred_usb2() ? usb_t6050_init(set_step) : usb_t8152_init(set_step); + dwc3_dev_t *dwc; + if (!usb_cdc_deferred_usb2()) + dwc = usb_t8152_init(set_step); + else if (chip_id == T6040) + dwc = usb_t6040_init(set_step); + else + dwc = usb_t6050_init(set_step); if (!dwc) { free(device); return -1; From ea1e97cd4b78a1c1e1bb0f1f46dceec30e68e8d1 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:13:01 +1100 Subject: [PATCH 2/8] usb: fix the T6040 CDC handoff PIPE route and PHY role 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). Co-Authored-By: Claude Opus 5.5 --- src/usb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/usb.c b/src/usb.c index 99d3f4b31..9037214c9 100644 --- a/src/usb.c +++ b/src/usb.c @@ -407,10 +407,15 @@ static dwc3_dev_t *usb_t6040_init(void (*set_step)(unsigned step)) udelay(10); mask32(pipe + PIPEHANDLER_MUX_CTRL, 3, 2); udelay(10); - mask32(pipe + PIPEHANDLER_MUX_CTRL, 0x70, 0x40); + /* T6040's MUX_CTRL has no bit 6: the M5's 0x42 reads back 0x02 here (J616s hardware row, + * 2026-11-19). The dummy USB2 route is 0x22, the value the generic port bring-up writes. */ + mask32(pipe + PIPEHANDLER_MUX_CTRL, 0x70, PIPEHANDLER_MUX_CTRL_DUMMY & 0x70); udelay(10); - if ((read32(pipe + PIPEHANDLER_MUX_CTRL) & 0x73) != 0x42) + if ((read32(pipe + PIPEHANDLER_MUX_CTRL) & 0x73) != PIPEHANDLER_MUX_CTRL_DUMMY) { + printf("CDC USB2: T6040 PIPE mux did not latch (mux=%x)\n", + read32(pipe + PIPEHANDLER_MUX_CTRL)); return NULL; + } set_step(3); if (tunables_apply_compact_addr("/arm-io/atc-phy0", "tunable_USB2PHY_DFLT", regs.phy, @@ -418,6 +423,9 @@ static dwc3_dev_t *usb_t6040_init(void (*set_step)(unsigned step)) tunables_apply_compact_addr("/arm-io/atc-phy0", "tunable_USB2PHY_DEV", regs.phy, regs.phy_size)) return NULL; + /* The J616s tunables leave the PHY in host mode (SIG read 0x01c0700f after them on hardware, + * 2026-11-19): no device pull-up, so the host never sees a connect. Device mode clears it. */ + clear32(regs.phy + USB2PHY_SIG, USB2PHY_SIG_HOST); set32(regs.phy + USB2PHY_SIG, USB2PHY_SIG_VBUSDET_FORCE_VAL | USB2PHY_SIG_VBUSDET_FORCE_EN | USB2PHY_SIG_VBUSVLDEXT_FORCE_VAL | USB2PHY_SIG_VBUSVLDEXT_FORCE_EN); From 11fcc66e581f867b29574032226e1c58dbb7ab02 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:13:01 +1100 Subject: [PATCH 3/8] usb: support full-speed hosts on the USB2 CDC gadget 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). Co-Authored-By: Claude Opus 5.5 --- src/proxy.c | 2 +- src/usb_cdc.c | 8 +++-- src/usb_cdc.h | 3 ++ src/usb_dwc3.c | 2 ++ src/usb_dwc3.h | 6 ++++ src/usb_dwc3_impl.inc | 70 +++++++++++++++++++++++++++++++++++++++---- 6 files changed, 82 insertions(+), 9 deletions(-) diff --git a/src/proxy.c b/src/proxy.c index f924dffa9..50fd9e2f0 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -504,7 +504,7 @@ int proxy_process(ProxyRequest *request, ProxyReply *reply) break; case P_CDC_SCHEDULE: - if (request->args[0] > 15000 || request->args[1] || request->args[2] > 7 || + if (request->args[0] > 15000 || request->args[1] || request->args[2] > 0xf || usb_cdc_schedule(request->args[0], request->args[1], request->args[2])) reply->status = S_ERROR; break; diff --git a/src/usb_cdc.c b/src/usb_cdc.c index 849475ab5..545aef471 100644 --- a/src/usb_cdc.c +++ b/src/usb_cdc.c @@ -8,6 +8,7 @@ #include "usb.h" #include "usb_cdc.h" #include "usb_cdc_state.h" +#include "usb_dwc3.h" #include "utils.h" #include "wdt.h" @@ -66,9 +67,12 @@ static void cdc_set_step(unsigned step) int usb_cdc_schedule(u32 delay_ms, u32 reserved, u32 flags) { if (usb2_target()) { - /* Explicit USB2 transition only: no HPM reset, lane swap or watchdog. */ - if (flags || reserved || cdc.state != USB_CDC_IDLE || delay_ms < 1000 || delay_ms > 15000) + /* Explicit USB2 transition only: no HPM reset, lane swap or watchdog. The one + * accepted flag advertises full speed (12 Mb/s) instead of high speed. */ + if ((flags & ~USB_CDC_USB2_FULL_SPEED) || reserved || cdc.state != USB_CDC_IDLE || + delay_ms < 1000 || delay_ms > 15000) return -1; + usb_dwc3_usb2_full_speed = !!(flags & USB_CDC_USB2_FULL_SPEED); cdc.deadline_ms = ticks_to_msecs(get_ticks()) + delay_ms; cdc.state = USB_CDC_SCHEDULED; return 0; diff --git a/src/usb_cdc.h b/src/usb_cdc.h index be42a9cc1..08edd2f15 100644 --- a/src/usb_cdc.h +++ b/src/usb_cdc.h @@ -4,6 +4,9 @@ #include "types.h" +/* USB2 targets (usb2_target()): the only flag they accept. T8140 uses bits 0-2. */ +#define USB_CDC_USB2_FULL_SPEED BIT(3) + int usb_cdc_schedule(u32 delay_ms, u32 reserved, u32 flags); u32 usb_cdc_status(void); void usb_cdc_poll(void); diff --git a/src/usb_dwc3.c b/src/usb_dwc3.c index 0821d596a..78142d0e9 100644 --- a/src/usb_dwc3.c +++ b/src/usb_dwc3.c @@ -3,6 +3,8 @@ #include "usb_dwc3.h" #include "malloc.h" +bool usb_dwc3_usb2_full_speed; + typedef struct dwc3_hs_dev dwc3_hs_dev_t; dwc3_hs_dev_t *usb_dwc3_hs_init(uintptr_t regs, dart_dev_t *dart); bool usb_dwc3_hs_shutdown(dwc3_hs_dev_t *dev); diff --git a/src/usb_dwc3.h b/src/usb_dwc3.h index 9eb196503..a69780bcb 100644 --- a/src/usb_dwc3.h +++ b/src/usb_dwc3.h @@ -15,6 +15,12 @@ typedef enum _cdc_acm_pipe_id_t { } cdc_acm_pipe_id_t; dwc3_dev_t *usb_dwc3_init(uintptr_t regs, dart_dev_t *dart); +/* + * USB2 (high-speed engine) only: advertise full speed instead of high speed on the next + * usb_dwc3_init(). Hosts or hubs limited to 12 Mb/s get the same CDC device either way; the + * bulk endpoints follow the speed the host actually connected at. + */ +extern bool usb_dwc3_usb2_full_speed; dwc3_dev_t *usb_dwc3_init_mode(uintptr_t regs, dart_dev_t *dart, bool superspeed); /* False when the controller may still reach its DMA buffers; they are then retained. */ bool usb_dwc3_shutdown(dwc3_dev_t *dev); diff --git a/src/usb_dwc3_impl.inc b/src/usb_dwc3_impl.inc index 8f0f0dd53..43555e8bb 100644 --- a/src/usb_dwc3_impl.inc +++ b/src/usb_dwc3_impl.inc @@ -49,6 +49,7 @@ #define DWC3_EP0_MAX_DESC_LEN 62 #define CDC_BULK_PACKET_SIZE 512 #define CDC_CONTROL_PACKET_SIZE 64 +#define CDC_FS_BULK_PACKET_SIZE 64 #endif #define CDC_DEVICE_CLASS 0x02 @@ -134,6 +135,10 @@ typedef struct dwc3_dev { bool dma_unsafe; /* usb_dwc3_shutdown() is retiring transfers: only their completions are handled */ bool shutting_down; +#if !USB_DWC3_SUPERSPEED + /* Bulk max packet size for the connected speed: 512 at high speed, 64 at full speed. */ + u16 bulk_mps; +#endif #if USB_DWC3_SUPERSPEED bool reset_in_progress; bool ep0_progressed_during_reset; @@ -515,6 +520,20 @@ static int usb_dwc3_retire_transfer(dwc3_dev_t *dev, u8 ep) return 0; } +#if !USB_DWC3_SUPERSPEED +/* DEPCFG "modify" action: change an initialized, not yet enabled bulk endpoint's packet size. */ +#define DWC3_DEPCFG_ACTION_MODIFY (2 << 30) +static int usb_dwc3_ep_reconfigure_mps(dwc3_dev_t *dev, u8 ep, u32 max_packet_len) +{ + u32 param0 = DWC3_DEPCFG_EP_TYPE(DWC3_DEPCMD_TYPE_BULK) | + DWC3_DEPCFG_MAX_PACKET_SIZE(max_packet_len) | DWC3_DEPCFG_FIFO_NUMBER(ep) | + DWC3_DEPCFG_ACTION_MODIFY; + u32 param1 = + DWC3_DEPCFG_XFER_COMPLETE_EN | DWC3_DEPCFG_XFER_NOT_READY_EN | DWC3_DEPCFG_EP_NUMBER(ep); + return usb_dwc3_ep_command(dev, ep, DWC3_DEPCMD_SETEPCONFIG, param0, param1, 0); +} +#endif + static int usb_dwc3_ep_configure(dwc3_dev_t *dev, u8 ep, u8 type, u32 max_packet_len) { u32 param0, param1; @@ -813,6 +832,29 @@ static void usb_cdc_get_string_descriptor(u32 index, const void **descriptor, u1 *descriptor_len = min(*descriptor_len, DWC3_EP0_MAX_DESC_LEN); } +#if !USB_DWC3_SUPERSPEED +/* The configuration descriptor with bulk packet sizes for the connected speed. */ +static const void *usb_dwc3_cdc_config_for(dwc3_dev_t *dev) +{ + static u8 fs[sizeof(struct cdc_dev_desc)] ALIGNED(4); + static const size_t bulk[] = { + offsetof(struct cdc_dev_desc, endpoint_data_in), + offsetof(struct cdc_dev_desc, endpoint_data_out), + offsetof(struct cdc_dev_desc, sec_endpoint_data_in), + offsetof(struct cdc_dev_desc, sec_endpoint_data_out), + }; + u16 mps = dev->bulk_mps; + + if (mps == CDC_BULK_PACKET_SIZE) + return &cdc_configuration_descriptor; + memcpy(fs, &cdc_configuration_descriptor, sizeof(fs)); + for (size_t i = 0; i < ARRAY_SIZE(bulk); i++) + memcpy(fs + bulk[i] + offsetof(struct usb_endpoint_descriptor, wMaxPacketSize), &mps, + sizeof(mps)); + return fs; +} +#endif + static int usb_dwc3_handle_ep0_get_descriptor(dwc3_dev_t *dev, const struct usb_setup_packet_get_descriptor *get_descriptor) @@ -835,7 +877,7 @@ usb_dwc3_handle_ep0_get_descriptor(dwc3_dev_t *dev, descriptor = usb_cdc_ss_configuration; descriptor_len = usb_cdc_ss_configuration_len; #else - descriptor = &cdc_configuration_descriptor; + descriptor = usb_dwc3_cdc_config_for(dev); descriptor_len = cdc_configuration_descriptor.configuration.wTotalLength; #endif break; @@ -1301,7 +1343,11 @@ static void usb_dwc3_cdc_start_bulk_in_xfer(dwc3_dev_t *dev, u8 endpoint_number) device2host->read = previous_read; return; } +#if USB_DWC3_SUPERSPEED dev->endpoints[endpoint_number].zlp_pending = len && (len % CDC_BULK_PACKET_SIZE) == 0; +#else + dev->endpoints[endpoint_number].zlp_pending = len && (len % dev->bulk_mps) == 0; +#endif } static bool usb_dwc3_cdc_copy_bulk_out_progress(dwc3_dev_t *dev, u8 ep) @@ -1609,11 +1655,21 @@ static void usb_dwc3_handle_event_connect_done(dwc3_dev_t *dev) return; } #else - if (speed != DWC3_DSTS_HIGHSPEED) { - usb_debug_printf( - "WARNING: we only support high speed right now but %02x was requested in DSTS\n", - speed); + bool full_speed = speed == DWC3_DSTS_FULLSPEED1 || speed == DWC3_DSTS_FULLSPEED2; + if (!full_speed && speed != DWC3_DSTS_HIGHSPEED) { + usb_debug_printf("WARNING: unsupported USB2 speed %02x in DSTS\n", speed); + } + u16 bulk_mps = full_speed ? CDC_FS_BULK_PACKET_SIZE : CDC_BULK_PACKET_SIZE; + if (bulk_mps != dev->bulk_mps) { + /* USB 2.0 9.6.6: full-speed bulk endpoints carry at most 64 bytes per packet. */ + for (int i = 0; i < CDC_ACM_PIPE_MAX; i++) { + if (usb_dwc3_ep_reconfigure_mps(dev, dev->pipe[i].ep_in, bulk_mps) || + usb_dwc3_ep_reconfigure_mps(dev, dev->pipe[i].ep_out, bulk_mps)) + usb_debug_printf("cannot resize bulk endpoints for speed %02x\n", speed); + } + dev->bulk_mps = bulk_mps; } + usb_debug_printf("CDC USB2: connected at %s speed\n", full_speed ? "full" : "high"); #endif if (!dev->endpoints[USB_LEP_CTRL_OUT].xfer_in_progress && @@ -1936,7 +1992,9 @@ dwc3_dev_t *usb_dwc3_init(uintptr_t regs, dart_dev_t *dart) #if USB_DWC3_SUPERSPEED mask32(dev->regs + DWC3_DCFG, DWC3_DCFG_SPEED_MASK, DWC3_DCFG_SUPERSPEED); #else - mask32(dev->regs + DWC3_DCFG, DWC3_DCFG_SPEED_MASK, DWC3_DCFG_HIGHSPEED); + dev->bulk_mps = CDC_BULK_PACKET_SIZE; + mask32(dev->regs + DWC3_DCFG, DWC3_DCFG_SPEED_MASK, + usb_dwc3_usb2_full_speed ? DWC3_DCFG_FULLSPEED2 : DWC3_DCFG_HIGHSPEED); #endif /* setup scratchpad at SCRATCHPAD_IOVA */ From a09e30d3448e9d50ed274e816654f540f121a3b4 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:19:37 +1100 Subject: [PATCH 4/8] tests: cover full-speed bulk sizing in the USB HS session harness 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. Co-Authored-By: Claude Opus 5.5 --- tests/python/test_usb_hs_session.py | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/python/test_usb_hs_session.py b/tests/python/test_usb_hs_session.py index ff44dd92e..3cbdae622 100644 --- a/tests/python/test_usb_hs_session.py +++ b/tests/python/test_usb_hs_session.py @@ -37,7 +37,7 @@ def macro(source, name): #include #include #include -typedef uint8_t u8; typedef uint32_t u32; typedef uint64_t u64; +typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; #define USB_DWC3_SUPERSPEED 0 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define MAX_ENDPOINTS 6 @@ -51,6 +51,10 @@ def macro(source, name): #define DWC3_DSTS 8 #define DWC3_DSTS_CONNECTSPD 7 #define DWC3_DSTS_HIGHSPEED 0 +#define DWC3_DSTS_FULLSPEED2 1 +#define DWC3_DSTS_FULLSPEED1 3 +#define CDC_BULK_PACKET_SIZE 512 +#define CDC_FS_BULK_PACKET_SIZE 64 #define DWC3_DCFG_DEVADDR_MASK 127 #define DWC3_DCFG_DEVADDR(x) (x) #define DWC3_DALEPENA_EP(x) (1U << (x)) @@ -70,7 +74,7 @@ def macro(source, name): typedef struct {size_t read, write;} ringbuffer_t; struct endpoint {bool xfer_in_progress, zlp_pending, stalled; int resource_index, trb_count, completed_trbs, transfer_length; unsigned char xfer_buffer[16]; struct dwc3_trb trb[2];}; -typedef struct {unsigned regs; bool failed; int ep0_state; struct endpoint endpoints[MAX_ENDPOINTS]; +typedef struct {unsigned regs; bool failed; int ep0_state; u16 bulk_mps; struct endpoint endpoints[MAX_ENDPOINTS]; struct {bool ready; ringbuffer_t *host2device, *device2host; u8 ep_in, ep_out;} pipe[2];} dwc3_dev_t; /* Controller model. */ @@ -82,7 +86,11 @@ def macro(source, name): static u64 now_ms; static void mask32(unsigned reg, unsigned mask, unsigned value) {(void)mask; if (reg == DWC3_DCFG) address = value;} static void write32(unsigned reg, unsigned value) {if (reg == DWC3_DALEPENA) enabled = value;} -static u32 read32(unsigned reg) {(void)reg; return DWC3_DSTS_HIGHSPEED;} +static u32 dsts_speed = DWC3_DSTS_HIGHSPEED; +static u32 read32(unsigned reg) {(void)reg; return dsts_speed;} +/* Bulk endpoint resizes (DEPCFG modify): count and last packet size. */ +static int resizes; static u32 resized_mps; +static int usb_dwc3_ep_reconfigure_mps(dwc3_dev_t *d, u8 ep, u32 mps) {(void)d; assert(ep == 4 || ep == 5 || ep == 0); resizes++; resized_mps = mps; return 0;} static int usb_dwc3_end_transfer(dwc3_dev_t *d, int ep) {(void)d; assert(address == 0 && enabled == 3); hw_owned[ep] = false; ends++; return 0;} static void usb_dwc3_ep_set_stall(dwc3_dev_t *d, int ep, int value) {assert(!value); d->endpoints[ep].stalled = false;} static int usb_dwc3_start_setup_phase(dwc3_dev_t *d) { @@ -113,6 +121,7 @@ def macro(source, name): memset(&d, 0, sizeof(d)); memset(hw_owned, 0, sizeof(hw_owned)); ends = setup_starts = setup_failures = out_arms = in_kicks = events_polled = 0; address = 29; enabled = 63; now_ms = 0; close_after = -1; stuck_ms = 0; chip_id = T8122; + d.bulk_mps = CDC_BULK_PACKET_SIZE; dsts_speed = DWC3_DSTS_HIGHSPEED; resizes = 0; resized_mps = 0; for (int i = 0; i < 2; i++) { d.pipe[i].ready = true; d.pipe[i].host2device = &rb[2 * i]; d.pipe[i].device2host = &rb[2 * i + 1]; rb[2 * i] = (ringbuffer_t){0, 0}; rb[2 * i + 1] = (ringbuffer_t){0, 0}; @@ -174,7 +183,24 @@ def macro(source, name): setup(); assert(usb_dwc3_can_read(&d, 0) == 0 && out_arms == 1); d.pipe[0].ready = false; assert(usb_dwc3_can_read(&d, 0) == 0 && out_arms == 1); - puts("USB HS session: reset, disconnect and closed-pipe loops PASS"); + /* High speed keeps the 512-byte bulk endpoints untouched. */ + setup(); idle_with_setup_armed(); + dev_event(DWC3_DEVT_USBRST); dev_event(DWC3_DEVT_CONNECTDONE); + assert(d.bulk_mps == CDC_BULK_PACKET_SIZE && !resizes); + /* A full-speed host gets 64-byte bulk endpoints on every pipe; SETUP still re-arms. */ + for (u32 fs = DWC3_DSTS_FULLSPEED2; fs <= DWC3_DSTS_FULLSPEED1; fs += 2) { + setup(); idle_with_setup_armed(); dsts_speed = fs; + dev_event(DWC3_DEVT_USBRST); dev_event(DWC3_DEVT_CONNECTDONE); + assert(d.bulk_mps == CDC_FS_BULK_PACKET_SIZE && resizes == 2 * CDC_ACM_PIPE_MAX); + assert(resized_mps == CDC_FS_BULK_PACKET_SIZE && !setup_failures); + assert(setup_completion_seen(&d)); + /* A later high-speed connect restores 512. */ + dsts_speed = DWC3_DSTS_HIGHSPEED; + dev_event(DWC3_DEVT_USBRST); dev_event(DWC3_DEVT_CONNECTDONE); + assert(d.bulk_mps == CDC_BULK_PACKET_SIZE && resized_mps == CDC_BULK_PACKET_SIZE); + } + + puts("USB HS session: reset, disconnect, closed-pipe and full-speed loops PASS"); return 0; } ''' From 1d34eaef189a48c9ec6376bb1003f855b586e93e Mon Sep 17 00:00:00 2001 From: Ryan <81541646+RyanTheTide@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:35:02 +1100 Subject: [PATCH 5/8] usb: select the T6040 CDC handoff by the ATC0 PHY compatible 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 --- src/usb.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/usb.c b/src/usb.c index 9037214c9..4caa8d5b7 100644 --- a/src/usb.c +++ b/src/usb.c @@ -131,15 +131,19 @@ static int usb_drd_adt_offset(u32 idx, char drd_path[sizeof(FMT_DRD_PATH)], int return offset; } -/* The J616s (T6040) Mac mini's ATC0 is the tether/debug port. Scope the explicit CDC handoff to - * this board so other T6040 (J614s) and T6041 (M4 Max J614c/J616c) machines keep the generic path. - */ -static bool usb_cdc_j616s(void) +/* ATC0 is the tether/debug port. Select the T6040 explicit USB2 handoff by the port's PHY IP + * revision in the ADT, not by board: any machine whose atc-phy0 is atc-phy,t6040 gets it (proven + * on the J616s, the 16-inch M4 Pro MacBook Pro), and usb_t6040_get_regs() still refuses a port + * whose DRD, DART or register layout does not match. */ +static bool usb_atc0_phy_is_t6040(void) { - return chip_id == T6040 && board_id == 6 && adt && adt_is_compatible(adt, 0, "J616sAP"); + if (!adt) + return false; + int node = adt_path_offset(adt, "/arm-io/atc-phy0"); + return node >= 0 && adt_is_compatible(adt, node, "atc-phy,t6040"); } -/* T6050 and the J616s T6040 have a different PIPE clock field. Never run the older automatic +/* The T6050 and T6040 ATC PHYs have a different PIPE clock field. Never run the older automatic * gadget initialization on them, including when the explicit setup is refused. */ bool usb_cdc_deferred_usb2(void) { @@ -153,10 +157,9 @@ bool usb_cdc_deferred_usb2(void) * The J714c (M5 Max) enumerates through the generic gadget path on every port, as the * omacom m1n1 Stage 1 does there; the explicit port-0 setup never comes up on it. */ - deferred = - node >= 0 && ((adt_is_compatible(adt, node, "atc-phy,t6050") && - !adt_is_compatible(adt, 0, "J714cAP")) || - (adt_is_compatible(adt, node, "atc-phy,t6040") && usb_cdc_j616s())); + deferred = node >= 0 && ((adt_is_compatible(adt, node, "atc-phy,t6050") && + !adt_is_compatible(adt, 0, "J714cAP")) || + adt_is_compatible(adt, node, "atc-phy,t6040")); } return deferred; } @@ -311,7 +314,7 @@ static dwc3_dev_t *usb_t6050_init(void (*set_step)(unsigned step)) return dwc; } -/* The J616s (T6040) tether/debug port. ATC0 USB-drd0/dart-usb0/atc-phy0 are the same roles as the +/* The T6040 ATC0 tether/debug port. ATC0 USB-drd0/dart-usb0/atc-phy0 are the same roles as the * M5's, so this mirrors usb_t6050_init: resolve the DWC3 core (usb-drd0 reg 0), the PIPEHANDLER * (usb-drd0 reg 3), the USB2 PHY (atc-phy0 reg 0) and the T8110 DART (dart-usb0 reg 1, mapper SID) * from the ADT, validate by compatible and size, then park the dummy PIPE and bring up the USB2 @@ -875,7 +878,7 @@ int usb_cdc_link_start(void (*set_step)(unsigned step), bool force_swapped) dwc3_dev_t *dwc; if (!usb_cdc_deferred_usb2()) dwc = usb_t8152_init(set_step); - else if (chip_id == T6040) + else if (usb_atc0_phy_is_t6040()) dwc = usb_t6040_init(set_step); else dwc = usb_t6050_init(set_step); From 456b58fd5789ac9be91069ad114a48ae202e8413 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:59:18 +1100 Subject: [PATCH 6/8] usb: drop the CDC link when a full-speed endpoint resize fails 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 --- src/usb_dwc3_impl.inc | 8 +++++++- tests/python/test_usb_hs_session.py | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/usb_dwc3_impl.inc b/src/usb_dwc3_impl.inc index 43555e8bb..1265fcd68 100644 --- a/src/usb_dwc3_impl.inc +++ b/src/usb_dwc3_impl.inc @@ -1664,8 +1664,14 @@ static void usb_dwc3_handle_event_connect_done(dwc3_dev_t *dev) /* USB 2.0 9.6.6: full-speed bulk endpoints carry at most 64 bytes per packet. */ for (int i = 0; i < CDC_ACM_PIPE_MAX; i++) { if (usb_dwc3_ep_reconfigure_mps(dev, dev->pipe[i].ep_in, bulk_mps) || - usb_dwc3_ep_reconfigure_mps(dev, dev->pipe[i].ep_out, bulk_mps)) + usb_dwc3_ep_reconfigure_mps(dev, dev->pipe[i].ep_out, bulk_mps)) { + /* The descriptors would advertise a packet size the endpoints do not have: + * drop the link rather than run with mismatched bulk endpoints. */ usb_debug_printf("cannot resize bulk endpoints for speed %02x\n", speed); + clear32(dev->regs + DWC3_DCTL, DWC3_DCTL_RUN_STOP); + usb_cdc_link_failed(); + return; + } } dev->bulk_mps = bulk_mps; } diff --git a/tests/python/test_usb_hs_session.py b/tests/python/test_usb_hs_session.py index 3cbdae622..b379d10e0 100644 --- a/tests/python/test_usb_hs_session.py +++ b/tests/python/test_usb_hs_session.py @@ -49,6 +49,8 @@ def macro(source, name): #define DWC3_DCFG 0 #define DWC3_DALEPENA 4 #define DWC3_DSTS 8 +#define DWC3_DCTL 12 +#define DWC3_DCTL_RUN_STOP (1U << 31) #define DWC3_DSTS_CONNECTSPD 7 #define DWC3_DSTS_HIGHSPEED 0 #define DWC3_DSTS_FULLSPEED2 1 @@ -90,7 +92,10 @@ def macro(source, name): static u32 read32(unsigned reg) {(void)reg; return dsts_speed;} /* Bulk endpoint resizes (DEPCFG modify): count and last packet size. */ static int resizes; static u32 resized_mps; -static int usb_dwc3_ep_reconfigure_mps(dwc3_dev_t *d, u8 ep, u32 mps) {(void)d; assert(ep == 4 || ep == 5 || ep == 0); resizes++; resized_mps = mps; return 0;} +static int resize_fail, link_failures; static bool run_stop = true; +static int usb_dwc3_ep_reconfigure_mps(dwc3_dev_t *d, u8 ep, u32 mps) {(void)d; assert(ep == 4 || ep == 5 || ep == 0); if (resize_fail) return -1; resizes++; resized_mps = mps; return 0;} +static void clear32(unsigned reg, unsigned mask) {if (reg == DWC3_DCTL && (mask & DWC3_DCTL_RUN_STOP)) run_stop = false;} +static void usb_cdc_link_failed(void) {link_failures++;} static int usb_dwc3_end_transfer(dwc3_dev_t *d, int ep) {(void)d; assert(address == 0 && enabled == 3); hw_owned[ep] = false; ends++; return 0;} static void usb_dwc3_ep_set_stall(dwc3_dev_t *d, int ep, int value) {assert(!value); d->endpoints[ep].stalled = false;} static int usb_dwc3_start_setup_phase(dwc3_dev_t *d) { @@ -200,7 +205,13 @@ def macro(source, name): assert(d.bulk_mps == CDC_BULK_PACKET_SIZE && resized_mps == CDC_BULK_PACKET_SIZE); } - puts("USB HS session: reset, disconnect, closed-pipe and full-speed loops PASS"); + /* A resize that fails drops the link instead of advertising sizes the endpoints lack. */ + setup(); idle_with_setup_armed(); dsts_speed = DWC3_DSTS_FULLSPEED1; resize_fail = 1; + dev_event(DWC3_DEVT_USBRST); dev_event(DWC3_DEVT_CONNECTDONE); + assert(link_failures == 1 && !run_stop && d.bulk_mps == CDC_BULK_PACKET_SIZE); + resize_fail = 0; run_stop = true; dsts_speed = DWC3_DSTS_HIGHSPEED; + + puts("USB HS session: reset, disconnect, closed-pipe, full-speed and resize-failure loops PASS"); return 0; } ''' From d33f3196fea7c393a11a7b2805f6cc7a3a04d3d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:37:18 +0000 Subject: [PATCH 7/8] gfya Aurora agent policy: remove assistant instruction files that are not copies of .github/aurora/AGENTS.md on main, and keep the copies on policy branches identical to it. --- .github/copilot-instructions.md | 28 ---------------------------- AGENTS.md | 28 ---------------------------- CLAUDE.md | 28 ---------------------------- GEMINI.md | 28 ---------------------------- 4 files changed, 112 deletions(-) delete mode 100644 .github/copilot-instructions.md delete mode 100644 AGENTS.md delete mode 100644 CLAUDE.md delete mode 100644 GEMINI.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index 95c6d4574..000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,28 +0,0 @@ -# Aurora Silicon assistant policy - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Rules - -- Only public code goes in. Never copy code from proprietary sources. -- Changes are tested on the hardware they affect before they are merged. - -## Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 95c6d4574..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,28 +0,0 @@ -# Aurora Silicon assistant policy - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Rules - -- Only public code goes in. Never copy code from proprietary sources. -- Changes are tested on the hardware they affect before they are merged. - -## Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 95c6d4574..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,28 +0,0 @@ -# Aurora Silicon assistant policy - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Rules - -- Only public code goes in. Never copy code from proprietary sources. -- Changes are tested on the hardware they affect before they are merged. - -## Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. diff --git a/GEMINI.md b/GEMINI.md deleted file mode 100644 index 95c6d4574..000000000 --- a/GEMINI.md +++ /dev/null @@ -1,28 +0,0 @@ -# Aurora Silicon assistant policy - -This is Aurora Silicon's own policy for AI coding assistants working in -this repository. It is the only assistant instruction file this tree -carries. Upstream projects' instruction files are never carried here. - -AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are -copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow -puts them back if anything else replaces them, including an upstream -merge. To change the policy, edit .github/aurora/AGENTS.md. - -## Rules - -- Only public code goes in. Never copy code from proprietary sources. -- Changes are tested on the hardware they affect before they are merged. - -## Testing and collaboration - -- Use the Context Mode plugin whenever it can reduce low-signal output. -- Fan independent work out to isolated agents and preserve unrelated worktrees. -- Never write unit tests after you write code. -- Highly prefer E2E tests as the sole testing mechanism. Use them to verify - complex features work. At the end of E2E tests, produce a verifiable and - repeatable artifact. -- If you must test a system in isolation, first write down all the ways it - could fail, then write the code. -- Delete low-signal unit tests that would not catch a real bug missed by E2E - tests. Preserve tests that provide distinct failure coverage. From dff7d43427eba35ea8e31acfc65d5886cd4a7a34 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Tue, 24 Nov 2026 15:48:58 -0500 Subject: [PATCH 8/8] Revert "gfya" Revert the automated agent-policy bot commit d33f3196fea7c393a11a7b2805f6cc7a3a04d3d0 that deleted assistant instruction files on this PR branch. The policy workflow has since been updated (aura#475) to stop pushing to PR branches. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- .github/copilot-instructions.md | 28 ++++++++++++++++++++++++++++ AGENTS.md | 28 ++++++++++++++++++++++++++++ CLAUDE.md | 28 ++++++++++++++++++++++++++++ GEMINI.md | 28 ++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 .github/copilot-instructions.md create mode 100644 AGENTS.md create mode 100644 CLAUDE.md create mode 100644 GEMINI.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..95c6d4574 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,28 @@ +# Aurora Silicon assistant policy + +This is Aurora Silicon's own policy for AI coding assistants working in +this repository. It is the only assistant instruction file this tree +carries. Upstream projects' instruction files are never carried here. + +AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are +copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow +puts them back if anything else replaces them, including an upstream +merge. To change the policy, edit .github/aurora/AGENTS.md. + +## Rules + +- Only public code goes in. Never copy code from proprietary sources. +- Changes are tested on the hardware they affect before they are merged. + +## Testing and collaboration + +- Use the Context Mode plugin whenever it can reduce low-signal output. +- Fan independent work out to isolated agents and preserve unrelated worktrees. +- Never write unit tests after you write code. +- Highly prefer E2E tests as the sole testing mechanism. Use them to verify + complex features work. At the end of E2E tests, produce a verifiable and + repeatable artifact. +- If you must test a system in isolation, first write down all the ways it + could fail, then write the code. +- Delete low-signal unit tests that would not catch a real bug missed by E2E + tests. Preserve tests that provide distinct failure coverage. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..95c6d4574 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,28 @@ +# Aurora Silicon assistant policy + +This is Aurora Silicon's own policy for AI coding assistants working in +this repository. It is the only assistant instruction file this tree +carries. Upstream projects' instruction files are never carried here. + +AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are +copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow +puts them back if anything else replaces them, including an upstream +merge. To change the policy, edit .github/aurora/AGENTS.md. + +## Rules + +- Only public code goes in. Never copy code from proprietary sources. +- Changes are tested on the hardware they affect before they are merged. + +## Testing and collaboration + +- Use the Context Mode plugin whenever it can reduce low-signal output. +- Fan independent work out to isolated agents and preserve unrelated worktrees. +- Never write unit tests after you write code. +- Highly prefer E2E tests as the sole testing mechanism. Use them to verify + complex features work. At the end of E2E tests, produce a verifiable and + repeatable artifact. +- If you must test a system in isolation, first write down all the ways it + could fail, then write the code. +- Delete low-signal unit tests that would not catch a real bug missed by E2E + tests. Preserve tests that provide distinct failure coverage. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..95c6d4574 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,28 @@ +# Aurora Silicon assistant policy + +This is Aurora Silicon's own policy for AI coding assistants working in +this repository. It is the only assistant instruction file this tree +carries. Upstream projects' instruction files are never carried here. + +AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are +copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow +puts them back if anything else replaces them, including an upstream +merge. To change the policy, edit .github/aurora/AGENTS.md. + +## Rules + +- Only public code goes in. Never copy code from proprietary sources. +- Changes are tested on the hardware they affect before they are merged. + +## Testing and collaboration + +- Use the Context Mode plugin whenever it can reduce low-signal output. +- Fan independent work out to isolated agents and preserve unrelated worktrees. +- Never write unit tests after you write code. +- Highly prefer E2E tests as the sole testing mechanism. Use them to verify + complex features work. At the end of E2E tests, produce a verifiable and + repeatable artifact. +- If you must test a system in isolation, first write down all the ways it + could fail, then write the code. +- Delete low-signal unit tests that would not catch a real bug missed by E2E + tests. Preserve tests that provide distinct failure coverage. diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 000000000..95c6d4574 --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,28 @@ +# Aurora Silicon assistant policy + +This is Aurora Silicon's own policy for AI coding assistants working in +this repository. It is the only assistant instruction file this tree +carries. Upstream projects' instruction files are never carried here. + +AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md are +copies of .github/aurora/AGENTS.md. The aurora-agent-policy workflow +puts them back if anything else replaces them, including an upstream +merge. To change the policy, edit .github/aurora/AGENTS.md. + +## Rules + +- Only public code goes in. Never copy code from proprietary sources. +- Changes are tested on the hardware they affect before they are merged. + +## Testing and collaboration + +- Use the Context Mode plugin whenever it can reduce low-signal output. +- Fan independent work out to isolated agents and preserve unrelated worktrees. +- Never write unit tests after you write code. +- Highly prefer E2E tests as the sole testing mechanism. Use them to verify + complex features work. At the end of E2E tests, produce a verifiable and + repeatable artifact. +- If you must test a system in isolation, first write down all the ways it + could fail, then write the code. +- Delete low-signal unit tests that would not catch a real bug missed by E2E + tests. Preserve tests that provide distinct failure coverage.