feat(hub): Added support for multiple root ports#389
Conversation
47c5fad to
8d0dbd6
Compare
8d0dbd6 to
ac72ef9
Compare
ac72ef9 to
f709e0f
Compare
peter-marcisovsky
left a comment
There was a problem hiding this comment.
Leaving some minor comments. I tested on the HW, working fine.
f709e0f to
72a169b
Compare
tore-espressif
left a comment
There was a problem hiding this comment.
@peter-marcisovsky thank you for the review! I fixed the easy comments and left few open, PTAL!
72a169b to
843edd7
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
843edd7 to
50cc647
Compare
50cc647 to
f456438
Compare
peter-marcisovsky
left a comment
There was a problem hiding this comment.
LGTM, nice addition. I will test bit more on HW.
f456438 to
74501cf
Compare
|
Before merging this, we should wait for the #393 to be merged and usb component v1.2 released. Not to include this changes to the v1.2 release. |
This will allow having both FS and HS root ports active at the same time and connected devices working properly.
74501cf to
82ace30
Compare
|
Overall the multi-port refactor looks solid. One small robustness suggestion: there are a few places where we rely on assert() / abort() to guard conditions that could potentially be hit in non-debug builds (where asserts may be compiled out). To make this safer in production configs, could we convert those into regular HUB_DRIVER_CHECK(_FROM_CRIT) / graceful error returns (and keep assert() only for true internal invariants)? This would help avoid any chance of a NULL deref or unexpected abort if configuration/state ever deviates. |
This will allow having both FS and HS root ports active at the same time and connected devices working properly.
Note
Medium Risk
Touches core USB host hub/enumeration plumbing and root-port state management, which can affect device attach/detach, enumeration ordering, and suspend/resume behavior across ports. Changes are scoped but concurrency/ISR-driven paths and multi-port edge cases increase regression risk.
Overview
Adds multi-root-port support across the USB host stack. The Hub driver now initializes/powers multiple HCD root ports based on
hub_config->port_map, tracks per-port state/requests, and routes ISR events and recovery/disable actions per root port.Makes devices root-port aware end-to-end. Device tree nodes and
usbh_devs_add()now associate devices with a specificroot_port_hdl, addsusbh_dev_get_root_port_hdl()andext_hub_get_root_port(), and tightens the “address 0” constraint to only conflict within the same root port.Improves enumeration scheduling for multi-port scenarios. Enumeration starts by UID via new
usbh_devs_open_uid(), and adds a small pending-UID queue so concurrent attach events enqueue and enumerate sequentially (returningESP_ERR_NO_MEMif the queue is full).Test/build updates. Moves/standardizes test port/PHY selection macros, adjusts an isoch test to use
TEST_PORT_NUM, bumps a CDC test leak threshold, and adds a Linux mock define forSOC_USB_OTG_PERIPH_NUM.Written by Cursor Bugbot for commit f456438. This will update automatically on new commits. Configure here.