On Wed, 20 Sep 2006, Harald Welte wrote:

> Hi!
> 
> I'm currently writing a USB device firmware for a Free Software / Free
> hardware project based on an AT91SAM7 (see http://www.openpcd.org/)
> 
> In order to implement USB DFU (device firmware upgrade), I need support
> for "big" control out transfers (larger than the 8 byte control endpoint
> size).  I suppose this is a rarely used feature, since most control
> transfers are used to read information from a device (control in
> transfers).
> 
> When I use libusb / usbdevio on a 2.6.17.13 kernel to send a control out
> transfer of e.g. 256 bytes, then I expect it to create 32 usb data out
> packets of each 8 bytes size, plus one zero-length packet to terminate
> the transfer.  I'm using usb_control_msg() to do the transfer.
> 
> However, on the AT91SAM7 I only see the 32 usb data out packets, and no
> ZLP (zero-length-packet).
> 
> Transfers of an non-modulo-eight size (e.g. 31 packets of 8 bytes, plus
> one four-byte packet) work perfectly fine, since in this case no ZLP is
> supposed to be at the end of the transfer.
> 
> The host controller is UHCI in this case.
> 
> Am I somehow assuming something wrong?  Is there anything at all on the
> host software stack that controls the generation of a ZLP at the end of
> the transfer, or is this all done by the host controller?

Your assumption is wrong.

When a control-out transfer takes, the host controller sends a SETUP
packet followed by as many OUT/DATA packets as necessary to transfer the
data, but no zero-length OUT/DATA.  There is a zero-length IN packet to
terminate the transfer (the "status stage"), but that's present regardless
of the amount of data.

The idea is that you don't need a zero-length packet to terminate the data 
stage of the transfer, since the status stage's IN packet will always mark 
the termination.

For bulk-out transfers you can force an extra zero-length packet at the 
end (if the data size is > 0 and divisible by the maxpacket length) by 
setting URB_ZERO_PACKET in urb->transfer_flags.  That works only for 
bulk-out, not for control-out.

Alan Stern


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to