usb-host: Replace pre with SplitInfo#5884
Merged
leftger merged 3 commits intoembassy-rs:mainfrom Apr 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the USB host stack to replace the legacy pre: bool (“emit PRE packet”) plumbing with an extensible SplitInfo type, allowing host/HAL drivers and class drivers to carry hub/port routing metadata needed for split transactions and PRE-based routing.
Changes:
- Introduce
SplitInfoinembassy-usb-driverand updateUsbHostDriver::alloc_channel/UsbChannel::retarget_channelto takeOption<SplitInfo>instead ofbool. - Thread
split: Option<SplitInfo>through enumeration (EnumerationInfo) and host-class drivers (HID/CDC ACM/GIP/UAC/KBD/HUB). - Update HAL host driver implementations (STM32 OTG/USBFS, RP2040, Synopsys OTG) to the new signatures, mapping split info to legacy PRE where applicable.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| embassy-usb-driver/src/host.rs | Adds SplitInfo and updates host/channel traits to accept Option<SplitInfo>. |
| embassy-usb-host/src/lib.rs | Updates root-device enumeration to pass None for split routing. |
| embassy-usb-host/src/handler.rs | Replaces ls_over_fs with split: Option<SplitInfo> in EnumerationInfo. |
| embassy-usb-host/src/control.rs | Threads split through enumerate_device() and retarget_channel() calls. |
| embassy-usb-host/src/class/hub.rs | Uses split during hub/device enumeration and when allocating channels behind hubs. |
| embassy-usb-host/src/class/kbd.rs | Passes enum_info.split into channel allocation. |
| embassy-usb-host/src/class/uac/mod.rs | Passes enum_info.split into channel allocation for control/iso endpoints. |
| embassy-usb-host/src/class/hid.rs | Extends HidHost::new to accept split and uses it for channel allocation. |
| embassy-usb-host/src/class/cdc_acm.rs | Extends CdcAcmHost::new to accept split and uses it for channel allocation. |
| embassy-usb-host/src/class/gip.rs | Extends GipHost::new to accept split and uses it for channel allocation. |
| embassy-usb-synopsys-otg/src/host.rs | Updates host driver/channel method signatures to accept split. |
| embassy-stm32/src/usb/usb_host.rs | Updates STM32 USBFS host driver/channel signatures and call sites to accept split. |
| embassy-stm32/src/usb/otg.rs | Updates STM32 OTG wrapper to forward split through. |
| embassy-rp/src/usb/host.rs | Adds split_to_pre() and maps Option<SplitInfo> down to the RP2040 PRE flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
09cb13a to
c9d7aac
Compare
c9d7aac to
59d3c95
Compare
Contributor
|
bender run |
1d6c69c to
f8670b6
Compare
Contributor
|
Apologies @bugadani . I think I created some merge conflicts in the process of merging in previous PRs. When you have time could you help me resolve them? This PR looks good honestly. |
f8670b6 to
63b2436
Compare
63b2436 to
8b10d65
Compare
leftger
added a commit
to leftger/embassy
that referenced
this pull request
Apr 20, 2026
…-rs#5897 review comments - Add SplitInfo/SplitSpeed types from upstream (embassy-rs#5884 usb-host-split-info) - Replace pre: bool with split: Option<SplitInfo> in alloc_channel - Add retarget_channel to UsbChannel trait and all implementations - Move RequestType/SetupPacket from embassy-usb-driver to embassy-usb-host/control.rs with new struct-based API (replacing bitflags approach) per review comment - Change control_in/control_out to take &[u8; 8] instead of &SetupPacket - Remove where T: channel::IsControl constraint from set_timeout - Fix UsbChannel doc link (was broken by super::UsbChannel path) - Add Babble and DataToggleError variants to ChannelError (requested by reviewers) - Update NAK handling docs: bulk retries indefinitely (cancel via drop), control uses configurable timeout via set_timeout - Add data toggle documentation to UsbChannel - Update all class drivers (hub, hid, cdc_acm, uac) to use new API - Add enumerate_device to ControlChannelExt, simplify UsbHost::enumerate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ensures future compatibility with high-speed USB hubs in the host driver. Additionally, enumeration now returns EnumerationInfo (duh) and class constructors consistently take EnumerationInfo to better support connecting through HUBs.