Fix Endpoint descriptor size for MIDI Device#688
Conversation
Endpoint descriptor should be 9 bytes in length (not 7) and have two extra bytes at the end: bRefresh and bSynchAddress According to MIDI USB specification 1.0 (6.2.1 Standard MS Bulk Data Endpoint Descriptor)
hathach
left a comment
There was a problem hiding this comment.
endpoint descriptor is always 7 (USB specs). There is probably some mis-handling somewhere.If you provide further details on how you test it, people could help to clear it up ( I am assuming you are using midi_test example, if you don't please use that example )
It does appear that for audio class, the descriptors are length 9. This is mentioned as a note in the USB 2.0 spec (section 9.6): So, to be standards compliant, descriptors should be modified to have length 9 for all audio-class endpoints. I don't know if this could cause any compatibility issues (or not), but it seems like this has been this way since 1998. I think the endpoint descriptors for other audio classes also need to be extended to 9. |
|
I just double checked with Audio 2.0 and 3.0 specs. USB-IF fixed this by using only 7 bytes for endpoint descriptor, that would be an untold story. |
hathach
left a comment
There was a problem hiding this comment.
Thank you very much for the PR, that was me being too confident. Sighed !!! PR is good for merge, though I think we need to put a bit of note in the comment to clarify it
|
@hathach , Eeek, yeah, I didn't even notice that USB-MIDI 2.0 and USB AUDIO 2.0 and 3.0 use the 7-byte descriptor: USB-MIDI spec 2.0: 5.3.1: It looks like the class driver here is for USB-MIDI 1.0, so this patch is correct. This library's other USB audio class uses audio 2.0, using the 7-byte descriptor, so that's correct as well. |
|
@pigrew I just now know about the exist of USB MIDI v2.0 which just come out in May 2020. It is probably too soon for us to support. We probably stick to MIDI v1.0 until its support is stable. I think Audio v1 is probably the only spec that use 9-byte endpoint descriptor. It must be written at the same time with the USB 2.0 specs, and they are just too late to adjust, I guess. |
|
@dhalbert Circuitpython should also update its MIDI endpoints descriptor as well, the correct endpoint size is 0x09. Just notice cpy is also 0x07. |

Endpoint descriptor should be 9 bytes in length (not 7) and have two extra bytes at the end: bRefresh and bSynchAddress
According to MIDI USB specification 1.0 (6.2.1 Standard MS Bulk Data Endpoint Descriptor)
This is actual error before fix:
Endpoint Descriptor (Audio/MIDI 1.0):
0x07 bLength
0x05 bDescriptorType
*** ERROR: Invalid descriptor length 0x07
Hex dump:
0x07 0x05 0x81 0x02 0x40 0x00 0x00