[U-Boot] [Bug Report] USB: descriptor handling
Remy Bohmer
linux at bohmer.net
Mon Dec 8 10:11:53 CET 2008
Hello Stefan,
> I found a bug when working with the u-boot USB subsystem on IXP425 processor
> (big endian Xscale aka ARMv5).
> I recognized that the second usb_endpoint_descriptor of the attached memory
> stick was corrupted.
Nice catch!
> --------------
> /* Endpoint descriptor */
> struct usb_endpoint_descriptor {
> unsigned char bLength;
> unsigned char bDescriptorType;
> unsigned char bEndpointAddress;
> unsigned char bmAttributes;
> unsigned short wMaxPacketSize;
> unsigned char bInterval;
> unsigned char bRefresh;
> unsigned char bSynchAddress;
>
> } __attribute__ ((packed));
>
> As usb_endpoint_descriptor is only 7byte in length, the start of all
> odd ep_desc[] structures is not word aligned. This makes wMaxPacketSize
> of these structures also not word aligned.
Hmm, I count 9 bytes instead of 7...
> As writing is only needed on big endian ARM (for data swapping)
> this issue has been undetected up to now.
> Either wMaxPacket size must be accessed with special code, or it
> must be aligned to modulo-2 address.
>
> I suggest:
> ------------
> diff --git a/include/usb.h b/include/usb.h
> index 9a2e72c..b36272b 100644
> --- a/include/usb.h
> +++ b/include/usb.h
> @@ -93,8 +93,7 @@ struct usb_endpoint_descriptor {
> unsigned char bInterval;
> unsigned char bRefresh;
> unsigned char bSynchAddress;
> -
> -} __attribute__ ((packed));
> +} __attribute__ ((packed)) __attribute__ ((aligned(2)));
> /* Interface descriptor */
> struct usb_interface_descriptor {
> unsigned char bLength;
> ------------
I agree, but this patch seems to be whitespace/tab broken...
> With this change memory stick is identied correctly. I can do "fatls",
> but I cannot read data correctly from the disk. But might be something
> completely different issue ....
I tested it, and fatls/fatload still works on ARM (at91), no
regression detected with this patch so far.
Kind regards,
Remy
More information about the U-Boot
mailing list