Skip to content

usb-host: Replace pre with SplitInfo#5884

Merged
leftger merged 3 commits intoembassy-rs:mainfrom
bugadani:usb-host-split-info
Apr 19, 2026
Merged

usb-host: Replace pre with SplitInfo#5884
leftger merged 3 commits intoembassy-rs:mainfrom
bugadani:usb-host-split-info

Conversation

@bugadani
Copy link
Copy Markdown
Contributor

@bugadani bugadani commented Apr 17, 2026

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.

Copilot AI review requested due to automatic review settings April 17, 2026 16:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SplitInfo in embassy-usb-driver and update UsbHostDriver::alloc_channel / UsbChannel::retarget_channel to take Option<SplitInfo> instead of bool.
  • 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.

Comment thread embassy-usb-host/src/class/hub.rs Outdated
Comment thread embassy-usb-host/src/class/hid.rs Outdated
Comment thread embassy-usb-host/src/class/cdc_acm.rs Outdated
@bugadani bugadani marked this pull request as draft April 17, 2026 16:34
@bugadani bugadani force-pushed the usb-host-split-info branch 2 times, most recently from 09cb13a to c9d7aac Compare April 17, 2026 17:16
@bugadani bugadani marked this pull request as ready for review April 17, 2026 17:16
@bugadani bugadani force-pushed the usb-host-split-info branch from c9d7aac to 59d3c95 Compare April 17, 2026 18:46
@xoviat
Copy link
Copy Markdown
Contributor

xoviat commented Apr 18, 2026

bender run

@bugadani bugadani force-pushed the usb-host-split-info branch from 1d6c69c to f8670b6 Compare April 18, 2026 13:04
@bugadani bugadani changed the title Replace pre with SplitInfo usb-host: Replace pre with SplitInfo Apr 18, 2026
@leftger leftger added the e-usb-host Issues for USB Host label Apr 19, 2026
@leftger leftger self-assigned this Apr 19, 2026
@leftger
Copy link
Copy Markdown
Contributor

leftger commented Apr 19, 2026

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.

@bugadani bugadani force-pushed the usb-host-split-info branch from f8670b6 to 63b2436 Compare April 19, 2026 07:14
@bugadani bugadani force-pushed the usb-host-split-info branch from 63b2436 to 8b10d65 Compare April 19, 2026 07:17
@leftger leftger added this pull request to the merge queue Apr 19, 2026
Merged via the queue into embassy-rs:main with commit f9d43e4 Apr 19, 2026
7 checks passed
@bugadani bugadani deleted the usb-host-split-info branch April 19, 2026 16:14
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e-usb-host Issues for USB Host

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants