Skip to content

Add embassy-usb-host support#5283

Open
bugadani wants to merge 11 commits intoesp-rs:mainfrom
bugadani:usb-host
Open

Add embassy-usb-host support#5283
bugadani wants to merge 11 commits intoesp-rs:mainfrom
bugadani:usb-host

Conversation

@bugadani
Copy link
Copy Markdown
Contributor

Implementation for embassy-rs/embassy#5633

@bugadani

This comment was marked as outdated.

@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label Mar 31, 2026
@github-actions
Copy link
Copy Markdown

New commits in main has made this PR unmergable. Please resolve the conflicts.

@brezina1
Copy link
Copy Markdown

brezina1 commented Apr 1, 2026

Amazing! Do you also plan on adding UVC device support?

@Dominaezzz
Copy link
Copy Markdown
Collaborator

Amazing! Do you also plan on adding UVC device support?

I think that's a little out of scope for this whole repository 😅

@bugadani
Copy link
Copy Markdown
Contributor Author

bugadani commented Apr 1, 2026

oh I thought that comment was made against the embassy repo 😅 I don't know if I have an appropriate camera, but maybe Claude can draft something up?

@github-actions github-actions Bot added merge-conflict Merge conflict detected. Automatically added/removed by CI. and removed merge-conflict Merge conflict detected. Automatically added/removed by CI. labels Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

New commits in main has made this PR unmergable. Please resolve the conflicts.

@github-actions github-actions Bot removed the merge-conflict Merge conflict detected. Automatically added/removed by CI. label Apr 17, 2026
@bugadani bugadani changed the title Usb host Add embassy-usb-host support May 4, 2026
@bugadani bugadani marked this pull request as ready for review May 4, 2026 07:37
Copilot AI review requested due to automatic review settings May 4, 2026 07:37
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 adds USB OTG FS host-mode support via embassy-usb-host and refactors the existing OTG FS support into a dedicated otg_fs/ module layout, updating examples and metadata to use the new driver modules.

Changes:

  • Introduces esp_hal::otg_fs::embassy_usb_host host controller driver based on embassy-usb-host.
  • Moves the existing embassy USB device-mode integration into esp_hal::otg_fs::embassy_usb_device and updates async examples accordingly.
  • Updates esp-metadata (and generated metadata) to attach the USB peripheral interrupt to USB0.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
examples/async/embassy_usb_serial/src/main.rs Updates import path to the new otg_fs::embassy_usb_device module.
examples/async/embassy_usb_ethernet/src/main.rs Updates import path to the new otg_fs::embassy_usb_device module.
examples/async/embassy_usb_ethernet/Cargo.lock Updates esp-pacs git rev in the example lockfile.
examples/async/embassy_usb_hid_host/src/main.rs Adds a new async HID host example using embassy-usb-host.
examples/async/embassy_usb_hid_host/Cargo.toml Adds a new example crate manifest for the HID host example.
examples/async/embassy_usb_hid_host/.cargo/config.toml Adds example-specific runner/rustflags and build-std config.
esp-metadata/devices/esp32s2.toml Associates USB0 with the USB peripheral interrupt.
esp-metadata/devices/esp32s3.toml Associates USB0 with the USB peripheral interrupt.
esp-metadata-generated/src/_generated_esp32s2.rs Regenerates peripheral interrupt bindings for USB0.
esp-metadata-generated/src/_generated_esp32s3.rs Regenerates peripheral interrupt bindings for USB0.
esp-hal/src/otg_fs/mod.rs New OTG FS module root, factoring common USB peripheral setup and exposing host/device submodules.
esp-hal/src/otg_fs/embassy_usb_device.rs New embassy-usb device-mode driver wrapper with custom init/interrupt binding.
esp-hal/src/otg_fs/embassy_usb_host.rs New embassy-usb-host controller driver and interrupt wiring.
esp-hal/src/otg_fs.rs Removes the previous monolithic OTG FS module file (replaced by otg_fs/).
esp-hal/Cargo.toml Enables embassy-usb-synopsys-otg host feature to support host mode.
esp-hal/CHANGELOG.md Adds changelog entries for host support and the device module move.

Comment thread esp-hal/src/otg_fs/embassy_usb_host.rs Outdated
Comment on lines +14 to +19
on_host_interrupt(
Driver::REGISTERS,
&HOST_STATE,
Usb::MAX_EP_COUNT.min(Usb::MAX_HOST_CH_COUNT),
)
}
Comment thread esp-hal/src/otg_fs/mod.rs Outdated
Comment thread esp-hal/src/otg_fs/mod.rs Outdated
Comment thread esp-hal/src/otg_fs/mod.rs
Comment thread examples/async/embassy_usb_hid_host/src/main.rs Outdated
Comment thread esp-hal/CHANGELOG.md Outdated
Copilot AI review requested due to automatic review settings May 4, 2026 08:52
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

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Comment thread esp-hal/CHANGELOG.md Outdated
Comment thread esp-hal/src/otg_fs/embassy_usb_host.rs Outdated
Comment thread esp-hal/src/otg_fs/embassy_usb_host.rs
Comment thread esp-hal/src/otg_fs/mod.rs Outdated
Comment thread esp-hal/src/otg_fs/mod.rs Outdated
Comment thread esp-hal/src/otg_fs/mod.rs Outdated
@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

Copilot AI review requested due to automatic review settings May 4, 2026 10:03
@github-actions github-actions Bot removed the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 4, 2026
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

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Comment thread esp-hal/Cargo.toml
Comment thread esp-hal/src/otg_fs/mod.rs
Comment thread esp-hal/src/otg_fs/embassy_usb_device.rs
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 5, 2026
@github-actions github-actions Bot added merge-conflict Merge conflict detected. Automatically added/removed by CI. and removed merge-conflict Merge conflict detected. Automatically added/removed by CI. labels May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

Copilot AI review requested due to automatic review settings May 6, 2026 07:53
@github-actions github-actions Bot removed the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 6, 2026
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

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Comment thread examples/async/embassy_usb_hid_host/src/main.rs
Comment thread esp-hal/CHANGELOG.md
@bjoernQ
Copy link
Copy Markdown
Contributor

bjoernQ commented May 7, 2026

Seems the hid-host doesn't work for me - it doesn't enumerate.

Might be my soldering however - so would be good if someone else could give it a try.

usb-device still works fine for me, code LGTM

@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

@github-actions github-actions Bot removed the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 7, 2026
@bugadani
Copy link
Copy Markdown
Contributor Author

bugadani commented May 7, 2026

Here's the output of my mouse:
image

This is running on a Freenove S3 CAM or whatever is the name of the board, because it has a type-c USB port so I can use my cute type-c to microusb cable. But the code was also tested on an S3-BOX-3 :)

@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict Merge conflict detected. Automatically added/removed by CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants