Commit graph

943 commits

Author SHA1 Message Date
Dmitrii Merkurev
45380e4ace Merge "fastboot: Use copy constructor to copy fastboot match callback" 2023-02-15 19:05:55 +00:00
Dmitrii Merkurev
96ea7b9ccf Merge "fastboot: Follow fastboot pattern to show network-connected device status" 2023-02-15 19:05:34 +00:00
Dmitrii Merkurev
c48cd9f6c0 fastboot: Follow fastboot pattern to show network-connected device status
Bug: 269348113
Test: checked output
Change-Id: Ie6c48d36bd67fcb060ad3f4a35185fd9cc59ff81
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-02-15 15:34:58 +00:00
Dmitrii Merkurev
b5b8276db1 fastboot: Use copy constructor to copy fastboot match callback
Test: fastboot -s 15171FDF6000CV getvar all on OSX
Bug: 269348113
Change-Id: I968626c95ee19ea348bac48cac308e3c817e0d55
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-02-15 15:21:22 +00:00
Treehugger Robot
368a908334 Merge "Fastboot: Add new TEXT message to protocol to handle long lines." 2023-02-15 11:49:24 +00:00
Raphael Herouart
99097cc020 Fastboot: Add new TEXT message to protocol to handle long lines.
Trusty Benchmarks need to be evaluated in ABL which is much more
controlled than linux. However fastboot prints evry atomic message from
trusty/abl on its own line starting with "(bootloader)"

Bug: 263454481
Test: - "fastboot oem trusty runtest trusty.hwrng.bench"
Change-Id: I99847a8cc54457c8ec809e219736325dce0ac891
2023-02-14 19:58:42 +00:00
David Anderson
2d6c30da7f Merge "fastboot: Add a mock transport and some driver tests." 2023-02-14 16:05:44 +00:00
David Anderson
e6d8dd3e15 fastboot: Add a mock transport and some driver tests.
Bug: N/A
Test: fastboot_test
Change-Id: I08d8dfedcc7e9dad9ce418e0f3aaf5ac69a3a2a2
2023-02-13 18:59:48 -08:00
David Anderson
6c5b6a8705 Merge "fastboot: Add a test for super_flash_helper." 2023-02-14 02:12:52 +00:00
David Anderson
ada871875e fastboot: Add a test for super_flash_helper.
This test checks that the sparsing logic matches a canonical sample
output.

Bug: N/A
Test: fastboot_test
Change-Id: Ic7bad08a79e4223f8352db2397b741c2179e76bb
2023-02-13 15:47:10 -08:00
Daniel Zheng
0d30718d9c Added support for flash task
Added Flash Task

Test: tested on raven
Change-Id: I4a6c22f795440afeba18497745dddf8d5c570f65
Bug: 194686221

changed flash {partition_name} to work with tasks

Test: tested flash {partition_name} on raven
Change-Id: I1fa45b949ad8e5017026dd542dfe1389279a9e64
Bug: 194686221
2023-02-13 23:27:41 +00:00
Treehugger Robot
77f4cb4db0 Merge "fastboot: Introduce connect / disconnect for network-connected devices" 2023-02-13 20:25:12 +00:00
Dmitrii Merkurev
0ee285aa68 fastboot: Introduce connect / disconnect for network-connected devices
Use introduced FileLock and network-connected devices storage entities
to introduce fastboot connect / disconnect commands

Test: everything works like discussed here go/fastboot-connect-disconnect on windows/linux
Bug: 267507450
Bug: 267506875
Change-Id: I2d6495ad567a3ddadd471a89b82d78c8c36a3d52
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-02-11 00:02:22 +00:00
Dmitrii Merkurev
4dd1ac9282 Merge "fastboot: Introduce network-connected devices storage" 2023-02-10 20:27:15 +00:00
Sandeep Dhavale
ee065fe080 Merge "Fastboot: Use AServiceManager_waitForService instead of AServiceManager_getService" 2023-02-10 04:12:06 +00:00
David Anderson
d45181f1c2 Merge "fastboot: Add fastboot_test to TEST_MAPPING." 2023-02-09 21:33:26 +00:00
Dmitrii Merkurev
91297172eb fastboot: Introduce network-connected devices storage
Bug: 267507577
Bug: 267505625
Test: tested file lock api works on linux/windows
Test: tested storage api works on linux/windows
Change-Id: I33dda819370900310ae7fc63cbf6b00ba22ad4e8
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-02-09 16:28:17 +00:00
David Anderson
86e869a566 fastboot: Add fastboot_test to TEST_MAPPING.
Bug: N/A
Test: fastboot_test on host
Change-Id: I1947b371ba6117e6eed811d1d6e1ed4019e0a0e9
2023-02-08 15:03:51 -08:00
Daniel Zheng
166efb16c7 Merge "Created new Task.h file to contain task classes." 2023-02-07 21:03:20 +00:00
Daniel Zheng
1a01a1cda1 Created new Task.h file to contain task classes.
Test: tested Reboot {target} + Flash {partition} on raven device
Bug: 194686221
Change-Id: I0d80230d682f80af12cca9705df0172651bf4461
2023-02-06 23:58:13 +00:00
John Stultz
3f061f9813 fastboot: Fix missing endian header in fastboot_driver.h to avoid header confusion
So fastboot_driver.h includes <android-base/logging.h>, but that
file has a dependency on <android-base/endian.h>. So if
fastboot_driver.h gets included somewhere before
<android-base/endian.h>, it results in *very* opaque error
message:

system/core/fastboot/fastboot.cpp:1490:9: error: expected unqualified-id
        LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device";
        ^
system/libbase/include/android-base/logging.h:221:23: note: expanded from macro 'LOG'
                      ^
system/libbase/include/android-base/logging.h:227:4: note: expanded from macro 'LOGGING_PREAMBLE'
  (WOULD_LOG(severity) &&                                                                  \
   ^
system/libbase/include/android-base/logging.h:202:40: note: expanded from macro 'WOULD_LOG'
  (UNLIKELY(::android::base::ShouldLog(SEVERITY_LAMBDA(severity), _LOG_TAG_INTERNAL)) || \
                                       ^
system/libbase/include/android-base/logging.h:174:26: note: expanded from macro 'SEVERITY_LAMBDA'
  using ::android::base::ERROR;               \
                         ^
prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include/wingdi.h:75:15: note: expanded from macro 'ERROR'
              ^

This patch includes <android-base/endian.h> before
<android-base/logging.h> to avoid this issue.

Reported-by: Daniel Zheng <zhengdaniel@google.com>
Signed-off-by: John Stultz <jstultz@google.com>
Change-Id: I8752f2cdbef5b13901f0f4e8adfe60a21db785b6
2023-02-04 04:06:48 +00:00
David Anderson
667b1efadd fastboot: Avoid reboots to userspace when using flashall/update.
Reboots to fastbootd (userspace fastboot) take a long time, particularly
due to the orange AVB screen and the likelihood of devices having uart
enabled. For "flashall", there is rarely a need to actually go into
userspace, because all of super is getting thrown away. We can just
flash super in the bootloader.

In the past we didn't do this because computing super.img is expensive -
both in terms of time (due to reading dependent images) and in terms of
space (it's easily over 5GB).

But we don't actually need to fully compute super.img. We can build a
sparse_file containing the metadata/headers, with additional references
to each image file containing partition data. Liblp provides the API to
do that, and here, we simply need to translate the layout to libsparse.

On Pixel, this reduces flashall time by around 35-50 seconds, or around
20% of total time, depending on whether uart is in use.

There are some caveats, in which case we'll fall back to normal
fastbootd. This does not work on non-A/B devices, on retrofit dynamic
partition devices (Pixel 3), and in some other edge-casey scenarios. If
it fails, -v will add logging information about why.

Bue: 266982466
Test: fastboot flashall on Pixel 5+
Change-Id: Ie040da597d739faa7f834202184cec8f8e412076
2023-02-01 11:28:18 -08:00
David Anderson
aa87dc5a0d fastboot: Move some helpers into util.h/.cpp.
Bug: 266982466
Test: builds
Change-Id: Ib744d763e11d8a7f7e3f417b331defff61fe4559
2023-02-01 11:28:16 -08:00
David Anderson
a67fc32a8a fastboot: Allow using LOG().
The die() and verbose() macros are not really standard for AOSP. To
allow a gradual transition off them, call InitLogging on startup. This
will also allow seeing liblp logs when -v is passed.

Bug: 266982466
Test: builds
Change-Id: I74278bb5f698edb0dc81477a575b130b0bd11cdf
2023-02-01 11:09:29 -08:00
David Anderson
a1c983e800 fastboot: Use RAII for sparse_file objects.
Bug: 266982466
Test: fastboot flash
Change-Id: I3d240d6ecc8a37d968ffdef9d50e349e787e8d3e
2023-02-01 11:09:28 -08:00
Jack Wu
0635794d2d fastboot: Update health AIDL HAL to V2
Bug: 251425963
Test: Build
Change-Id: I538ebee69ebe69a1ad1fa934bb7440ef12fc2cc2
Signed-off-by: Jack Wu <wjack@google.com>
2023-01-21 15:21:00 +08:00
Isaac J. Manjarres
acb49528a7 fastboot: Copy AVB footer from recovery.img to the end of the partition
Copy the AVB footer of the recovery.img to the end of the recovery
partition, so that it can be found when loading a recovery image
from a partition that is larger than the image.

Bug: 261673286
Test: m and flashing recovery image and bootloader can now detect
AVB footer.
Change-Id: Ib93da33c72f3a96eb8d9bcedaab5ef0c3a4d418d
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
2023-01-12 14:33:56 -08:00
Shaju Mathew
dce1371666 Zero-length packet send bug resolution for fastboot.
Bug: 208675141

Test: Treehugger, cursory test of fastbootd against macOS Monterey running fastboot.

Change-Id: Id2ac1be428470385c866d505f860e50bd9132e2e
Signed-off-by: Shaju Mathew <shaju@google.com>
2023-01-11 19:32:01 +00:00
Sandeep Dhavale
63928c310e Fastboot: Use AServiceManager_waitForService instead of AServiceManager_getService
AServiceManager_getService waits unncessarily waits for 5 seconds if
service is not available. Use isDeclared() and waitForService() instead.

Bug: 261759425
Test: build and flash
Change-Id: I20a5f422ca0c26c6e9e183e6636b30a2f19e76d3
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
2022-12-10 05:29:26 +00:00
Daniel Zheng
14000f19a9 Merge "Updating fastboot to modern c++ standards" 2022-12-08 17:23:08 +00:00
Chih-Hung Hsieh
c76bc32d95 Fix "Attempt to delete released memory" warning.
EXPECT_NONFATAL_FAILURE(statement, ...) expands to
  do {
    ... statement ...
  } while (::testing::internal::AlwaysFalse());

Clang analyzer cannot see into AlwaysFalse(),
and gives a false warning assuming that the
do loop can be done twice.

Use a unique_ptr::reset to call delete,
because reset can be called multiple times..

Bug: 259999410
Test: make tidy-system-core-fastboot_subset
Change-Id: Ie536f76635dd55f4e47b80eed6498fd1193b88ee
2022-12-02 12:38:41 -08:00
Daniel Zheng
65452d036e Updating fastboot to modern c++ standards
Test: tested fastboot on raven device
Change-Id: I0c1fa4cd09378282edf5df54ae26d747e6d4f3eb
2022-11-30 03:36:46 +00:00
Yi-Yo Chiang
38b68c6a0e fastbootd: Add getvar is-force-debuggable
Export ro.force.debuggable property so that the user can check image
compatibility prior to running fastboot flash.
For example, if is-force-debuggable is yes, then the "system" and
"vendor" build fingerprint must match.

Bug: 191649082
Test: fastboot getvar is-force-debuggable
Change-Id: I772d98253f58ba208d5803e18b589ff693deebd0
2022-11-22 17:32:21 +08:00
Sandeep Dhavale
2534d485d8 Fastbootd: Use Fastboot AIDL with the help of fastbootshim for legacy fastboot HAL
Bug: 205760652
Test: build & flash & reboot fastboot
Change-Id: I79617a396f536258655bdc28006ac2d0a7ab1912
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
2022-11-09 00:38:34 +00:00
Treehugger Robot
460f70bb52 Merge "Adding target (sdk-repo-platform-tools) that is used by gmac(sdk_mac) build." 2022-10-07 04:13:51 +00:00
Shaju Mathew
6c27f235cf Adding target (sdk-repo-platform-tools) that is used by gmac(sdk_mac) build.
Bug: 249370316
Test: N/A (coastguard)

Signed-off-by: Shaju Mathew <shaju@google.com>
Change-Id: I641d4f8dc60652c7e8eaebafd905090d3c0324f2
2022-10-06 22:37:09 +00:00
Florian Mayer
4c3c526e54 [MTE] Reset MTE state for userdata wipe in fastbootd
Test: $ adb shell su root [...]/mtectrl memtag,memtag-kernel default
      $ adb shell 'su root dd bs=1 skip=32832 if=/dev/block/bootdevice/by-name/misc count=15 | xxd'
      00000000: 015a fefe 5a05 [...]
      $ adb reboot fastboot
      $ fastboot -w
      $ fastboot reboot
      $ adb shell 'su root dd bs=1 skip=32832 if=/dev/block/bootdevice/by-name/misc count=15 | xxd'
      00000000: 0000 0000 0000 [...]

Bug: 245596152
Change-Id: I5e2d4584776ab1685bdf37124e32dcb827eaf05a
2022-10-03 11:01:36 -07:00
Treehugger Robot
a67092a7b8 Merge "Updates the FB_COMMAND_SIZE from 64 to the linux max value of 4096 and updates the relevant unit tests." 2022-09-15 08:48:52 +00:00
Nicolas Gagnon
e21b7a552d Port ADB's new handling of the USB packet ClearFeature(HALT) to Fastboot.
This patch addresses Fastboot/Fastbootd connection issues seen on ARM Mac devices.

Original ADB patch: https://android-review.googlesource.com/c/platform/packages/modules/adb/+/1699250/

Bug: 238779161
Test: 'fastboot update <path_to_update_archive>.zip' now works on ARM Mac.

Signed-off-by: Nicolas Gagnon <nicolasgagnon@google.com>
Change-Id: Id67904d91abc8b66ef1a00962e1fd57c97df98a7
2022-09-14 21:11:30 +00:00
Bradley Furman
7518e8ba7e Updates the FB_COMMAND_SIZE from 64 to the linux max value of 4096 and
updates the relevant unit tests.

BUG=182864081

Test: Update the size check to the existing unit tests

Change-Id: I66b08884a5228e164c22c575a6f6c82a236fece2
2022-09-13 20:58:06 +00:00
Kelvin Zhang
682e5b530a Add io_uring support to fastboot
Test: th
Bug: 31712568

Change-Id: If18bd4eb53ffe851c31d7dc61906921da111114f
2022-08-11 18:58:43 -07:00
Thiébaud Weksteen
3c1f230971 Remove e2fsdroid and sload_f2fs dep from fastboot
In commit 5d72d6c, an unused code path for e2fsdroid and sload_f2fs was
removed from fastboot. Remove them from the build dependency list.

Bug: 237960487
Test: m fastboot
Change-Id: Ibee72a86eeb43fcde3a032094bfc1c19de09bc03
2022-08-11 15:36:17 +10:00
Thiébaud Weksteen
5d72d6ce20 Remove unused execution paths when formatting
fastboot uses the internal functions generate_ext4_image and
generate_f2fs_image when called via the `format` subcommand. An option
for populating the newly created fs with an initial directory exists,
but it is not exposed to the command line interface (initial_dir is
always ""). Remove the unused codepaths for this preloading.

Test: atest --host fastboot_test
Bug: 237960487
Change-Id: I7acfe6352cf26b5cbe0e5553b288c3798e96a893
2022-07-21 14:50:05 +10:00
Kelvin Zhang
1fcdce21d6 Add zhangkelvin@ as owner of fastboot
Working on replacing aio w/ liburing in fastboot recently

Change-Id: I8076e2e53dc8d620faf9bff7f37ba2d2538460d6
2022-07-12 11:05:33 -07:00
Kelvin Zhang
6befe78c3c Convert fastboot/libsnapshot to new BootControl client
Thew new client will use AIDL if available, and fallback to HIDL
otherwise.

Test: th
Bug: 227536004
Change-Id: I9af21037a76a4a6db00144f5b2774ea23f3a5cc2
2022-07-08 10:57:53 -07:00
Kelvin Zhang
5cb1b0295e Add lz4 support for VABC
Add lz4 support in CowWriter/CowReader. Lz4 should offer faster
read/write performance but slightly larger COW sizes.

Download time: Reduced from 1264s to 825s (~35% faster)
Filesystem verification time: from 69s to 59s (~15% faster)
COW Size: 2.59GB to 3.21GB, (~25% regression)
Merge time: 37046ms to 27690ms (~25% faster)
Boot time: LZ4 is 2.7% faster

Overall, LZ4 offers faster read/write performance at the cost of 25%
space regression.

Test: th
Bug: 228478555
Change-Id: Ie521852fb3c9ff8a12e55b764c1eb1838f7b2181
2022-06-29 13:10:55 -07:00
David Anderson
ebc8fe19f8 fastboot: Add a command to get current kernel logs.
This adds "fastboot getvar dmesg", usable only in userspace fastboot,
and only on unlocked devices. This is to debug flashing failures when
serial log access is not available.

Bug: 230269532
Test: fastboot getvar dmesg
Change-Id: Ic57881e362efe3f0687f41ab986d30b3a59dc4e4
2022-06-21 19:32:19 -07:00
Keith Mok
1e490f032e fastboot: vendor boot img util OOB
If vendor image size is less than what the header claims,
there is OOB access.
And it did not check page size equal to zero also.

Bug: 234208198
Test: fastboot_fuzzer
Change-Id: Iec08acf9bb354db4c4cd25e3a0c581974fee7eed
2022-06-07 16:14:43 +00:00
David Anderson
954ff922ea fastbootd: Add better logging for flashing failures.
Bug: 233980876
Test: builds, fastboot flashall
Change-Id: Icc81ac4d9a4ca76f7eb757df5524d95f488fcd8c
2022-06-01 22:46:35 -07:00
Michael Bestas
bcf7680614
fastboot: Print OemCmdHandler return message on success
This allows OEM commands to print messages in fastboot output.

Test: run fastboot oem getprop ro.boot.rf_version
      and observe property value being printed in console

Change-Id: Id9bd5a107861a790cd02dc87057600de5bb94d42
2022-05-16 19:42:28 +03:00