Commit graph

369 commits

Author SHA1 Message Date
David Pursell
6f233a7799 fastboot: create Transport object.
This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.

Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.

Bug: http://b/22029765
Change-Id: I68641af0da7d13db4647f5e20a18d04d67f0b327
2015-11-13 11:08:17 -08:00
Daniel Rosenberg
8336a96c9c Merge changes I8fb6b513,I6dd16245,I0c2753e2
* changes:
  Update fastboot help command with long options
  Changed set_active to be a flag
  Fix fastboot variable name
2015-11-12 23:22:00 +00:00
Elliott Hughes
a2db2618ec Cope with angler's whitespace-padded partition size reporting.
Before:

  $ fastboot -w
  wiping userdata...
  Couldn't parse partition size '0x        0x66257ee00'.
  wiping cache...
  Couldn't parse partition size '0x        0x6400000'.
  erasing 'userdata'...

Bug: http://b/25653580
Change-Id: I301b8410689c1e52681796c240a149d270360edf
2015-11-12 07:28:39 -08:00
Daniel Rosenberg
7aa38bc54c Update fastboot help command with long options
Change-Id: I8fb6b5139f81893b324202d4c68f29393213ee6f
2015-11-11 20:27:56 -08:00
Daniel Rosenberg
0d08856416 Changed set_active to be a flag
set_active must be able to accept flag like arguments

Change-Id: I6dd162453835d2d64fd8d877f2a7b98e8dd8a907
2015-11-11 20:27:50 -08:00
Daniel Rosenberg
a797479bd5 Fix fastboot variable name
Change-Id: I0c2753e2b79d715f227ee314c071ce68d91779b3
2015-11-11 20:27:43 -08:00
Elliott Hughes
c1fd492ac5 Revert "Revert "adb/base: fix adb push of Unicode filenames on Win32""
This reverts commit cc8cd59456.

With the dependency on libcutils (for gettid for non-bionic) removed,
this no longer breaks the build.

Change-Id: I645bd6876e2502ddc1535b69af1e645c0df9d178
2015-11-11 18:23:00 -08:00
Elliott Hughes
cc8cd59456 Revert "adb/base: fix adb push of Unicode filenames on Win32"
This reverts commit ac9514a452.

The new gettid dependency caused other breakage.

Change-Id: I74a75e40c30a45beb275f9dd38eb5c7beac15fbd
2015-11-11 18:01:12 +00:00
Spencer Low
ac9514a452 adb/base: fix adb push of Unicode filenames on Win32
ae5a6c06cd made adb push use
android::base::ReadFileToString() for small files, but that API did not
support UTF-8 filenames on Windows, until this fix which does the
following:

- Add android::base::{WideToUTF8,UTF8ToWide}() which are only available
  on Windows. The signatures are based on Chromium's APIs of the same
  name.

- Add the namespace android::base::utf8 which has versions of APIs that
  take UTF-8 strings. To use this, make sure your code is in a namespace
  and then do "using namespace android::base::utf8;". On Windows, this will
  make calls to open() call android::base::utf8::open(), and on other
  platforms, it will just call the regular ::open().

- Make ReadFileToString() and WriteStringToFile() use utf8::open() and
  utf8::unlink().

- Adapt unittests from Chromium.

- fastboot needs to link with libcutils because it links with libbase
  which depends on libcutils for gettid() for logging.

Change-Id: I1aeac40ff358331d7a1ff457ce894bfb17863904
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-10 15:48:54 -08:00
Daniel Rosenberg
f8e70a3a60 Merge "Fastboot changes to support A/B partitioning" 2015-11-06 03:43:49 +00:00
Daniel Rosenberg
b7bd4ae529 Fastboot changes to support A/B partitioning
Introduce support for -slot option for specifying slots,
and set_active, for changing the current slot.
Change-Id: Ib3b2a75491c0d0413534dd0c1d7bcb52555bba66
2015-11-05 18:07:46 -08:00
Elliott Hughes
4ca547be67 Merge "Fix fastboot to cope with hammerhead\'s implicit hex."
am: 2b7b3bd100

* commit '2b7b3bd100747fb7a02f1d8c7c2e8a5ee6cdc82f':
  Fix fastboot to cope with hammerhead's implicit hex.
2015-11-03 16:55:42 +00:00
Elliott Hughes
2030bac88b Fix fastboot to cope with hammerhead's implicit hex.
Before:

  wiping userdata...
  Couldn't parse partition size '3321fa800'.
  wiping cache...
  Couldn't parse partition size '2bc00000'.

Groan. So much variation between bootloaders. I wish we had a reference
bootloader like ChromeOS does.

I've also removed a harmless warning:

  couldn't parse max-download-size ''

Change-Id: Ia1099d2f87000ebb96622ad9171819a1326fa249
2015-11-03 08:20:30 -08:00
Elliott Hughes
d09dc85d63 Merge "Work around an angler bootloader bug."
am: 9eab787560

* commit '9eab7875602dec9910002f080df513077f56a2dd':
  Work around an angler bootloader bug.
2015-11-03 00:07:18 +00:00
Elliott Hughes
77c0e66bef Work around an angler bootloader bug.
It's probably not the only device whose bootloader is similarly broken.
NVIDIA did a sufficiently good job with Nexus 9 that it's almost a bad
idea for me to do most of my development there...

Change-Id: I71436cc5c33023be077ca77f6dad5dbe75b11b09
2015-11-02 15:51:12 -08:00
Elliott Hughes
a2a6b0bfa9 Merge "Clarify and fix the intent of the partition-type checking code."
am: d0f45aa24c

* commit 'd0f45aa24c09c0802784263fe2dccd38e226e23a':
  Clarify and fix the intent of the partition-type checking code.
2015-11-02 23:47:39 +00:00
Elliott Hughes
8ab9a32323 Clarify and fix the intent of the partition-type checking code.
Change-Id: I202dab4ee91208b632bc2086d1e5c387a4c29edd
2015-11-02 14:05:57 -08:00
Elliott Hughes
1de89478ac Merge "Fix ParseInt/ParseUint to handle explicit "0x" hex."
am: ddf5edacc2

* commit 'ddf5edacc24125730b537265f69a081b19606246':
  Fix ParseInt/ParseUint to handle explicit "0x" hex.
2015-11-02 18:30:59 +00:00
Elliott Hughes
3ab05869d8 Fix ParseInt/ParseUint to handle explicit "0x" hex.
Also improve fastboot error reporting around max-download-size.

Change-Id: Ic3aec9460de01e5264a2803a0a6be3706d73026b
2015-11-02 09:01:53 -08:00
Elliott Hughes
5e58724b33 Merge "fastboot shouldn\'t erase non-existent cache partitions."
am: 9ebdf72a54

* commit '9ebdf72a5465b75ab4ce359e11c1ff6c2f3e376a':
  fastboot shouldn't erase non-existent cache partitions.
2015-10-30 21:42:04 +00:00
Elliott Hughes
2fd45a9cea fastboot shouldn't erase non-existent cache partitions.
Check that the cache partition exists before trying to erase it.

Also clean up some of the C string handling and int booleans.

Bug: http://b/25375777
Change-Id: I1880e542b729f2026ab3a2943d4bee9d659b1eeb
2015-10-30 14:15:22 -07:00
Elliott Hughes
259ad4a8e7 Fix the fastboot build.
load_file takes an int64_t rather than a size_t to support large files on LP32.

Change-Id: I8d3032cab63c30c4158dbc521d3d520415cdf58f
2015-09-02 20:33:44 -07:00
Elliott Hughes
45be42e89e resolved conflicts for merge of 7af48652 to mnc-dr-dev-plus-aosp
Change-Id: Icde642757a1335da49d2f884de33b368888ae709
2015-09-02 20:15:48 -07:00
Dan Willemsen
87a419c8b1 Remove USE_MINGW/CYGWIN; Whitelist windows modules
CYGWIN is not supported, USE_MINGW and HOST_OS==windows are being
replaced with LOCAL_..._windows variables.

Bug: 23566667
Change-Id: I3e4a1e4097dc994cf5abdce6939e83a91758fd75
2015-09-02 17:10:35 -07:00
Patrick Tjin
51e8b03f84 fastboot: add flashing bootloader commands
add the following commands:
    flashing unlock_bootloader
    flashing lock_bootloader
    flashing get_unlock_bootloader_nonce

Change-Id: Ia4f56ebdcb6785a5196cc669d68da1553ed53c58
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-09-01 12:40:12 -07:00
Elliott Hughes
3ab8b859c2 Fix missing <stdarg.h>.
system/core/fastboot/engine.cpp:84:5: error: use of undeclared identifier 'va_start'

Change-Id: I8aff9a40d33f403c0d0d91a15638863fe24dca2e
2015-08-25 19:34:13 -07:00
Elliott Hughes
fc79767fc2 Use 64-bit file sizes in fastboot.
Bug: 20110580
Change-Id: I5d3718103ff581ff3b5241c8b0e52b585b4f37e5
2015-08-25 19:11:52 -07:00
Elliott Hughes
b46964f3c9 fastboot should say which device it's waiting for.
Change-Id: Ia8a04b2727983cb05a9a3e85d9a9586b15c71600
2015-08-19 17:49:45 -07:00
Matt Reimer
81c24f6f86 Get fastboot working on OS X
Get fastboot working on OS X by calling USBDeviceOpen() before
calling SetConfiguration().

Change-Id: I5034721d5f33ef18273153ff40eb940baa8261cd
2015-08-19 14:46:17 -07:00
Elliott Hughes
2d4f852da4 Start iterating USB pipe endpoints from 1.
Bug: http://b/22829602
Change-Id: I5051880730ba8fadae5d78f1d19b5d527610d4a5
2015-08-13 16:00:12 -07:00
Elliott Hughes
e1746fda6a Remove the USB vendor id whitelist from fastboot.
Change-Id: I661a0538776d4ba74fcee37e2964d987eb861342
2015-08-10 15:30:54 -07:00
Elliott Hughes
2ae8d2ebae More Mac fastboot failure debugging.
Bug: http://b/22829602
Change-Id: I27738883eb545ed72eaae55fe3a077e6d1421302
2015-08-07 10:49:36 -07:00
Elliott Hughes
6e02c24cfc Include the error code if GetPipeProperties fails.
Bug: http://b/22829602
Change-Id: I90a89e70518053a4581e1862a7dbd5d09e06dadc
2015-08-06 10:48:19 -07:00
Elliott Hughes
93f65faee8 Document the current MAX_USBFS_BULK_SIZE situation.
Bug: http://b/22688598
Change-Id: I8e5b92996d635f6b939f3add4dda0b9023629a8b
2015-07-28 14:18:50 -07:00
Yusuke Sato
07447544ad Rename ZipEntryName to ZipString
since the struct is now used for other purposes. Also add some
comparator functions to the struct to simplify zip_archive.cc.

This is a follow-up CL for f1d3d3b247.

Bug: 21957428
Change-Id: I60d4171eeacc561d59226d946e9eb5f9c96d80cf
2015-06-26 10:34:01 -07:00
Elliott Hughes
fbcb93abe2 Fix Mac fastboot build.
Change-Id: I516c07cee39845caaa47608604eeb30ce15f06cb
2015-06-24 13:28:24 -07:00
Elliott Hughes
75d47421d0 Merge "Move fastboot's Windows code to C++." 2015-06-24 19:30:58 +00:00
Elliott Hughes
20750ad823 Move fastboot's Mac OS code to C++.
Change-Id: I4f452860a401a115b6e8349237923949f2f476d1
2015-06-24 11:17:28 -07:00
Elliott Hughes
c636b64e31 Move fastboot's Windows code to C++.
Change-Id: I92414594cbdbc1896402c6d950d890042f8df6cf
2015-06-24 10:48:43 -07:00
Elliott Hughes
b3748de33f Move fastboot to C++.
Minimal conversion.

Change-Id: I32cbf125be481a8757720d10fa303c38a7fd5e38
2015-06-23 20:56:01 -07:00
Elliott Hughes
08df533e2a Fix fastboot --help formatting.
Bug: http://b/21755417
Change-Id: I827d8e9ebe7ba8e8f75c2fa0ca975560817c18fa
2015-06-10 12:10:00 -07:00
Elliott Hughes
8bdd4bbc1c Add a working Windows tmpfile(3) to fastboot.
Windows' tmpfile(3) implementation requires administrator rights because
it creates temporary files in the root directory. Write an alternative
that uses the user's temporary directory instead.

Bug: http://b/21558406
Change-Id: Ic9aece5c69429797a332a97681a76b76ac3551bf
(cherry picked from commit a26fbeeaa4)
2015-06-05 13:28:44 -07:00
Elliott Hughes
966339b2d6 Don't say "update package missing" unless we mean it.
unzip_to_file reports failures itself these days, so there's it's unhelpful
of the caller to just guess what might have gone wrong.

Bug: http://b/21558406
Change-Id: I1e3d06c6cf902b8c6ef333dc60fd8f49680a493b
(cherry picked from commit acdbe92c60)
2015-06-04 13:26:57 -07:00
Elliott Hughes
c688c23286 'usb' doesn't need to be global in fastboot.
Bug: http://b/21558406
Change-Id: Id014399640865d889918661bae0161b3165eee48
(cherry picked from commit c0ce65f961)
2015-06-04 13:26:48 -07:00
Elliott Hughes
e283ca29c5 Add "fastboot --version".
So bug reporters can actually tell us what they're running.

Bug: http://b/21558406
Bug: http://b/21583225
Change-Id: If2a4ae97b4792aa321566603ce2c354a72d32307
(cherry picked from commit 379646b2ca)
2015-06-04 13:26:40 -07:00
Narayan Kamath
67ab5d9505 Use base::WriteFully in zip_archive.
We're already linking against libbase but we'll have to add
a libbase dependency to every target that includes libziparchive
as a STATIC_LIBRARY dependency, given that there's no way to
express that what we want (except by adding a LOCAL_WHOLE_STATIC_LIBRARY
dependency on libbase to libziparchive but that seems bad too)

Bug: http://b/21558406
Change-Id: I294ad389a9c61a1134a7bc323da25b0004a8f1e0
(cherry picked from commit e97e66ea7c)
2015-06-04 13:26:22 -07:00
Elliott Hughes
a26fbeeaa4 Add a working Windows tmpfile(3) to fastboot.
Windows' tmpfile(3) implementation requires administrator rights because
it creates temporary files in the root directory. Write an alternative
that uses the user's temporary directory instead.

Bug: http://b/21558406
Change-Id: Ic9aece5c69429797a332a97681a76b76ac3551bf
2015-06-03 15:27:52 -07:00
Narayan Kamath
f6e9ffbc73 Fix file descriptor leak when opening invalid archives.
Also add -Wunreachable-code to the set of compiler flags, otherwise
noreturn becomes considerably less useful.

bug: https://code.google.com/p/android/issues/detail?id=171099
Change-Id: I9a95d45633c731c7046d4e4a39844d9cebfd1718
(cherrypick of 241bcf05e0e394bbf2681f359f52646dd6c707f6.)
2015-06-03 12:16:43 -07:00
Elliott Hughes
acdbe92c60 Don't say "update package missing" unless we mean it.
unzip_to_file reports failures itself these days, so there's it's unhelpful
of the caller to just guess what might have gone wrong.

Bug: http://b/21558406
Change-Id: I1e3d06c6cf902b8c6ef333dc60fd8f49680a493b
2015-06-03 11:01:41 -07:00
Elliott Hughes
f26eb51c2a Merge "Add "fastboot --version"." 2015-06-03 02:36:50 +00:00
Elliott Hughes
379646b2ca Add "fastboot --version".
So bug reporters can actually tell us what they're running.

Bug: http://b/21583225
Change-Id: If2a4ae97b4792aa321566603ce2c354a72d32307
2015-06-02 13:50:00 -07:00
Elliott Hughes
c0ce65f961 'usb' doesn't need to be global in fastboot.
Change-Id: Id014399640865d889918661bae0161b3165eee48
2015-06-02 13:34:07 -07:00
Badhri Jagan Sridharan
a873e1dc02 fastboot: Add support for fastboot flashing commands
Commands added:
fastboot flashing lock
      - Prevents flashing partitions
fastboot flashing unlock
      - Enable user to flashing partitions
fastboot flashing lock_critical
      - Prevents flashing bootloader related
        paritions
fastboot flashing unlock_critical
      - Enables user to flash bootloader
        related partitions
fastboot flashing get_unlock_ability
      - Query bootloader to check if device is
        locked.

(cherry picked from commit bf11095f92)
Change-Id: Id6db16ba32f7a2b1c3f041a76bd3bdf2d3ab471e
2015-05-28 19:15:27 +00:00
Badhri Jagan Sridharan
bf11095f92 fastboot: Add support for fastboot flashing commands
Commands added:
fastboot flashing lock
      - Prevents flashing partitions
fastboot flashing unlock
      - Enable user to flashing partitions
fastboot flashing lock_critical
      - Prevents flashing bootloader related
        paritions
fastboot flashing unlock_critical
      - Enables user to flash bootloader
        related partitions
fastboot flashing get_unlock_ability
      - Query bootloader to check if device is
        locked.

Change-Id: Id6db16ba32f7a2b1c3f041a76bd3bdf2d3ab471e
2015-05-15 18:00:50 -07:00
Narayan Kamath
241bcf05e0 Fix file descriptor leak when opening invalid archives.
Also add -Wunreachable-code to the set of compiler flags, otherwise
noreturn becomes considerably less useful.

bug: https://code.google.com/p/android/issues/detail?id=171099
Change-Id: I9a95d45633c731c7046d4e4a39844d9cebfd1718
2015-05-13 09:20:44 +00:00
Elliott Hughes
fe93e8d2a7 Remove dead files.
Auto-imported from cupcake, not touched since then, or used anyway.

Change-Id: If2d50cddff0238dff818c7bae92fe8e1100fccdf
2015-05-11 21:57:33 -07:00
Narayan Kamath
e97e66ea7c Use base::WriteFully in zip_archive.
We're already linking against libbase but we'll have to add
a libbase dependency to every target that includes libziparchive
as a STATIC_LIBRARY dependency, given that there's no way to
express that what we want (except by adding a LOCAL_WHOLE_STATIC_LIBRARY
dependency on libbase to libziparchive but that seems bad too)

Change-Id: I294ad389a9c61a1134a7bc323da25b0004a8f1e0
2015-04-29 14:31:45 +00:00
Colin Cross
1c3a69151b am 10766eac: am 6de70784: am 631cf146: Merge "Fix windows adb build"
* commit '10766eac61120732f11b82b1695207a3a5870a47':
  Fix windows adb build
2015-04-20 20:53:10 +00:00
Colin Cross
dc1e482b20 Fix windows adb build
libc++ is not available on windows yet, but it already defaults to
static libstdc++.

Change-Id: I85a766ead84f71fe1f2f59be6ac739b0b833b6db
2015-04-20 12:43:02 -07:00
Colin Cross
454f35fd75 am 48131449: am 858cd9db: am b2b06de5: Merge "statically link adb and fastboot against libc++"
* commit '48131449d6258e369e5afeb6c665cc6a343ca297':
  statically link adb and fastboot against libc++
2015-04-20 18:56:32 +00:00
Colin Cross
55bf5f0017 statically link adb and fastboot against libc++
libc++.so is not widely available on the host, so we compile against
one built as part of the platform.  This causes problems for adb and
fastboot, which are distributed through a number of channels - the
sdk, distro packages, downloaded from the build server, or manually
copied.  Instead of forcing all users to handle libc++.so too,
statically link against libc++.

Change-Id: I51b75258653a23558c8b598802005f6c1166a439
2015-04-16 17:09:46 -07:00
Mohamad Ayyash
94cd52391c am a15881a9: am ed926596: am 6900d34e: Merge "Add verbose param to sparse_file_import_auto"
* commit 'a15881a9e9d2951eda7a7a85fbaadd93bfb9da9b':
  Add verbose param to sparse_file_import_auto
2015-04-01 18:04:50 +00:00
Mohamad Ayyash
80cc1f6864 Add verbose param to sparse_file_import_auto
Change-Id: I0c5607f7aa5e964abc2031bbe71ff5c6e6ef56cc
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
2015-03-31 12:09:37 -07:00
Elliott Hughes
ac6bc5f45a am 369aa9e9: am 99938804: Merge "fastboot/sparse: propagate error code"
* commit '369aa9e90d741545a7a639f7f0f4cd265faf252e':
  fastboot/sparse: propagate error code
2015-03-19 19:26:19 +00:00
Elliott Hughes
5b40fcbd1d am a782173a: am 261a82a6: Merge "Switch fastboot to ExtractEntryToFile."
* commit 'a782173a26f192fe9f51e1ee53e8d329501df409':
  Switch fastboot to ExtractEntryToFile.
2015-03-19 19:17:40 +00:00
Elliott Hughes
99938804a5 Merge "fastboot/sparse: propagate error code" 2015-03-19 19:05:24 +00:00
Elliott Hughes
a82c89da1f Switch fastboot to ExtractEntryToFile.
Rather than malloc, ExtractToMemory, and write.

Also fix the tmpfile error check (tmpfile returns NULL on failure),
and improve error reporting.

Bug: 19765860
Change-Id: I236923e883128083377607f1519bb2e27b8f03f8
2015-03-19 11:44:32 -07:00
Elliott Hughes
ddaabcf22f am 41233fcc: am 294d3f74: Merge "Remove a prehistoric fastboot hack."
* commit '41233fcc35ce8c5efa06348f013c31072505229b':
  Remove a prehistoric fastboot hack.
2015-03-19 18:27:08 +00:00
Elliott Hughes
787ed98d68 am f99e47a0: am 445e5ede: Merge "Switch fastboot to libziparchive."
* commit 'f99e47a0a0604aef2f3b1d07953d5f220662353c':
  Switch fastboot to libziparchive.
2015-03-19 17:39:57 +00:00
Elliott Hughes
7c6d884e2b Remove a prehistoric fastboot hack.
If you don't have android-info.txt in your zip file, you're probably
not using a current fastboot binary anyway.

Change-Id: Ic721dc5f068f704c6792493d1e99f05f907678ba
2015-03-19 10:30:53 -07:00
Elliott Hughes
b7ca152be0 am 8e70f63a: am 57bf3109: Merge "Prepare for switching to libziparchive."
* commit '8e70f63aba8e14f3b40b2a0769522505c1019c33':
  Prepare for switching to libziparchive.
2015-03-19 16:01:06 +00:00
Elliott Hughes
d30ad8a2ee Switch fastboot to libziparchive.
Bug: 19765860
Change-Id: I83ea56e3b317893995d7106852b65584f99c0e64
2015-03-18 23:23:11 -07:00
Elliott Hughes
253c18d2fb Prepare for switching to libziparchive.
Bug: 19765860
Change-Id: I58249d28fbc4975428d0dcac5107d1994c35676c
2015-03-18 22:47:54 -07:00
Jeremy Compostella
9f0d6bdd66 fastboot/sparse: propagate error code
sparse_file_write_block calls functions that might failed.  This patch
makes sparse_file_write_block catch the error code and propagate it.

Without this patch, fastboot crashes on a segmentation fault if
usb_write() fail during a sparse file image flashing.

Change-Id: If9c0e8dfac8fa380628a2504e13abe8cf7d62726
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2015-03-01 11:54:02 +01:00
Elliott Hughes
7f4e0138ab am 0beef09b: am 58b81bf8: am a82f2b25: Merge "Support "fastboot reboot bootloader"."
* commit '0beef09b1c10ca7d1699078f7b9f2e0912854160':
  Support "fastboot reboot bootloader".
2015-02-25 18:57:43 +00:00
Elliott Hughes
ca85df0662 Support "fastboot reboot bootloader".
This matches the more general adb syntax, though the fastboot
protocol doesn't support rebooting into the recovery image.

Change-Id: I6d93d4c63d4a9b81c71e681e7a7bf76867fba019
2015-02-25 10:02:00 -08:00
Elliott Hughes
6c8de1b1be resolved conflicts for merge of c162dbb2 to master
Change-Id: If7ffc80560a807cb8e4338d42bec454f567fd9ad
2014-12-10 13:53:17 -08:00
Yabin Cui
71a968602d kill libunz
Bug: 18571533
Change-Id: I4214f9236f80629152d969a6ee9fce489079cefa
2014-12-09 22:24:07 -08:00
Christopher Ferris
67a7a4ae27 Fix adb/fastboot windows compilations.
Many of the windows files where not including stdlib.h even though they
are using malloc/free calls.

(cherry-pick of ae7bf0959bd3f79afbf365e41f015ed1c304afdc.)

Change-Id: If6959df9909d9d9928e9f4a2a96018166361cf3c
2014-12-09 16:03:29 -08:00
Elliott Hughes
58cd6d3573 am 7da97265: am ab0d5425: Merge "fastboot: Support USB 3.x SuperSpeed devices on Linux"
* commit '7da97265e596fc1bb112a4b2aa939057fef18fcb':
  fastboot: Support USB 3.x SuperSpeed devices on Linux
2014-12-09 23:44:45 +00:00
Elliott Hughes
7da97265e5 am ab0d5425: Merge "fastboot: Support USB 3.x SuperSpeed devices on Linux"
* commit 'ab0d542506b5fdbcc431ba2606248471d22322ba':
  fastboot: Support USB 3.x SuperSpeed devices on Linux
2014-12-09 14:40:58 +00:00
Jack Pham
1c02213e89 fastboot: Support USB 3.x SuperSpeed devices on Linux
When enumerating USB 3.x devices, an extra 6-byte SuperSpeed
companion descriptor follows each standard endpoint descriptor.
The loop parsing the descriptors will stumble if they're not
handled. Since they're not needed once the bulk endpoints are
identified, we can simply skip over them.

Change-Id: I7e73bcf9135f23c3059cd7c55b432557b28cb6ef
2014-12-05 12:11:20 -08:00
Badhri Jagan Sridharan
c8e84fe7d1 am ad32ebec: am 97133621: Merge "system: core: fastboot: Increase USB protocol buffer size to 1024"
* commit 'ad32ebecc9a0d781f66f39f467be0b30cc05f65b':
  system: core: fastboot: Increase USB protocol buffer size to 1024
2014-12-05 00:15:03 +00:00
Badhri Jagan Sridharan
ad32ebecc9 am 97133621: Merge "system: core: fastboot: Increase USB protocol buffer size to 1024"
* commit '971336213a32e5f3841bc22413632e0108f1c9e2':
  system: core: fastboot: Increase USB protocol buffer size to 1024
2014-12-04 22:38:14 +00:00
Badhri Jagan Sridharan
971336213a Merge "system: core: fastboot: Increase USB protocol buffer size to 1024" 2014-12-04 18:58:46 +00:00
Stephen Hines
622a75d5ab am fafbd329: am ba1552bd: Merge "Clarify the strcmp() with the empty string."
* commit 'fafbd329cb1685dc91172230a0671175e80ca8b3':
  Clarify the strcmp() with the empty string.
2014-11-27 14:01:26 +00:00
Stephen Hines
d97d6d524a am 8d49c8b0: am f66486ef: Merge "Fix incorrect path name check."
* commit '8d49c8b0bfdc7bed855acec603bacc355b5bcb8c':
  Fix incorrect path name check.
2014-11-27 14:01:25 +00:00
Stephen Hines
fafbd329cb am ba1552bd: Merge "Clarify the strcmp() with the empty string."
* commit 'ba1552bd2438a8a47779ed3d05d5ce15bfb5741c':
  Clarify the strcmp() with the empty string.
2014-11-27 13:54:31 +00:00
Stephen Hines
8d49c8b0bf am f66486ef: Merge "Fix incorrect path name check."
* commit 'f66486ef09bfc53da65ca6b4137c47d583f31356':
  Fix incorrect path name check.
2014-11-27 13:54:24 +00:00
Stephen Hines
04f895314d Clarify the strcmp() with the empty string.
Change-Id: Ie246b3c2de3f19b95693f634b0ebd46bdcf3962b
2014-11-26 14:54:43 -08:00
Stephen Hines
f66486ef09 Merge "Fix incorrect path name check." 2014-11-26 22:32:23 +00:00
Stephen Hines
60f21a7f61 Fix incorrect path name check.
This was caught by clang 3.6's -Wpointer-bool-conversion. The device_path
field is a char[256], and thus never NULL. The intention for this code was
to check whether or not there is a named path at all. Checking whether this
is an empty string matches the original intent.

Change-Id: I5ccedc03167e6a457e472089de26130aff7f96e3
2014-11-26 14:30:01 -08:00
Elliott Hughes
0e6d8a3ab4 am 87fdfc71: am cb321921: Merge "fastboot: add parameter for unbuffered stderr/stdout"
* commit '87fdfc718e9eccdd9c40e7bca7a48af40b6bf732':
  fastboot: add parameter for unbuffered stderr/stdout
2014-11-25 19:56:53 +00:00
Elliott Hughes
87fdfc718e am cb321921: Merge "fastboot: add parameter for unbuffered stderr/stdout"
* commit 'cb321921fe04f6ccaeb56c4bf3e8965ee4764738':
  fastboot: add parameter for unbuffered stderr/stdout
2014-11-25 18:52:01 +00:00
Florian Bäuerle
27ded4832d fastboot: add parameter for unbuffered stderr/stdout
This is useful for writing Windows GUIs that want to parse the output of
fastboot before it exits.

Change-Id: Ic0171fe379fc4db7b65b1501e5f2e771ac7c62c4
Signed-off-by: Florian Bäuerle <florian.bae@gmail.com>
2014-11-24 18:12:22 +01:00
Elliott Hughes
224c3735ee am 542324f4: am 0750f786: Merge "Remove explict use of ASCII encoding"
* commit '542324f4b48897d40adb010afc440261c599633d':
  Remove explict use of ASCII encoding
2014-11-21 22:32:42 +00:00
Elliott Hughes
542324f4b4 am 0750f786: Merge "Remove explict use of ASCII encoding"
* commit '0750f78659758352490e599d057a39dc44e93340':
  Remove explict use of ASCII encoding
2014-11-21 19:08:15 +00:00
Al Sutton
2a4b5f9e80 Remove explict use of ASCII encoding
Replace the use of CFStringGetCString with kCFStringEncodingASCII specified
with CFStringGetFileSystemRepresentation which will ensure the correct
character encoding is used to conver the CFString into a NULL terminated
char array suitable for use with POSIX APIs.

Change-Id: Ibab1dc05c4f4db8604d329a493b4241992b8e69d
2014-11-21 15:56:59 +00:00
Elliott Hughes
b99dbe9aaf am 4c2aec09: am aa3e17e1: Merge "Return path including executable instead of without"
* commit '4c2aec09cf2da437f3995ff4cac87e4c20d1d4b0':
  Return path including executable instead of without
2014-11-20 18:47:24 +00:00
Elliott Hughes
4c2aec09cf am aa3e17e1: Merge "Return path including executable instead of without"
* commit 'aa3e17e1b685218cddeb7a05e68ff1721a322147':
  Return path including executable instead of without
2014-11-20 18:43:12 +00:00
Al Sutton
26b53bb75e Return path including executable instead of without
The previous implementation returned the path the executable was in instead
of returning the path including the executable (i.e. it returned ...bin
instead of ...bin/executable). This is not what the original methods did
and caused the process forking of adb to fail.

This patch corrects the implementation.

Change-Id: Ib58497cab35706041f170c1bc97c31fd5d965f90
2014-11-20 13:33:57 +00:00
Elliott Hughes
6309cb35f7 am 2097e9a1: am 20860a28: Merge "Fix building on modern versions of Xcode and OS X."
* commit '2097e9a1491e850545cd0c38522c22dafd2cf6af':
  Fix building on modern versions of Xcode and OS X.
2014-11-19 22:00:18 +00:00
Elliott Hughes
2097e9a149 am 20860a28: Merge "Fix building on modern versions of Xcode and OS X."
* commit '20860a28c5be013da111cb794c92dae02aa30089':
  Fix building on modern versions of Xcode and OS X.
2014-11-19 21:55:28 +00:00
Al Sutton
f456d47c50 Fix building on modern versions of Xcode and OS X.
Recent versions of XCode fail to compile the adb and fastboot binaries due to
two functions being deprecated in 10.9 (GetCurrentProcess and
ProcessInformationCopyDictionary), and the use of -Werrror.

This patch replaces the method implementations which use calls to methods
deprecated in the 10.9 SDK with versions which only call non-deprecated methods.

Change-Id: I855bf26aff45093ca9022924f3ecd1b80f2305a8
2014-11-19 19:50:48 +00:00
Channagoud Kadabi
b2117739ed system: core: fastboot: Increase USB protocol buffer size to 1024
With USB3.0 SS support the max packet size supported by USB protocol
is 1024 bytes. When connected to a USB device in SuperSpeed, if only
512 bytes are sent at a time the device would interpret each transfer
as a short packet and slows down overall throughput. To accommodate
for SuperSpeed USB bulk endpoints, increase the buffer size to 1024.

Change-Id: I4f447fe38045bc0008e2d6dd3f36c2d6819d6c15
2014-11-07 12:01:33 -08:00
Christopher Ferris
8e8ae85754 am ae7bf095: Fix adb/fastboot windows compilations.
* commit 'ae7bf0959bd3f79afbf365e41f015ed1c304afdc':
  Fix adb/fastboot windows compilations.
2014-11-07 03:49:08 +00:00
Christopher Ferris
ae7bf0959b Fix adb/fastboot windows compilations.
Many of the windows files where not including stdlib.h even though they
are using malloc/free calls.

Change-Id: If6959df9909d9d9928e9f4a2a96018166361cf3c
2014-11-06 14:34:24 -08:00
Stephen Hines
82921192f4 am f9d61a00: am 4acabfee: am 64f44b84: Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev
* commit 'f9d61a007426f47337f9842930b15c2160281c58':
  Remove obsolete reference to ddk; Fixes for -Werror
2014-10-02 13:52:59 +00:00
Stephen Hines
f9d61a0074 am 4acabfee: am 64f44b84: Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev
* commit '4acabfee9e00962be02d06a6771da2e7ade20859':
  Remove obsolete reference to ddk; Fixes for -Werror
2014-10-02 13:37:26 +00:00
Stephen Hines
1e95e0b19c am 64f44b84: Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev
* commit '64f44b8444dabd69cf391d42e10d44e8e926a79d':
  Remove obsolete reference to ddk; Fixes for -Werror
2014-10-01 23:21:09 +00:00
Andrew Hsieh
b75d6f1429 Remove obsolete reference to ddk; Fixes for -Werror
Bug: 14416410

1. The new mingw-w64 toolchain x86_64-w64-mingw32-4.8 has ddk
   in x86_64-w64-mingw32/include/ddk
2. Add -Wno-error=cpp to suppress a warning that turns into error
   thanks to -Werror:

      Please include winsock2.h before windows.h
3. Cast GetLastError() return type DWORD to "int"
4. Include direct.h for _mkdir
5. Include stdint.h for uint8_t on Windows

Change-Id: I4bec0587f6573692f08c760da6c98ae551b8b5eb
2014-09-30 02:24:07 -07:00
Daniel Rosenberg
aa3ed7844a am 81b857f3: Merge "fastboot: Remove tos from flashall" into lmp-dev
* commit '81b857f3a21f3ae96a5ec72e54982fe30278049f':
  fastboot: Remove tos from flashall
2014-09-17 14:12:09 +00:00
Daniel Rosenberg
4c13769dba am 24e834ab: am 81b857f3: Merge "fastboot: Remove tos from flashall" into lmp-dev
* commit '24e834ab6037cee0d3e8569d5fd45695f86865bd':
  fastboot: Remove tos from flashall
2014-09-16 21:46:37 +00:00
Daniel Rosenberg
24e834ab60 am 81b857f3: Merge "fastboot: Remove tos from flashall" into lmp-dev
* commit '81b857f3a21f3ae96a5ec72e54982fe30278049f':
  fastboot: Remove tos from flashall
2014-09-16 21:34:45 +00:00
Daniel Rosenberg
015d73ff4e fastboot: Remove tos from flashall
bug: 17498561
Change-Id: I0190c1a5ac635375404799c040e4be523fa29622
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-09-15 13:44:07 -07:00
Jeremy Compostella
310db68903 am a42adff9: fastboot: add the support of the second stage image [DO NOT MERGE]
* commit 'a42adff905600219cbf5ef217d2b46670225aca3':
  fastboot: add the support of the second stage image [DO NOT MERGE]
2014-08-16 05:17:12 +00:00
Jeremy Compostella
a42adff905 fastboot: add the support of the second stage image [DO NOT MERGE]
The AOSP bootimage format allows the use of a second stage image
however the fastboot boot and flash:row commands do not allow the
"secondstage" optional argument.  This patch adds the support of this
argument for both commands.

Change-Id: I00403a95d7460a00233841ba0fe0e8a69d78c7b4
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2014-08-15 21:21:09 -07:00
Ying Wang
0c3d98b02b am 87ad7cdc: am e1ba39aa: Merge "Fix 64-bit host build."
* commit '87ad7cdc590aa4033f0b7ae23d83e2fbc119d07a':
  Fix 64-bit host build.
2014-08-14 23:20:06 +00:00
Ying Wang
42a809ba06 Fix 64-bit host build.
Bug: 13751317
Change-Id: Ibf62935b7d12a55ffc57242a26a2581b52796847
2014-08-14 15:52:54 -07:00
Tim Murray
b2e13ae4fe am 3a5f3db2: am c894ced1: Merge "Fix fastboot for Darwin."
* commit '3a5f3db2aa5324518eb71c69cd1fb3e2125cbd43':
  Fix fastboot for Darwin.
2014-07-25 02:38:02 +00:00
Tim Murray
bd87944805 Fix fastboot for Darwin.
bug 16172793

Change-Id: Ib58446effc13a6e465d176da141b025d36841b8f
2014-07-24 19:27:37 -07:00
Patrick Tjin
4415e2a269 Scan all descriptors when checking for fastboot [DO NOT MERGE]
For Linux, the USB code was only looking at the first
descriptor when searching for the fastboot interface
which caused some devices to not be found.

Also clarify some code by using the actual USB structures
instead of void or char pointers.

(Cherry Picked from aac89db8a5)
Change-Id: I9e4871c4d477ac10ba75bb17a955f176809af289
Signed-off-by: Patrick Tjin <pattjin@google.com>
2014-07-17 10:07:19 -07:00
Patrick Tjin
3a07ce8c04 am 7793a109: am 5328f671: Merge "Scan all descriptors when checking for fastboot"
* commit '7793a10993a357db6a963760737193992055a690':
  Scan all descriptors when checking for fastboot
2014-07-17 12:59:43 +00:00
Patrick Tjin
aac89db8a5 Scan all descriptors when checking for fastboot
For Linux, the USB code was only looking at the first
descriptor when searching for the fastboot interface
which caused some devices to not be found.

Also clarify some code by using the actual USB structures
instead of void or char pointers.

Change-Id: I9e4871c4d477ac10ba75bb17a955f176809af289
Signed-off-by: Patrick Tjin <pattjin@google.com>
2014-07-11 14:15:30 -07:00
Markus Mayer
c335a3500c Fix typo in fs.h
fs.h defined _FH_H_ rather than _FS_H_

Change-Id: I710ef53e88d3601e486fde9957f6d022871d9602
Signed-off-by: Markus Mayer <code@mmayer.net>
2014-07-09 15:27:53 -07:00
Elliott Hughes
67db9d5f73 am b2ac4243: am f76c8fe6: am 328c3ef6: Merge "Fix typo in fs.h"
* commit 'b2ac4243000057baf1656c93197150ba7665137e':
  Fix typo in fs.h
2014-07-10 00:49:53 +00:00
JP Abgrall
fab6ebafa6 am 47050442: am 31132182: am 07703339: Merge "Wait for device to disappear after "fastboot reboot"."
* commit '4705044243225ffde88910154485a84c27a33709':
  Wait for device to disappear after "fastboot reboot".
2014-06-25 00:28:50 +00:00
Daniel Rosenberg
f530c93c4a Added support for vendor partition and image
Modified fastboot to flash vendor.img as well. Moved symlink
for /vendor to occur after mounting partitions. Changed mount
to also create the mount point.

Change-Id: I78e1ba24e6bb8b4af96a67ee0569af579439e682
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-06-24 21:51:31 +00:00
Mark Wachsler
ec25e7bc4b Wait for device to disappear after "fastboot reboot".
This is a follow-up to commit 157b00171a.
After "fastboot reboot", "fastboot devices" was still showing the device as
connected even though it was starting to reboot; now "fastboot reboot" will
wait until the device has disconnected.

The wait timeout is 3 seconds.

Change-Id: I8066741f0be91e53f3e3f5bc968bc1b9de31db05
2014-06-24 22:34:34 +00:00
JP Abgrall
188fdd1c0f Merge "fastboot: Allow searching for needed dynamic libs in '.' (F2FS)" 2014-06-19 20:37:59 +00:00
JP Abgrall
436abebf8c fastboot: Allow searching for needed dynamic libs in '.' (F2FS)
Currently the default rpath includes $ORIGIN/../lib
So we throw in '.' which should help distributions of fastboot.

readelf -d $(which fastboot)|grep RPATH
 0x0000000f (RPATH) Library rpath: [$ORIGIN/../lib:.]

Bug: 15731906
Change-Id: I2f4345d178e5b3c87f6f159faf105ae30f3b52eb
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-19 14:47:19 -07:00
Ying Wang
6b048ce839 Store libf2fs_fmt_host_dyn on the build server.
It will be dynamically loaded by fastboot.

Bug: 15731906
Change-Id: Iff6f2b745b4ffd2c5fe343160b3efb8dcd5702fa
2014-06-19 14:44:23 -07:00
JP Abgrall
64c0ff21e4 fastboot: correctly set dependency on f2fs dynamic lib
In the past it would incorrectly also link against the dlopen()'d lib.

Now it clearly does not care about it.

ldd $(which fastboot)
        linux-gate.so.1 =>  (0xf7735000)
        libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf76d9000)
        libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf75f4000)
        libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf75c7000)
        libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75a9000)
        libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf73ff000)
        /lib/ld-linux.so.2 (0xf7736000)

Bug: 15717498
Change-Id: I5465e97a445b17f5493a1f590e181ef98a382451
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-18 11:13:05 -07:00
Torne (Richard Coles)
11d8ac2afb Only try and use f2fs on linux.
F2FS was already disabled on windows, but the library doesn't build for
mac either, so only try and use it on Linux hosts.

Change-Id: I8bacfa4c01c9ee13123aef6d05d17b3f9094c765
2014-06-18 13:48:38 +01:00
JP Abgrall
6bd72beff6 fastboot: fix windows sdk build (don't do f2fs dyn load on windows)
Only do f2fs dynamic loading on linux.
Adds a stub for windows builds.

Change-Id: I7bbaaa1b2ff5992709d904b7ace40ae263d32922
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 23:43:18 -07:00
JP Abgrall
1235158c29 F2FS support for fastboot format and fsmgr
- Enables fsck.f2fs for partitions with type F2FS.
- Adds support for f2fs as format fs-type.
- f2fs is optional and support is dlopen()d when needed.

Needs changes in
  system/extras/f2fs_utils
  external/f2fs-tools

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 17:01:14 -07:00
Ying Wang
cf86e2f85d Fix host 64-bit build.
Bug: 13751317
Change-Id: Ib42d24408d053bacc24142ed18fc5f3181d2345b
2014-05-16 09:36:17 -07:00
Mark Salyzyn
5957c1ffe7 fastboot: turn on -Werror
- Deal with a missing initializer issue
- Deal with some -Wunused issues
- Deal with some signed/unsigned issues
- switch to usleep from sleep to facilitate win_sdk compile

Change-Id: I64e32a5b0782aeed9582f489e866173c4df1afbf
2014-05-14 08:33:56 -07:00
Alexander Levitskiy
8d7ddb35d5 Revert "System: Fastboot: warning fixit, misc bugs and cleanup."
This reverts commit 782111b3bc.

Change-Id: Ib66400dfaeef7f01e6461a57b9f09be08de2f1fe
2014-05-07 23:31:59 +00:00
Sasha Levitskiy
782111b3bc System: Fastboot: warning fixit, misc bugs and cleanup.
Change-Id: Ib8517a852977962de3f05c879ba7dce89bcef644
Signed-off-by: Sasha Levitskiy <sanek@google.com>
2014-05-07 11:43:12 -07:00
JP Abgrall
7e85974fc2 fastboot: support for overriding format fs-type and size
This changes allows overriding the fs-type and size that
are normally returned by the booloader.

This is in preparation for supporting other FSes.

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-05-06 15:14:15 -07:00
Daniel Rosenberg
73a4ad288f fastboot: Added tos as an optional image
Change-Id: Ibff1f74ee4a949501ceae0b897f896067f022763
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-05-06 12:28:41 -07:00
Daniel Rosenberg
82280594ef fastboot: Fixed optional entries
Previously, if an image was listed as optional, but was not found,
flashall would fail. Now it will proceed if optional images are not
present.

Change-Id: Ic82595cf0cd6ddce4c676de590f03f1a95f32040
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-05-06 12:28:39 -07:00
Dmitry Grinberg
e6f3e9bd26 fastboot: allow format on devices with small buffers
Formatting large partitions on devices with small transfer buffers did
not work before since format used a strange path through the code to
send data. It now uses the normal path. Also cleaned up a bit. FS
code now lives in a separate file and the custom path for format is
gone.

Change-Id: If4e01cabc2e250b7c02ca7ce8c268e51d49e1529
2014-05-06 12:28:37 -07:00
JP Abgrall
8e26b25222 Merge "Fastboot: fix fastboot timeout issue of Windows host side" 2014-05-06 02:24:19 +00:00
Mohamad Ayyash
29fd7b1f4f fastboot: Make tags_offset a command line option.
cherry picked from commit bdf513c5f2

Change-Id: I4ceca528f88cc8ede5742f8a67bec972e41eebe7
2014-05-01 20:31:29 +00:00
Jiebing Li
bbb7981e49 Fastboot: fix fastboot timeout issue of Windows host side
Normally fastboot follows the procedure that host sends a command
to device and device sends back response after the command
is executed.

But sometimes device spends too long time to execute the command
so that timeout error occurs before host receives the response.

This patch fixes the issue by aligning with the solution of ADB.
ADB commit id: 1c4b760a5d

Change-Id: I50e6bf428ea38219b64cca6ab82db22af28e0264
Author: Jiebing Li <jiebing.li@intel.com>
Signed-off-by: Bo Huang <bo.b.huang@intel.com>
2014-04-25 14:15:08 +08:00
The Android Open Source Project
66ed50af68 Merge commit '536dea9d61a032e64bbe584a97463c6638ead009' into HEAD
Change-Id: I5c469a4b738629d99d721cad7ded02d6c35f56d5
2013-11-22 13:44:43 -08:00
Elliott Hughes
14e28d39f7 Fix a bunch of small system/core bugs.
Missing frees in:
  adb/file_sync_client.c
  fastboot/fastboot.c
  libsparse/output_file.c

Missing closedirs in:
  adb/file_sync_service.c
  cpio/mkbootfs.c
  libcutils/dir_hash.c

Potential buffer overrun in:
  gpttool/gpttool.c

Incorrect NULL check in:
  libsparse/backed_block.c

Bug: https://code.google.com/p/android/issues/detail?id=61564
Change-Id: If97838a9e73a77aef7f416c31c237ce1fca4ce21
2013-10-29 14:12:46 -07:00
Mark Wachsler
157b00171a Wait for device to disappear after reboot-bootloader.
(Linux only for now) With fastboot reading serial numbers from sysfs, it had
become possible for a fastboot command issued immediately after rebooting
the bootloader to fail, because sysfs still thought the device was online.
To prevent this, after reboot-bootloader we wait for the device to disconnect.

Also made usb_read and usb_write fail immediately if the descriptor has been
closed; this prevents an incorrect error message ("Bad file descriptor")
when errors from fb_getvar are ignored (e.g., by fb_format_supported).

Also removed unused fd param from filter_usb_device, and simplified logic
in usb_write by using do/while instead of a special case for len == 0.

Change-Id: I799b857eab411fd8ad25f5777fc61c685152ea86
2013-10-17 20:06:32 +00:00