Commit graph

971 commits

Author SHA1 Message Date
Daniel Zheng
719caca725 Merge "Added some error logs to wipe" 2023-03-30 21:30:11 +00:00
Daniel Zheng
4aa47338f2 Merge "Added check to copy AVB footer" 2023-03-30 18:24:31 +00:00
Daniel Zheng
6f213b2c79 Added some error logs to wipe
Changed so if we call wipe on a partition that doesn't exist we'll get
some helpful error messages.

Test: tested wipe test
Bug: 194686221
Change-Id: I19dc0396a7a98d0b2be7859edbffeb8acdc9850a
2023-03-30 18:19:04 +00:00
Daniel Zheng
e33e8a8685 Added check to copy AVB footer
is_logical shouldn't work in bootloader for some devices, so we also need to check
using should_flash_in_userspace to see if partition is dynamic

Test: tested to flash {partition} on raven and checked to see avb
footers are not copied from dynamic partitions

Change-Id: Iabb3ea535fa80b26cf1c08040beb3d4ea5e8c2ae
2023-03-30 18:19:04 +00:00
Ayushi Khopkar
33ff88f9c3 Updated fuzz_config in Android.bp file
Added new fields in fuzz_config like - hotlists,
description, vector, service_privilege, users, fuzzed_code_usage, etc.

Bug: 271384401
Test: Build fastboot_fuzzer

Change-Id: I7799ffcb7f11202711b19cf40e8c05e050d3b519
2023-03-23 16:06:24 +05:30
David Anderson
ecdbbbda82 Merge changes Ie68aed2f,Ic40696b3
* changes:
  fastboot: Handle libsparse failures better.
  libsparse: Fix allocation failures on 32-bit systems.
2023-03-22 00:02:13 +00:00
David Anderson
74c7807af1 fastboot: Handle libsparse failures better.
sparse_file_len is not actually infallible; on Windows it's pretty easy
to make it fail by embedding large files in the stream. fastboot didn't
handle this anywhere, leading to bad sparse images when libsparse
runs out of address space.

Bug: 273933042
Bug: 268872725
Test: fastboot flashall on Windows
Change-Id: Ie68aed2f1970e820350d9f97aa89a6c0242229b8
2023-03-20 15:55:57 -07:00
Daniel Zheng
0bf3b71fbb Updating Flashall to work off tasks
Test: testing fastboot flashall on raven
Bug: 194686221
Change-Id: I82ac2392686775b57c3d98ea003ab30b48f1ab0f
2023-03-20 20:21:31 +00:00
Daniel Zheng
85c0f3e567 Updated location of initialization
Test: tested flashall on raven
Bug: 194686221
Change-Id: Ie0dd7acd65833a938623e374e2b21e6bd6079d08
2023-03-20 20:21:31 +00:00
Daniel Zheng
f1ddba9dfd Updating FlashTask to require img-name
Test: tested flash {partition} on pixel
Bug: 194686221
Change-Id: I8018e48f68606ec9c559d06973154d79e7c0634a
2023-03-20 20:20:43 +00:00
Daniel Zheng
980985af6e Removed hardcoded check to copy AVB Footer
Test: tested flashall on raven
Bug: 194686221
Change-Id: Iaca03bde51fcd6b2886dc8ba84da4f67174a9c3f
2023-03-20 16:24:40 +00:00
Daniel Zheng
403657d998 Changing FlashTask to take in apply_vbmeta
Test: tested on Raven
Change-Id: I709842d87aa4ad6a7772e4f441886d127c3028a7
2023-03-13 18:28:14 +00:00
Daniel Zheng
15e7783263 Added support for Wipe Task
Test: tested wipe on Raven
Bug: 194686221
Change-Id: I582800a279cbe8a3e733a1e75447e5b5142d4120
2023-03-13 17:37:31 +00:00
Daniel Zheng
43987c948b Fixed parameter styling and minor error in tasks
Test: tested compilation
Change-Id: Ieb949243da1284dec3bad2caa895a59465858adc
2023-03-08 23:07:51 +00:00
Daniel Zheng
aa70f4c748 Added support for Delete Task
Test: tested delete-logical-partition {partition} and flashall on Raven

Change-Id: I04f07c8132159deda42434b9178e8c98d5ab768b
Bug: 194686221
2023-03-08 23:07:51 +00:00
Daniel Zheng
9f7bf7eff3 Added support for Resize Task
Test: tested flashall on raven
Bug: 194686221
Change-Id: I60586756b2d5f99848a664def8204c0bd47d7e67
2023-03-08 23:07:50 +00:00
Daniel Zheng
6bb8baa929 Added support for Update Super Task
Test: tested flashall on raven
Bug: 194686221
Change-Id: Ifc99af77f9235bf56a549f53e7d43575686fb42b
2023-03-08 23:07:50 +00:00
Daniel Zheng
47d70a5559 Added support for FlashSuperLayoutTask
Test: testing flashall code with this change
Bug: 194686221
Change-Id: Ibb96980402db51b48c9a296338f29195f68c65bf
2023-03-08 23:07:48 +00:00
Dmitrii Merkurev
48b39ba01e Merge "fastboot: Introduce ParseNetworkSerial unit tests" 2023-03-03 18:52:33 +00:00
Daniel Zheng
78a0f7f1b2 Merge "Changed FlashTask and RebootTask to take in FlashingPlan" 2023-03-03 07:43:03 +00:00
Daniel Zheng
f8da682c84 Merge "Added Flashing Plan" 2023-03-03 07:42:55 +00:00
Daniel Zheng
bc01da5c0d Changed FlashTask and RebootTask to take in FlashingPlan
Test: tested flash {partition} on raven and reboot {target} on raven
Change-Id: I26f4723474c3a142b086c1ac361578f8487ec3b9
Bug: 194686221
2023-03-03 06:49:34 +00:00
Daniel Zheng
7df2ab9c87 Added Flashing Plan
Fastboot has a lot of flags that are used by many different functions
including the Flashall Class and newly added FlashSuperTask. Passing all
of these flags as paramaters is cumbersome, so adding a Flashing Plan
that contains these flags simplifies the code.

Test: tested Flashall and update img.zip on raven
Change-Id: I9c842f25389a20b852d55f684e1b86040af1d86a
Bug: 194686221
2023-03-03 06:49:32 +00:00
Dmitrii Merkurev
cdbfa7a3e8 fastboot: Introduce ParseNetworkSerial unit tests
Introduced positive and negative unit tests to cover
ParseNetworkSerial logic. Alongside with that move
result related stuff to the separate header.

Test: atest fastboot_test
Test: manually checked basic functionality works fine
Bug: 271155012
Change-Id: Icac6053c11b5a36daa64555209555826ea28cc61
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-03-02 00:03:49 +00:00
Dmitrii Merkurev
95c90c6588 fastboot: Fix fastboot_vendor_boot_img_utils_test mac os compilation
Use more universal lseek instead of lseek64

Test: atest fastboot_vendor_boot_img_utils_test
Test: mm on mac os
Bug: 271152365
Change-Id: I4d094dd2c24e4ffec8ea7fe2f3b355122fd8cd19
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-03-01 15:49:56 +00:00
Treehugger Robot
396b107a41 Merge "fastboot: Fix IPv6 connect and -s host parsing" 2023-02-28 22:46:02 +00:00
Dmitrii Merkurev
4785554ca1 fastboot: Fix IPv6 connect and -s host parsing
During fastboot connect / disconnect introduction, we
completely broke the IPv6 support (it was considering
all IPv6 addresses as a USB serial).

Makeing sure this problem isn't reproducible anymore
alongside with fixing EXCPECT causing process crash
and improve network serial error detection.

Bug: 271152365
Change-Id: Ic52aa5fff1948a64ac3d2672f3cf4d2b022e5cea
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-02-28 21:02:48 +00:00
Daniel Zheng
71b3b43495 Added support for reboot task
Test: tested on raven device
Change-Id: I4935d720f567e70da95ea8da37f3404b80b313c8
Bug: 194686221

Changed reboot {target} to work off tasks. reboot-{target} commands are
also supported.

Test: tested reboot on raven device
Change-Id: I05aed269d121a5d651c1ab1180a1b4878ae213fd

Modified load_buf to be able to find images in $OUT directory

Test: tested flash {partition} and flash {partition} {img_name} on raven
device

Change-Id: I3879792d11ad15bc910670853d2a7fe200fcc66f
2023-02-23 00:15:08 +00:00
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