Adding const decorator to class constructor to ensure Flashing Plan
isn't modified during task construction
Bug: 194686221
Test: tested Flashall on raven
Change-Id: I99b71b2b756beaf871a31a1a035545d754d128e8
Updating old clean up slot logic change. Some devices don't know current
slot so we can't always just call get_current_slot()
Test: tested flashall on raven
Change-Id: Id655f1c1ee0b1ff09331f0d91d77412836d0af8d
cleaning up main() code in fastboot.cpp to run off one task vector. The
eventual goal is to just have all functionality run off this vector.
Test: tested commands on raven
Bug: 194686221
Change-Id: I98d0ba33091eff31ff1bc338766c3689ffb54746
Modifying fastboot-info.txt to directly call reboot fastboot instead of
reboot userspace -> so no longer need "userspace" in reboot task. Also
moving skip_reboot check to task since in old code we can have
skip_reboot be true and still reboot to bootloader, fastboot, or
recovery
Test: tested reboot commands on Raven
Change-Id: I98ba51747bf7229a88ba737540c81d20b42e5981
Doesn't look like we actually need current_slot, since we can always
just call function get_current_slot
Test: tested flashall on raven
Change-Id: Icba64bc9fdd08f36d44965e32558a73d0beab0e1
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
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
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
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
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>
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>
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>
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
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
This test checks that the sparsing logic matches a canonical sample
output.
Bug: N/A
Test: fastboot_test
Change-Id: Ic7bad08a79e4223f8352db2397b741c2179e76bb
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>
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>
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
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
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
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>
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>
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
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
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
updates the relevant unit tests.
BUG=182864081
Test: Update the size check to the existing unit tests
Change-Id: I66b08884a5228e164c22c575a6f6c82a236fece2
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
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
Thew new client will use AIDL if available, and fallback to HIDL
otherwise.
Test: th
Bug: 227536004
Change-Id: I9af21037a76a4a6db00144f5b2774ea23f3a5cc2
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
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
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
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
fuzzy_fastboot causes vts to fail when it has isolated set to true
so manually set it to false to avoid this.
Bug: 178498003
Test: Ran tests that failed presubmit
Change-Id: I871854c26e07ac6ad94feb14703b705a3054c176
Writes on file descriptors opened with O_DIRECT will fail if the buffer
is not page aligned. This CL will reset the file descriptor without the
O_DIRECT flag for such instances.
Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I841c84f5d2c0b9435b394c48b1bfcc2d51d771bb
There are cases where the flags the file descriptor was opened with need
to be modified. This CL adds functionality to reset the file descriptor
held by a PartitionHandle, reopening with new flags and repositioning
file offset to previous.
Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I9adb0e7696bc6af74e14dd61a6cb0ef10b4c98c8
There are cases such as non 4KB aligned buffers which break writes on
file descriptors opened with O_DIRECT. Flashing functions need more
control over the file descriptor, which is not achievable easily by
having only a file descriptor passed. This CL modifies the logic to pass
the PartitionHandle in place of the file descriptor during flashing.
Bug: 225108941
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I049d0ffb183c9de1267b7e442488c8ba5002186a
Fastboot format fails to wipe any partition that doesn't at least return
"raw" partition type. Also both android.hardware.fastboot@1.0-impl.pixel
and android.hardware.fastboot@1.1-impl-mock return FileSystemType::RAW
so I assume this is fine.
Change-Id: I5707bddb1ba32edb6359858853d7b1afbf138b9f
This ensures that the dynamic "scratch" partition is removed when doing
a flashall operation.
If "scratch" is on /data, disable the partition. Add IsImageDisabled to
ImageManager so EnsureScratchMapped can skip mapping it. Also, fix
"scratch" not getting unmapped if on /data.
Bug: 205987817
Test: adb remount
adb sync
adb reboot fastboot
fastboot flashall --skip-reboot # no errors
Test: adb-remount-test.sh
Change-Id: I4b9702e1dac15fb663635506fb50a8274e1e10d1
The vbmeta partition might have additional prefix
(e.g., guest_vbmeta_a) on some virtual machine
environment. Allowing rewriting the disable-verity/
disable-verification bits in the vbmeta image upon
flash under such use case.
Bug: https://partnerissuetracker.corp.google.com/u/1/issues/181791553
Test: manual tests with different names of vbmeta partition
Change-Id: Iacadaf587fce1e1e7fef946f56bbfc7f4e8233d8
Add a malformed download command test.
And add a sparse file test with very large block size
Bug: 215236564
Test: bootloader fastboot
Change-Id: I1072ba189ac15b2e1eb8f13ffd754f93c967e2d5
The BSD license used by some of the files in the project was lacking a
license_text file.
Bug: 191508821
Test: m fastboot
Change-Id: I3bdfdea3de69ceaa28528b72a09d02d2a9535e85
Sparse file can come from an untrusted source.
Need more checking to ensure that it is not a malformed
file and would not cause any OOB read access.
Update fuzz test for decoding also.
Test: adb reboot fastboot
fuzzy_fastboot --gtest_filter=Fuzz.Sparse*
fuzzy_fastboot --gtest_filter=Conformance.Sparse*
sparse_fuzzer
Bug: 212705418
Change-Id: I7622df307bb00e59faaba8bb2c67cb474cffed8e
win_sdk is deprecated, if given on the command line
sdk will be build instead.
Bug: 212724080
Test: Presubmits
Change-Id: Ia92b879fe08f0a1d9ebefc90e369adf1d4aa4112
The funciton is now used for init_boot and boot partitions, so the name
and the error messages should be more generic.
Bug: 203698939
Test: m
Change-Id: I168fdcb08accb11b2c9cfc402168744274f59665
Similar to GKI boot.img, init_boot.img is released as a specific size
and should be able to be flashed into partitions that have different
sizes. So the AVB footer is moved from the end of the init_boot.img to
the end of the partition in the case that the partition is larger than
the image.
Bug: 203698939
Test: m
Change-Id: Ib5a63a7bf1b4be4eba4941972750f12e3edb3a17
Add more checking for fastboot to detect malformed
requests.
Such as checking no control characters in the command
send from host.
Make sure the download command length is eight bytes.
And report FAIL if download length is zero.
Test: adb reboot fastboot
fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid1
fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid2
fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid7
fuzzy_fastboot --gtest_filter=Fuzz.DownloadInvalid8
Bug: 212628476
Change-Id: I750174205377395b5328923fb00462d078f3310d
Device might return I/O error instead of FAIL message
if command send to device is too large.
Since maximum command size in fastboto protocol is 64 bytes.
The device might only try to read 64 bytes for the bulk transfer,
sending data more than that might result in USB I/O error.
Do proper handler for that in fuzzy_fastboot and reset the USB
if I/O error encounter during the Comman.dTooLarge test
Test: adb reboot fastboot
fuzzy_fastboot --gtest_filter=Fuzz.CommandTooLarge
fuzzy_fastboot --gtest_filter=Fuzz.BadCommandTooLarge
Bug: 212628476
Change-Id: I3612e131de02435ee3ed7d18f2b2d20b50ae6c3f
The fuzzy_fastboot does not output error
with invalid command line argument.
Fix typo in README for running with gtest_filter
Bug: 212628476
Test: N/A
Change-Id: I4a67a84807b59db50f063f1b9cf60dc964c1df20
Direct writes for partition flashing significantly increase performance.
Use O_DIRECT flag when opening partition for flashing. Additionally use
a 4096b aligned buffer which is required for O_DIRECT.
Switch from using 8MB write buffer to 1MB write buffer, as the extra
allocation has no performance impact.
Test: flash locally and reach home screen
Bug: 205151372
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I060f438cf698d0fda1e59e35338bb5dc1cd05b51
Allow caller to pass additional flags when opening a partition. Obsolete
usage of boolean read, and make previous callers use O_RDONLY instead.
Explicitly OR (O_EXCL | O_CLOEXEC | O_BINARY) to keep existing design
working as is.
Test: flash locally and reach home screen
Bug: 205151372
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I48fbca459a17fcf0b0926ab339585e3bd8e31e35
Soong is installing binaries directly to HOST_OUT_EXECUTABLES instead
of SOONG_HOST_OUT_EXECUTABLES, dist from the HOST_OUT_EXECUTABLES
location.
Bug: 204136549
Test: m checkbuild
Change-Id: Iee7ae8d1ed478aa2a0344fc9f54ad2c146841cb0
socket.cpp fails to compile on musl with a missing definition of
fd_set. Include sys/select.h for the definition.
Bug: 190084016
Test: m USE_HOST_MUSL=true fastboot
Change-Id: I095a56381a85981f42444f4c39ae8e7786d8640f