USB Host Lib - Set Configuration of USB Device

martin.k
Posts: 1
Joined: Tue Sep 26, 2023 2:20 am

USB Host Lib - Set Configuration of USB Device

Postby martin.k » Tue Sep 26, 2023 3:01 am

Hello there,

I am developing a device driver for a USB-Ethernet Adapter on the ESP32-S3 using the USB Host Library.
The device has two different USB configurations (bNumConfigurations = 2). One configuration is used for a proprietary protocol, and the second one is for the USB-ECM class.
Therefore, I need to switch to the second configuration (SET_CONFIG 1).
What I found out, is that the USB Hub Class is handling this internal while enumeration and always sets it default to 0, but I will need 1.
I can change it by modifying the default value in
  1. #define ENUM_CONFIG_INDEX 1 //Index used to get the first configuration descriptor of the device
inside the hub.c file of the ESP IDF v5.1.1, and the class will read the correct descriptors.
But this will not work if different USB devices are used, because most of them only support one configuration.

Is there a way or function i am missing to change the config without manipulating the USB Hub class?
Is it possible to send a control frame with a SET_CONFIG command from the device driver, because if I interpret the USB code correct, this will not change the configuration and interface descriptor inside the USB Hub Class, because these values are cached while enumeration.

Otherwise, I would recommend adding a callback from the hub class to the device driver before the SET_CONFIG step, to set the needed configuration. The VID, PID and bNumConfigurations of the device should be known at this point and can be used to select the needed configuration inside the device driver class.

Thank you
Martin

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: USB Host Lib - Set Configuration of USB Device

Postby iParcelBox » Mon Feb 17, 2025 1:51 pm

Hi @martin.k,

I'd be very interested to know how far you got with this project, as I was looking at developing something very similar (i.e. a Host class driver for a USB-Ethernet adapter for an esp32s3.

Are you able to share any progress on whether you managed to get this working?

Many thanks!

DrMickeyLauer
Posts: 180
Joined: Sun May 22, 2022 2:42 pm

Re: USB Host Lib - Set Configuration of USB Device

Postby DrMickeyLauer » Wed Mar 12, 2025 5:18 pm

Let me get this straight, you're working on having the ESP32S3 _posing_ as an USB-C-Ethernet-Adapter, right? If so, I'm very interested in this as well. My case is allowing the ESP32S3 to talk to an iOS device over USB-C.

chegewara
Posts: 2463
Joined: Wed Jun 14, 2017 9:00 pm

Re: USB Host Lib - Set Configuration of USB Device

Postby chegewara » Wed Mar 12, 2025 5:54 pm

DrMickeyLauer wrote:
Wed Mar 12, 2025 5:18 pm
Let me get this straight, you're working on having the ESP32S3 _posing_ as an USB-C-Ethernet-Adapter, right? If so, I'm very interested in this as well. My case is allowing the ESP32S3 to talk to an iOS device over USB-C.
He is doing the opposite configuration. Connecting ethernet to usb dongle to esp32.
What you need is something like this
https://github.com/espressif/esp-idf/tr ... e/tusb_ncm

chegewara
Posts: 2463
Joined: Wed Jun 14, 2017 9:00 pm

Re: USB Host Lib - Set Configuration of USB Device

Postby chegewara » Wed Mar 12, 2025 5:57 pm

martin.k wrote:
Tue Sep 26, 2023 3:01 am
Hello there,

I am developing a device driver for a USB-Ethernet Adapter on the ESP32-S3 using the USB Host Library.
The device has two different USB configurations (bNumConfigurations = 2). One configuration is used for a proprietary protocol, and the second one is for the USB-ECM class.
Therefore, I need to switch to the second configuration (SET_CONFIG 1).
What I found out, is that the USB Hub Class is handling this internal while enumeration and always sets it default to 0, but I will need 1.
I can change it by modifying the default value in
  1. #define ENUM_CONFIG_INDEX 1 //Index used to get the first configuration descriptor of the device
inside the hub.c file of the ESP IDF v5.1.1, and the class will read the correct descriptors.
But this will not work if different USB devices are used, because most of them only support one configuration.

Is there a way or function i am missing to change the config without manipulating the USB Hub class?
Is it possible to send a control frame with a SET_CONFIG command from the device driver, because if I interpret the USB code correct, this will not change the configuration and interface descriptor inside the USB Hub Class, because these values are cached while enumeration.

Otherwise, I would recommend adding a callback from the hub class to the device driver before the SET_CONFIG step, to set the needed configuration. The VID, PID and bNumConfigurations of the device should be known at this point and can be used to select the needed configuration inside the device driver class.

Thank you
Martin
This is quite old question but i think i can try to answer it now, just in case anyone else is looking for it.
I believe this is what you are asking for

https://github.com/espressif/esp-idf/bl ... .c#L88-L99

Who is online

Users browsing this forum: Google [Bot] and 70 guests