Skip to content

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

@george-norton

Description

@george-norton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions