diff options
author | Nicolas Gagnon <nicolasgagnon@google.com> | 2022-09-14 17:48:18 +0000 |
---|---|---|
committer | Keith Mok <keithmok@google.com> | 2023-01-31 16:51:48 +0000 |
commit | bc680ab1fafffc811896e9723cded4dbde46f39b (patch) | |
tree | a1a32f65db6b9e7ef4075ff5dd4edd3b88f14af7 | |
parent | 8ea0c2e276e913ad4d5756e691686573ffad5a03 (diff) | |
download | core-bc680ab1fafffc811896e9723cded4dbde46f39b.tar.gz |
Port ADB's new handling of the USB packet ClearFeature(HALT) to Fastboot.
This patch addresses Fastboot/Fastbootd connection issues seen on ARM Mac devices.
Original ADB patch: https://android-review.googlesource.com/c/platform/packages/modules/adb/+/1699250/
Bug: 238779161
Test: 'fastboot update <path_to_update_archive>.zip' now works on ARM Mac.
Signed-off-by: Nicolas Gagnon <nicolasgagnon@google.com>
Merged-In: Id67904d91abc8b66ef1a00962e1fd57c97df98a7
Change-Id: Id67904d91abc8b66ef1a00962e1fd57c97df98a7
(cherry picked from commit 3efef5694ee242f0fbeeaaa15c128dfb84418798)
-rw-r--r-- | fastboot/device/usb.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fastboot/device/usb.cpp b/fastboot/device/usb.cpp index 4115a6d28..1257055de 100644 --- a/fastboot/device/usb.cpp +++ b/fastboot/device/usb.cpp @@ -171,6 +171,16 @@ static int usb_ffs_do_aio(usb_handle* h, const void* data, int len, bool read) { if (num_bufs == 1 && aiob->events[0].res == -EINTR) { continue; } + if (read && aiob->events[0].res == -EPIPE) { + // On initial connection, some clients will send a ClearFeature(HALT) to + // attempt to resynchronize host and device after the fastboot server is killed. + // On newer device kernels, the reads we've already dispatched will be cancelled. + // Instead of treating this as a failure, which will tear down the interface and + // lead to the client doing the same thing again, just resubmit if this happens + // before we've actually read anything. + PLOG(ERROR) << "aio: got -EPIPE on first read attempt. Re-submitting read... "; + continue; + } int ret = 0; for (int i = 0; i < num_bufs; i++) { if (aiob->events[i].res < 0) { |