Page 1 of 1

USB Host Lib - Set Configuration of USB Device

Posted: Tue Sep 26, 2023 3:01 am
by martin.k
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