Commit graph

770 commits

Author SHA1 Message Date
Jaegeuk Kim
638d05e84e fastboot: add casefold/projid/compress options
fastboot -w --fs-options=casefold
fastboot -w --fs-options=casefold,projid
fastboot format:f2fs --fs-options=casefold
fastboot format:f2fs --fs-options=casefold,projid
fastboot format:f2fs --fs-options=casefold,projid,compress

Bug: 172514669
Bug: 160198145
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: If3fad004fdd25dd754432ce98934b4ae6c8a8706
2020-11-09 10:04:30 -08:00
Yo Chiang
66d0d96c89 Refactor fs_mgr_overlayfs_teardown()
Right now fs_mgr_overlayfs_teardown() does slightly different things
when called from the userspace or recovery. This is accomplished by many
runtime checks, runtime assumptions and conditional execution of code.

This makes the control flow of the function very hard to follow, and
assumptions becomes more fragile as the function becomes more complex.

This CL forks fs_mgr_overlayfs_teardown() and removes "recovery" bits
from it. A new entry point TeardownAllOverlayForMountPoint() is added
for recovery.

Recovery (fastbootd) should call TeardownAllOverlayForMountPoint() to
teardown overlays of all sources (cache dir, scratch device or DSU).
While fs_mgr_overlayfs_teardown() should only be called from the
userspace.

Also apply some linter suggestions.

Bug: 165925766
Test: adb-remount-test.sh
Change-Id: I7ff7e3409c910782e1ec207fcd02b967a9762bc1
2020-10-28 16:05:09 +08:00
David Anderson
aca0beaf77 libsnapshot: Partially implement OpenSnapshotWriter.
This is a re-landing of the original CL, with a few changes:
 - The correct device is now returned in MapUpdateSnapshot.
 - The old API is used for tests, and the new API is only tested when
   used on a VABC device.
 - A sync() call has been added to ensure that writes to the base and
   target snapshot devices have been fully flushed. This makes
   IsPartitionUnchanged detect the MapUpdateSnapshot bug.

Implement OpenSnapshotWriter for non-compressed Virtual A/B. This is
done by adding an OnlineKernelSnapshotWriter class, which forwards all
writes to a dm-snapshot block device.

This also introduces a new ISnapshotWriter class which extends
ICowWriter, and adds features specific to libsnapshot (versus ICowWriter
which is intended only for the new COW format). The OpenSnapshotReader
call has been moved here since the writer retains all the information
needed to create the reader.

To test the new call, vts_libsnapshot_test has been modified to use
OpenSnapshotWriter.

As part of this change, all consumers of libsnapshot must now link to
libsnapshot_cow.

Bug: 168554689
Test: vts_libsnapshot_test
Test: full OTA with update_device.py
Test: incremental OTA with update_device.py
Change-Id: I90364a58902a4406a37cb14a816642c57a72bec2
2020-10-14 21:41:36 -07:00
David Anderson
f74c1a9556 fastbootd: Add more logging for when the USB transport fails.
Bug: 161542676
Test: fastboot flashall
Change-Id: Ief4e7452b72504c51c807dd38a07765ad65c96a4
2020-10-12 15:55:48 -07:00
Joseph Jang
012ee0ae0a Merge "fastboot: add new oem command for post wipe userdata" 2020-10-05 02:34:52 +00:00
Tianjie Xu
5aa52d91dd Revert "libsnapshot: Partially implement OpenSnapshotWriter."
Revert "Link to libsnapshot_cow everywhere libsnapshot is linked."

Revert submission 1433573-vab-libsnapshot-linkage

Reason for revert: b/169981170, update crash for droidfooders.
Reverted Changes:
Ie75bba98c:Link to libsnapshot_cow where libsnapshot is linke...
Ieedfadc55:libsnapshot: Partially implement OpenSnapshotWrite...
I28a5d4a88:Link to libsnapshot_cow everywhere libsnapshot is ...

Exempt-From-Owner-Approval: Revert to unblock dogfood
Change-Id: I0677df77672aca9fd54d94e009ac0be7c88a1a9d
2020-10-03 19:26:18 +00:00
josephjang
2906975399 fastboot: add new oem command for post wipe userdata
When Android userdata partition has been erased in fastbootd, call
oem specific API doOemSpecificErase() to wipe other userdata in
device.

If oem doesn't implement this specific API in fastboot_hal lib,
fastbootd will receive 'NOT_SUPPORTED' return status.

Bug: 169173873
Change-Id: I9b6a5a4aaed31d1168e633418b189f9bb6d34d01
2020-10-01 05:09:26 +00:00
David Anderson
75b982ad30 libsnapshot: Partially implement OpenSnapshotWriter.
Implement OpenSnapshotWriter for non-compressed Virtual A/B. This is
done by adding an OnlineKernelSnapshotWriter class, which forwards all
writes to a dm-snapshot block device.

This also introduces a new ISnapshotWriter class which extends
ICowWriter, and adds features specific to libsnapshot (versus ICowWriter
which is intended only for the new COW format). The OpenSnapshotReader
call has been moved here since the writer retains all the information
needed to create the reader.

To test the new call, vts_libsnapshot_test has been modified to use
OpenSnapshotWriter.

As part of this change, all consumers of libsnapshot must now link to
libsnapshot_cow.

Bug: 168554689
Test: vts_libsnapshot_test
Change-Id: Ieedfadc557833c1e0540922aabc6e95c80266a64
2020-09-28 11:24:37 -07:00
Yifan Hong
4fd78ec4b3 Merge changes from topic "revert-1413808-modules_partition-UXSIXCGPHZ"
* changes:
  Revert "rootdir: Add modules directory"
  Revert "fastboot: add modules partition"
2020-09-16 22:45:54 +00:00
Elliott Hughes
b407414fd0 fastboot: switch to ZipEntry64.
Test: treehugger
Change-Id: I17a023f113590e469f69174f7004c4579255c6ed
2020-09-15 14:26:17 -07:00
Yifan Hong
0d4a6887fb Revert "fastboot: add modules partition"
Revert submission 1413808-modules_partition

Reason for revert: modules partition no longer needed
Reverted Changes:
Iceafebd85:Add modules partition
I2fa96199a:rootdir: Add modules directory
Ie397b9ec6:Add modules partition.
I4200d0cf5:fastboot: add modules partition

Bug: 163543381

Change-Id: I17dc2da5a0901797c1bc1905274e7eb02e80fd83
2020-09-15 19:08:57 +00:00
Yifan Hong
135508168a Merge changes from topic "modules_partition"
* changes:
  fastboot: add modules partition
  rootdir: Add modules directory
2020-09-11 00:25:24 +00:00
Jiyong Park
fd890289e2 libfastboot uses usb_linux.cpp for all Linux targets
The build system has added the new target named 'linux_cross' which is
the cross-compiled (i.e. arm on x86) host target. libfastboot is now
configured to use usb_linux.cpp not only for linux_glibc (which is the
native host target using glibc), but for all Linux-based host targets
including linux_glibc, linux_bionic, and the new linux_cross.

Note that the device target 'android' is also included in the 'linux'
target. But that doesn't cause a problem because libfastboot is a host
library which is not enabled for the device target.

Bug: 159685774
Test: HOST_CROSS_OS=linux_cross m
out/soong/host/linux_cross-arm64/bin/fastboot

Change-Id: I3a2191b0878a26914cb0282ecf41a45296827c04
2020-08-28 13:30:35 +09:00
Yifan Hong
260b12b445 fastboot: add modules partition
Test: none
Bug: 163543381

Change-Id: I4200d0cf525ca7b350fdf468c4f3795a8c5015c9
2020-08-25 18:02:23 -07:00
Jaegeuk Kim
ef2c28bf71 Merge "support f2fs casefolding formatting tool" 2020-08-04 04:18:07 +00:00
Hongguang Chen
5330ccdd5b Use more inclusive language for #inclusivefixit
Updating language to comply with Android’s inclusive language guidance.

See https://source.android.com/setup/contribute/respectful-code for reference.

Bug: 161896447
Test: Trivial changes
Change-Id: Ia84d47930b5d9ca4a5f7c809777c886bece4f512
2020-07-23 01:23:45 +00:00
Jaegeuk Kim
a389610d9c support f2fs casefolding formatting tool
Bug: 159672232
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ia9dd5d63f03c2365b5d82a84ff93263424f116bb
2020-07-20 13:18:09 -07:00
Yifan Hong
be78bb624c fastboot: Add odm_dlkm
Test: add odm_dlkm partition and flash
Bug: 156020364
Change-Id: I577b4420f2be8e8141d967f0d9107cae381c7675
2020-07-15 17:15:49 -07:00
Yifan Hong
6b1c15c063 fastboot: Add vendor_dlkm
Test: add vendor_dlkm partition and flash
Bug: 156020364
Change-Id: If6794ca5a76613a1a3337a4637edd1d364eff5dd
2020-07-09 15:06:44 -07:00
Steve Muckle
3af575bcad fastboot: copy AVB footer on boot image to end of partition
If the flashed boot image is smaller than the block device, the AVB
footer will not be at the end of the partition. Although images are
normally created to match the partition size the GKI boot.img must work
on all devices, and the size of the boot partition will vary.

Copy the AVB footer to the end of the partition before flashing, if it
is not there already.

Bug: 159377163
Change-Id: I5a5e25fb54dc9d6a2930fda63434968808ffa1f0
2020-06-18 21:56:14 -07:00
Treehugger Robot
53122b14bc Merge "fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol." 2020-06-15 20:05:15 +00:00
Tom Cherry
2217c50a4f fastboot: don't print anything in Status() if the input is empty
Status() is called with an empty string to handle `fastboot oem`
commands.  This currently emits a set of spaces and sets
last_start_time such that the epilog can track the time spent in this
command.  Emitting the spaces is problematic however, since it results
in the follow:

 $ fastboot oem device-info
                                                  (bootloader) Verity mode: false
(bootloader) Device unlocked: true
(bootloader) Device critical unlocked: true
(bootloader) Charger screen enabled: true
OKAY [  0.000s]
Finished. Total time: 0.000s

If we skip emitting the spaces, then we get the correct result:

 $ fastboot oem device-info
(bootloader) Verity mode: false
(bootloader) Device unlocked: true
(bootloader) Device critical unlocked: true
(bootloader) Charger screen enabled: true
OKAY [  0.001s]
Finished. Total time: 0.001s

There are no other uses of Status() with an empty string, so this
changes won't impact other commands.

Bug: 158310284
Test: fastboot formats this and other commands correctly.
Change-Id: I6294acefc65a8399160c0944b3fbc2f2ace919ed
2020-06-10 09:29:25 -07:00
Elliott Hughes
6a7ff5811d Fix fastboot flash-all on Nexus 7.
The Nexus 7 bootloader just returns the empty string for unknown
variables, which confused the new snapshot code.

Bug: https://issuetracker.google.com/158232468
Test: no Nexus 7 available during covid-19 :-(
Change-Id: I35ff8889b27944e8b7426eca4f513d9fa562c6d4
2020-06-05 14:09:21 -07:00
Hongguang Chen
0e743a25c9 fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol.
The fastbootd over ethernet was implemented with IPv6 link-local
address. An IPv6 address may include many ':'. It will break this fuzzy
test. This new solution uses "tcp:" prefix to identify the fastboot
protocol, like the host fastboot command.

BUG: 158040108
Test: fuzzy_fastboot --serial=tcp:fe80::230:1bff:feba:8128%wlan0 \
      --gtest_filter=*Logical*
Change-Id: I971fd9e25741e18bf7f5907d562556b09db1d624
2020-06-03 17:48:37 -07:00
David Anderson
e681cf01c8 Merge "fastboot: Allow fastboot to asynchronously differentiate between fastboot and fastbootd." 2020-05-29 04:47:35 +00:00
David Anderson
4e058cac0d fastboot: Allow fastboot to asynchronously differentiate between fastboot and fastbootd.
It's not possible to programmatically determine which fastboot mode a
device is in, without sending a getvar:is-userspace query. Unfortunately
this is not possible asynchronously, and may interrupt other queries
being processed.

This patch changes fastbootd's USB interface name to "fastbootd". Note
that tools use the protocol number/class and not this string, so it
should be safe to extend. When using "fastboot devices", the interface
name is now listed if set. Note that currently only the Linux version of
the fastboot tool is capable of reading the interface name.

Bug: 156966319
Test: fastboot devices on Linux
Change-Id: I57ccf2bec1dda573fe3ac628a646624b76f45905
2020-05-28 17:42:00 +00:00
Treehugger Robot
4222040bd5 Merge "fastbootd: Support TCP protocol." 2020-05-18 17:05:43 +00:00
Hongguang Chen
1e239289d5 fastbootd: Support TCP protocol.
The current fastbootd only supports USB protocol. But some Android TV
devices are built without USB port. The fastbootd cannot be used on
those ATV devices due to it.
This change adds TCP protocol for such devices and fastbootd.protocol
property is added to control which protocol to use.

BUG: 152544169
Test: manual test.
Change-Id: Idc391e677eb6a1880036419ba5f6c4160e8dbcbc
2020-05-13 01:25:58 +00:00
Steve Muckle
a9b3443e53 fastbootd: copy AVB footer on boot image to end of block device
If the flashed boot image is smaller than the block device, the AVB
footer will not be at the end of the partition. Although images are
normally created to match the partition size the GKI boot.img must work
on all devices, and the size of the boot partition will vary.

Copy the AVB footer to the end of the partition before flashing, if it
is not there already.

Bug: 156036850
Change-Id: I11f0c7d32d1b6c74edd4f84f815d175605280cb8
2020-05-12 16:21:41 -07:00
David Anderson
5a0177d945 fastboot: Fix snapshot-update merge behavior.
When merging in recovery, the "imminent data wipe" code was used, which
made the assumption the /metadata and /data state would be zapped. This
caused future OTAs to error because the old snapshots were detected.

This CL allows OTAs to proceed even if unexpected snapshots are present.
It also forces the state to "MergeCompleted" after a merge in recovery,
so that the next normal boot can perform cleanup.

Bug: 155339165
Test: fastboot snapshot-update merge, then take another OTA
      vts_libsnapshot_test
Change-Id: Ief6dea3ba76323044e61307272dda320a4494aea
2020-05-02 16:02:07 -07:00
Yifan Hong
66f0115b05 libsnapshot clients: Add missing dep.
libsnapshot* uses update_metadata-protos. This
used to be optimized out, but now that SnapshotManager is
virtual, CreateUpdateSnapshots can no longer be optimized out.

Bug: 148956645
Test: compiles
Change-Id: Ib67cafd156308bf5a477996ec32eb786f8e896db
2020-04-16 13:12:41 -07:00
Treehugger Robot
edf8335c72 Merge "Rename vts-core to vts" 2020-04-07 05:11:55 +00:00
Dan Shi
ab8acaedae Rename vts-core to vts
Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL moves all tests in vts-core to vts.
It won't change test logic or behavior.

Change-Id: I24779951257ce37fc18929f214d3cf5f76c23a19
Merged-In: I24779951257ce37fc18929f214d3cf5f76c23a19
2020-04-07 02:48:48 +00:00
Tom Cherry
e4a6ed8534 fastbootd: sync() after flashing partitions or updating super
There is a chance that devices are failing to reboot in the lab due to
sync() taking explicitly long during reboot.  Let's add the sync()'s
here to ensure they get accounted for in the flashing process.

A side benefit is it's likely safer to sync immediately after
flashing than to hope init does it during reboot.

Bug: 150863651
Test: flash local devices successfully
Change-Id: I4c4b0114f3cde8af4b8b2cb283ec21f869ef9f6f
2020-03-31 10:54:58 -07:00
Josh Gao
0871824de6 Move adbd's legacy USB implementation to fastboot.
This code path is effectively dead in adbd, and fastboot's dependency on
libadbd makes it hard to refactor adbd's dependencies.

Bug: http://b/150317254
Test: built and flashed aosp_walleye-eng
Change-Id: I5118136d32fdcbbd011559ed0a4a71e1dc7bf064
2020-03-30 16:43:06 -07:00
David Anderson
2ffc31b090 fastbootd: Unmount /cache before flashing.
Bug: 150112538
Test: fastboot flash cache on non-A/B device
Change-Id: I8a86bc4d12e4b3be020bbe47e02262a5aaa913a7
2020-03-25 21:00:13 -07:00
Treehugger Robot
3ab681c9a8 Merge "fastboot: add support for v3 boot header format" 2020-03-19 05:47:48 +00:00
Steve Muckle
15303f2f67 fastboot: add support for v3 boot header format
Support v3 header format when changing the command line with
fastboot boot or using flash:raw.

Bug: 151750405
Test: fastboot boot and flash:raw with updated cmdline and v3 header
Change-Id: Ibf396e2d18d8b22cad50db290f3fd4e46ff85d9b
2020-03-18 15:00:47 -07:00
yongcheol.lee
019f731097 Restore fastboot delete-logical-partition command for VTS
1. delete-logical-partition was deleted
	- After merge "Don't require bootloader fastboot for VTS compliance." commit, delete-logical-partition sequence was deleted in LogicalPartitionCompliance test. "create-logical-partition failed" is occurred when run vts fastbootverification module. So restore this sequence.

Signed-off-by: Yongcheol LEE <yongcheol09.lee@lge.com>

Test: VTS
Test: run vts -m VtsFastbootVerification

Change-Id: I00366b281eafa5677b0941419a86f2702fb3484b
2020-03-11 13:05:07 +09:00
Hridya Valsaraju
45719a8f07 fastbootd: use FastbootDevice::GetCurrentSlot to get current slot suffix
Using FastbootDevice::GetCurrentSlot to get the current slot suffix
instead of reading the same from the device's boot control HAL
is required to account for the prior set_active commands issued via
fastbootd in the same boot.

Test: fuzzy_fastboot
--gtest_filter=Conformance.Slots:Conformance.SetActive --gtest_repeat=10
Bug: 146589281

Change-Id: I2edb0f024d93c2483659623423ef5c69c717c7af
2020-03-02 13:14:11 -08:00
David Anderson
ac892d7569 Merge "Don't require bootloader fastboot for VTS compliance." 2020-02-07 21:46:01 +00:00
David Anderson
7868246e30 Don't require bootloader fastboot for VTS compliance.
Bug: 144820025
Test: vts
Change-Id: Ib99ddbe611645fe0f89134a628ddb486b02df170
2020-02-06 13:13:56 -08:00
Bowgo Tsai
27d5fb344b Increases fastbootd response message size
Some output of `fastboot getvar` exceeds current message size.
Increases the message size to 256 to fix the issue.

Bug: 74445765
Bug: 144473561
Test: fastboot getvar system-fingerprint
Change-Id: Id5064be4bb500697ce87c473f662d86c7c344d65
2020-02-06 16:22:59 +08:00
Baligh Uddin
3d902d1637 Use SOONG_HOST_OUT_EXECUTABLES
Bug: 147699225
Test: m com.android.tzdata (apexer requires these executables)
Change-Id: I008d244e330d2113cb3f2dd4b6c770df3f2fac06
2020-01-23 14:09:01 +00:00
Bowgo Tsai
99f9a38a8b fastbootd: exporting more properties
Exporting more properties that can be useful for image compatibility
check, prior to run fastboot flash.

Bug: 74445765
Bug: 144473561
Test: fastboot getvar <new variable>
Change-Id: I2ddfa2c1e9e719e05a3a64b9ca1d608957aebf11
2020-01-22 23:29:07 +08:00
steven_fann
fde5e27602 Allow fuzzy_fastboot test devices over internet
Bug: 144667236
Test: fuzzy_fastboot --serial=192.168.1.104:5555 --gtest_filter=*Logical*

Change-Id: I02e62f706d0a3a19a9b7b56788abe05759d2d63d
2020-01-21 15:40:52 +00:00
Yifan Hong
38f3706ab3 Merge "fastboot: Mount /metadata before overlayfs teardown." 2020-01-15 01:31:59 +00:00
Dan Shi
754167b241 Add libc++ as static library
This is for the test to run without packaging libc++.so in vts-core
suite.

Bug: 147249791
Test: atest FastbootVerifyUserspaceTest
Change-Id: I0263d13a2dd08186502b30b2fad25d4f0f3a6be8
2020-01-09 14:24:23 -08:00
Dan Shi
44b29c643a Add fuzzy_fastboot to vts-core suite
The binary is required by FastbootVerifyUserspaceTest.
Disable test config generation as fuzzy_fasboot itself is not part of
vts-core suite.

Bug: 147249791
Test: atest FastbootVerifyUserspaceTest
Change-Id: Ief86f33b41990a354497b128e154da04fec58ae9
2020-01-06 15:52:10 -08:00
David Anderson
23243497fd fastboot: Mount /metadata before overlayfs teardown.
fs_mgr_overlayfs needs access to /metadata to tell whether or not the
scratch partition exists on /data.

Bug: 134949511
Test: adb remount, fastboot flash system
Change-Id: I3a09aae495d691e9c1a1e25a8fb3514e355ecd05
2019-12-30 13:42:57 -08:00