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.
Hydradancer sets the endpoints status to
NAK
while sending data to Facedancer, to avoid buffering packets (which means Facedancer is in sync with the USB2 controller).I was setting the data toggles in advance (after each successful transfer), thinking the
NAK
status on the endpoint was enough to prevent the controller from saving data.Since I was having issues with duplicated data/weird buffers (correct transfer length but wrong data, too much or too little data), I created a test
test_usb_stress_test_delayed
which reproduces the delayed change of endpoint status toACK
with a timer and was able to reproduce the issue.Turns out, not setting the toggle in advance worked and seemingly keeps the USB2 controller from messing up its internal FIFO. Setting
NAK
on the endpoint should have been enough but that's not how it works apparently.I've been able to delay each OUT transfer in the stress test by 1ms, which confirmed this works and also fixed the issue in Hydradancer.