[USB] Fixes an issue with Serial when receiving consecutive multiple 64-byte transmissions from Host #1336
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
With RX queue full, the device NAKs OUT (Host->Device) transfers. With
bInterval
set to0
(1 ms) this causes the device to spend too much time in USB interrupt, not giving any processing time to the application/system thread to consume RX queue. For some reason CDC driver on OSX doesn't attempt to send any data after about 300 NAKed transfers. Closing/re-opening the port doesn't help either.Solution
Set
bInterval
to a maximum value (16 ms) on OUT endpoint to give enough time for the device to consume RX queue and not send too many NAKs to Host.We should probably add some workaround as well: e.g. count the number of NAKs sent and silently drop incoming data after a certain threshold instead of NAKing it. Even though this is OSX driver's fault. 🤕
Steps to Test
The bug is easily reproducible on OSX when setting WPA Enterprise credentials over Serial. A simple copy-paste of a certificate (e.g. CA) will not complete and get stuck somewhere half-way through.
Example App
N/A
References
N/A
Completeness
Bug fix
[PR #1336]
Fixes an issue with Serial when receiving consecutive multiple 64-byte transmissions from Host