ESP32-S3: multi devices with usb host library
ESP32-S3: multi devices with usb host library
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
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
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3: multi devices with usb host library
Yep. We don't have hub support at this point in time.
Re: ESP32-S3: multi devices with usb host library
Do you known when this feature will be released ?
Re: ESP32-S3: multi devices with usb host library
I would also be interested on how long it will take until the feature is released. Best wishes
Re: ESP32-S3: multi devices with usb host library
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
Because on this page, it says
. 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)?The Host Port can only connect to a single device, though more devices can be connected via hub devices
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3: multi devices with usb host library
As it says at the bottom of that page:
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.)The Host Stack currently has the following notable limitations:
No HS (High Speed) support
No Hub support (currently only supports a single device)
Re: ESP32-S3: multi devices with usb host library
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.
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.
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3: multi devices with usb host library
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.
Re: ESP32-S3: multi devices with usb host library
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.
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.
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3: multi devices with usb host library
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: No registered users and 94 guests