USB control transfers vs ZLP

NIIBE Yutaka gniibe at fsij.org
Wed Sep 4 02:08:39 CEST 2019


Jeremy Drake <jeremy at drastrom.science> writes:
> Well, a year later, and I seem to have hit another similar case.  I have a
> HID report descriptor which just happens to be exactly 64 bytes long.  It
> seems like your fix did not properly handle the case when only one packet
> would be needed.

Sorry for my incomplete fix in last summer.  It was too hot.  Hotter
than this year.

I think that I pushed the correct fix finally (over the change of last
year), like:

-  if (data_p->len < USB_MAX_PACKET_SIZE)
+  if (data_p->len <= USB_MAX_PACKET_SIZE)
     {
       len = data_p->len;
       dev->state = LAST_IN_DATA;

> Alas, this does not seem to work with a Windows 10 host.  I have poked it
> with gdb over SWD, and while with Linux len_asked is the correct size (64
> in this case), with Windows len_asked is 64 MORE than the size of the
> report descriptor (128 in this case, but I tested a different descriptor
> which was 56 bytes long and len_asked was 120).  It would seem a ZLP
> should be required in that case, but Windows does not like it, and works
> properly if I disable the ZLP.  Times like these make you wish you could
> take a look at the driver's source and see what they're trying to
> accomplish ;)

For 64-byte descriptor, I believe a single ZLP is required.  Two ZLPs
was sent before the fix.  I guess that it is not good for a Windows 10
host.

For USB full-speed, the packet size is 64-byte.  When len_asked is more
than that for 64-byte descriptor, (I think) a host side expects ZLP
to find end of transaction.

Please test.
-- 



More information about the Gnuk-users mailing list