Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add USB host support for esp32s2(s3), support OTG dual-mode #2922

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Dec 12, 2024

This PR updates the USB library to enable Host support for esp32s2 and s3 (untested).
This is by switching ot the synopsis DWC2 driver.

The basic CDC, HID and MSC interfaces work OK but isochronous are transfers not yet supported. (I'd like this for attaching a USB DAC.)

In addition, the OTG hardware (for rp2040 and esp32s2) supports dual-mode operation and this PR allows the operation mode to be selected at run time. The application still needs to decide which mode is required: this can be as simple as connecting a GPIO input to the ID pin. Mode switching between two OTG hosts is more complex and involves session negotiation support which hasn't been investigated yet.

Disconnection events

The esp32s2 doesn't report when devices are disconnected in host mode. There's an open issue for this in tinyusb hathach/tinyusb#564. There's a reference to the IDF regarding self-powered devices which states that a separate GPIO is required to sense VBUS for disconnect events. A quick look at the IDF usb code suggests that it handles this using polling and a debounce timer.

However, there is a separate disconnect interrupt which requires only a few lines of code to enable and seems to work reliably. Doubtless there will be further host improvements in the future but this is pretty functional as-is.

Todo:

  • Disconnection events not reported via tuh_umount_cb for esp32s2
  • Re-test on rp2040

Copy link

what-the-diff bot commented Dec 12, 2024

PR Summary

  • Enhancements to 'hw_timer.h'
    The team has added specific compiler instructions to ignore unused parameter warnings. This can enhance code cleanliness while keeping the functionality intact.

  • Update to 'component.mk'
    The list of SDK include directories now includes 'usb/include', which is crucial for USB related functionalities.

  • Conditional USB support in 'SDK_COMPONENTS'
    The inclusion of USB support is now dependent on the specific ESP32 SoC being utilized. This currently covers the 'esp32s2' and 'esp32s3' chips, making the solution more tailored and resource-effective.

  • USB subproject Commit Update
    The team has changed the commit hash for the USB subproject. This typically suggests that the USB functionalities have been updated to a more recent or stable version.

  • Modification in 'application.cpp'
    The initialization method for USB, USB::begin() has been updated to use true as a parameter. This presents an implication that the USB functionality starts in a ready or active state by default.

@slaff slaff added this to the 6.0.0 milestone Dec 12, 2024
@mikee47 mikee47 force-pushed the feature/esp32s2-usb branch from 0c46ece to bbf9860 Compare December 12, 2024 19:58
@mikee47 mikee47 force-pushed the feature/esp32s2-usb branch 2 times, most recently from 9b5be30 to 3fa8fbc Compare December 12, 2024 21:21
`USB::begin()` now requires parameter indicating mode (device or host)
@mikee47 mikee47 force-pushed the feature/esp32s2-usb branch from 3fa8fbc to df55bc4 Compare December 12, 2024 21:47
@slaff slaff merged commit 75ddc8f into SmingHub:develop Dec 13, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants