ESP32-S3 USB OTG - USB Hub support?
-
- Posts: 19
- Joined: Thu Oct 07, 2021 8:11 am
Re: ESP32-S3 USB OTG - USB Hub support?
Hi everyone,
Here's an update about this topic, that should answer all questions mentioned here.
Espressif's USB Host implementation is fully open-source. The only non-public part is the USB peripheral itself (that is 3rd party Synopsys DWC).
The HUB feature must be implemented in esp-idf (open source ESP-IDF codebase), where the rest of USB Host driver is.
There are some notable limitations, when implementing HUB support, that are coming from the USB peripheral. ESP32-S2 and S3 implements 'smaller' version of the USB peripheral, to save chip size and manufacturing costs. In practice, it has following implications:
1. Limited number of USB channels - 8: Only 8 endpoints (including EP0s) can be active at the same time. Small USB devices typically implement EP0 and 2 additional endpoints (1 IN and 1 OUT). The USB HUB also has EP0 and 1 IN endpoint. In this example scenario, only 2 USB devices can be active at the same time.
2. Small Receive FIFO - 512 bytes: 512 bytes is borderline enough for one streaming (high-bandwidth) FullSpeed device. It will not be possible to stream from 2 USB camera at the same time on S2/3 (at reasonable definition of the video).
Other usecases, such as ESP->HUB->CDC device or ESP->HUB->2xHID device are feasible.
Current status
We have an internal work-in-progress branch that adds support for HUBs. Currently you can hot-plug devices, HUBs and run all the current examples (HID, CDC, UVC, MSC) through USB HUB, even with multiple layer HUBs.
We have not merged it yet (and made it public), because the feature requires more testing and reviews.
If there is anyone willing to test/contribute we can make the branch public on GitHub so you can start prototyping faster.
Side note: Porting to TinyUSB Host should be possible, but we don't plan to support it.
Here's an update about this topic, that should answer all questions mentioned here.
Espressif's USB Host implementation is fully open-source. The only non-public part is the USB peripheral itself (that is 3rd party Synopsys DWC).
The HUB feature must be implemented in esp-idf (open source ESP-IDF codebase), where the rest of USB Host driver is.
There are some notable limitations, when implementing HUB support, that are coming from the USB peripheral. ESP32-S2 and S3 implements 'smaller' version of the USB peripheral, to save chip size and manufacturing costs. In practice, it has following implications:
1. Limited number of USB channels - 8: Only 8 endpoints (including EP0s) can be active at the same time. Small USB devices typically implement EP0 and 2 additional endpoints (1 IN and 1 OUT). The USB HUB also has EP0 and 1 IN endpoint. In this example scenario, only 2 USB devices can be active at the same time.
2. Small Receive FIFO - 512 bytes: 512 bytes is borderline enough for one streaming (high-bandwidth) FullSpeed device. It will not be possible to stream from 2 USB camera at the same time on S2/3 (at reasonable definition of the video).
Other usecases, such as ESP->HUB->CDC device or ESP->HUB->2xHID device are feasible.
Current status
We have an internal work-in-progress branch that adds support for HUBs. Currently you can hot-plug devices, HUBs and run all the current examples (HID, CDC, UVC, MSC) through USB HUB, even with multiple layer HUBs.
We have not merged it yet (and made it public), because the feature requires more testing and reviews.
If there is anyone willing to test/contribute we can make the branch public on GitHub so you can start prototyping faster.
Side note: Porting to TinyUSB Host should be possible, but we don't plan to support it.
Re: ESP32-S3 USB OTG - USB Hub support?
Why not just open it up as beta and let anyone/everyone test at their leisure? That's effectively how things are anyways with the rest of esp-idf, everybody heads to the issues section to report problems. I don't think it makes sense to require anyone/someone to proclaim themselves as official testers in order for the HUB code to be open-sourced (if its on a private branch, then it's effectively closed-source or no-source).
Re: ESP32-S3 USB OTG - USB Hub support?
Can you please be more specific what is meant by " Only 8 endpoints (including EP0s) can be active at the same time" ?
Especially in the context of HID devices. You mean only 8 endpoints can have scheduled IN/OUT transactions inside one 1 ms frame?
Or is this some enumeration limit, i.e. 3rd HID device may not be enumerated at all?
Especially in the context of HID devices. You mean only 8 endpoints can have scheduled IN/OUT transactions inside one 1 ms frame?
Or is this some enumeration limit, i.e. 3rd HID device may not be enumerated at all?
-
- Posts: 19
- Joined: Thu Oct 07, 2021 8:11 am
Re: ESP32-S3 USB OTG - USB Hub support?
Yes, this is a HW limitation. Each active endpoint must have a HW implementation (channel). There are 8 such implementations (channels) in ESP32-S2/S3.You mean only 8 endpoints can have scheduled IN/OUT transactions inside one 1 ms frame?
Again yes, this is a software/hardware limitation. In current implementation, each endpoint of a connected device is assigned to a channel. So the host driver will fail to open a device if it has run out of channels. In theory, the HW channels could be reused (recycled) to serve multiple endpoints in round-robin fashion. This is fairly complex and lower-priority at this moment.Or is this some enumeration limit, i.e. 3rd HID device may not be enumerated at all?
Just for completeness, the upcoming ESP32-P4 will have 16 High Speed channels.
Re: ESP32-S3 USB OTG - USB Hub support?
>In theory, the HW channels could be reused (recycled) to serve multiple endpoints in round-robin fashion. This is fairly complex and lower-priority at this moment.
Actually, this was the point of my question. For example, if IN endpoint reports 4 ms interval we should allocate HW channel and query it once per 4 frames only, and in other frames this channel could be reused for other endpoints. Alas, your answer tells me i want "too much" and all channels are allocated statically during enumeration time, not dynamically per frame.
Also sometimes we may have to deal with composite devices with lot of endpoints on different interfaces, but we may want to use
only some of them. Would it be possible for application layer to make decision for which endpoint we need to allocate HW channels and which can be skipped? This at least could partially solve the issue with lack of channels.
Anyway, thank you for explanation! This helps a lot.
Actually, this was the point of my question. For example, if IN endpoint reports 4 ms interval we should allocate HW channel and query it once per 4 frames only, and in other frames this channel could be reused for other endpoints. Alas, your answer tells me i want "too much" and all channels are allocated statically during enumeration time, not dynamically per frame.
Also sometimes we may have to deal with composite devices with lot of endpoints on different interfaces, but we may want to use
only some of them. Would it be possible for application layer to make decision for which endpoint we need to allocate HW channels and which can be skipped? This at least could partially solve the issue with lack of channels.
Anyway, thank you for explanation! This helps a lot.
-
- Posts: 21
- Joined: Sun Nov 15, 2015 4:14 am
Re: ESP32-S3 USB OTG - USB Hub support?
With the Beta USB-Hub support would it be possible to just read the VID/PID + serial from a large number (20 devices total ie. HUBs connected to HUB with multiple devices in each) of connected USB devices (Phones in this case) and detect insertion/removal ?
If so I'm very interested in testing this out as we have a customer interested in this.
Kind regards
Jimmy
If so I'm very interested in testing this out as we have a customer interested in this.
Kind regards
Jimmy
-
- Posts: 3
- Joined: Tue Aug 15, 2023 7:25 am
Re: ESP32-S3 USB OTG - USB Hub support?
Hi everybody. Any news?
Re: ESP32-S3 USB OTG - USB Hub support?
tore-espressif wrote: ↑Fri Dec 29, 2023 7:17 pmHi everyone,
Here's an update about this topic, that should answer all questions mentioned here.
Espressif's USB Host implementation is fully open-source. The only non-public part is the USB peripheral itself (that is 3rd party Synopsys DWC).
The HUB feature must be implemented in esp-idf (open source ESP-IDF codebase), where the rest of USB Host driver is.
There are some notable limitations, when implementing HUB support, that are coming from the USB peripheral. ESP32-S2 and S3 implements 'smaller' version of the USB peripheral, to save chip size and manufacturing costs. In practice, it has following implications:
1. Limited number of USB channels - 8: Only 8 endpoints (including EP0s) can be active at the same time. Small USB devices typically implement EP0 and 2 additional endpoints (1 IN and 1 OUT). The USB HUB also has EP0 and 1 IN endpoint. In this example scenario, only 2 USB devices can be active at the same time.
2. Small Receive FIFO - 512 bytes: 512 bytes is borderline enough for one streaming (high-bandwidth) FullSpeed device. It will not be possible to stream from 2 USB camera at the same time on S2/3 (at reasonable definition of the video).
Other usecases, such as ESP->HUB->CDC device or ESP->HUB->2xHID device are feasible.
Current status
We have an internal work-in-progress branch that adds support for HUBs. Currently you can hot-plug devices, HUBs and run all the current examples (HID, CDC, UVC, MSC) through USB HUB, even with multiple layer HUBs.
We have not merged it yet (and made it public), because the feature requires more testing and reviews.
If there is anyone willing to test/contribute we can make the branch public on GitHub so you can start prototyping faster.
Side note: Porting to TinyUSB Host should be possible, but we don't plan to support it.
Hi, where can i find the beta code or may be the stable one to use devices through hubs ?
thanks.
-
- Posts: 19
- Joined: Thu Oct 07, 2021 8:11 am
Re: ESP32-S3 USB OTG - USB Hub support?
This is how it works now! Upon device connection only EP0 is allocated, which must be present for successful device enumeration. After that, the application is responsible for selection which USB functions from the composite device (that is which USB interface and endpoints) it wants to use, only those are allocated.Would it be possible for application layer to make decision for which endpoint we need to allocate HW channels and which can be skipped? This at least could partially solve the issue with lack of channels.
This should be possible, although we haven't tested with 20 devices. The nested HUBs work fine in our initial tests. The Beta support would mean here, that if you unplug too many devices and/or HUBs at the same time, we occasionally see crashes.With the Beta USB-Hub support would it be possible to just read the VID/PID + serial from a large number (20 devices total ie. HUBs connected to HUB with multiple devices in each) of connected USB devices (Phones in this case) and detect insertion/removal
We aim to prepare a beta branch for public testing within a week
Re: ESP32-S3 USB OTG - USB Hub support?
Thank you for your answer.tore-espressif wrote: ↑Wed Feb 14, 2024 8:28 amThis is how it works now! Upon device connection only EP0 is allocated, which must be present for successful device enumeration. After that, the application is responsible for selection which USB functions from the composite device (that is which USB interface and endpoints) it wants to use, only those are allocated.Would it be possible for application layer to make decision for which endpoint we need to allocate HW channels and which can be skipped? This at least could partially solve the issue with lack of channels.
This should be possible, although we haven't tested with 20 devices. The nested HUBs work fine in our initial tests. The Beta support would mean here, that if you unplug too many devices and/or HUBs at the same time, we occasionally see crashes.With the Beta USB-Hub support would it be possible to just read the VID/PID + serial from a large number (20 devices total ie. HUBs connected to HUB with multiple devices in each) of connected USB devices (Phones in this case) and detect insertion/removal
We aim to prepare a beta branch for public testing within a week
Actually, I'm developing on esp-iot-bridge framework and I want to access hubs and devices through wifi using a wireless nic example, is it possible to integrate it inside? if so, how?
Who is online
Users browsing this forum: No registered users and 35 guests