Commit graph

794 commits

Author SHA1 Message Date
Hridya Valsaraju
a15fe31507 Pass OEM commands to HAL
Bug: 78793464
Bug: 79480454
Test: fastboot oem command

Change-Id: Ibaabef6ea725857102f7531997fcff2a1dbdc1ca
Merged-In: Ibaabef6ea725857102f7531997fcff2a1dbdc1ca
(cherry picked from commit 993b4edb0f)
2018-09-25 22:55:47 +00:00
Tom Cherry
9027af0d40 fastboot: remove engine.cpp/engine.h
Replace the remnants of engine.cpp with better functionality in
FastBootDriver.  Particularly, add prolog() and epilog()
callbacks to FastBootDriver for printing actions and their result to
the console.  Then clean up the rest of fastboot.cpp to directly use
FastBootDriver.

Test: fastboot works
Change-Id: I0ff01d6a10f75e9dc1c82b46c6e9bb3bc4c68638
2018-09-25 14:32:56 -07:00
Tom Cherry
4aa60b382c fastboot: clean up CheckRequirements
CheckRequirements() had various issues that are cleaned up here,

1) Move from C string parsing to C++
2) Moved from C data structures to C++, including fixing memory leaks.
3) Removed the 'cur_product' global and the 'query_save' function that
   stores it
4) Actually writing tests for the parsing function for
android-info.txt
5) Check that a variable needs to be checked for a given product before
   trying to read it.  Previously, fastboot would fail if a variable
   isn't recognized on a device, even if the check should be ignored.

A lot of flexibility is allowed for the input strings, to keep
backwards compatibility with the previous parsers.

Test: fastboot works, unit tests

Change-Id: Idc3bba8b8fe829d8eefe5f6c495e63a9441c0b60
2018-09-21 12:50:39 -07:00
Tom Cherry
dfd85df11a Use vector<char> instead of char* and malloc() for images
And fix the associated memory leaks in the process.

Test: fastboot works
Change-Id: I6e41f351ca6cebf79282d30b1eca1506496e0c21
2018-09-20 16:48:36 -07:00
David Anderson
1109c92bea fastboot: Add vbmeta_mainline to the partition list.
Bug: 115939310
Test: fastboot flash vbmeta_mainline works
      fastboot flashall includes vbmeta_mainline

Change-Id: I081660cd8437ac66cab750b270f5019230050285
2018-09-17 17:34:22 -07:00
Treehugger Robot
e9997f8152 Merge "Integrate with fastboot HAL to get partition type" 2018-09-08 02:47:41 +00:00
Hridya Valsaraju
bf9f8d1a64 Integrate with fastboot HAL to get partition type
Bug: 79480454
Bug: 78793464

Test: fastboot getvar partition-type:userdata

Change-Id: Ib096ee8061568b8503f3a3f2dbb7e19a932162c4
2018-09-07 12:22:00 -07:00
David Anderson
c8ac4e7644 fastbootd: Wait for /dev/block paths when opening logical partitions.
Note that in addition to waiting for the path to appear, we must also
wait for it to be unlinked. Otherwise, we could accidentally access an
older device when opening and closing the same partition twice in a row.

Bug: 114198005
Test: fastboot flashall works
Change-Id: Iddffc34e1ac8aa066c28e7b1a92b09b6dfd7945c
2018-09-06 17:38:06 -07:00
Greg Kaiser
1fd4b364fc Merge changes I891f64fb,I6182d84e
* changes:
  logcat: Fix buffer size
  UsbTransportSniffer: Defensively use 'final'
2018-09-06 17:11:13 +00:00
Tom Cherry
04ccbfd62c Merge "fastboot: remove command queue" 2018-09-06 16:07:18 +00:00
Greg Kaiser
33b07ba96c UsbTransportSniffer: Defensively use 'final'
UsbTransportSniffer invokes the virtual method Close() within
its destructor.  This usage is fine right now, but if a future
class inherited from UsbTransportSniffer and overrode the Close()
method, then this destructor would not act as expected.

To protect against this, we declare Close() 'final' in
UsbTransportSniffer, and add a comment.

Test: Treehugger
Change-Id: I6182d84e7caf67cb06f37c22c6203ad6d6e57f34
2018-09-06 06:18:01 -07:00
Treehugger Robot
8c0a3e0a7d Merge "fastbootd: Implement getvar hw-revision." 2018-09-06 00:55:32 +00:00
Treehugger Robot
950ec1a001 Merge "fastbootd: Perform CRC check when flashing sparse images." 2018-09-05 22:12:32 +00:00
Treehugger Robot
6e66d36c24 Merge "fastbootd: Fix getvar max-download-size formatting." 2018-09-05 22:11:40 +00:00
Treehugger Robot
61b6c5cdfe Merge "Remove request for read access to partitions." 2018-09-05 21:45:24 +00:00
Tom Cherry
11f12099cc fastboot: remove command queue
There is little advantage and increasingly much disadvantage to
queueing up fastboot commands before executing them.  This change
removes the queue in the most simple way possible to enable further
clean up.

Test: fastboot works
Change-Id: I9abab05df07ed167dbe6a42e1eb9eab8f8d4f157
2018-09-05 14:28:47 -07:00
David Anderson
c091c176cb fastbootd: Implement getvar hw-revision.
Bug: 78793464
Test: fastboot getvar hw-revision works
      fuzzy_fastboot Conformance.GetVarRevision passes

Change-Id: I5a3e9893d61e18567f2f818ef06cad8e862d637f
2018-09-05 12:52:15 -07:00
David Anderson
56843eec45 fastbootd: Perform CRC check when flashing sparse images.
Bug: 78793464
Test: fuzzy_fastboot Conformance.SparseCRCCheck passes
Change-Id: I717fbec42599a43bafafa1f73837e115a9f9109a
2018-09-05 12:52:15 -07:00
David Anderson
28b81cdc91 fastbootd: Fix getvar max-download-size formatting.
Bug: 78793464
Test: fuzzy_fastboot Conformance.GetVarDownloadSize passes
Change-Id: I8f33cb01e5b2ba66eab91b2481322d7fae593cf0
2018-09-05 12:52:14 -07:00
Hridya Valsaraju
3ffed21262 Remove request for read access to partitions.
It is not needed for flash or erase.

Bug: 113648914
Test: fastboot flashall
Change-Id: I34ba57ac809934556569e3b38ab594969860882a
2018-09-05 12:11:13 -07:00
David Anderson
4758967bf9 fastbootd: Fix partition size testing issues.
Partition sizes must be reported with an "0x" prefix for fuzzy_fastboot.
Also, with dynamic partitions, the size of a partition can be 0.

Bug: 78793464
Test: fuzzy_fastboot Conformance.PartitionInfo does not error on
      partition sizes when using fastbootd

Change-Id: I4148440bd9ed420878940829618cbf8cee85bf6a
2018-09-04 16:25:06 -07:00
David Anderson
6c30f6e3d2 fuzzy_fastboot: Use uint64_t for partition sizes.
Bug: N/A
Test: fuzzy_fastboot Conformance.PartitionInfo passes
Change-Id: I27182585a1522d22dd3ddfe83ce22e06dd7fc762
2018-09-04 15:58:28 -07:00
David Anderson
03de645aac fastbootd: Fix transport ownership.
This change moves Transport ownership back out of FastBootDriver.
Callers of set_transport must ensure that the previous transport is
destroyed. In addition, deleting a transport now ensures that it is
closed.

Bug: 78793464
Test: fastboot, fuzzy_fastboot works
Change-Id: I8f9ed2f7d5b09fd0820b2677d087a027378f26db
2018-09-04 15:01:12 -07:00
David Anderson
0f6266305e fastbootd: Implement getvar all.
This implements getvar all by invoking each callback and writing an INFO
status for each result. For commands that take arguments, the variable
handler can specify a function that returns all possible arguments.
Currently this only applies to partition variables.

Bug: 78793464
Test: fastboot getvar all works
Change-Id: I1cf84e06bf67614b6f56171c0ee6ca5d7ac383c9
2018-08-31 18:39:28 -07:00
David Anderson
1fb3fd7242 fastbootd: Refactor for getvar all.
It is easier to implement getvar all if we can invoke each variable
handler and collect their results. This change reverts the handlers to
return their messages as an outparam, rather than going through
FastbootDevice.

Bug: 78793464
Test: fastboot getvar works
Change-Id: I8544251ce517526b26435526756359ce220520cc
2018-08-31 17:03:50 -07:00
Dan Willemsen
822465a930 Fix the mac fastboot build
The Carbon framework isn't on the list of libraries that Soong allows
linking against, so this broke the Mac build. This compiles just fine
without Carbon though, and I don't see any references to Carbon in the
code.

Test: mma
Change-Id: I83044d244f7cec778c8b8b6132249c0f016c10fc
2018-08-30 18:26:11 -07:00
Dan Willemsen
4d8929773b Merge "Convert fastboot to Soong" 2018-08-30 23:36:54 +00:00
Treehugger Robot
c47c508dcd Merge "fastboot: Use a single codepath for flashall and update." 2018-08-30 20:12:16 +00:00
Dan Willemsen
ab971b5e7e Convert fastboot to Soong
Also fix adb's version number to match.

See build/soong/README.md for more information.

Test: cd system/core/fastboot; mma
Test: fastboot --version
Test: adb --version
Test: out/host/linux-x86/nativetest/fastboot_test/fastboot_test
Test: out/host/linux-x86/nativetest64/fastboot_test/fastboot_test
Change-Id: I65ea39af9183c602e84f3bc0e4a0d066a30fc464
2018-08-30 11:28:18 -07:00
David Anderson
cf444f3633 fastboot: Use a single codepath for flashall and update.
This patch extracts the common logic out of the flashall and update
command implementations. There is now a FlashAllTool helper class, and
an ImageSource class for commands to specify how to find built images.

With these paths merged, the update command now supports logical
partitions.

Bug: 78793464
Test: flashall works with or without a super partition
      update works with or without a super partition

Change-Id: I63a8690bbc4da6ea98a07eb2c07166ddd993a7b7
2018-08-29 15:58:34 -07:00
Tom Cherry
e51dadb8a7 fastboot: remove 'verify'
This isn't sent by the fastboot client.
This isn't in our bootloader requirement document.
Neither my hikey nor sailfish respond to this.

Test: fastboot still works
Change-Id: I11ff0aed818d98f3427ed427605d99b3c76ccb06
2018-08-29 15:29:20 -07:00
Tom Cherry
566751444d fastboot: remove 'powerdown'
This isn't sent by the fastboot client.
This isn't in our bootloader requirement document.
Neither my hikey nor sailfish respond to this.
The README.md literally uses this as an example for 'unknown command'

Test: fastboot still works.
Change-Id: Ia442a41de517dae078dd7e73c951aadb97646c73
2018-08-29 14:10:47 -07:00
David Anderson
0debda098f fastboot: Clean up the image array a bit.
This makes the following changes to the images array:
 * The "optional_if_no_partition" flag is removed, as it was a temporary
   workaround for super.img.
 * The "flashall" flag is removed.
 * The "needed_for_fastbootd" flag is now an ImageType enum.

Bug: N/A
Test: fastboot builds, flashall works
Change-Id: Id000ea20cf83639cec2c9ae94f28c799b34606f1
2018-08-28 15:17:48 -07:00
David Anderson
95d4093b49 fastboot: Flash boot partitions before rebooting to fastbootd.
Userspace fastboot is required when flashing logical partitions. If for
some reason userspace fastboot is broken, the user may be stuck with
bootloader fastboot. To address this scenario, we now flash "boot",
"vbmeta", "recovery", "dtbo", and "dts" before booting into userspace
fastboot, using whatever fastboot is currently active.

Bug: 78793464
Test: fastboot flashall with device in bootloader fastboot
Change-Id: I773707bbbe9235c560416c70976e32fd8e52a5a3
2018-08-28 12:54:01 -07:00
David Anderson
1d887434da fastboot: Automatically reboot to userspace fastboot.
In order to flash logical partitions, "flashall" must be run against
userspace fastboot. When the bootloader supports the "reboot-fastboot"
command, we now attempt to automatically reboot into userspace fastboot.

We do this by closing the transport, sleeping for one second, and then
polling for a new connection until one is available. FastBootDriver is
then assigned the new transport.

Bug: 78793464
Test: fastboot flashall on device with logical partitions, while booted
      into bootloader fastboot

Change-Id: I6949871b93ab5e352784cabe0963c6ecfc0af36d
2018-08-28 09:07:40 -07:00
Mark Salyzyn
8fb0fb86a7 fastboot: allow automatic detection of super location
Add "super" to the table of known images so that automatic file
resolution can occur.  Add a flag to indicate if the image should
be flashed with flashall and set it to false for the new "super"
image, all else true.

Test: 'fastboot flash super' works.
      'fastboot flashall' does not flash super
Bug: 78793464
Change-Id: I5b85536b1d4890264531af357aba84a061d6df44
2018-08-24 15:24:41 -07:00
Treehugger Robot
07c2c9a58d Merge "Added support to fuzzy_fastboot for more sparse tests" 2018-08-24 17:54:24 +00:00
Aaron Wisner
ab2645514d Added support to fuzzy_fastboot for more sparse tests
Test: Pixel 2
Change-Id: Ibd491336ace4f346c3900a61bca30ac3023e4f21
2018-08-24 16:22:54 +00:00
Aaron Wisner
a5ad20aecc Fix mac build breakage due to missing usb_osx.cpp in
Android.cpp file for libfastboot2

https://android-review.googlesource.com/c/platform/system/core/+/722153

Test: Build on osx
Change-Id: I6151e37581ac332e4d5cfb5e40feb3ea0e3093df
2018-08-24 10:53:04 -05:00
Treehugger Robot
5d3edb1422 Merge changes from topic "fastbootd-flashall"
* changes:
  fastbootd: Support flashall with logical partitions.
  fastboot: Use _WIN32 instead of WIN32.
2018-08-23 18:55:42 +00:00
David Anderson
32e376f848 fastbootd: Support flashall with logical partitions.
Currently, fastboot flashall will try to flash every partition in the
image list. For devices with logical partitions, this will cause those
partitions to be flashed twice (once via super.img, and again for each
individual image). Additionally, super.img is needed to synchronize the
logical partition list, but it is only generated with "make dist",
making it inconvenient for most workflows.

This patch removes automatic flashing of super.img. Instead, devices
with a super partition must now generate a "super_empty.img"
describing the super geometry and logical partition layout. Before
flashing any other partitions, this image is used to ensure the device
has created all necessary logical partitions.

Additionally, before flashing (but after updating super), all logical
partitions that will be flashed are resized to 0. This ensures that
logical partitions will receive more optimal space allocation.

Finally, during flashing of individual images, logical partitions are
resized to the image size, since they do not have hardcoded sizes in the
build.

Bug: 78793464
Test: fastboot flashall can flash vendor, product, product_services
      without a make dist/super.img.

Change-Id: I18c2291e0d0cb10de729c5646b75ac84dde8c871
2018-08-23 10:43:46 -07:00
David Anderson
c3ade7f48a fastboot: Use _WIN32 instead of WIN32.
Bug: N/A
Test: fastboot.exe builds
Change-Id: I316611f581c80ec813b953a7e6074293399ab7d7
2018-08-23 10:42:59 -07:00
Treehugger Robot
e41cb2e767 Merge "fastbootd: Add an update-super command to sync the super partition." 2018-08-23 00:54:26 +00:00
Treehugger Robot
9dc6f90cb8 Merge "adbd: use unique_fd for the usb file descriptors." 2018-08-23 00:45:03 +00:00
Treehugger Robot
e37c5ca4dd Merge "Create fuzzy-fastboot pen tester" 2018-08-23 00:42:54 +00:00
Josh Gao
860cc5ae39 adbd: use unique_fd for the usb file descriptors.
Test: adb shell
Change-Id: I8b5e31377bbda9b02e522e3a4b75ac908197912f
2018-08-22 15:33:08 -07:00
David Anderson
38b3c7a122 fastbootd: Add an update-super command to sync the super partition.
This change introduces an "update-super" command to the fastboot
protocol. Unlike the "flash" command, which copies raw or sparse data to
a partition, the "update-super" command requires the data to be a super
image generated by lpmake.

If the super partition is not yet formatted (or is corrupt), then it
will be formatted using the given image. Otherwise, "update-super" will
preserve the existing partition layout, and only ensure that logical
partition entries exist for all the new partitions in the given image.
All new partitions added this way will have a zero size, and it is the
host's responsibility to size them as needed afterwards with the
"resize-logical-partition" command.

In addition, the "update-super" command supports a "wipe" argument,
which will force the super partition to be reformatted with the given
image, overwriting any existing partition tables.

Bug: 78793464
Test: fastboot flashall with a super partition
Change-Id: If37d839a03e396e11b6c08a9c32984106613d1dc
2018-08-22 15:05:03 -07:00
Chris Fries
1572771495 Merge "Add support to fastboot_driver for sending sparse images with CRC check" 2018-08-22 18:39:16 +00:00
Aaron Wisner
00737b3939 Create fuzzy-fastboot pen tester
Test: Run on Sailfish, Walleye, and other devices
Bug: http://b/111126621
Change-Id: I309af79411d0a16d11874a048ce0db024770d7b2
2018-08-22 11:30:29 -05:00
Aaron Wisner
9812b58fc4 Add support to fastboot_driver for sending sparse images with CRC check
The default argument will prevent anything from breaking

Test: Build on glinux
Change-Id: Ib427ab210476db1ec1c69c0a3238d0653e98b79a
2018-08-22 11:02:47 -05:00
Dario Freni
ab5583b585 s/product-services/product_services/g
Attempting to reduce the number of different spellings we have for
"product services" partition in the codebase.

Bug: 112431447
Test: m
Change-Id: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
Merged-In: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
2018-08-20 17:46:42 +00:00
David Anderson
79ab0e3e98 fastbootd: Complete the implementation of getvar has-slot.
Bug: 78793464
Test: fastboot getvar has-slot:super returns "no"
Change-Id: I80f171df062c008718b810bbe12070834d4aa3fb
2018-08-14 16:24:07 -07:00
David Anderson
3195e6edc3 Allow C++17 in fastboot.
Bug: N/A
Test: fastboot builds
Change-Id: Ife120dbe4f45e8aa83225978ea9d5e88bbb58b9e
2018-08-13 13:18:02 -07:00
Chris Fries
3b984c7efe Merge "Increase fastboot timeout to 30 seconds" 2018-08-13 14:58:34 +00:00
Aaron Wisner
50acca7226 Increase fastboot timeout to 30 seconds
Some OEM commands can take quite a while.
The current 10 second timeout is too small.

Test: fastboot tool
Change-Id: Icf59615919c92dc85807abe3ec5793504cf7a162
2018-08-10 17:44:28 -05:00
David Anderson
d9ba061e77 fastbootd: Add is-userspace variable.
Bug: 78793464
Test: fastboot getvar is-userspace
          returns true for fastbootd
      fastboot getvar is-userspace
          returns false or error for bootloader fastboot.

Change-Id: I80e1ef6dcf3922e4f555cb2e409e3e098c16fbbc
2018-08-09 15:06:53 -07:00
David Anderson
0d4277d7b3 fastbootd: Add commands for logical partitions.
This patch adds the following new commands to fastbootd:

    getvar is_logical:<partition>
    create-logical-logical-partition <partition> <size>
    delete-logical-partition <partition>
    resize-logicallogical-partition <partition> <size>

All of these commands operate on logical partitions only, and require a
properly configured "super" partition to operate.

Bug: 78793464
Test: fastboot create-logical-partition example 4096
      fastboot create-logical-partition example 4096 returns error
      fastboot getvar is-logical:example returns "yes"
      fastboot getvar partition-size:example returns "1000"
      fastboot resize-logicalpartition example 8000
      fastboot getvar partition-size:example returns "2000"
      fastboot delete-logical-partition example
      fastboot getvar is-logical:example returns error
      fastboot getvar is-logical:system_a returns "no"

Change-Id: Iff323eabcf5c559fa04c7c92574650b01803eb1f
2018-08-09 15:06:52 -07:00
David Anderson
88ef0b1f25 fastbootd: Add support for flashing logical partitions.
When flashing logical partitions, we read the "super" partition metadata
corresponding to the current slot. We then temporarily create a
device-mapper device for that partition, and immediately destroy the
device after all operations are complete. We do not mount partitions
ahead of time, or keep them mounted, because a fastboot operation may
change the layout of the logical partition table (or change which slot
is current).

Bug: 78793464
Test: fastboot flash a logical partition under "super"
Change-Id: Id2a61d3592decabeebfd283c4fd6e6cbe576a18c
2018-08-09 11:15:23 -07:00
David Anderson
12211d163e fastbootd: Enable erase and flash commands for physical partitions.
Bug: 78793464
Test: adb reboot fastboot && fastboot flashall

Change-Id: Ibe802c36f6efe20111a2315616ef34d3a027950f
2018-08-09 09:58:37 -07:00
Tao Bao
075c351af2 Merge "fastboot: fastbootd uses libadbd.so." 2018-08-09 16:31:29 +00:00
David Anderson
856b7ecbb6 fastbootd: Allow returning errors from getvar handlers.
Currently a few getvar handlers will return invalid strings when an
error occurs. This change allows those handlers to instead send a proper
failure message.

Bug: 78793464
Test: N/A
Change-Id: I7ff7d036c1e6fb0a3d700ecf21b1103ab77278d2
2018-08-08 18:24:09 -07:00
Tao Bao
b71eedf912 fastboot: fastbootd uses libadbd.so.
The size of `fastbootd` goes down from 64088-byte to 38488-byte
(aosp_taimen-userdebug) after the change.

Bug: 78793464
Test: `m -j installclean && m -j fastbootd`. Check that
      $OUT/recovery/root/system/lib64/libadbd.so exists and
      $OUT/recovery/root/system/bin/fastbootd depends on that.
Change-Id: Ic36c98da1a0dda4e0d86e671f858c42578f53f90
2018-08-08 15:54:48 -07:00
Hridya Valsaraju
31d2c26409 fastbootd: Implement the getvar command.
This implements basic "fastboot getvar" support, including commands supported
by IBootControl.

Bug: 78793464
Test: fastboot getvar <fastboot variable>

Change-Id: Iee1a7b3f43dea46f80dcdf73c45034e2ffe4727d
2018-08-08 11:41:53 -07:00
Treehugger Robot
6b0ecdab15 Merge "fastboot: Fix product-services typo" 2018-08-07 18:24:10 +00:00
David Anderson
8cdea7ff0c fastboot: Fix product-services typo
The build system generates a partition name of "product_services" for
the product-services partition, so fastboot's image list must reflect
this.

Bug: 78793464
Test: fastboot flash product_services works with fastbootd
Change-Id: I348f970c9584fd3dd4369e8cded66b6e39eee2b2
2018-08-07 09:29:11 -07:00
Xin Li
fb973d34ac Merge Android Pie into master
Bug: 112104996
Change-Id: Ib0e5b2801a931b469b753806b1fbe2fabb0c1de5
2018-08-06 17:26:31 -07:00
Treehugger Robot
c4630ef445 Merge "Allow existance of partition to be checked before flashall or update" 2018-08-07 00:20:46 +00:00
Treehugger Robot
c30a75a007 Merge "Add fastbootd." 2018-08-07 00:08:18 +00:00
Hridya Valsaraju
f1f0a9c8a5 Allow existance of partition to be checked before flashall or update
Bug: 112108453
Test: fastboot flashall with super.img and product-services.img in $OUT,
fastboot update with super.img and product-services.img in image.zip.

Change-Id: I5718b5e60c546c55af74292895b3f7fe169e4f02
2018-08-06 11:05:37 -07:00
Aaron Wisner
794fb0107b Merge "Minor fixes to fastboot_driver"
am: 8cf510ff81

Change-Id: I358512c168fbe19c164bb201cf57accdb613f1a3
2018-08-02 17:49:30 -07:00
Treehugger Robot
8cf510ff81 Merge "Minor fixes to fastboot_driver" 2018-08-03 00:41:16 +00:00
Aaron Wisner
c771ae0fd4 Minor fixes to fastboot_driver
- Make RCString() static
- Add clearer error message for 0 length upload error
- Fix regex hex matching for partition-size
- Move ZLP packet checking to SparseWriteCallback()

Test: build fastboot on glinux
Change-Id: I51a040e07b9698a41f64b35a9e2baa8d575527a9
2018-08-02 17:47:38 -05:00
Hridya Valsaraju
dea91b4b53 Add fastbootd.
Fastbootd is started by recovery, and communicates
over usb with the fastboot protocol.

Add additional fastboot commands to move in and out of
fastbootd. "fastboot reboot recovery" and "fastboot reboot fastboot"

Bug: 78793464
Test: fastboot reboot recovery, fastboot reboot fastboot
Change-Id: Iffb77b2d3ceefb7335c38aa9fba7bd17821484f0
2018-08-02 09:43:23 -07:00
Hridya Valsaraju
cb10dca496 Merge "Flash super partition with fastboot flashall"
am: 10601fd512

Change-Id: Ibd1b1ba6ccd16ff82c7c050fb6bdf0121e851268
2018-08-01 13:57:11 -07:00
Treehugger Robot
10601fd512 Merge "Flash super partition with fastboot flashall" 2018-08-01 20:47:53 +00:00
Hridya Valsaraju
94943ee331 Flash super partition with fastboot flashall
Bug: 111763923
Test: fastboot flashall
Change-Id: I9b89825bac00d1237972a61715da05f933ac35ce
2018-08-01 18:30:36 +00:00
Dario Freni
586282a771 Merge "Add product-services.img for fastboot flashall."
am: 8b8d7d67f2

Change-Id: I698a75c06e6041ddf403aba2ae5e894308bce2c3
2018-07-31 19:15:00 -07:00
Treehugger Robot
8b8d7d67f2 Merge "Add product-services.img for fastboot flashall." 2018-08-01 02:00:40 +00:00
Dario Freni
c7ea1afe90 Add product-services.img for fastboot flashall.
This CL is largely and adaptation of
Ifd119650dd3316508870df0dfc770099e95ae1d1

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.

Change-Id: I204a831e052d018018ab124d70ad1ff1610ee007
2018-08-01 00:08:52 +01:00
David Anderson
64465fde9f Merge "fastboot: Fix hang when sparse images end in small chunks."
am: d0d7d0a6b9

Change-Id: Ia98cc2ed8f09ad99aa8d00ba7edb16553827556c
2018-07-30 16:50:32 -07:00
David Anderson
0c7bde8de6 fastboot: Fix hang when sparse images end in small chunks.
When host fastboot sends sparse blocks to the device, it tries to only
send blocks in multiples of 1024 bytes. If a block is not aligned to this
size, the excess bytes are prepended to the next write operation. This
is implemented by doing the write in two steps: first the previous
excess from the last write (plus new data up to alignment), then a
second write for the aligned remainder of the new data.

This logic has a bug if the final block plus the previous excess data
contains >= 1024 but < 2048 bytes. In this case the first write will
drain 1024 bytes from the data, and the second write will not have 1024
bytes to write. Instead of retaining this data for the next write, it
tries to write 0 chunks (and thus 0 bytes), which hangs the ioctl() call.

Bug: N/A
Test: "fastboot flash super super.img" where super.img is generated by
      lpmake, containing system and product_services partitions and
      images.

Change-Id: I9e8523c976ec84d5a57b36a28f4b1ca800edb7e7
2018-07-30 14:48:13 -07:00
Chris Fries
c6e9a94ed0 Merge "Add support for fastboot transport timeouts and USB Reset() on linux"
am: d6f97d67e0

Change-Id: I3da3a3a9679c375572de0a35e40a86f9476918fa
2018-07-26 13:05:34 -07:00
Aaron Wisner
acf78d462f Add support for fastboot transport timeouts and USB Reset() on linux
USB Reset() allows simulating unplugging and replugging device.

Test: build and run fastboot on mac 10.13.3
Test: glinux build and run fastboot
Change-Id: Id924d063e549a4cca9dda03afd8f8fe266f6d2ab
2018-07-26 11:19:44 -05:00
Tobias Thierer
c526c79b37 Merge "Revert "Add derived UsbTransport class with USB reset method""
am: f6ee8fe515

Change-Id: Ia50999004b5505566051e3927daa646a2024687b
2018-07-25 08:34:14 -07:00
Tobias Thierer
f6ee8fe515 Merge "Revert "Add derived UsbTransport class with USB reset method"" 2018-07-25 15:24:54 +00:00
Tobias Thierer
ec1542f22d Revert "Add derived UsbTransport class with USB reset method"
This reverts commit ceb7cbf5fd.

Reason for revert: Broke mac builds:
system/core/fastboot/usb_osx.cpp:513:35: error: use of undeclared identifier 'USB_TRANSACTION_TIMEOUT'
USB_TRANSACTION_TIMEOUT, USB_TRANSACTION_TIMEOUT);
^

Change-Id: Ibe2f9ff2d5c63f9d33f4bd6d9ba962604cf8caeb
2018-07-25 10:41:24 +00:00
Chris Fries
34bdf4e824 Merge "Add derived UsbTransport class with USB reset method"
am: 56795ac483

Change-Id: I0203e059f415ee63600a7f55c42107c21569d96e
2018-07-24 12:41:55 -07:00
Chris Fries
56795ac483 Merge "Add derived UsbTransport class with USB reset method" 2018-07-24 19:30:02 +00:00
Aaron Wisner
ceb7cbf5fd Add derived UsbTransport class with USB reset method
For testing there needs to be a way to simulate unplugging and
replugging a device. This change adds support for a USB reset
method that does this.

Also add timeouts, so USB reads/writes don't block forever
on an unresponsive device.

Test: glinux, fastboot tool still works
Test: Reset confirmed working via wireshark Linux URB captures

Change-Id: I7213a2395d4ef1c0238810e4929ab966e78c8b55
2018-07-24 11:24:15 -05:00
Elliott Hughes
99fea016f4 Merge "fastboot: add tomcherry to OWNERS."
am: b13c49b1b0

Change-Id: I72b43f9e162a3e10fc92b9d5c7be8534ba3dfbdd
2018-07-20 17:11:09 -07:00
Treehugger Robot
b13c49b1b0 Merge "fastboot: add tomcherry to OWNERS." 2018-07-20 22:16:42 +00:00
Chris Fries
40cd9e03c9 Merge "Refactor libfastboot"
am: 767506fc5a

Change-Id: I1e20f30872969dd847fe67a23ebc5975dcb743e7
2018-07-20 14:06:46 -07:00
Chris Fries
767506fc5a Merge "Refactor libfastboot" 2018-07-20 20:52:58 +00:00
Elliott Hughes
4239aa7b75 fastboot: add tomcherry to OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie2a367b7fbf1dd5319a3506d09951d571512f438
2018-07-20 13:20:09 -07:00
Josh Gao
6a928587f8 Merge "fastboot: fix USB_TRACE, make it better."
am: a570644b7d

Change-Id: I1d88e012d14af45e5a7332a1f3f675132c1f8ed4
2018-07-20 13:10:13 -07:00
Treehugger Robot
a570644b7d Merge "fastboot: fix USB_TRACE, make it better." 2018-07-20 20:01:05 +00:00
Jim Tang
a3024ba1fa Merge "Adb and fastboot completion supports zsh users."
am: 74be24d696

Change-Id: I9cc9fdfe875479eb1f6aa2fce7b896fd9d656630
2018-07-20 03:36:23 -07:00
Aaron Wisner
db511207ed Refactor libfastboot
This change creates a nice and clean API for issuing
fastboot commands without using the fastboot tool itself.

Test: fastboot tool itself (now using libfastboot2)
on sailfish, walleye, and other devices.
Test: flash bootloader bootloader.img
Test: flash radio radio.img
Test: -w update img.zip
Test: Manually getvar and reboot commands.

Bug: 111126621
Change-Id: I0022536b204ce0c5ad8329367fd522fa3c57877d
2018-07-19 15:16:47 -05:00
Jim Tang
0bd3432c5b Adb and fastboot completion supports zsh users.
Builtin command "type" in zsh doesn't support -t option and this
is resolved by checking the shell type prior to sourcing them.
Instead of using "type -t" explicitly, check_type() knows the the
type of the current shell and behaves accordingly.

Bug: 110629292
Test: (zsh) source build/envsetup.sh && lunch aosp_arm
      (bash) source build/envsetup.sh && lunch aosp_arm

Change-Id: Ie39e130e9cc87135cfd522abedba11ad5ac25261
2018-07-17 14:19:35 +08:00
Jerry Zhang
8666830fb1 Merge "fastboot: Refactor string constants to constants.h"
am: fcc16c53e1

Change-Id: I97770eed7cb35989fac6bc51dfb5ec1c33e3872a
2018-07-16 17:16:43 -07:00
Jerry Zhang
769a9c1d11 fastboot: Refactor string constants to constants.h
This allows them to be shared between host and device
implementations.

Test: fastboot works
Bug: 78793464
Change-Id: I79271687850ade2a904fd03d6a97dad1a9ab8e1c
2018-07-16 14:18:41 -07:00
Elliott Hughes
1f40b2c171 Merge "Simplify __attribute__((__printf__)) use."
am: 2aa50ff56d

Change-Id: Idbbad879ce10878aef55c4ead9ecaee40a4c1a71
2018-06-26 17:17:48 -07:00
Elliott Hughes
d8a4c60276 Simplify __attribute__((__printf__)) use.
We don't need this now everyone's using clang...

Bug: http://b/69933068
Test: ran tests
Change-Id: I88f0cf03981ade47e210387fd6f3a2706dfeb9b8
2018-06-26 13:07:21 -07:00
Pirama Arumuga Nainar
057fb5bede Merge changes from topic "mingw-clang"
am: b8f4fe4fd4

Change-Id: Ic3fff5a3f8801d9df3b6304cec9b055d6d582949
2018-06-26 12:57:37 -07:00
Pirama Arumuga Nainar
a2df1ef441 Do not customize __format__ for Windows/MinGW to gnu_printf
Bug: http://b/69933090
Bug: http://b/69933068

MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf.  So just use the default that's used for
other platforms.  This also mirrors upstream commit
015e637b4b/.

Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
2018-06-25 11:52:54 -07:00
Josh Gao
f22e953272 fastboot: fix USB_TRACE, make it better.
Fix some bit-rotten instances of printf("%d", size_t), add more
logging for device selection.

Test: fastboot.exe devices
Change-Id: I4683fab8f88805e1ac88e193a1e84821be8bfa4c
2018-06-01 13:05:49 -07:00
Elliott Hughes
7337fd1802 Merge "Clarify 'fastboot flash' help." am: f90137da60
am: 06d71a71fa

Change-Id: I2ebcb2e389abe78329f457b68b23ae4af6e2622f
2018-05-24 22:29:15 -07:00
Elliott Hughes
07fc6828a8 Clarify 'fastboot flash' help.
Bug: http://b/80206492
Test: `fastboot --help`
Change-Id: Idd4305628836eb0bcbcf3d217db0a9fc54a1d6d6
2018-05-24 18:30:58 -07:00
Elliott Hughes
db4c182063 Merge "fastboot: better temporary file errors." am: 9971005cd3
am: 301b6b39c8

Change-Id: I34e9ad732b605bda7239e6f9940ba996c0fbb62c
2018-05-22 11:12:46 -07:00
Elliott Hughes
da1dbd6e6a fastboot: better temporary file errors.
Bug: http://b/80082652
Test: N/A
Change-Id: Ib9f34342157ea3a15fd48504d03f4f3a2c710579
2018-05-21 23:02:26 -07:00
android-build-prod (mdb)
a1ece0bf7f Merge "Make fastboot host builds match adb." am: b004620f80
am: f270f31d72

Change-Id: I9f9d619bf4328db2bab978e457c019b2753ac421
2018-05-08 13:19:11 -07:00
Elliott Hughes
645b50e75d Make fastboot host builds match adb.
Bug: http://b/79131183
Test: builds
Change-Id: I572362e8d1c52ebbfb78f84fd2af5428711317d7
2018-05-08 11:30:07 -07:00
Tao Bao
d5a261670c Merge changes from topic "libsparse-callback" am: 49b7f296b9
am: b2cacbb983

Change-Id: If7807fcc8b33f9a404c25ea53917462b3a320a32
2018-04-30 16:18:51 -07:00
Tao Bao
49b7f296b9 Merge changes from topic "libsparse-callback"
* changes:
  fastboot: Track the libsparse API change.
  libsparse: Use 'size_t' for the 'len' parameter in callbacks.
2018-04-30 21:48:46 +00:00
Paul Crowley
edb12341ac Merge "Wipe metadata when we wipe userdata and cache." am: f88905d231
am: 9f5aa032f8

Change-Id: I001d86a509e46b313bfaf116479ccea3b175cdc1
2018-04-25 14:02:49 -07:00
Paul Crowley
4d17006b57 Wipe metadata when we wipe userdata and cache.
Bug: 78469699
Test: Run "fastboot -w" and see that metadata is wiped
Change-Id: I2d795281c48b59c87d4f8f010037d95186f55684
2018-04-25 10:51:05 -07:00
Tao Bao
7d27ffdd45 fastboot: Track the libsparse API change.
Bug: 78432315
Test: Successfully flash a previously failing (huge) sparse image.
Test: `fastboot update` existing marlin-img.zip.
Change-Id: I09c9a06109769882d26be56d4a0d2a2b7b62cb5f
2018-04-25 10:37:01 -07:00
Tao Bao
c3177b0094 Merge "fastboot: sparse_file_len() returns int64_t." am: 9249f4bc41
am: a1b308e288

Change-Id: I08114ba90aaea4c18e479dbff6f0507b4da239d0
2018-04-25 06:46:11 -07:00
Tao Bao
41cf35f8b2 fastboot: sparse_file_len() returns int64_t.
Check that the value fits in uint32_t that's supported by the current
protocol.

Also fix and sanity check the max_size before passing it to
sparse_file_resparse(), which accepts `unsigned int`. This shouldn't
happen in practice because of RESPARSE_LIMIT (1 GiB).

Test: `fastboot flash` with small and large images.
Change-Id: I0a8279fc14c54c40a70ddce65c3b25173c0d0a40
2018-04-24 18:10:42 -07:00
Elliott Hughes
30b408c6f0 Merge changes I1f55c6e1,Ib2adcf0a am: 395131df7b
am: 4a9a08183e

Change-Id: Ib571c60a499dd349358d7019d8004906b2acdaee
2018-04-20 13:31:45 -07:00
Elliott Hughes
542370dead Move fastboot over to ParseByteCount.
Bug: N/A
Test: `fastboot flashall` and `fastboot -S 100m flashall`
Change-Id: I1f55c6e10be74780bbf8dc30b2d4be3f362ac662
2018-04-19 19:49:44 -07:00
Hridya Valsaraju
cc331a0198 Merge "Remove header version check for command "fastboot boot boot.img"" am: b245377f0e
am: 72a1a812ad

Change-Id: Ia9604f30578452ee8058dab49aa6a9b147abe3dd
2018-04-17 12:12:29 -07:00
Hridya Valsaraju
d016ee4dbe Remove header version check for command "fastboot boot boot.img"
The header version argument is meant for creation of boot images
using boot and flash:raw commands. It is unnecessary to specify the same
while using the boot command with a complete boot image.

Bug: 77920157
Test: fastboot boot boot.img
Change-Id: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
Merged-In: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
2018-04-16 16:55:58 -07:00
Fernando Lugo
24b17cb296 Merge "fastboot: fix header_actual calculation" am: 53135a4772
am: 11f27f42f5

Change-Id: Ibf9a86e1ccc50772460a35343679784782b3c0be
2018-04-11 23:34:10 -07:00
Fernando Lugo
91dfaecca7 fastboot: fix header_actual calculation
Bug: 77920157
Test: fastboot boot $OUT/kernel
Change-Id: Ibe2f4b9a6476ac11937448e6547b5159af011633
Signed-off-by: Fernando Lugo <flugo@google.com>
2018-04-11 19:02:59 -07:00
Dan Willemsen
ca37bd3457 Merge "Fix mac build (ldflags -> ldlibs)" am: 1b2f2ee621
am: 808c7351c5

Change-Id: I1ae0648fdf3706260c476a5ac398d7cc05d43e33
2018-04-11 01:27:01 -07:00
Dan Willemsen
d81279f7ed Fix mac build (ldflags -> ldlibs)
Test: mmma system/core/fastboot   (on mac)
Change-Id: Ib917758c59fc33d6f8d9bd4f8716cf530c646f54
2018-04-10 22:55:55 -07:00
Jaegeuk Kim
64673e14cc Merge "fastboot, fs_mgr: set fsverity feature bit" into pi-dev
am: 44fd93d0d3

Change-Id: I2f5bf8e218c7e8204fbd42a6429c8e76357e42f4
2018-04-10 21:07:57 -07:00
Treehugger Robot
002959e492 Merge changes I983f361d,I899c8433,Ie6f4b029,Ic3cb9c82,I27107d05
* changes:
  Remove unused variable.
  Remove -i vendor id matching.
  Add quotes to -v INFO/OKAY/FAIL for clarity.
  Remove legacy slot-suffix support.
  Add fastboot_test.cpp and test --os-version/--os-patch-level parsing.
2018-04-11 03:22:26 +00:00
Elliott Hughes
7678ffd6d9 Fix Darwin build.
TEMP_FAILURE_RETRY in fs.cpp.

Bug: N/A
Test: N/A
Change-Id: If77da90eeb59e485d5caf4a2e73f7aa91801be2a
2018-04-10 18:01:08 -07:00
Elliott Hughes
bd86420b83 Remove unused variable.
Bug: N/A
Test: builds
Change-Id: I983f361d3d5a779600077a78b121c4ee399089db
2018-04-10 15:59:46 -07:00
Elliott Hughes
f3192bd052 Remove -i vendor id matching.
We removed this from adb years ago.

Bug: N/A
Test: N/A
Change-Id: I899c8433665e64a0c0302d2c30a8e689b8c83d65
2018-04-10 15:38:08 -07:00
Elliott Hughes
234910bc3b Add quotes to -v INFO/OKAY/FAIL for clarity.
This makes it easier to see which part came from the device.

Bug: N/A
Test: fastboot -v flashall
Change-Id: Ie6f4b02933cab21f343998b5fc84f8e487dd3984
2018-04-10 15:34:19 -07:00
Elliott Hughes
42b18a518b Remove legacy slot-suffix support.
Bug: N/A
Test: flashed Pixel
Change-Id: Ic3cb9c8225c75697099723347f7fd820bcadca6e
2018-04-10 15:32:21 -07:00
Elliott Hughes
6ebec932d6 Add fastboot_test.cpp and test --os-version/--os-patch-level parsing.
Also switch all remaining headers over to #pragma once, and actually
use FB_COMMAND_SZ.

Bug: http://b/77340848
Test: ran tests
Change-Id: I27107d054c206e66c39208099e36a55df604e08f
2018-04-10 14:24:02 -07:00
Elliott Hughes
11ff345979 Minimal changes to build fastboot as a library.
Bug: http://b/77809061
Test: builds
Change-Id: I0c388334d643a0a2abf0c03a29f336dc3af2f83f
2018-04-09 20:40:45 -07:00
Dan Willemsen
94e4dc26bb Fix fastboot dist to be compatible with adb
We've got an internal target 'static_sdk_tools' that attempts to ensure
that both adb and fastboot are distributed as artifacts. It's
essentially a loop calling dist-for-goals on
$(HOST_OUT_EXECUTABLES)/{adb,fastboot}.

The dist-for-goals macro has de-duplication checks, but both the src and
dest needs to be identical. Currently adb is using the installed
executable, fastboot is using the built executable, and static_sdk_tools
is trying to use the installed versions of both.

This causes an overriding commands for target warning, which I recently
turned into a warning.

Maybe everything should be converted over to using the built
executables, but that requires a bunch more checks everywhere, and most
places are already using the installed version.

Bug: 77775726
Test: check treehugger, fastboot is dist
Test: m BUILD_HOST_static=1 static_sdk_tools dist
Change-Id: If45fb9706fa75a812610224708b5f95f65b1f1bf
2018-04-09 14:26:23 -07:00
Elliott Hughes
577e8b44b6 Add fastboot --os-version and --os-patch-level.
Also move -c to --cmdline to match the python mkbootimg tool. Remove
the short options for these rarely-used options.

Remove #if 0 cruft from <bootimg/bootimg.h>.

Bug: http://b/77340848
Test: manual testing (need to fix http://b/77809061 for unit tests)
Change-Id: Ieaa795566611bd89ba3fee39a1d9f6ad0713a587
2018-04-09 18:37:39 +00:00
Jaegeuk Kim
b68b02ca5a fastboot, fs_mgr: set fsverity feature bit
Bug: 74604441
Bug: 67380979
Change-Id: Ia336be99eed42bbd0eab1b22e2cc3179a92d5233
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-04-06 10:18:21 -07:00
Elliott Hughes
59efd440eb Remove the "needs_erase" workaround.
This workaround shouldn't be necessary now we're using mke2fs.

Bug: http://b/25429933
Test: `fastboot -w flashall`
Change-Id: I577ad445a02a448102fb49674360a732aa3d153c
2018-04-05 14:24:00 -07:00
Treehugger Robot
243be559a1 Merge "Remove emergency from the fastboot reboot completions." 2018-04-05 02:36:19 +00:00
Treehugger Robot
3810f0076b Merge "Add newer partitions to the fastboot flash completions." 2018-04-05 02:24:34 +00:00
Treehugger Robot
52cd10fed6 Merge "Consistently use - rather than _ in fastboot option tab completion." 2018-04-04 23:11:47 +00:00
Elliott Hughes
eace8e2e53 Merge changes I50e27f46,I0b7cd983,I3639fdee
* changes:
  Remove lock_bootloader/unlock_bootloader.
  Remove `reboot emergency`.
  Clean up fastboot help:
2018-04-04 22:57:17 +00:00
Elliott Hughes
bd1e2dd67d Remove emergency from the fastboot reboot completions.
Bug: N/A
Test: N/A
Change-Id: Ia22f51061c845ea19a697e86ac109c02960251fa
2018-04-04 13:51:54 -07:00
Elliott Hughes
f0b9c7ccd2 Add newer partitions to the fastboot flash completions.
Bug: N/A
Test: `fastboot flash \t`
Change-Id: I1f33c90b8c26b18b9984102ac084b8865d72ff06
2018-04-04 13:51:24 -07:00
Elliott Hughes
b2b90154a8 Consistently use - rather than _ in fastboot option tab completion.
(fastboot actually supports both, but only barbarians use underscore.)

Bug: N/A
Test: `fastboot \t`
Change-Id: I52166d8b0e91285d16bcf65ad51de20f57a00ad1
2018-04-04 13:43:56 -07:00
Elliott Hughes
2e9b779d42 Remove lock_bootloader/unlock_bootloader.
These were implemented on Nexus 5X/6P, but the infrastructure for the
challenge-response system isn't available.

Bug: N/A
Test: N/A
Change-Id: I50e27f469ea7c668de1af314f83f5171376ccda4
2018-04-04 13:36:44 -07:00
Elliott Hughes
2cb9075b63 Remove reboot emergency.
This isn't in the bootloader requirements doc, and the internet implies
that you actually need to use `fastboot oem edl` or `fastboot oem
reboot-edl` anyway.

Bug: N/A
Test: N/A
Change-Id: I0b7cd9839fbd06fc104d029e92d5986dc3c6eda3
2018-04-04 13:31:30 -07:00
Elliott Hughes
fbfa0e8781 Move adb/fastboot bash completion into adb/fastboot.
Bug: http://b/74443706
Test: bash completion still works.
Change-Id: I9da3a0ae748a202407652f513c990e9d05f8b01a
2018-04-04 08:33:33 -07:00
Elliott Hughes
b76188ffc1 Clean up fastboot help:
After:

  usage: fastboot [OPTION...] COMMAND...

  flashing:
   update ZIP                 Flash all partitions from an update.zip package.
   flashall                   Flash all partitions from $ANDROID_PRODUCT_OUT.
                              On A/B devices, flashed slot is set as active.
                              Secondary images may be flashed to inactive slot.
   flash PARTITION [FILENAME]
                              Flash given partition only.

  basics:
   devices [-l]               List devices in bootloader (-l: with device paths).
   getvar NAME                Display given bootloader variable.
   reboot [bootloader]        Reboot device.

  locking/unlocking:
   flashing lock|unlock       Lock/unlock partitions for flashing
   flashing lock_critical|unlock_critical
                              Lock/unlock 'critical' bootloader partitions.
   flashing get_unlock_ability
                              Check whether unlocking is allowed (1) or not(0).

  advanced:
   erase PARTITION            Erase a flash partition.
   format[:FS_TYPE[:SIZE]] PARTITION
                              Format a flash partition.
   set_active SLOT            Set the active slot.
   oem [COMMAND...]           Execute OEM-specific command.

  boot image:
   boot KERNEL [RAMDISK [SECOND]]
                              Download and boot kernel from RAM.
   flash:raw PARTITION KERNEL [RAMDISK [SECOND]]
                              Create boot image and flash it.
   -c CMDLINE                 Override kernel command line.
   --base ADDRESS             Set kernel base address (default: 0x10000000).
   --kernel-offset            Set kernel offset (default: 0x00008000).
   --ramdisk-offset           Set ramdisk offset (default: 0x01000000).
   --tags-offset              Set tags offset (default: 0x00000100).
   --page-size BYTES          Set flash page size (default: 2048).
   --header-version VERSION   Set boot image header version.

  Android Things:
   stage IN_FILE              Sends given file to stage for the next command.
   get_staged OUT_FILE        Writes data staged by the last command to a file.

  options:
   -w                         Wipe userdata.
   -u                         Do not erase partition first when formatting.
   -s SERIAL                  Specify a USB device.
   -s tcp|udp:HOST[:PORT]     Specify a network device.
   -i VENDOR_ID               Filter devices by USB vendor id.
   -S SIZE[K|M|G]             Use sparse files above this limit (0 to disable).
   --slot SLOT                Use SLOT; 'all' for both slots, 'other' for
                              non-current slot (default: current active slot).
   --set-active[=SLOT]        Sets the active slot before rebooting.
   --skip-secondary           Don't flash secondary slots in flashall/update.
   --skip-reboot              Don't reboot device after flashing.
   --disable-verity           Sets disable-verity when flashing vbmeta.
   --disable-verification     Sets disable-verification when flashing vbmeta.
   --wipe-and-use-fbe         Enable file-based encryption, wiping userdata.
   --unbuffered               Don't buffer input or output.
   --verbose, -v              Verbose output.
   --version                  Display version.
   --help, -h                 Show this message.

Bug: N/A
Test: `fastboot --help`

Change-Id: I3639fdee68de544f12e75004ccbb03b8386e64ed
2018-04-03 13:30:18 -07:00
Treehugger Robot
a10d40e2b2 Merge "Add a header-version argument to fastboot" 2018-04-03 18:33:57 +00:00
Jayant Chowdhary
0a5bc29353 Merge "Add dummy vndk library libmkbootimg to enable abi checks on boot_img_hdr." into pi-dev 2018-04-03 16:43:28 +00:00
Jayant Chowdhary
f4bda9a188 Add dummy vndk library libmkbootimg to enable abi checks on boot_img_hdr.
Bug: 74763691

Test: m -j libmkbootimg creates libmkbootimg.so.lsdump.

Test: make -j64

Merged-In: I8d716c560467aaf090f4f7ee9cfbc53a9405f05d
Change-Id: I8d716c560467aaf090f4f7ee9cfbc53a9405f05d
(cherry picked from commit 4cc755dce5)
2018-04-02 17:32:23 -07:00
Hridya Valsaraju
7d824136ae Add a header-version argument to fastboot
The argument would set the boot header
version for flash:raw and boot
commands when they are used for boot
image creation.

Bug: 77154616
Test: Dumped the created boot image and checked
the header version using unpack_bootimg

Change-Id: I2c458996817615f4351db102b4234984108d47c0
Merged-In: I2c458996817615f4351db102b4234984108d47c0
(cherry picked from commit 88de5556ec)
2018-04-02 16:00:59 -07:00
Hridya Valsaraju
88de5556ec Add a header-version argument to fastboot
The argument would set the boot header
version for flash:raw and boot
commands when they are used for boot
image creation.

Bug: 77154616
Test: Dumped the created boot image and checked
the header version using unpack_bootimg

Change-Id: I2c458996817615f4351db102b4234984108d47c0
2018-04-02 22:50:53 +00:00
Elliott Hughes
855cdf82f5 Improve fastboot verbose output.
Move some verbose messages so they're only output with -v.

Remove some misleading verbose messages altogether (such as "wiping
userdata...").

Properly log all the commands sent and responses received. Example:

  $ fastboot -v flashall
  ...
  Sending sparse 'system' 2/2 (443712 KB)
  fastboot: verbose: sending command "download:1b1500d0"
  fastboot: verbose: received DATA 1b1500d0
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (165596160 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (267762688 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (20978688 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (7168 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (3072 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (3072 bytes)
  fastboot: verbose: sending data (1024 bytes)
  fastboot: verbose: sending data (3072 bytes)
  fastboot: verbose: sending data (208 bytes)
  fastboot: verbose: received OKAY
  OKAY [ 13.871s]
  Writing sparse 'system' 2/2
  fastboot: verbose: sending command "flash:system"
  fastboot: verbose: received OKAY
  OKAY [  3.228s]
  Rebooting
  fastboot: verbose: sending command "reboot"
  fastboot: verbose: received OKAY

  Finished. Total time: 36.939s

Bug: http://b/30953083
Bug: http://b/74444116
Test: `fastboot -v flashall`
Change-Id: I2cca198daa062fd1fb732218343263803b111e38
2018-04-02 14:28:18 -07:00
Elliott Hughes
194e27bf5e Merge "Modernize fastboot output format." 2018-04-02 20:47:53 +00:00
Elliott Hughes
f238d8751b Modernize fastboot output format.
After:

  --------------------------------------------
  Bootloader Version...: 0.5
  Baseband Version.....: 0.5
  Serial Number........: serialv1.0
  --------------------------------------------
  Checking product                                   OKAY [  0.032s]
  Sending 'boot' (9962 KB)                           OKAY [  0.350s]
  Writing 'boot'                                     OKAY [  0.143s]
  Sending 'dts' (14 KB)                              OKAY [  0.068s]
  Writing 'dts'                                      OKAY [  0.048s]
  Sending sparse 'system' 1/2 (460796 KB)            OKAY [ 14.383s]
  Writing sparse 'system' 1/2                        OKAY [  4.138s]
  Sending sparse 'system' 2/2 (443712 KB)            OKAY [ 13.871s]
  Writing sparse 'system' 2/2                        OKAY [  3.246s]
  Rebooting
  Finished. Total time: 36.962s

For a failure:

  extracting android-info.txt (0 MB) to RAM...
  --------------------------------------------
  Bootloader Version...: 0.5
  Baseband Version.....: 0.5
  Serial Number........: serialv1.0
  --------------------------------------------
  Checking product                                   FAILED

  Device product is 'hikey960'.
  Update requires 'marlin' or 'sailfish'.

  fastboot: error: requirements not met!

This change also adds a -v/--verbose flag, but doesn't make much use of
it yet (http://b/30953083 will need it).

Bug: N/A
Test: manual
Change-Id: I7d19f5775859ffad5f3be5707b37dcb6e180917f
2018-04-02 11:01:48 -07:00
Jayant Chowdhary
478c7c1eaf Add dummy vndk library libmkbootimg to enable abi checks on boot_img_hdr.
Bug: 74763691

Test: m -j libmkbootimg creates libmkbootimg.so.lsdump.

Test: make -j64

Change-Id: I8d716c560467aaf090f4f7ee9cfbc53a9405f05d
(cherry picked from commit 4cc755dce5)
2018-03-31 07:13:33 -07:00
Elliott Hughes
9b7cd9ad04 Add "require partition-exists=" support.
The Pixel 2 system images release was a bit of a disaster because anyone
using an old version of fastboot would blindly flash too few partitions,
potentially bricking their device. This change lets us add a line to
the android-info.txt file for a device with a new partition.

Also error out sooner in such cases by checking the requirements
immediately, rather than optimistically unpacking everything first.

Switch Action over to C++ to fix memory issues.

Bug: http://b/77158188 (partition checking)
Bug: http://b/74444116 (error out sooner)
Test: manual testing with a modified android-info.txt

(cherry picked from commit 5620d224b6)

Change-Id: Ib97af6f9392f7672430ff71228484e6ee7af6fbf
2018-03-29 10:46:46 -07:00
Bowgo Tsai
de2472d63e Adding odm.img for fastboot flashall
Bug: 64195575
Test: fastboot flashall
Change-Id: Ie6c20a1004867e7c9cfa1894abab9252316a9154
Merged-In: Ie6c20a1004867e7c9cfa1894abab9252316a9154
(cherry picked from commit 017217ec57)
2018-03-29 08:18:37 +08:00
Elliott Hughes
539f3ddff5 Merge "Add "require partition-exists=" support." 2018-03-28 23:25:24 +00:00
Elliott Hughes
5620d224b6 Add "require partition-exists=" support.
The Pixel 2 system images release was a bit of a disaster because anyone
using an old version of fastboot would blindly flash too few partitions,
potentially bricking their device. This change lets us add a line to
the android-info.txt file for a device with a new partition.

Also error out sooner in such cases by checking the requirements
immediately, rather than optimistically unpacking everything first.

Switch Action over to C++ to fix memory issues.

Bug: http://b/77158188 (partition checking)
Bug: http://b/74444116 (error out sooner)
Test: manual testing with a modified android-info.txt
Change-Id: I58b426cad410107e368f35f5725216d07281dd97
2018-03-28 12:43:53 -07:00
Bowgo Tsai
017217ec57 Adding odm.img for fastboot flashall
Bug: 64195575
Test: fastboot flashall
Change-Id: Ie6c20a1004867e7c9cfa1894abab9252316a9154
2018-03-29 01:31:51 +08:00
Bowgo Tsai
7e50de4449 Adding product.img for fastboot flashall
Bug: 64195575
Test: fastboot flashall

Change-Id: Ifd119650dd3316508870df0dfc770099e95ae1d1
Merged-In: Ifd119650dd3316508870df0dfc770099e95ae1d1
(cherry picked from commit 0afc6b07f1)
2018-03-27 09:40:35 +08:00
Bowgo Tsai
0afc6b07f1 Adding product.img for fastboot flashall
Bug: 64195575
Test: fastboot flashall
Change-Id: Ifd119650dd3316508870df0dfc770099e95ae1d1
2018-03-26 15:47:59 +08:00
Steven Moreland
5d88aee9c1 fastboot: only require Linux modules on Linux
The following three modules aren't defined for Windows
builds:
 e2fsdroid mke2fs.conf sload_f2fs

Which leads to the following errors:
build/make/core/main.mk:586: warning: Missing required dependency host_cross_e2fsdroid from module host_cross_fastboot defined in system/core/fastboot/Android.mk
build/make/core/main.mk:586: warning: Missing required dependency host_cross_mke2fs.conf from module host_cross_fastboot defined in system/core/fastboot/Android.mk
build/make/core/main.mk:586: warning: Missing required dependency host_cross_sload_f2fs from module host_cross_fastboot defined in system/core/fastboot/Android.mk

Here, I've removed their requirement for the Windows build and
only included the requirement for the Linux build.

Bug: 7456955
Test: above errors no longer present
Change-Id: I14fdb880d868f893fa5899ea200820bd885a3bc1
2018-02-13 17:49:16 +00:00
Treehugger Robot
b6d7f2655d Merge "Fix fastboot memory corruption." 2018-01-19 22:39:14 +00:00
Elliott Hughes
aaa3b6bbf2 Fix fastboot memory corruption.
Bug: http://b/68664649
Test: echo 'ANDROID!' > fake.img ; fastboot -c `python -c "print 'A'*4000"` boot fake.img
Change-Id: I3299e0fba24a6c1f6178c994731a94cea68f7254
2018-01-18 16:50:14 -08:00
Treehugger Robot
d1f0687fe9 Merge "Add __attribute__((__format__)) to fastboot's die()." 2018-01-09 23:18:39 +00:00
Treehugger Robot
ef213b6d5b Merge "adb/fastboot: switch over to shared AdbWinApi." 2018-01-09 19:49:23 +00:00
Elliott Hughes
3d7fa22164 Add __attribute__((__format__)) to fastboot's die().
Also make the <android-base/stringprintf.h> macro less likely to collide.

Bug: N/A
Test: builds
Change-Id: I868a0a0002c9c53c1ec0670153df2af5f48fd969
2018-01-09 11:18:10 -08:00
Changrong Jin
e69917c59c fastboot: fix log print type mismatch
Test: mma -j8
Change-Id: I8b4373f4a044b802fc9f1dd4f998e880f7843b4a
2018-01-09 11:29:54 +08:00
Josh Gao
b0449da977 adb/fastboot: switch over to shared AdbWinApi.
Bug: http://b/71721338
Test: manually ran adb/fastboot on windows
Change-Id: I9fee6ea4c0e07cbeb69a48e456161832a5994e7b
2018-01-08 16:45:30 -08:00
Jaegeuk Kim
cf27dbacaf Merge "fastboot: support make_f2fs and sload_f2fs for win32" 2017-12-08 00:58:05 +00:00
Jaegeuk Kim
ec87074542 Merge changes from topic "sload_f2fs"
* changes:
  fastboot/fs_mgr/init: add sload_f2fs
  fs_mgr: format f2fs with length=xx fstab
2017-12-08 00:57:42 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Jaegeuk Kim
aa64620eaa fastboot: support make_f2fs and sload_f2fs for win32
This patch enalbes to use windows tools for f2fs.

Change-Id: Id9109d3d1d8db85f433a20c6a9b18a88daa540d0
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-12-06 22:40:08 -08:00
Jaegeuk Kim
899ad558cd fastboot/fs_mgr/init: add sload_f2fs
Change-Id: Iab1e4037cbb835aba97f941c8840b8971caf38e7
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-12-06 22:40:08 -08:00
Jin Qian
0c04f78286 fastboot: fix build break
execvpe is a GNU extension. Use execve instead.

Change-Id: I8bf4b6a4e9fd0cae0239f4c5aa9707f141460a7d
2017-12-05 21:39:40 -08:00
Jin Qian
03c73e106f fastboot: pass environment variables to exec_e2fs_cmd
Set MKE2FS_CONFIG to point to a config file that comes with mke2fs
binary.

Change-Id: I1d68726ff8baa0c00b930b32f66c54c298c46b81
2017-12-05 14:06:26 -08:00
Dan Willemsen
22088fd2d1 Mark more win32 parameters as unused
Missed one new instance with my last patch.

Bug: 69933068
Test: m native-host-cross
Change-Id: Ib6d0b994131a0011b3a2f1a4633b21756a9d6732
2017-11-30 23:35:42 +00:00
Dan Willemsen
f106bb6bb8 Merge "Fix / suppress new unused warnings for mingw+clang" 2017-11-30 22:31:54 +00:00
Dan Willemsen
528f144e77 Fix / suppress new unused warnings for mingw+clang
Bug: 69933068
Test: mmma system/core
Change-Id: I089166a979d3d8c5ada38a7745d507b555048499
2017-11-29 21:37:28 -08:00
Jaegeuk Kim
8d9b6ee621 fastboot: make_f2fs call by linux/darwin
Bug: 69298953
Change-Id: I6a7483e8617b649666247c4ca985384d086f15f8
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-15 14:22:37 -08:00
Jaegeuk Kim
d872118d88 fastboot: support f2fs format
+ quota support

This patch fixes broken f2fs_format by replacing the existing flow with calling
legacy mkfs.f2fs binary explicitly likewise ext4.

This removes obsolete ext4 stuffs as well.

Bug: 67009570
Change-Id: Ia81bcbc7adc3a8b57ada860f7f7871602ac1c6e9
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-11 18:29:02 -08:00
Elliott Hughes
23af112314 fastboot: show how long extraction takes.
Before:
  extracting android-info.txt (0 MB)...
  extracting boot.img (29 MB)...
  target reported max download size of 536870912 bytes
  archive does not contain 'boot.sig'
  archive does not contain 'boot_other.img'
  archive does not contain 'dtbo.img'
  archive does not contain 'dt.img'
  archive does not contain 'recovery.img'
  extracting system.img (1928 MB)...
  archive does not contain 'system.sig'
  extracting system_other.img (574 MB)...
  archive does not contain 'system.sig'
  archive does not contain 'vbmeta.img'

After:
  extracting android-info.txt (0 MB) to RAM...
  extracting boot.img (29 MB) to disk... took 0.232s
  target reported max download size of 536870912 bytes
  archive does not contain 'boot.sig'
  archive does not contain 'boot_other.img'
  archive does not contain 'dtbo.img'
  archive does not contain 'dt.img'
  archive does not contain 'recovery.img'
  extracting system.img (1928 MB) to disk... took 10.122s
  archive does not contain 'system.sig'
  extracting system_other.img (574 MB) to disk... took 3.424s
  archive does not contain 'system.sig'
  archive does not contain 'vbmeta.img'

Bug: http://b/69128980
Test: ran manually
Change-Id: Ib190d1cc56ad9da06a4f9a9e822f7dad4a9a53b7
2017-11-10 08:43:16 -08:00
Connor O'Brien
ebcfa44937 Merge "fastboot: handle small flash block sizes correctly" 2017-11-03 21:15:34 +00:00
Jin Qian
525205508f Merge "fastboot: remove reference of deprecated make_ext4 code" 2017-11-03 17:28:26 +00:00
Tao Bao
67212f9083 fastboot: Don't give parsing error for unsupported 'getvar erase-block-size'.
Couldn't parse erase-block-size '0x'.
Couldn't parse logical-block-size '0x'.
mke2fs 1.43.3 (04-Sep-2016)
...

Some bootloaders explicitly return error on failed query (e.g. walleye),
while others return empty message (e.g. bullhead). We should just return
zero for empty message, instead of giving a misleading parsing error.

Test: `fastboot format userdata` on bullhead, with no parsing error.
Test: `fastboot format userdata` on walleye still works.
Change-Id: I194d41d24679929eccc65bfe895d6ab2a26315b7
2017-11-02 15:53:12 -07:00
Jin Qian
988a51a9fe fastboot: remove reference of deprecated make_ext4 code
Bug: 64395169
Change-Id: Ida14996dc1488657e7bdeb34d6e767a8f6ed44ed
2017-11-02 15:13:46 -07:00
Connor O'Brien
6ef5c24b84 fastboot: handle small flash block sizes correctly
Erase block sizes smaller than the ext4 block size may be valid, but
can incorrectly result in a stripe width smaller than the stride
size. Instead of reporting these sizes as invalid, add a check to
enforce that raid_stripe_width >= raid_stride.

Bug: 68770797
Test: Hack fb_getvar to report small erase block size, run fastboot
-w and confirm it does not print a warning or set stripe_width smaller
than stride.
Signed-off-by: Connor O'Brien <connoro@google.com>

Change-Id: I689ce4bdd5b38bd0952bb6de54785cca39176010
2017-11-02 12:51:46 -07:00
Elliott Hughes
4089d34b93 fastboot should fail if it runs out of space while unzipping.
Previously fastboot would carry on regardless if decompression failed:

  fastboot: archive does not contain 'vbmeta.img'
  fastboot: extracting vendor.img (260 MB)...
  fastboot: W/ziparchive(56777): Zip: unable to allocate  272781472 bytes at offset 0 : No space left on device
  fastboot: failed to extract 'vendor.img': I/O error
  fastboot: archive does not contain 'vendor_other.img'
  fastboot: wiping userdata...

This is because all but "boot" and "system" are considered "optional",
and the implementation of "optional" was "ignore any failures". What it
_should_ have meant was "it's okay if these don't exist, but if they do,
failures matter".

Fix this logic, use die() more aggressively, and remove spurious "\n"s
from die() format strings.

Also fix spurious whitespace in the libziparchive format string. Before:

  Zip: unable to allocate  272781472 bytes at offset 0 : No space left on device

After:

  Zip: unable to allocate 272781472 bytes at offset 0: No space left on device

Bug: http://b/68383022
Test: `fastboot update` on marlin
Change-Id: I3cbf55f1a33ca125f293f873eafbcfb86c880ba8
2017-10-27 14:21:12 -07:00
Jin Qian
1e0df16e20 fastboot: bail out if failed to generate fs image
we don't want to continue fastboot process if failed to
generate fs image. Print an error message and exit early.

Bug: 64915319
Change-Id: I5506d2a7a5063c188685633d6c3890239f9d658e
2017-08-23 13:43:15 -07:00
Josh Gao
f806a3c303 fastboot: gracefully handle failure to open a USB device on OS X.
High Sierra restricts opening some USB devices (e.g. the touchbar)
to processes that have specific entitlements. Ignore devices that we
can't open.

Bug: http://b/64292422
Test: manual
Change-Id: I6074b53a365b8d936610bafea60244f8bba1a33f
2017-08-18 18:25:44 -07:00
David Zeuthen
b6ea435a20 fastboot: Add --disable-verity and --disable-verification options.
This can be used to disable verity and/or verification when flashing a
build to a device. It works with both 'fastboot flashall' and
'fastboot flash vbmeta /path/to/vbmeta.img'.

Bug: 62903976
Test: Manually tested.
Change-Id: Iad22d42a9dd5befd70ecd0224803721a10a28d90
2017-08-07 16:52:55 -04:00
Jin Qian
29fc859a6d fastboot: call mke2fs to format ext4 filesystem on windows
Bug: 35219933
Change-Id: I0cc8c165176e8dc9cbe4b6a52679937bc872e2d0
2017-08-01 00:19:56 +00:00
Jin Qian
99e3964e0d fastboot: enable uninit_bg for ext4
This speeds up mke2fs as well as e2fsck.

Bug: 23686092
Bug: 64032335
Change-Id: I9f2d4c15e431647bb845d50a2361b2a9a091fba6
2017-07-31 23:57:39 +00:00
Jin Qian
3fdf5eca70 fastboot: add mke2fs and e2fsdroid to build package
Bug: 23686092
Bug: 63849632
Change-Id: Iff0d92b7174597d43ee646847888aedc2080052a
(cherry picked from commit 6ce78321a2)
2017-07-21 12:00:16 -07:00
Jin Qian
4afba66781 fastboot: call mke2fs tools to generate ext4 image
Set MKE2FS_CONFIG to empty to use mke2fs default configs

Test: fastboot --wipe-and-use-fbe
Bug: 35219933
Change-Id: Ibc97bb125899e1f1fe820d53709fdb2ab291c171
(cherry picked from commit d14d7c14cb)
2017-07-21 12:00:16 -07:00
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