AristoChen / usb-proxy

A USB proxy based on raw-gadget and libusb
Apache License 2.0
136 stars 29 forks source link

Patch bMaxPacketSize0 to be at least 64 #10

Closed xairy closed 8 months ago

xairy commented 8 months ago

A lot of UDCs require bMaxPacketSize0 to be at least 64 for High Speed devices (usb-proxy always uses High Speed right now) due to their hardware limitations: dwc2, dwc3, musb (also dummy).

Thus, patch this value into the device descriptor dynamically.

As mentioned in the comment, Raw Gadget should expose this information, but this is not implemented at the moment.

Providing a lower bMaxPacketSize0 works fine sometimes, but e.g. providing bMaxPacketSize0 of 8 fails with dwc3 with a Windows host (Linux, interestingly, works fine).

This issue also came up during the discussion in one of the previous PRs.

AristoChen commented 8 months ago

LGTM. I will merge it soon! thanks for the PR

I think it makes sense to set it to 64 by default since you mentioned that lots of UDCs require it, and I will probably add a config or a input argument which can disable this behavior in case some UDCs does not expect this behavior