-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix handling of control transfers where size is a multiple of bMaxPacket... #194
Conversation
…ketSize0 End of transfer is indicated by a "short" packet where packet size is less than MaxPacketSize. If the transfer has a length that is a multiple of MaxPacketSize, a zero length packet must be sent to indicate the end of the transfer.
Do you have a test case for this, or is this conjecture? |
I have a test case using a composite device with MSC and HID. The firmware was just sending NAKs after the first data packet of the configuration descriptor. I had both MSC and HID working fine independently, and also a composite with HID and CDC, but this was the only example that resulted in a 64 byte descriptor. From Jan Axelson's USB Complete:
|
cases:
disclaimer: just my analysis. i could be completly wrong! |
current code: you changes: disclaimer: just my analysis. i could be completly wrong! |
If someone wants to "fix" this, it should be pretty easy to provide test device firmware and some test host code. @nagasakihacky do you have that available at all? |
After finding this and a few other quite fundamental bugs along the way I ended up reverting to ST's libraries. At some point I may see if I can switch back to this library, but I didn't have the luxury of time and so had to abandon |
no problem, thanks for the report at least. |
please try out https://github.com/kuldeepdhaka/libopencm3-examples/tree/usb-stack-tester |
as per my finding, this commit will break the usb stack. |
@kuldeepdhaka So, this commit as is is no good, but the issue it attempts to fix is valid, is that correct? I was hoping to look at your stack tester control transfer sizing tests, that's the problem here right? |
@karlp yes, the issue is valid but commit has problems. |
Control transfers can transfer less than was requested by the host in the wLength field. if this short transfer is a multiple of the endpoint's packet size, a zero length packet must be sent. Adds tests for a range of control transfer IN requests, and properly supports this in the core. Based heavily on work by Kuldeep Dhaka. See #505 and #194 for original discussion. Tested with stm32f4, stm32f103 and stm32l053.
fixed via merge of 3ed12b6 |
...Size0
End of transfer is indicated by a "short" packet where packet size is less than MaxPacketSize. If the transfer has a length that is a multiple of MaxPacketSize, a zero length packet must be sent to indicate the end of the transfer.
By calling the "normal transmission" section rather than the "end of transmission" section for the last packet of data, the state is not prematurely set to LAST_DATA_IN, so usb_control_send_chunk() gets called again and sends a ZLP