Skip to content

Support ESP32-S3 USB Host #2634

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

Closed
1 task done
marchingband opened this issue May 9, 2024 · 14 comments
Closed
1 task done

Support ESP32-S3 USB Host #2634

marchingband opened this issue May 9, 2024 · 14 comments

Comments

@marchingband
Copy link

Related area

I would like to have tinyUSB support USB Host on ESP32-S3

Hardware specification

ESP32-S3

Is your feature request related to a problem?

I have USB MIDI Host working under esp-idf, but I need to port my project to Arduino, and TinyUSB does not yet support ESP32-S3 host.

Describe the solution you'd like

Add host support, and ideally a MIDI example :)

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
@shufps
Copy link

shufps commented Jul 3, 2024

Would like to have the same, I hope to get USB CDC ACM (virtual com port) devices running on a ESP32 as USB Host.

Preferably with Micropython, since Micropython uses tinyusb, I thought would be a good idea to look here if Host actually is supported 🫣

slaff pushed a commit to SmingHub/Sming that referenced this issue Jul 7, 2024
This PR updates the USB library, mainly bringing the tinyusb submodule up to date. Many fixes and small improvements but no impact to applications using the library itself.

NB. Still no host support for esp32sx :-( See hathach/tinyusb#2634
@tore-espressif
Copy link
Contributor

tore-espressif commented Jul 8, 2024

Hi guys, in case you are still interested in USB Host applications, we have it supported on ESP32-S2 and ESP32-S3 in esp-idf

Here's some documentation https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-reference/peripherals/usb_host.html

And some CDC examples https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc

@marchingband
Copy link
Author

marchingband commented Jul 8, 2024

@tore-espressif Thanks, yes I use that when I am on esp-idf. I have some projects that are on Arduino (ex. https://www.sparkfun.com/products/21307), and it would be very valuable to have USB Host available in both frameworks. Is there a brief way to explain why this is especially challenging for the developers? The question comes up fairly frequently and I never know what to say.

@niklasekstrom
Copy link

Hi guys, in case you are still interested in USB Host applications, we have it supported on ESP32-S2 and ESP32-S3 in esp-idf

Hi Tomas,

Does your usb stack support connecting a hub, and then connecting multiple HID devices to that hub (e.g., keyboard and mouse)?

I see in this directory https://github.com/espressif/esp-idf/tree/master/components/usb that there are some files related to hubs, but I can't find any information about if hubs are actually supported.

@tore-espressif
Copy link
Contributor

Is there a brief way to explain why this is especially challenging for the developers?

I checked with Arduino team and this is what I got: It should be technically possible, there are two approaches

  1. Use Arduino as esp-idf component, then you can easily use USB Host Library that is part of esp-idf. Here are some resources about this option:
    https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html
    https://www.youtube.com/watch?v=8w3MmsZBa9o&ab_channel=EspressifSystems
  2. You can write your own wrapper that would enable you to use USB Host Library in esp-idf. The USB Library is rather big, so this is not a trivial thing, plus it is not documented properly. You can ask in the arduino project if you want to know more

Does your usb stack support connecting a hub, and then connecting multiple HID devices to that hub (e.g., keyboard and mouse)?

External HUB support is work in progress in esp-idf, it should be ready beginning of October

@sashahilton00
Copy link

Is there any plan to implement this in tinyusb? I'm not too familiar with the inner workings, wondering if host in tinyusb is likely or whether the only option is esp-idf for the foreseeable.

@hathach
Copy link
Owner

hathach commented Feb 6, 2025

already implemented, you can try with stock host example with _freertos or host/device_info

@hathach hathach closed this as completed Feb 6, 2025
@marchingband
Copy link
Author

marchingband commented Feb 6, 2025

@hathach are you saying it is implemented in a way that works on esp32-s3 in Arduino?
When I opened this issue it was intended to be WRT Arduino support ...

@hathach
Copy link
Owner

hathach commented Feb 6, 2025

it is implemented by tinyusb in host controller driver (hcd). I am not sure which frame/lib you use with Arduino, but you can use the existing tinyusb host API to communicate with device.

@marchingband
Copy link
Author

In the past I have used Adafruit_TinyUSB_Arduino.
Will this host controller driver be available there?
If not, what frame/lib do you recommend for using tinyusb with Arduino for ESP32-S3?
I am specifically interested in USB MIDI Host.
Thanks!

@hathach
Copy link
Owner

hathach commented Feb 10, 2025

For Arduino, it depends on arduino-esp32 core, it may start up initizliaing usb stack as device mode in which case tusb stack need to be teardown/re-initialized to host mode (api may not available yet). Sum up, To use Adafruit_TinyUSB you need to make sure

  • CFG_TUH_ENABLED = 1
  • usb is initialized

@marchingband
Copy link
Author

@hathach wow that is incredible news thank you!
I would love to see some Arduino examples sketches.
Is there an issue at Arduino-ESP32 I can follow to know when your updates get compiled into core?

@hathach
Copy link
Owner

hathach commented Feb 11, 2025

@hathach wow that is incredible news thank you! I would love to see some Arduino examples sketches. Is there an issue at Arduino-ESP32 I can follow to know when your updates get compiled into core?

I haven't paid attention to arduino-esp32 lately, but It is moving fast. My CI HIL pool actually test esp32-p4 host function each PR https://github.com/hathach/tinyusb/blob/master/test/hil/tinyusb.json#L10 same dwc2 as s3 (with different usbip configuration). You can try to run stock host examples with s3, it should work.

@marchingband
Copy link
Author

That is a little beyond my skills, but I have opened an issue with core, asking for example Arduino code.
Thank you very much for your help :)
espressif/arduino-esp32#10978

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

No branches or pull requests

6 participants