Description
I believe I have run into an error with the Arduino Core that has really been puzzling me -- I may need support from the person or team who wrote this piece of the code to unpuzzle it.
I ran into a puzzling issue while creating a pluggableUSB device descriptor, and sending it to the host machine.
The host machine during enumeration, asks in a setup packet for the Configuration Descriptor (0x02). I have the arduino responding with my configuration descriptor, which, when I implement the USB speaker device, it works fine. But unfortunately when I add the microphone terminals, I end up with an error in the device manager that the Get Configuration Descriptor failed.
Best I can tell, the reason for this error is because my USB configuration descriptor with the microphone enabled, in combination with the CDC and HID descriptors, is greater than 255 bytes!
I have traced the issue through the call stack, and the whole descriptor does indeed stay uncorrupted through the _pack_messages shenanigans and winds up in USBDeviceClass::armSend(uint32_t ep, const void* data, uint32_t len) completely.
As well, I have verified that in the *data buffer, the header of the config descriptor contains an accurate wTotalLength.
Somewhere the issue might be inside
usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);
usbd.epBank1SetByteCount(ep, len);
usbd.epBank1SetMultiPacketSize(ep, 0);
But all these are simply helper functions that set registers internally in the Samd21. Is there some sort of error in the SAMD21, which would clip the udd_ep_in_cache_buffer[] message prematurely? Or, is something not set right in the register map?
I do not have a hardware USB tracer on hand to know for sure if the config_descriptor sent from the MCU is whole, but windows certainly doesn't accept them for enumeration.
Note, I have made sure udd_ep_in_cache_buffer[] is big enough -- 1024 bytes to be exact.
Edit: Also posted at https://forum.arduino.cc/index.php?topic=570577.0