-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Handle receiving a ZLP in USB_Available #6886
base: master
Are you sure you want to change the base?
Conversation
✅ Build completed. Please test this code using one of the following: ⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6886-BUILD-734-linux32.tar.xz ℹ️ The |
@sandeepmistry I currently do not have the hardware nor time to test this, I am sorry. Thanks for mentioning me though. If the official arduino hid libraries work, mine should work too. |
I found this issue because I just debugged a very similar "256-byte transfer problem on the Arduino Micro" in my project. See kervinck/gigatron-rom#36 I was about to file a problem report when I found this issue report here. However, I just tested arduino-PR-6886-BUILD-734-macosx.zip and it doesn't resolve my case. I have opened https://github.com/arduino/Arduino/issues/7838 although I do have a workaround that seems to work in my project. The reason I'm commenting here is that you may want to take a quick look at it. My conclusion and workaround are using a different observation, namely that the datasheet sequence is not followed by USBCore.cpp, specifically this:
The way USB_Recv is written I don't think ReleaseRX will ever be called twice in a row. And that is exactly what gets me out of the hangup situation. |
@kervinck would you be able to open a new pull request for your suggested changes? |
That would take me one or two weeks of study, cleanup and testing. Sorry. |
|
I've just tested this patch against a longstanding issue I've had where, only on macOS, sending 384 or more bytes to the AVR USB Serial device from the host causes USB Serial to lock up. ...and it appears to solve the issue. Without this patch, sending the following string (or any string of equal or greater length) from the Classic Arduino IDE's serial console will cause the USB Serial connection to stop reading input, but only on macOS.
The trivial repro sketch for this failure is
@cmaglie Apologies for tagging you directly, but who's the right code owner to see about getting this PR either merged or rejected? |
Confirmed the observation by @kervinck that this fix is incomplete. If the application calls This additional patch appears to fix it in our use case (diff is against the keyboardio fork of the core): --- a/avr/cores/keyboardio/USBCore.cpp
+++ b/avr/cores/keyboardio/USBCore.cpp
@@ -245,6 +245,10 @@ int USB_Recv(u8 ep, void* d, int len)
LockEP lock(ep);
u8 n = FifoByteCount();
+ if (!n && HasOUT()) {
+ ReleaseRX(); // handle ZLP
+ n = FifoByteCount();
+ }
len = min(n,len);
n = len;
u8* dst = (u8*)d; I also agree that the datasheet says to always clear |
The fix in arduino/Arduino#6886 is incomplete. `USB_Recv` also needs to handle ZLPs. Signed-off-by: Taylor Yu <code@argon.blue>
This probably needs to be moved to https://github.com/arduino/ArduinoCore-avr |
To address https://github.com/arduino/Arduino/issues/6669.
If a ZLP is received the FifoCount will be zero, but
RXOUTI
will still be triggered.@NicoHood could you please try this change out to ensure it's ok HID API wise. Thanks.