Conversation
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
There was a problem hiding this comment.
Pull request overview
This PR improves hub enumeration reliability by addressing two edge cases that could cause the hub to become stuck during device enumeration:
-
Graceful handling of EP0 open failures: When
usbh_edpt_control_open()fails (e.g., whenCFG_TUH_FSDEV_ENDPOINT_MAXis exhausted or during quick plug/unplug scenarios), enumeration now stops gracefully by callingenum_full_complete(false)and cleaning up device state, rather than triggering a hard assertion that leaves the hub stuck. -
Earlier hub status transfer initiation: Hub status transfers are now initiated immediately when a device is configured (before driver initialization), rather than waiting until after all drivers complete their
set_config()callbacks. This prevents the hub from getting stuck when a driver'sset_config()fails or stalls (e.g., MSC devices that take time to initialize).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: HiFiPhile <admin@hifiphile.com>
|
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in sizeNo entries. Changes <1% in size
No changes
|
hathach
left a comment
There was a problem hiding this comment.
prefect, thank you, every changes make sense.



Describe the PR
I've made 3 hub enumeration reliability improvements, they works well here but not sure if there are any edge case.
Stop enumeration gracefully if EP0 can't be open
When configured endpoint is not enough,
usbh_edpt_control_open()fails and the hub become stuck.With quick plug/unplug sometimes old endpoint release happens after new endpoint open. Normally my config only needs 15 EPs (3 for hub + 4 for keyboard + 4 for USB key + 4 for FTDI) but I hit
assert(usbh_edpt_control_open())with total 16 EPs.---> Fixed by
#3Start hub status transfer before driver config
At the end of enumeration driver config is launched by
usbh_driver_set_config_complete(), if the device is bouncing and transfer failed,enum_full_complete()is not called (especially MSC needs some time to init) leaving hub in stuck.I've also made
enum_full_complete(bool success)to avoid triggering a 2nd hub status in case of success, which cause some wieldiness stuff.Detach existing device first if an attach event is received
Previously old device is not removed until
ENUM_SET_ADDR, remove the device before EP0 opening can lower endpoint peak usage.