Commit graph

60 commits

Author SHA1 Message Date
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
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
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
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
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
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
Treehugger Robot
e4046c7886 Merge "Allow erase, set_active and download commands only on unlocked devices." 2018-10-08 18:38:59 +00:00
Hridya Valsaraju
d1e623160c Allow erase, set_active and download commands only on unlocked devices.
Bug: 117276890
Bug: 117277405
Bug: 117278071
Test: make

Change-Id: Ic5e3a3ce9e2199578c2788b3b14aac7a8860a270
2018-10-08 10:27:48 -07:00
Treehugger Robot
e06850afdb Merge "Support fastboot variable battery-soc-ok" 2018-10-07 17:53:45 +00:00
Hridya Valsaraju
a534a5a973 Support fastboot variable battery-soc-ok
Bug: 79480454
Test: fastboot getvar battery-soc-ok

Change-Id: Icfd70a71f1598e437316d4b8f895fd851516febb
Merged-In: Icfd70a71f1598e437316d4b8f895fd851516febb
(cherry picked from commit 9a1203b7ac)
2018-10-05 16:16:49 -07:00
Treehugger Robot
02678f32be Merge "Don't hardcode the super partition name." 2018-10-04 19:29:34 +00:00
David Anderson
e5f2f06b00 liblp: Remove the guid field from LpMetadataPartition.
Bug: 117229984
Test: liblp_test gtest
Change-Id: Ie42b3a8005b1cf711303966a2a117c255f0fb08c
2018-10-03 14:48:42 -07:00
David Anderson
5cbd2e43ee Don't hardcode the super partition name.
If a device has logical partitions but does not use a partition called
"super", we will need this to be configurable. Note that the "slot"
argument is currently unused, but will be necessary for update_engine if
there are A and B super partitions.

Bug: 116608795
Test: super partition works
Change-Id: Ieb548a158faeb423f3561230f26d582325efbc6b
2018-10-01 14:13:22 -07:00
Hridya Valsaraju
47658caae4 Interface with health HAL to read battery voltage
Bug: 78793464
Test: fastboot getvar battery-voltage
Change-Id: Ie0763e4f08327ec7649c5629066eb73e8142e0e6
2018-09-28 14:28:49 -07:00
Hridya Valsaraju
7c9bbe948b Add support to read fastboot variable 'off-mode-charge'
Bug: 78793464
Bug: 79480454

Test: fastboot getvar off-mode-charge
Change-Id: I4c40847be292e8e2e420340f81bb624b247bc11b
Merged-In: I4c40847be292e8e2e420340f81bb624b247bc11b
(cherry picked from commit b05d278696)
2018-09-28 14:16:47 -07:00
Hridya Valsaraju
4af80901a6 Support fastboot variable 'variant'.
Bug: 79480454
Bug: 78793464
Test: fastboot getvar variant
Change-Id: Iefef82c147d8405318c793ad0a73f00674bbb63d
Merged-In: Iefef82c147d8405318c793ad0a73f00674bbb63d
(cherry picked from commit 4785287a00)
2018-09-28 11:38:58 -07:00
Treehugger Robot
e4931c5bd4 Merge "Support 'fastboot getvar unlocked' command." 2018-09-26 16:21:28 +00:00
Hridya Valsaraju
dca328d55c Support 'fastboot getvar unlocked' command.
Test: fastboot getvar unlocked.
Bug: 78793464

Change-Id: Ie59c6db90a503e9a6e9ac1c416e4ee5deac60479
2018-09-25 16:25:46 -07:00
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
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
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
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
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
Treehugger Robot
e41cb2e767 Merge "fastbootd: Add an update-super command to sync the super partition." 2018-08-23 00:54:26 +00:00