diff options
| author | hathach <[email protected]> | 2026-08-28 00:36:38 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-08-28 00:36:38 +0700 |
| commit | f748c01c4fa1104168a0f3317c37e6586d0027f7 (patch) | |
| tree | 90ddab4dcdc8917c90664ba06e55d79e61b0c71a /src/tusb_option.h | |
| parent | 42db982e7c6e8ee7d2f80d15a93a7092d3b708c9 (diff) | |
usbh: add enumeration control transfer timeoutclaude/usbh-enum-timeout
A device that ACKs SETUP but never completes the following stage (e.g. NAKs
the EP0 IN data stage forever) froze the control state machine: enumeration
never finishes and hub interrupt polling never resumes, so one dead device
blocks all further enumeration on the bus. Observed with a degraded USB disk
behind a hub on a rp2040 PIO-USB host: wire capture shows SETUP ACKed then
an endless IN/NAK storm with no completion event.
Arm a watchdog (CFG_TUH_ENUM_TIMEOUT_MS, default 5s to match Linux's
USB_CTRL_GET_TIMEOUT, 0 disables) on enumeration-owned control transfers
using the existing call_after slot, which already wakes a blocked host task.
On expiry abort the transfer at hcd level and complete it as FAILED so the
normal enumeration failure path frees dev0 and resumes hub polling.
Non-enumeration control transfers keep their current behavior.
Diffstat (limited to 'src/tusb_option.h')
| -rw-r--r-- | src/tusb_option.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tusb_option.h b/src/tusb_option.h index 1eb23fb00..8b3a41a75 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -753,6 +753,13 @@ #define CFG_TUH_ENUMERATION_BUFSIZE 256 #endif + // Timeout in ms for each enumeration control transfer, 0 to wait forever. + // A broken device that ACKs SETUP but never completes the following stage would otherwise + // stall enumeration and hub polling forever. 5s matches Linux's USB_CTRL_GET_TIMEOUT. + #ifndef CFG_TUH_ENUM_TIMEOUT_MS + #define CFG_TUH_ENUM_TIMEOUT_MS 5000 + #endif + #endif // CFG_TUH_ENABLED // Attribute to place data in accessible RAM for host controller (default: CFG_TUSB_MEM_SECTION) |
