Commit graph

640 commits

Author SHA1 Message Date
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
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
4aa42b46c9 Merge "Allow Conformance tests to verify userspace fastboot." 2018-10-08 16:34:26 +00: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
Hridya Valsaraju
bdc1429454 Allow Conformance tests to verify userspace fastboot.
Bug: 117220134
Test: ./fuzzy_fastboot --gtest_filter=Conformance.*

Change-Id: Iab04fdff71e7e90a56d53d24cf14e94c81131009
2018-10-05 15:56:12 -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
Treehugger Robot
49ef2c5897 Merge "Remove tests for sparse images with CRC from fuzzy_fastboot" 2018-10-02 23:05:13 +00:00
Tom Cherry
e6fc328d16 Merge "fastboot: remove engine.cpp/engine.h" 2018-10-02 21:21:50 +00:00
Hridya Valsaraju
94d05063ba Remove tests for sparse images with CRC from fuzzy_fastboot
Sparse images with CRC are currently not supported by the
Android build system.

Test: ./fuzzy_fastboot --gtest_filter=Conformance.*
Change-Id: I6a73fb0dc5d4c77a3d1a0384c137789eb06fa956
2018-10-02 17:21:39 +00: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
Treehugger Robot
c448000e42 Merge "Pass OEM commands to HAL" 2018-09-26 00:29:21 +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
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