Merge "Zero-length packet send bug resolution for fastboot."

This commit is contained in:
Treehugger Robot 2023-01-11 20:55:28 +00:00 committed by Gerrit Code Review
commit 46134b9cae

View file

@ -191,16 +191,30 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {
// Iterate over the endpoints for this interface and see if there
// are any that do bulk in/out.
for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; endpoint++) {
for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; ++endpoint) {
UInt8 transferType;
UInt16 maxPacketSize;
UInt16 endPointMaxPacketSize = 0;
UInt8 interval;
// Attempt to retrieve the 'true' packet-size from supported interface.
kr = (*interface)
->GetEndpointProperties(interface, 0, endpoint,
kUSBOut,
&transferType,
&endPointMaxPacketSize, &interval);
if (kr == kIOReturnSuccess && !endPointMaxPacketSize) {
ERR("GetEndpointProperties() returned zero len packet-size");
}
UInt16 pipePropMaxPacketSize;
UInt8 number;
UInt8 direction;
// Proceed with extracting the transfer direction, so we can fill in the
// appropriate fields (bulkIn or bulkOut).
kr = (*interface)->GetPipeProperties(interface, endpoint,
&direction,
&number, &transferType, &maxPacketSize, &interval);
&number, &transferType, &pipePropMaxPacketSize, &interval);
if (kr == 0) {
if (transferType != kUSBBulk) {
@ -216,7 +230,8 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {
}
if (handle->info.ifc_protocol == 0x01) {
handle->zero_mask = maxPacketSize - 1;
handle->zero_mask = (endPointMaxPacketSize == 0) ?
pipePropMaxPacketSize - 1 : endPointMaxPacketSize - 1;
}
} else {
ERR("could not get pipe properties for endpoint %u (%08x)\n", endpoint, kr);