summaryrefslogtreecommitdiff
path: root/examples/device/usbtest/src/main.c
AgeCommit message (Collapse)Author
2026-07-08Add SuperSpeed isochronous support to the CH56x USB3 dcdhathach
The register model comes from disassembling WCH's official USB30 device blob (libCH56x_USB30_device_lib.a): USB30_ISO_Setendp reveals per- endpoint isochronous mode bits in UEP_CFG (bit 16+ep for OUT, bit 24+ep for IN); arming and completion then use the normal endpoint flow. The usbtest example moves back to tier 4 at SuperSpeed with an iso pair in the SS descriptor set - all four kernel usbtest iso cases (15/16/22/23) pass on hardware at 5000M. The endpoint-halt latch from the previous commit is kept (it fixes usbtest case 29); case 13 is now documented as a silicon limitation after exhaustive on-hardware experiments: a halted endpoint answers exactly one probe with a STALL TP and no re-arm strategy (any NUMP, ERDY, 30 us timer re-assertion, endpoint enable bounce) revives it - no event fires per stall TP. The CH32H417's reworked endpoint engine adds a persistent RB_EP_TX_HALT mode, evidently addressing exactly this. Battery results: 30/30 at high speed, 28/30 at SuperSpeed (case 13 = silicon halt limitation; case 14 ctrl_out is intermittent - pre-existing EP0 OUT flakiness under investigation). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019MRGjBT2NBkCoWwyDT4LaE
2026-07-08Pass the usbtest battery on CH569 at high and SuperSpeedhathach
Running the Linux kernel usbtest/testusb battery against the CH569 for the first time. Results: 30/30 at high speed (4 consecutive reflash cycles), 25/26 at SuperSpeed. DCD fixes found by the battery: - dcd_ch56x_usbhs: clear-halt on an armed bulk-OUT pipe reset the toggle but dropped the queued receive, NAKing forever (usbtest case 29 - the same defect previously found on rp2040/fsdev/ch32_usbhs/rusb2) - dcd_ch56x_usb30: endpoint halt is now latched; the endpoint event handler used to clear the response field on every completion, wiping a just-set STALL while the peer streamed, and clear-halt now re-arms a still-armed transfer with the fresh packet sequence (cases 13/29) usbtest example gains SuperSpeed support: tier 3 on SS builds, a 4-endpoint SS descriptor set with companions, EP0 512 config and 1024-byte receive buffers. test/hil/usbtest.py gains SuperSpeed-aware case parameters: bulk sizes and vary steps must be 1024-multiples at SS or the device's whole-packet source overruns the host request (case 4 EOVERFLOW). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019MRGjBT2NBkCoWwyDT4LaE
2026-07-07usbtest: negotiated-speed int/iso refill + harden HIL sudoershathach
Copilot review: - tud_vendor_int_tx_cb/iso_tx_cb submitted sizeof(chunk) (the HS-capacity buffer) instead of the negotiated-speed mps, diverging from usbtest_pump() on an HS-capable build enumerated at full speed. Factor the length into shared usbtest_int_len()/usbtest_iso_len() helpers used by the pump and both callbacks. - Reword the usb_descriptors.h comment that still called the plain mps macro 'live operating speed' — it is the compile-time capability maximum. Claude review (test/hil/tinyusb-sudoer): drop the two grants that bypassed the file's root-owned-helper boundary and gave uid 1000 passwordless root: - /sbin/debugfs (unused; permits '!/bin/sh' shell escape + raw root-disk write). - /home/*/actions-runner/svc.sh (user-writable script). Replace with a root-owned, argument-restricted 'systemctl stop/start actions.runner.*' grant. Also tighten the dmesg/uhubctl runas from (ALL) to (root). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-07address review round 2 (4 fixed, 1 answered)hathach
- dcd(nrf5x): dcd_edpt_iso_activate drops a stale armed transfer (started/ data_received/iso_in_transfer_ready) — there is no dcd close on this port, so a transfer armed before SET_INTERFACE would trip TU_ASSERT(!xfer->started) on the class's next arm after usbd reset the endpoint's claim state. - class(vendor): tud_vendor_n_mounted() counts the interrupt endpoints, so an interrupt-only vendor interface (bulk absent) reports mounted. - example(usbtest): int/iso write lengths follow the negotiated speed (tud_speed_get), not the compile-time capability — a high-speed build enumerated at full speed serves the FS descriptor (mps 64/128) and must not submit HS-sized packets. - test/hil: test_example() return annotation matches the (err, status, metric) 3-tuple it returns. Verified: feather_nrf52840_express and raspberry_pi_pico 30/30 through the HIL battery; pico/feather/ch32v307-usbhs builds clean. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-06usbtest: single-pass pump for the non-FreeRTOS task (SonarCloud ↵hathach
loop-executes-once) Extract the endpoint pump into usbtest_pump(); the FreeRTOS task loops it, the bare-metal path calls it once per main-loop tick instead of a while(1){...return;} whose body can only execute once. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-04feat(usbtest): add FreeRTOS/espressif supporthathach
Mirror the video_capture #if pattern: dual-mode tasks that vTaskDelay under FreeRTOS and return under OS_NONE, a usb_device_task + freertos_init (xTaskCreate blinky/usbd/app), and an ESP_PLATFORM app_main. Add the ESP-IDF src/CMakeLists.txt and CFG_TUSB_OS_INC_PATH; replace the family:espressif skip with per-MCU skips for parts that can't fit the tier-4 descriptor. Verified: esp32s3 (FS) and esp32p4 (HS) both 30/30 on the usbtest battery. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-02example(usbtest): tier 4 - isochronous source/sink (cases 15/16/22/23)hathach
Gadget-Zero parity: alt 0 carries no endpoints, alt 1 the full set (bulk + interrupt + iso IN/OUT, iso FS 128B / HS 512B). The host usbtest driver skips pipe-less altsettings and selects alt 1 itself, so no usbtest module parameters are needed. The complete 30-case battery (all four tiers) passes on stm32f407disco, stm32f723disco, stm32h743nucleo and stm32l476disco, including the ch9 case which now exercises 256 consecutive SET_INTERFACE cycles. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-02example(usbtest): tier 3 - interrupt source/sink (cases 25/26)hathach
The host usbtest driver collects interrupt pipes from the same altsetting as the bulk pair, so the interface grows to 4 endpoints (hand-rolled descriptor: bulk IN/OUT + interrupt IN/OUT, FS 64B interval 1 / HS 512B interval 4) using the vendor class with CFG_TUD_VENDOR_EP_INT_OUT/IN. The interrupt pumps mirror the bulk ones: poll + re-arm from callbacks, self-healing across the halt tests. Full tier-3 battery (26 cases, now incl. 25/26 interrupt write/read) passes on stm32f407disco, stm32f723disco, stm32h743nucleo and stm32l476disco. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-02example(usbtest): tier 2 - vendor control 0x5b/0x5c write/read-backhathach
Gadget-Zero ctrl_out protocol: 0x5b stores the host's wLength bytes in a 1 KiB buffer (multi-packet EP0 data stage), 0x5c returns them for comparison. bcdDevice now advertises tier 2 so the runner adds usbtest cases 14/21. No descriptor change needed: ctrl_out is unlocked by the Gadget Zero capability profile of the dynamic-id binding, not by endpoints (interrupt/iso endpoints come with tiers 3/4). Full tier-2 battery (24 cases) passes on stm32f407disco, stm32f723disco, stm32h743nucleo and stm32l476disco. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-02example(usbtest): add device-side peer for Linux usbtest/testusb (tier 1: ↵hathach
bulk source/sink) Vendor interface with bulk IN source / bulk OUT sink implementing the Gadget-Zero style protocol expected by the kernel usbtest driver. Non-buffered vendor mode keeps every transfer an exact packet multiple so the data-integrity cases never see an unexpected short packet, and polling pumps self-heal after the endpoint-halt cases. Tier (bulk-only for now) is advertised in bcdDevice for the host-side runner. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg