Fix USB CDC NCM endpoint allocation ordering#5521
Fix USB CDC NCM endpoint allocation ordering#5521RoseBeaupreARA wants to merge 1 commit intoembassy-rs:mainfrom
Conversation
|
There's nothing in the USB spec that requires IN and OUT endpoint numbers to match. Using 0x02/0x81 should be perfectly fine. There must be a bug somewhere else and this change is masking it by accident.
|
|
I would guess that it's the synopsys one, however i'm unsure how to know for sure. |
|
As per NCM11.pdf 6.2.:
Just this sentence suggests that at the very least the Interrupt IN endpoint shouldn't be removed from the first interface. 6.3.:
Nothing about an interrupt endpoint there. One slight discrepancy I see with the spec is that it refers to Another random, offtopic-to-this-PR finding I have is this paragraph that differs from implementation:
|
|
I did also spot that missing notification. I tried to add it, it didn't fix the issue of the interface staying down. The minimal fix really was moving the interrupt endpoint after the bulks. I had a working implementation in C++, and the biggest significant changes were the notifications and the endpoint ordering. |
|
But the question is, if embassy-usb conforms to the spec, why should it be "fixed"? To me this suggests that the root cause of the issue is somewhere else. |
|
I think my initial hypothesis is misleading. Moving the line down a few lines adds the comm endpoint to the 2nd alt setting instead of the 1st. Could that be the reason for it to work with my suggested fix? |
The current embassy-usb implementation (with an ESP32-S3 device) works just fine on Windows, but not on Ubuntu. Your PR makes it work with Ubuntu, but breaks Windows. |
|
linux logic is here doesn't feel that intended to me... |
|
Now that #5552 is merged, @RoseBeaupreARA could you check if your problem still exists? There's also a possibility that for some unknown reason you need to insert some delay before running the USB stack, like Ariel OS does. |
|
@bugadani I tried removing my patch, adding the same delay as ariel-os and adding the following dependency in my project: The ethernet interferface still stays down. I'm not a Rust veteran, let me know if this was not the right way to test. I took the commit referenced in the PR you mentioned. |
The USB CDC NCM device enumerates correctly on my Ubuntu 24.04 machine, but the interface stays down. I use an STM32F405RGT7 chip.
Allocating a dummy
endpoint_interrupt_in(None, 8, 255);aftercomm_epalso fixes the issue. Specifying the endpoint numbers as well.I suspect that allowing the endpoint allocation to do its thing allocates 0x02 for the bulk in, and 0x81 for the bulk out, leading to a mismatch. They should be on 0x01/0x81, or 0x02/0x82.
Moving the
comm_epallocation after the bulk endpoint allocations therefore fixes the mismatch.