Skip to content

Commit

Permalink
adb/fastboot: Support SuperSpeed USB devices
Browse files Browse the repository at this point in the history
When enumerating USB 3.0 devices, a 6-byte SuperSpeed companion
descriptor follows each standard descriptor. The ADB and Fastboot
Linux clients currently fail to interpret these additional
descriptors and simply bail. Fix this by skipping over them.

Change-Id: I254dad8ed81e8de74a4fac36e8ce54b5da9715fe
  • Loading branch information
Peter Heatwole authored and hyperb1iss committed Oct 22, 2014
1 parent 676d8aa commit de42ce3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions adb/usb_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ static void find_usb_device(const char *base,
// looks like ADB...
ep1 = (struct usb_endpoint_descriptor *)bufptr;
bufptr += USB_DT_ENDPOINT_SIZE;

// USB3 devices are required to have superspeed
// companion descriptors. They aren't needed to
// locate the target so just skip them.
//
// When using the Android build environment, the old
// ch9.h header from the prebuilts directory for the
// host does not contain superspeed definitions.
#ifndef USB_DT_SS_EP_COMP_SIZE
#define USB_DT_SS_EP_COMP_SIZE 6
#endif
if (device->bcdUSB >= 0x0300) {
bufptr += USB_DT_SS_EP_COMP_SIZE;
}

ep2 = (struct usb_endpoint_descriptor *)bufptr;
bufptr += USB_DT_ENDPOINT_SIZE;

Expand Down
15 changes: 15 additions & 0 deletions fastboot/usb_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ static int filter_usb_device(int fd, char *ptr, int len, int writable,
} else {
out = ept->bEndpointAddress;
}

// USB3 devices are required to have superspeed companion
// descriptors. They aren't needed to locate the target
// so just skip them.
//
// When using the Android build environment, the old ch9.h
// header from the prebuilts directory for the host does
// not contain superspeed-related definitions.
#ifndef USB_DT_SS_EP_COMP_SIZE
#define USB_DT_SS_EP_COMP_SIZE 6
#endif
if (dev->bcdUSB >= 0x0300) {
len -= USB_DT_SS_EP_COMP_SIZE;
ptr += USB_DT_SS_EP_COMP_SIZE;
}
}

info.has_bulk_in = (in != -1);
Expand Down

0 comments on commit de42ce3

Please sign in to comment.