Skip to content
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

usb_stream_helper requires the chunk buffer size to be a power of 2 #66

Open
george-norton opened this issue May 24, 2023 · 0 comments
Open

Comments

@george-norton
Copy link

george-norton commented May 24, 2023

The asserts in the code indicate that that chunk_size must be a multiple of the usb packet size (64 bytes):

assert(!(chunk_size & 63u)); // buffer should be a multiple of USB packet buffer size

But in reality things break if the chunk_size is not also a power of 2 as the offset computation breaks down here:

return transfer->offset & (transfer->chunk_size - 1);

For example, if the chunk_size is 192 bytes the offset will not be updated after the first packet is sent, and so the first packet gets sent twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant