-
Notifications
You must be signed in to change notification settings - Fork 997
machine/atsamd21,atsamd51,nrf52840: correct USB CDC #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tors Signed-off-by: Ron Evans <ron@hybridgroup.com>
aykevl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two notes below. Not blocking this PR (there's already a lot of heap allocation) but noting it in case you'd want to fix that.
…r to reduce code duplication and heap allocations Signed-off-by: Ron Evans <ron@hybridgroup.com>
|
i added another commit to this PR that addresses the heap allocation. More importantly, it removes a bunch of code duplication by moving the creation of the device descriptor into shared code for all USB CDC supported boards. |
|
That looks much better! |
|
This commit appears to have broken USB registration with my desktop. |
|
@jaddr2line what OS are you running on desktop? Also, what program are you running on your Arduino Nano33 board? You should try to test with |
|
Linux (Manjaro) 4.14-rt, this is also the same machine that used to time out in the USB interrupt |
|
Now that we are sending the correct vendor and product id, you might need a udev rule for them to be able to be used by non-root user. |
|
No, that is not it. The device is not enumerating. From It looks like it is unable to read the device descriptor. |
| setEPINTENCLR(0, sam.USB_DEVICE_EPINTENCLR_STALL1) | ||
| } | ||
| } else { | ||
| sendZlp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line appears to have caused the regression. What is it supposed to be doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I added to send a zlp when the other cases were not handled, which seemed to correct an issue with the USB enumeration on Windows 10, based on a comment from @sago35
Removing that line gets it to work on Linux and macOS, but does not work on Windows 10. I suppose that means we need to further investigate what Windows in sending as the initial request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a proposal for sendZlp() below and in the comments that follow.
However, I'm not sure that this idea is correct.
#884 (comment)
The samd51 I'm trying has five USB Device EndPoint Interrupt Flags.
https://www.mouser.com/datasheet/2/268/60001507A-1130176.pdf
P.1161.
I did an additional check on atsamd51 and USB-CDC worked if you called sendZlp() on TRCPT0.
It may be better to process TRCPT0 as follows.
My environment is Windows 10 + PyPortal (samd51).
Since sendZlp() clears the bottom 12 bits of PCKSIZE, it assumes that BYTE_COUNT = 0.
The PCKSIZE is described on P.1197.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR, which probably exists only in Windows, needs to be handled well.
Maybe a careful reading of the Aruduino and circuitpython sources will solve the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This process is not in machine_atsamd51.go.
On the else side, sendZlp () may not be necessary or should not be called.
https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/USB/USBCore.cpp#L951
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR corrects the USB CDC composite descriptors for the ATSAMD21, ATSAMD51, and NRF52840 processors.
Turns out that the clues provided by @sago35 were correct, the descriptor needed to be changed.
I tested the
example/echoprogram with these boards:On these OS: