ESP32-S3: multi devices with usb host library

vsfred
Posts: 9
Joined: Mon Aug 15, 2022 12:12 pm

ESP32-S3: multi devices with usb host library

Postby vsfred » Fri Feb 10, 2023 1:00 pm

Hello,

I would like to connect a keyboard and mouse over USB HID on my ESP32-S3.

To connect the two devices at the same times, I will use an USB hub.

From the USB Host Library documentation :
https://docs.espressif.com/projects/esp ... _host.html
it says "Only supports a single device, but the Host Library’s API is designed for multiple device support".

What does it mean ? it's not possible to connect an USB hub with two USB device ?

Best regards

ESP_Sprite
Posts: 9582
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3: multi devices with usb host library

Postby ESP_Sprite » Sat Feb 11, 2023 3:11 am

Yep. We don't have hub support at this point in time.

vsfred
Posts: 9
Joined: Mon Aug 15, 2022 12:12 pm

Re: ESP32-S3: multi devices with usb host library

Postby vsfred » Mon Feb 20, 2023 1:23 pm

Do you known when this feature will be released ?

benboo
Posts: 1
Joined: Sat Oct 28, 2023 8:13 pm

Re: ESP32-S3: multi devices with usb host library

Postby benboo » Sat Oct 28, 2023 8:46 pm

I would also be interested on how long it will take until the feature is released. Best wishes

moefear85
Posts: 43
Joined: Sun Sep 05, 2021 4:55 pm

Re: ESP32-S3: multi devices with usb host library

Postby moefear85 » Tue Nov 14, 2023 5:01 pm

On this page, the graphic shows a hub driver. does that mean it is actually possible to talk to a device over a hub? If so, why isn't the feature exposed?

Because on this page, it says
The Host Port can only connect to a single device, though more devices can be connected via hub devices
. Does this mean the limitation is purely in the open-source part of esp-idf? Or is it a limitation in hardware or closed-portion (which I believe includes some usb phy code)?

ESP_Sprite
Posts: 9582
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3: multi devices with usb host library

Postby ESP_Sprite » Wed Nov 15, 2023 6:23 am

As it says at the bottom of that page:
The Host Stack currently has the following notable limitations:

No HS (High Speed) support

No Hub support (currently only supports a single device)
So yes, it's a software limitation, the hardware is capable of talking to hubs just fine. I don't think there's anything closed-source in the software that drives USB, so technically a capable programmer with enough time could add hub support themselves. (But please poke us first if you're planning on doing that.)

moefear85
Posts: 43
Joined: Sun Sep 05, 2021 4:55 pm

Re: ESP32-S3: multi devices with usb host library

Postby moefear85 » Sun Dec 03, 2023 10:13 pm

well my intention is to do so... but I currently don't even have a vague idea as to any timetable... I'm occasionally learning more and more about the usb standard... trying to eventually find a detailed description of how a hub reports devices to the host and how the host addresses devices through the hub. I don't know how many endpoints are needed, keeping in mind the usb peripheral has a limit of 5 endpoints. I assume this is a hardware limit (or is it also a software one?). There is a section on hubs I think in the USB 2.0 Specification, I haven't reached it yet so I don't know if it's relevant.

Basically I feel its a fundamental feature anybody would be hoping for, when promised a full-fledged usb port on an mcu that supports host/OTG, to expect to be able to connect both a mouse & a keyboard, and not have to choose one or the other. So... if I'm gonna have to implement it myself... fine. How fast though depends on how urgent I need it. Currently not so much.

What confused me was why espressif would go through the trouble of writing the software multi-device capable at every level except at at one location and leave it like that. It made me wonder if maybe something is closed source, or there is an agreement, or that it is preparation for future hardware with the capability. but glad that its not a show-stopper for the esp32s2/s3.

ESP_Sprite
Posts: 9582
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3: multi devices with usb host library

Postby ESP_Sprite » Mon Dec 04, 2023 1:36 am

The issue is mostly time. When we were setting up the host stack, we knew we were adding USB hub support at some point in time, so all the preparations are there as they were easier to build when we were writing the code anyway, but the actual driver code that is specific to hub control was never written because of priorities. We'll get around to it at some point in time, but at this point it's not ready yet.

moefear85
Posts: 43
Joined: Sun Sep 05, 2021 4:55 pm

Re: ESP32-S3: multi devices with usb host library

Postby moefear85 » Fri Dec 08, 2023 12:36 am

i see... in the mean time... it occurred to me... one can get keyboard+mouse on both esp32 & esp32s3 even without usb, by using BT. Even on the esp32s2, one can use one of those BT keyboard+mouse sets with a single usb dongle (composite device). Hence the issue is no longer a top priority for me at the moment, but sooner or later I hope to get around to it anyways.

Some tips for anyone else interested... you can use wireshark with usbmon to sniff usb packets. First connect only a hub & analyze the setup process of the hub itself. Then connect individual devices to the hub & see how packets are routed through the hub. My assumption is the host would technically address the hub & its endpoints, but somehow encapsulate payloads targeted to the device. Given a hub can theoretically support a tree with 127 devices, it is unlikely that it uses a separate endpoint for each target device, so all encapsulated packets would have to technically be sent to the first few endpoints of the hub. But each device is known to have its own address, which is multilayered (one namespace per hop, delimited by points like ip addresses), so the address would still be the final target. But the end device would have to see communication to each and every one of its endpoints that are setup for a particular interface... hence it seems the final hub in the chain would then have to de-encapsulate the endpoints.

For IN packets, I think things are much easier, because each device has a unique address, and they all only ever talk to the root, so the packet simply passes through unaffected to the root.

On second thought... why would the host need to encapsulate endpoints anyways? If it mentions the address, then the hub already knows where to forward the packet to, and besides, hubs don't even route packet anyways, rather these are sent to all devices. Hence all of a sudden it seems to trivial, it makes me wonder why anything has to be done to support hubs in the first place.

ESP_Sprite
Posts: 9582
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3: multi devices with usb host library

Postby ESP_Sprite » Fri Dec 08, 2023 5:18 am

Or you can read the USB specification docs; it's an open specification so no need to reverse-engineer.

Who is online

Users browsing this forum: BinaryPoet and 214 guests