Commit graph

662 commits

Author SHA1 Message Date
David Anderson
b81bc9ec00 Merge "fastboot: Wait for reboot-fastboot to complete before signaling success." 2018-12-08 06:19:52 +00:00
David Anderson
11d6d278cd fastboot: Wait for reboot-fastboot to complete before signaling success.
Bug: N/A
Test: manual test
Change-Id: I07495c1befcf63607c9996d6da6b4df05c060641
2018-12-07 16:39:55 -08:00
David Anderson
0047580398 fastboot: Check if super_empty.img exists before reading it.
On non-DAP devices, fastboot flash <partition> will spam error messages
about not being able to read super_empty.img. We should check that
super_empty.img exists before trying to read it.

Bug: 120429424
Test: fastboot flash system on non-DAP device
Change-Id: I6c4eec19cb3ef8d24595a75e072e1d75baaa8cdd
2018-12-04 17:12:58 -08:00
Treehugger Robot
a7f54b1592 Merge "C++17 is the default now." 2018-12-04 07:53:24 +00:00
Elliott Hughes
3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -08:00
Mark Salyzyn
307a41fe9f fastboot: call fs_mgr_overlayfs_teardown() in UpdateSuper
When the update-super command is issued, we want overlayfs overrides
to disappear without a doubt, which includes non-A/B utilizing
/cache/overlay/ tree.  Call fs_mgr_overlayfs_teardown() on successful
return.

Test: adb-remount-test.sh
Bug: 120034852
Change-Id: Ia5cdb797f7e8350b5591a51fc8ae5f323901aee4
2018-12-03 07:33:38 -08:00
David Anderson
0c73234fe0 fastboot: Delete logical "other" partitions on retrofit devices.
On retrofit devices, if both slots contain dynamic partition builds,
then "flashall" will attempt to write secondary images to dynamic
partitions in the other slot. At worst, this can fail with an error. At
best, it will result in the "other" partition not being mounted on first
boot.

This patch therefore deletes logical partitions for secondary images, on
retrofit devices only. On a Pixel device on the "b" slot, this means
"system_a" and "vendor_a" will be deleted before flashing, and therefore
system_other and vendor_other will be flashed to physical partitions
instead.

Bug: 120034852
Test: fastboot set_active a
      fastboot flashall
      fastboot set_active b
      fastboot flashall

Change-Id: I6affe9a6c639b0495bffc77fcf20f329b86ad159
2018-11-28 17:47:21 -08:00
Treehugger Robot
4055587ddd Merge changes Ic4e1a1de,Icfceaa46
* changes:
  fastboot: propagate error for format command
  fs_mgr: overlayfs: resize scratch should it be too small
2018-11-28 23:34:29 +00:00
David Anderson
e0e693c32f fastboot: do not die if ANDROID_PRODUCT_OUT undefined
When checking for existence of "super_empty.img" to determine if
flash image product set is meant for logical partitions, we die if
ANDROID_PRODUCT_OUT environment is unset or empty.  This check
is done before we look at the flash image name to determine if it
is a candidate to look at the logical metadata.

Instead, allow this check to conservatively fail for now.

Test: export ANDROID_PRODUCT_OUT=
      fastboot flash bootloader
Bug: 120041144
Change-Id: I43f124015f9d26c79a0feb9123522432fe937343
Merged-In: I43f124015f9d26c79a0feb9123522432fe937343
2018-11-28 18:54:28 +00:00
Jaegeuk Kim
9c4ae20f0e Merge "make_f2fs: use -g android by default" 2018-11-28 00:57:25 +00:00
Mark Salyzyn
a30b6964d6 fastboot: propagate error for format command
If fastboot format command fails, return error.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ic4e1a1dea8861028f19ac7f9c834d26e8adba56c
2018-11-27 13:51:42 -08:00
Treehugger Robot
ee9d6382d1 Merge "Switch from dist-for-goals to dist in Android.bp" 2018-11-27 00:59:19 +00:00
Jaegeuk Kim
46542f9ecc make_f2fs: use -g android by default
Bug: 119875846
Change-Id: I0c6d642d474df5cc678ced9ec4c04027ee51c6d1
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-11-22 03:42:07 -08:00
David Anderson
66a6d8877c Merge "fastbootd: Support two super partitions for retrofit devices." 2018-11-21 17:40:43 +00:00
David Anderson
d25f1c3775 fastbootd: Support two super partitions for retrofit devices.
Retrofit devices will have two super partitions, spanning the A and B
slots separately. By design an OTA will never cause "A" or "B"
partitions to be assigned to the wrong super. However, the same is not
true of fastbootd, where it is possible to flash the inactive slot. We
do not want, for example, logical "system_a" flashing to super_b.

When interacting with partitions, fastbootd now extracts the slot suffix
from a GetSuperSlotSuffix() helper. On retrofit devices, if the partition
name has a slot, that slot will override FastbootDevice::GetCurrentSlot.
This forces partitions in the inactive slot to be assigned to the correct
super.

There are two consequences of this. First, partitions with no slot
suffix will default to the current slot. That means it is possible to
wind up with two "scratch" partitions, if "adb remount" is used on both
the "A" and "B" slots. However, only the active slot's "scratch" will be
visible to the user (either through adb or fastboot).

Second, if one slot does not have dynamic partitions, flashing will
default to fixed partitions. For example, if the A slot is logical and B
is not, flashing "system_a" will be logical and "system_b" will be
fixed. This works no matter which slot is active. We do not try to
upgrade the inactive slot to dynamic partitions.

Bug: 116802789
Test: fastboot set_active a
      fastboot flashall # dynamic partitions
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # false
      fastboot set_active b
      fastboot flashall --skip-secondary
      fastboot getvar is-logical:system_a # true
      fastboot getvar is-logical:system_b # true
      Booting both slots works.

Change-Id: Ib3c91944aaee1a96b2f5ad69c90e215bd6c5a2e8
2018-11-20 13:47:01 -08:00
David Anderson
8956964ee2 fastboot: Warn when flashing dynamic partitions in the bootloader.
On retrofit devices, it is easy to accidentally overwrite
system/vendor/product by flashing system in the bootloader. The reason
is that GPT system_a is really the super partition, and the bootloader
doesn't know it.

Addressing this in bootloaders would require two separate commands: one
that rejects flashing system/vendor/product, and another for
expert/factory use that would allow direct flashing.

This patch introduces protection into the host fastboot tool instead.
It's not mutually exclusive with bootloader changes; having protection
in the host tool affords us better and consistent UI. However it does
rely on users having newer builds.

With this change, the following will not work in the bootloader:

    fastboot flash system       # or vendor, product, etc

The message is the same whether or not the device is a retrofit. To
continue anyway, you can do:

    fastboot flash --force system

If we decide on bootloader protection as well, the --force flag can be
re-used.

Bug: 119689480
Test: fastboot flash system # disallowed in bootloader, allowed in fastbootd
      fastboot flash --force system # allowed in bootloader
Change-Id: I0861e3f28a15be925886d5c30c7ebd4b20c477cf
2018-11-20 12:10:16 -08:00
Dan Willemsen
3f439a7a88 Switch from dist-for-goals to dist in Android.bp
Removes a few more Android.mk files.

Test: check for adb, mkbootfs, and fastboot in the build artifacts
Change-Id: Ie4e50a363a734d0b9207f0d0098c54719f038e76
2018-11-19 23:06:12 -08:00
Mark Salyzyn
9f1cf25332 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-14 09:35:34 -08:00
Eran Messeri
be0ab0a6e0 fastboot: pin USB interface versions on darwin.
Similar to the change to adb in Id26760bc62c89a1f7ef67511b21f9d9252ab69f3,
pin the interface version to IOUSBFamily 5.0.0.

Bug: 119264733
Test: Manual
Change-Id: Ied9164532c0ba6f20415dafecb0c774578aa5c57
2018-11-11 18:14:58 -08:00
David Anderson
90fe0a43ab fastboot: Query the name of the super partition.
This patch adds a new variable, "super-partition-name", to query the
name of the super partition (with a slot suffix if it has one). The
fastboot flashing tool has been updated to query this variable.

Since the super partition name can no longer be determined without
fastbootd, the presence of super_empty.img is used to test for
dynamic partition support rather than the presence of a super partition.

Bug: 116802789
Test: fastboot flashall on retrofit device
Change-Id: If830768eba6de7f31ac3183c64167fae973c77a4
2018-11-06 11:43:04 -08:00
David Anderson
96a9fd4063 fastboot: Fix flashing both slots with dynamic partitions.
When updating the super partition, attempt to preserve partitions from
the other slot. If any partition can't be preserved, fail and require a
wipe (-w) to proceed. This allows two bootable builds to be flashed to
both slots.

The preserve operation can fail if the metadata is not compatible with
the old partition layout. For example, if the partition references a
group that no longer exists, or a group changed its capacity, or the
metadata's block device list or list contents changed.

Bug: N/A
Test: liblp_test gtest
      fastboot flashall --skip-secondary

Change-Id: I53fdd29bc1f0ef132005a93d3cf1cdcd7f2fc05f
2018-11-06 11:43:03 -08:00
David Anderson
63ffb447a7 fastbootd: Partition commands should update all metadata slots.
Without this, it is much more difficult to ensure that the "a" and "b"
slots are both bootable during development. We already update all
metadata slots for update-super, so we should here as well.

Bug: N/A
Test: fastboot flashall
      fastboot set_active other
      fastboot flashall
Change-Id: Ib661e35fa89171a68a0b1da195dc5ba0375d72e4
2018-11-01 17:43:45 -07:00
Treehugger Robot
787de64fad Merge "fastboot: wipe overlayfs for partition" 2018-10-27 00:18:24 +00:00
David Anderson
43cb5db90a Merge "fastbootd: Remove metadata merging code." 2018-10-26 23:23:34 +00:00
Yuchao Zhou
55d31ecd86 Merge "More Mac build fixes." 2018-10-26 22:47:40 +00:00
Mark Salyzyn
044f04baed fastboot: wipe overlayfs for partition
Arrange to delete the overlayfs backing when a specified partition
has been flashed.

Test: manual
Bug: 109821005
Bug: 117605276
Change-Id: I1c6a0341c6cd2ecfbb7c71bec5679a74d579aadd
2018-10-26 20:57:14 +00:00
David Anderson
b6134a6d4e fastbootd: Remove metadata merging code.
The purpose of this code was to support preserving partitions across a
flashall operation. Since we are not supporting persistent read-write
partitions, this merging code is effectively useless - it is preserving
only partitions that will be deleted.

Additionally, this code does not merge partition group changes, since
doing so accurately is difficult. Partition size changes aren't sent
until after update-super resolves, so a valid re-grouping could be
rejected during update-super if the existing partitions are too big.

This patch removes the update-super merging code until a use case comes
along and we can properly evaluate how it should work.

Bug: N/A
Test: fastboot flashall
Change-Id: I1d622b23dabdf031897be9de49f59fc8cf3caf3b
2018-10-26 13:34:40 -07:00
David Anderson
3eb5ba753c Merge "fastboot: Resize logical partitions when using the flash command." 2018-10-26 18:26:42 +00:00
Elliott Hughes
a56a729c14 More Mac build fixes.
The libziparchive public headers that refer to `off64_t` also need the
Mac workaround.

In fastboot, there's a stray `lseek64` but since it's only for offset 0,
any kind of seek is fine.

Bug: N/A
Test: builds
Change-Id: I68b4f95202623ebf07ffe6c3e0e21437e7922c5b
2018-10-26 10:53:24 -07:00
Treehugger Robot
dd85c74655 Merge "fastboot: Check that reboot to userspace succeeded." 2018-10-25 23:06:51 +00:00
David Anderson
629e51c109 fastboot: Resize logical partitions when using the flash command.
If an image size changes slightly in between "flashall" and some change
in the build, it's inconvenient to have to reflash the whole device again.
This patch resizes partitions when using a normal flash command, to
improve the developer workflow.

Bug: N/A
Test: fastboot flash system
Change-Id: I349364a4742a0c15748f545fcfda946107720d45
2018-10-25 20:10:20 +00:00
David Anderson
0444a8cbd9 fastboot: Check that reboot to userspace succeeded.
After rebooting to userspace fastboot, the first command issued is
"update-super". If we wound up in the bootloader by accident (as
happened to a few users with a busted vbmeta_system), the resulting
error message will be very misleading ("update-super" will be an
unrecognized command).

Instead, this patch explicitly errors if we did not successfully boot
into fastbootd.

Bug: N/A
Test: fastboot flashall
Change-Id: I7d5bd64db540978bd0bae884f40ce8c3df48f856
2018-10-25 12:31:49 -07:00
Elliott Hughes
32df7ee5c8 libbase: add O_CLOEXEC to <android-base/file.h>.
We already expose O_BINARY, and O_CLOEXEC seems equally legitimate.

Bug: N/A
Test: builds
Change-Id: I7f07e1bb2a5d6b5c5f293783c39ceab148fabefb
2018-10-24 14:06:45 -07:00
Elliott Hughes
e8f4b14301 Add a simple MappedFile to libbase and switch fastboot and libziparchive over.
This allows us to remove libziparchive's dependency on libutils.

Bug: http://b/79112958
Test: ran libbase and libziparchive tests, ran fastboot manually
Change-Id: I95c651976dad222863e5b8c37d4514b778f5dce7
2018-10-23 13:20:49 -07:00
Treehugger Robot
b59b20caac Merge "fastboot: use constants.h values" 2018-10-18 14:27:33 +00:00
Mark Salyzyn
8e7e9cb395 fastboot: use constants.h values
Cleanup to utilize all the manifest values in constants.h.

If the cli command _and_ the protocol name match, use a common
source of convenient truth.  This should set a pattern for future
additional commands.  When the command and the protocol differ,
we want to introduce resistance as it results in confusion and
maintenance issues.

Test: compile
Change-Id: Idad413c63cbbfcb6e851856105a5d5a9ef53ef29
2018-10-18 14:26:27 +00:00
David Anderson
166bfef4e6 Rename vbmeta_mainline to vbmeta_system.
Bug: 116859651
Test: fastboot flash vbmeta_system
Change-Id: Ice65b6f5141ec6da3e1c91d6a3aac58533dc2314
2018-10-15 14:48:00 -07:00
Treehugger Robot
a605668edd Merge "Do not calculate CRC for sparse images during fastboot flash" 2018-10-10 22:22:30 +00:00
Treehugger Robot
cd72cbb5d8 Merge "set_active command should update current slot information." 2018-10-10 22:13:15 +00:00
Hridya Valsaraju
aec0de5d96 Do not calculate CRC for sparse images during fastboot flash
Bug: 78793464
Test: fastboot flashall

Sparse images with CRC are not supported by the Android build
system and hence the calculated CRC is unused.

Change-Id: Ia48b2f7e29f2adea26d185c5a8f2337c4cbe6dcb
2018-10-10 13:18:35 -07:00
Hridya Valsaraju
20bdf899b2 set_active command should update current slot information.
Boot control HAL implementations will return the current boot
slot as the active slot. If a set_active command is issued on another
slot, it should be considered as the new active slot and subsequent
flashes should flash the same.

Test: fastboot set_active "b", fastboot getvar current-slot
Bug: 78793464
Change-Id: Ida3817670de8e74a7d7ae2a905e7ac1756c6bdf1
2018-10-10 12:25:11 -07:00
Treehugger Robot
9810709d91 Merge "Check validity of partition for getvar:partition-type" 2018-10-09 23:21:54 +00:00
Treehugger Robot
b2263b4a07 Merge "Return partition size in hex format." 2018-10-09 21:38:48 +00:00
Hridya Valsaraju
4165e00d67 Check validity of partition for getvar:partition-type
Test: fastboot getvar partition-type:product_services_a
Bug: 79480454

Change-Id: I4020b0c94daf8fb86c29104aecc1eb8f44f89999
2018-10-09 13:32:04 -07:00
Hridya Valsaraju
2a377da2f6 Return partition size in hex format.
This is required to pass fuzzy_fastboot conformance tests.
Also, allow for zero sized partitions in fuzzy_fastboot.

Test: ./fuzzy_fastboot --gtest_filter=Conformance.Slots
Bug: 117220134

Change-Id: Ifb12994a7796b081215084cb68b37674210aaa12
2018-10-09 12:16:50 -07:00
Treehugger Robot
f7d154e10f Merge "Check maximum allowed download size for download command." 2018-10-08 23:35:10 +00:00
Hridya Valsaraju
aae84e813c Check maximum allowed download size for download command.
Bug: 117272937
Test: fastboot flashall
Change-Id: Ied34a89129813a7f9fce6d4f48d8b65967558731
2018-10-08 14:07:56 -07:00
Treehugger Robot
32f5ff0dae Merge changes Id6c00c76,Ibc74a12f
* changes:
  Check return status of ReadFileToString() in GetDeviceLockStatus()
  Validate partition name when searching for physical partitions.
2018-10-08 20:33:46 +00:00
Hridya Valsaraju
bb12c5e45b Check return status of ReadFileToString() in GetDeviceLockStatus()
Return lock status of true if unable to read kernel command line.

Test: fastboot getvar unlocked
Bug: 117275849
Change-Id: Id6c00c769bcdcdf87fcc9e88902713a8eff3e320
2018-10-08 19:21:12 +00:00
Hridya Valsaraju
99f3772cb2 Validate partition name when searching for physical partitions.
Bug: 117274137
Test: fastboot getvar has-slot:../by-name/system
Change-Id: Ibc74a12f836a30bdf1fd7f6b2a1e941de2430c70
2018-10-08 11:59:07 -07:00