chegewara / EspTinyUSB

ESP32S2 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
MIT License
473 stars 70 forks source link

USB descriptor larger then expected in Arduino IDE #146

Open Lights-On-42 opened 10 months ago

Lights-On-42 commented 10 months ago

Hello @chegewara,

I've been using your library, EspTinyUSB, to interface a USB camera with an ESP32-S2 module. First and foremost, I appreciate your work on developing this library, as it has been immensely helpful for USB mass storage functionality.

However, I've encountered an issue when attempting to connect my USB camera to the ESP32-S2. I've made sure to properly wire the connections, with the following pin configuration:

5V: 5 Volt GND: Ground D+: Connected to pin 19 D-: Connected to pin 20

While the library works well for USB mass storage, I'm facing an error specifically when trying to connect the USB camera. The error message I'm encountering is as follows:

E (26569) HUB: Configuration descriptor larger than control transfer max length E (26569) HUB: Stage failed: CHECK_SHORT_CONFIG_DESC

After some investigation, I believe this issue might be related to the maximum length of the control transfer for the configuration descriptor. I'm wondering if it would be possible to address this by adjusting a value within the Arduino IDE.

I've attempted to modify the value of CHECK_SHORT_CONFIG_DESC by changing it from 1024 to 4096 using the following define:

define CHECK_SHORT_CONFIG_DESC 4069

However, this modification did not yield the desired results and the issue persists.

Please look at this issue from Expressif https://github.com/espressif/esp-idf/issues/9868

I wanted to reach out to you to seek your insights on this matter. Could you kindly provide guidance on how to resolve this issue? If there are any alternative solutions or adjustments that I should consider, I would greatly appreciate your input.

Thank you once again for your dedication to this library.

Best regards, Lights on 42

serifpersia commented 8 months ago

Were you able to fix this issue in Arduino IDE? I have similar issue on S3 USB MIDI Host, some devices work while some don't with this error. Any info you have is appreciated.

Lights-On-42 commented 8 months ago

Hello serifpersia,

I have looked in many files and found this code:

case ENUM_STAGE_CHECK_SHORT_CONFIG_DESC: { usb_config_desc_t cfg_desc = (usb_config_desc_t )(enum_done->transfer.data_buffer + sizeof(usb_setup_packet_t)); full_config_length = cfg_desc->wTotalLength; UVC_CHECK_GOTO(full_config_length <= CTRL_TRANSFER_DATA_MAX_BYTES, "Configuration descriptor larger than control transfer max length", stagefailed); break;

then i write in my Code

define CTRL_TRANSFER_DATA_MAX_BYTES 4096

The file name is usb_stream.h but it works not. I think the tinyUSB Version work with a other File. And i find not the correct File witch used TinyUSB.

serifpersia commented 8 months ago

I resolved the issue, after re compile of sdk for s2/s3 with CONFIG_USB_HOST_TRANSFER_MAX_SIZE=4096 and deleting esp32s2/s3 folder from the Arduino15\packages\esp32\hardware\esp32\2.0.14\tools\sdk and placing my recompiled sdk's it works.

Lights-On-42 commented 8 months ago

Thanks,

I have change the Parameter in the sdkconfig in my folder. But the problem is the same. how it is possiply to change the parameter and compile it?

Do you used https://github.com/espressif/esp32-arduino-lib-builder/ have you experients in esp IDF?

serifpersia commented 8 months ago

That does nothing. You need to recompile the whole sdk and replace it in arduino folders. I can build it for you and share a link if you want. Just confirm me are you in Arduino IDE, Windows or Linux, and ESP32 S2 or S3? Yes I used that tool in wsl ubuntu linux. If you want you can do it yourself but its very complicated... You need to use the v4.4 branch and then run ./build.sh -t esp32s2 or esp32s3 if you are using esp32s3.. But before that you need to add line in defconfig for your board CONFIG_USB_HOST_TRANSFER_MAX_SIZE=4096 then you can do the build thing, esp32s2 or s3 folder will be in out folder, you can you see that to replace one you delete one you have in your arduino dir.

Lights-On-42 commented 8 months ago

Hello serifpersia,

i have a functionally esp-idf in visual studio code on windows and in this projekt it works on my esp32s3. Can you please give me a explanation how this works?

https://github.com/espressif/esp32-arduino-lib-builder/tree/release/v4.4

can you help me for a ESP32S3 and my problem a usb web cam work on arduino?

serifpersia commented 8 months ago

Since you already use esp-idf and have built working project in it, all you have to do is do this before building it. Launch ESP-IDF shortcut on desktop its like cmd thing, then cd to your project folder, you can backup the folder just in case, then do idf.py fullclean, idf.py set-target esp32s3, then idf.py menuconfig, go to component configuration, find usb otg, the first one should be max transfier size press enter and type 4096 default is 256, then ctrl s or s enter and it wil lsave the config in sdkconfig file, then you esc from this and you are back in that cmd windows, then you just do idf.py build, once done you can do flash via this command idf.py flash your-com-port-example-COM19 Keep in mind this will work if you don't have arduino style code if its straight using esp-idf framework then no need to do anything else, If you need help find me on discord serifpersia