Commit graph

392 commits

Author SHA1 Message Date
Jin Qian
4a335829da fastboot: use filename instead of fd to generate filesystem image
mke2fs tool takes a filename and has its own open function to handle
output file. Change fastboot in preparation to switch from make_ext4
to mke2fs.

Test: fastboot format:ext4 userdata
Bug: 35219933
Change-Id: I7a31cb215f443a4a7cb0bfc23ec28c121a6101e6
2017-05-31 21:23:12 +00:00
Elliott Hughes
1eec97af07 Fix "fastboot flashing".
...without breaking "fastboot oem". Turns out the bootloader actually needs
to know whether it's getting a "flashing" or "oem" command.

Bug: http://b/38321935
Test: "fastboot flashing unlock" "fastboot oem uart enable"
Change-Id: I2b3c0b42b01e3c884aa794fa273034a366985089
2017-05-15 16:53:53 -07:00
Dmitry Shmidt
de8c08c612 fastboot: Add DTS partition support for 'flashall' command
Hikey960 has DTS partiton for DT image

Test: Manual
Bug: 38310807

Change-Id: I9f8e9b27ed40ebdd225f3c4e4b30f53e7cdb5ee7
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-05-15 10:25:31 -07:00
Elliott Hughes
29d5d7d718 Fix "fastboot oem".
Broken by d6365a7052.

Bug: https://issuetracker.google.com/38216236
Test: "fastboot oem uart enable"
Change-Id: I672d5b96bb16fd77e7af61115b8a38606c691ea8
2017-05-11 15:05:13 -07:00
SzuWei Lin
b3526e1ee8 Fix build error when (ADB|FASTBOOT)_VERSION has space
Test: make, and build pass
Change-Id: I8fc608a5b8bccb43b8af72978ce16a945147f62d
2017-05-10 18:52:02 +08:00
Treehugger Robot
6f4d47438d Merge "Show the "platform tools" version in adb/fastboot --version." 2017-05-10 01:41:41 +00:00
Elliott Hughes
4d4f64ff94 Show the "platform tools" version in adb/fastboot --version.
Annoyingly folks parse the "adb --version" output so we have the
less-interesting protocol version first. But at least now we'll
have the "real" version somewhere...

Bug: N/A
Test: "adb --version"/"fastboot --version"
Change-Id: Ia85b561bd8d84c6fd6995923730d36f53b2f800b
2017-05-09 08:21:54 -07:00
Elliott Hughes
d6365a7052 Make fastboot command-line parsing a bit more like adb.
Only show all the help if asked to, and have a few more descriptive
syntax errors.

Also show the help on stdout rather than stderr.

Bug: N/A
Test: manually ran "fastboot flash"/"fastboot update"/"fastboot flashall"
Change-Id: I59abd60e58a56fe7e44da5116a702087c36e14ce
2017-05-09 08:16:23 -07:00
Elliott Hughes
2708a953d2 Give slightly less useless versions to adb and fastboot.
This will let us see (a) whether the user has a legit build or something they
built themselves and (b) what Android release it corresponds to.

This isn't as useful as showing what Platform Tools release we correspond to,
but I'm planning on doing that as a separate line.

Bug: N/A
Test: adb --version ; fastboot --version
Change-Id: Idca489295e3c6f8571146f95822c08808e36b382
2017-05-05 16:29:19 -07:00
Elliott Hughes
bdbcdf3a16 Merge "Clean up the partition name mapping in fastboot." 2017-05-05 00:04:45 +00:00
Elliott Hughes
45964a8e90 Clean up the partition name mapping in fastboot.
Also remove -p.

Bug: N/A
Test: builds
Change-Id: Iea55affc7262323c0d341003359d3175580efbfd
2017-05-03 22:45:37 -07:00
Elliott Hughes
92433d8af0 Remove bogus _LARGEFILE_SOURCE.
Bug: N/A
Test: builds
Change-Id: I145a521a58dc8f838ce188540b02bcda4e81b610
2017-05-03 22:21:16 -07:00
Yueyao Zhu
e67da71dc1 Add dtbo image support for device tree overlay
Test: Used the built fastboot tool to run flashall on a device
Bug: 32969430
Bug: 36813951
Change-Id: If2db3055bb7250a57d9a78b0534df491b68b6224
2017-05-03 14:36:43 -07:00
Treehugger Robot
9349b72a67 Merge changes I5b1a1ce0,I483a18f9
* changes:
  fastboot: Add 'get_staged' command
  fastboot: Add 'stage' command
2017-04-28 18:34:08 +00:00
Jocelyn Bohr
91fefadc2e fastboot: Add 'get_staged' command
(cherry-picked from internal nyc-iot-dev to AOSP)

New user-level command usage:

 * fastboot get_staged <outfile>
   Reads staged data from the last command handled by the device. If the
   last command did not result in staged data, this command will fail.

This enables data staged by OEM commands to be transferred from device
to host. get_staged wraps new device command "upload". Fastboot
clients are not required to support "upload", so get_staged won't
work on all devices.

Bug: 36002804
Test: Implemented "upload" in fastboot on imx6ul. Verified that uploading
      ~100K data from the device works.
Change-Id: I5b1a1ce023f362062505ee62746ea8ab6f36bfbf
(cherry-picked from commit 83a875de994bf48f0faa2a8a23ceb0b8f52b6b04)
2017-04-27 16:47:51 -07:00
Elliott Hughes
bbfc281485 Make "fastboot update" respect $TMPDIR.
Bug: http://b/32701538
Test: TMPDIR=/ fastboot update
Change-Id: I06d1bc8d43b306855dfe19bc736513d3336df287
2017-04-26 17:20:36 -07:00
Jocelyn Bohr
98cc283168 fastboot: Add 'stage' command
(cherry-picked from internal nyc-iot-dev to AOSP)

New user-level command usage:

 * fastboot stage <infile>
   Sends the contents of <infile> to the device to stage for use in the
   next command.

This enables OEM commands to use data downloaded from host to device.

Bug: 35811075
Test: Manual test on imx6ul
Change-Id: I483a18f9f4205d3289ee524656b9d741b16e9fe6
(cherry-picked from commit 001c75c6c0fe6a70a1db2a65253ab3c43ec17d46)
2017-04-26 11:08:41 -07:00
Chris Fries
0ea946c007 fastboot: Support larger transfers during flash
Adding methods to queue and download flashable images by fd instead of
by pointer, so that we can deal with sending large (up to 4GB) files
on windows and linux.  This gets past limitations on linux to read
more than 2GB from a file at a time, as well as memory limitations
on win32, in order to download up to 4GB in a single transfer.

Test: fastboot -w
Test: "flash-all" from nexus factory images site (incl. fastboot -w update)
Test: fastboot flash with large and small image, large and small max-download-size
Test: Sanity check flashing on win32, darwin, linux.
Test: Sanity check 3GB image download (with 3GB max-download-size)
      on win32, darwin, linux.

Bug: 36810152
Change-Id: I528d739d344eb080d59d721dadf3b3b34d4b375e
2017-04-17 09:22:49 -05:00
Chris Fries
6a99971096 fastboot: Cap max size sent to libsparse
This is required for large (>INT_MAX) sparse limit reported by
the target.

Also, patch up return chains of "int" that need to deal with sizes
bigger than 2GB as well as return negative error codes.

Test: -S works with large max-download-size
Test: Flash 3GB system.img with max-download-size 2.5GB

Bug: 36810152
Change-Id: I562a50eabd706bd5b97c71a1aef07c1ffd1a2e5c
2017-04-14 15:44:20 -05:00
Chris Fries
4bf1be7ec8 fastboot: add AdbWinUsbApi as a required module
fastboot uses AdbWinUsbApi on Windows, let's keep it required.

Test: rm -rf out/host; mma fastboot and confirm AdbWinUsbApi is in out/
Bug: 36810152
Change-Id: Ica8b27cb1d0bca260f716dc61fdcea2ccc282623
2017-04-14 15:43:47 -05:00
Elliott Hughes
d2d8b68f70 Merge "Show install path in "adb --version" and "fastboot --version"." 2017-04-04 01:16:11 +00:00
Vineeta Srivastava
20ef986715 Add vbmeta image support for verified boot 2017-03-31 13:22:34 -07:00
Elliott Hughes
1fd46dfa72 Show install path in "adb --version" and "fastboot --version".
Bug: http://b/36766455
Bug: http://b/34691048
Test: ran tests
Change-Id: I4b67ec54d41a281fe7a33c017d3cfbc8055e3b43
2017-03-30 15:10:24 -07:00
Elliott Hughes
4a66730d6a Move "fastboot oem" to std::string.
Not sure how this code got missed when we moved everything else off
C string handling...

  $ adb reboot bootloader
  $ fastboot oem `perl -e 'print "x"x1024;'`

Before:
  <crashes>

After:
  error: Command length (1028) exceeds maximum size (64)

(The error says 1028 instead of 1024 because it includes the "oem ".)

Bug: http://b/36232671
Test: fastboot oem `perl -e 'print "x"x1024;'`
Change-Id: Ib4664e49222bd2b71be5aa3fe81f386d6073414f
2017-03-15 09:40:28 -07:00
Tom Cherry
5b4eb23cfd Remove extraneous .clang-format files
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format.  Therefore, let's reduce the
differences and use only the two top level clang-format files.

Secondly perform some small clean-up of the top level .clang-format
files.  AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed.  AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.

The diff stats for these changes are:

./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)

./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)

./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)

./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)

./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)

./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)

Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
2017-03-14 14:06:31 -07:00
Connor O'Brien
ce16a8a940 Fastboot: use flash erase & logical block size for building userdata
If the bootloader provides erase-block-size and logical-block-size
getvar variables, then pass these to libext4_utils when building a new
userdata image. This info is used to tune stride and stripe-width.

Bug: 33243520
Test: Modify fb_getvar to return values for "erase-block-size" and
"logical-block-size" and check that fastboot -w sets userdata
parameters correctly.
Signed-off-by: Connor O'Brien <connoro@google.com>

Change-Id: Id48b7a3ebb9074983a4422a79a64dcb437c0f888
2017-02-08 18:30:40 -08:00
Elliott Hughes
c8cad2cbfc Merge "Revert "Get fastboot working on OS X"" 2017-02-03 18:40:46 +00:00
Elliott Hughes
35c1a6203e Revert "Get fastboot working on OS X"
This reverts commit 81c24f6f86.

Change-Id: If2f7220ff00582c3e1b38917352ab961ded48642
2017-02-03 01:28:42 +00:00
Elliott Hughes
fc267f865e Merge "fastboot: Workaround for touchbar hang on MBP 2016" 2017-01-26 21:39:39 +00:00
Keith Mok
d23afb5980 fastboot: Workaround for touchbar hang on MBP 2016
fastboot will try to set usb configuration on connected
usb devices. When it tries to change the usb configuration
on iBridge device on MBP 2016 model, it hangs, and frozen
the touchbar. Skip set usb configuration.

Bug: https://code.google.com/p/android/issues/detail?id=231129
Change-Id: Ib055fc0524d26092555fc135588fa362e70eeb39
2017-01-26 19:57:09 +00:00
Pavlin Radoslavov
6adbd4e787 Fix a crash when parsing fastboot command-line arguments
Fix a crash when running "fastboot reboot bootloader"

Test: Manual run "fastboot reboot bootloader" and "fastboot reboot emergency"
Change-Id: I6d163a5b640afcae1dfa606f409e23ec5f499184
2017-01-25 19:07:46 -08:00
Alexey Polyudov
e0bfb759cb fastboot: add EDL mode support
reboot device into emergency download mode (if HW supports it)

Change-Id: If068fdd041c5bdc7bf65515a78aabf18082cba2a
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
2017-01-24 18:55:17 -08:00
Elliott Hughes
84cb36e02d Switch fastboot docs to markdown.
Bug: N/A
Test: N/A
Change-Id: I4713c692f67e1aaba079819a6876d0c7bb94f925
2017-01-13 16:03:13 -08:00
Alex Deymo
b0c395955d Remove "_host" and "_static" suffix from libsparse definition.
This now combines all the "libsparse" libraries into the same soong
target. A minor side-effect of this change is that the libsparse
static library depends on the libz shared library instead of the libz
static library. This minor change has no effect since targets using
the static libsparse library need to explicitly include either the
static libz or the shared one.

Bug: 34220783
Change-Id: I8f41586cf4c3336791cfa57ab4f5ae59a76d7ffa
2017-01-11 19:15:11 -08:00
Alex Deymo
705353ae27 Remove "_static" and "_host" suffix from libext4_utils.
Bug: 34220783
Change-Id: I967dbaa9c48ad1feed2369c3a40f745b86a350f8
2017-01-11 14:05:42 -08:00
David Pursell
c56d63e59d fastboot: update getvar documentation.
The protocol doc states that calling `fastboot getvar` for an unknown
variable should return an empty OKAY message, but in reality modern
devices return a FAIL response in this case (tested with marlin and
shamu).

Additionally, some A/B logic in fastboot expects a FAIL response for
unknown variables in order to function properly.

This CL changes the documentation to match reality.

Bug: http://b/33756193
Test: none
Change-Id: I41f7c80585be73e60ca0ac216787596c4d60a1d5
2016-12-21 15:59:50 -08:00
David Pursell
04396f62da fastboot: fix set_active for legacy A/B.
Legacy A/B implementations use _a and _b slot names, but currently the
set_active command is unconditionally stripping the _ prefix. This CL
adds some code to add the _ back in if connected to a legacy A/B
implementation.

This isn't a complete fix (there are other places in the code that also
unconditionally strip the prefix) but is sufficient for Android Things
use case, and we want to keep this change as small and safe as possible
to avoid breaking anything else.

Bug: http://b/32996227
Test: `fastboot set_active _a` and `fastboot set_active a` works on
      both AndroidThings Edison board and Marlin.
Test: AndroidThings Edison flashall script now completes successfully.
Change-Id: I1a07e48b9e2726f386e9ece5267a9f1d8edefe22
2016-12-15 16:27:48 -08:00
Elliott Hughes
290a228fdc Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for.
Bug: http://b/32878766
Test: boots
Change-Id: Ie0ddfb7e60f2da5f6eefbb10c83a92e88c137ae3
2016-11-14 17:08:47 -08:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Tao Bao
6d881d6db4 Update the header path for ext4_utils.
Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
2016-10-09 10:23:36 -07:00
Mitchell Wills
31dce302db Add fastboot --skip-reboot flag
Add a flag to fastboot that will cause it to not reboot the device after
performing commands like update and flashall.

Fixed: 31743001
Test: run fastboot update with and without --skip-reboot flag
Change-Id: I7f4056249a52779c7fc752c9d1009a58a44762df
2016-09-26 11:27:16 -07:00
Elliott Hughes
82ff315bb0 Add android::base::GetExecutablePath, switch adb and fastboot over.
We'd long had two copies of this stuff, so rather than rewrite both
Linux versions to use android::base::Readlink, let's kill the duplication
too...

Bug: http://b/30988271
Change-Id: I4de58a94a22a4b1faf969a6fc70ca1560a4d5121
2016-09-01 09:24:24 -07:00
Colin Cross
99f6b86733 Replace libziparchive-host with libziparchive
libziparchive-host is no longer necessary, and mixing libziparchive-host
and libziparchive can cause ODR violations.

Change-Id: I27b2cc9974000ee7bf1d1ac15fd7b069862d9b01
2016-08-26 11:12:38 -07:00
Daniel Rosenberg
559cc01e3e resolve merge conflicts of 40eff95 to stage-aosp-master
Change-Id: I91935ba9603ffd41af2009adc13a024701619c52
2016-08-22 20:13:52 -07:00
Daniel Rosenberg
92b4476aa0 Add skip-secondary flag
The skip-secondary flag now replaces flash-primary. This flag will
skip over the secondary images for both flashall and update.

Change-Id: I9f380f3195006d325d6c45776bf79ecec17506ad
(cherry-picked from commit e180929866)
2016-08-19 16:52:26 -07:00
Daniel Rosenberg
8091947847 Switch fastboot to new A/B spec
Slots are now referred to as a and b instead
of _a and _b. For the moment, _a and _b will
still be supported. For old devices that
support A/B, they are assumed to have 2 slots.

Bug: 29643845
Change-Id: Ieab6bed7b4977d8386dcec0afa434371f54bd63f
(cherry-picked from commit 563fcf6f69)
2016-08-19 16:52:26 -07:00
Alex Light
bb9b8a5abf Add Fastboot support for flashing secondary images
Fastboot update and flashall will now flash secondary
images if provided, and if the --slot flag is not set
to 'all'. Also added flash-primary to preserve the
previous behavior, and flash-secondary to just flash
the secondary images.

Fixes from: I5bd2de1c1e0e6224a195b566f7dcbe383555a80a

Bug: 29278988
Change-Id: Ia870e4be55617c0eefa4e1381287f8cd14affe7e
(cherry-picked from commit 6c98509c34)
2016-08-19 16:52:26 -07:00
Daniel Rosenberg
ad3d3c184e Handle invalid suffix lists
Some devices will report an error string as a value
when unknown variables are queried. This can lead to
unexpected behavior, so we attempt to detect this case
by seeing if the suffix list doesn't make sense.

Change-Id: I939b1e01c40ddc05d881fd54423406db250cc8e5
(cherry-picked from commit 190d968414)
2016-08-19 15:31:01 -07:00