summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
AgeCommit message (Collapse)Author
2021-06-09fastboot: support vbmeta_vendor.imgBowgo Tsai
Bug: 181909612 Bug: 190564127 Test: build Change-Id: If61fff1c83513d71605c0cef2737a38f7575d69b Merged-In: If61fff1c83513d71605c0cef2737a38f7575d69b (cherry picked from commit a48a78356fa59c94e61482ab5bc39532530bac58)
2021-04-12fastboot: Add a few missing fastboot commands from helpLuca Stefani
Test: m, fastboot help Change-Id: I8c40ad25123470ea214b9d93d7305945973a2b0b
2021-04-06fastboot: use --force to bypass requirementsAndrew Chant
Allow using --force to bypass flashing requirements from android-info.txt. We often provide builds to deviceholders who don't have an exact matching bootloader or radio image and it is unimportant. Having the option to override is useful. This shouldn't affect bootloader.img so should never prevent a device from returning to fastboot in case of gross error. Test: Downloaded a build w/ different radio. Got the following output: ... Checking 'version-baseband' FAILED Device version-baseband is 'xyz'. Update requires 'abc' or '123'. requirements not met! but proceeding due to --force Setting current slot to 'a' OKAY [ 0.065s] Bug: 184661990 Change-Id: I8680b8275b854304026cff3b2e663b7ef2594383
2021-03-29Merge "fastboot: Don't fail when unable to get boot partition size"David Anderson
2021-03-25fastboot: Refactor bootimg_utils.cpp:mkbootimg()Yi-Yo Chiang
Change mkbootimg() to return void, as we already have a |out| parameter. Bug: 183455415 Test: Presubmit Change-Id: I51439e273752ab9e21f8d7138e900ea55bdfdfc0
2021-03-24fastboot: Don't fail when unable to get boot partition sizeMichael Bestas
* Some devices don't report boot partition size Change-Id: If83f785e235569ee8ef0de2b37f11dbd2a9a71f4
2021-03-24Merge "fastboot driver: add virtual dtor to ImageSource."Treehugger Robot
2021-03-22fastboot driver: Disallow implicit conversion from unique_fd to int.Yifan Hong
Do not use the implicit cast from unique_fd to int so that it is clearer to the reader what the ownership model is. Test: pass Change-Id: Iaf40a6eed3fcfd001651980c865ed5efb85ac0eb
2021-03-22fastboot driver: Fix fd ownership.Yifan Hong
load_sparse_files assumes that the client maintains the lifetime of the input fd is longer than the output sparse_file handle. Bug: 183409401 Bug: 183223098 Test: flash super image Change-Id: I295b912c665577b5767a133f3148e58a22733998
2021-03-19fastboot driver: add virtual dtor to ImageSource.Yifan Hong
Test: Treehugger Change-Id: Ia91d6d344186a07d90e3983c153d8170859eed5b
2021-03-19fastboot driver: Avoid use after std::move()Greg Kaiser
Test: TreeHugger Change-Id: I2857f6d6384c8c80809f21202dbbbfc9ed71beeb
2021-03-17fastboot driver: repack vendor boot ramdiskYifan Hong
When a user issues `fastboot flash vendor_boot:foo ramdisk.img`, the fastboot driver fetches the vendor_boot image from the device, determines if `foo` is a valid vendor ramdisk fragment, repacks a new vendor boot image, then flash the vendor boot image back. This requires vendor boot header V4. As a convinent alias, `fastboot flash vendor_boot:default ramdisk.img` flashes the whole vendor ramdisk image. This works on vendor boot header V3 & 4. Fixes: 173654501 Test: pass Change-Id: I42b2483a736ea8aa9fd9372b960502a642934cdc
2021-03-17fastboot driver: Allow colon in partition name when flashingYifan Hong
If fastboot flash vendor_boot:default, only call has-slot on the first token, and append slot to the first token only. Test: fastboot flash vendor_boot:default Bug: 173654501 Change-Id: I8ff7b3a0bafb964792ab8a788d64d14bc47ae83d
2021-03-17fastboot driver: add fetch command in driverYifan Hong
The `fastboot fetch` command is a wrapper around the fetch protocol. It: - getvar max-fetch-size - get the size of the partition - read the data by chunks, chunk size = max-fetch-size. The name of the partition is passed directly to the device (with the usual has-slot magic for flashing etc.) If we support fetching partitions other than vendor_boot in the future, no change in the driver is needed. Bug: 173654501 Test: manual Change-Id: Ie576eea668234df236b096a372e65c5e91c1e48c
2021-03-17fastboot driver: Fix ownership of fd in fastboot_buffer.Yifan Hong
fastboot_buffer owns the fd. Make ImageSource::Open() returns a unique_fd and pass ownership all the way down to the fastboot_buffer to avoid leaking fds. Test: none Change-Id: I9e7e176fc1da74c532a86d0fdba0113bdc81a166
2021-03-17fastboot driver: fix messageYifan Hong
Test: pass Bug: 173654501 Change-Id: I7d5e7ce817a5ec4e3aba6b44bab3149683a46fdd
2021-02-26fastboot: Bring back legacy A/B supportLuK1337
Some devices, such as the Essential PH-1, don't have an updated bootloader and the bootloader is appending an extra underscore. This patch works around that issue by sanitizing the slot to be inline with modern expectations. Offending commit: https://github.com/aosp-mirror/platform_system_core/commit/42b18a518bac85c3eea14206f6cbafbd1e98a31f Most of the commit above is not needed because an underscore + slot is automatically appended when flashing to a partition. Normally, this would result in something like boot__b instead of boot_b, where b is the current slot. Test: flash an image on mata without specifying slot, boots Change-Id: Ia0b7cee603a4f9ba2e3a61ce6e369ca8c07a7caf
2021-01-15fastboot: Add pvmfwAndrew Scull
The pvmfw partition holds the protected VM firmware that is used by Protected KVM to bootstrap the trust in protected VMs. Teach fastboot about the partition so it gets flashed with flashall. pvmfw is an AVB chained partition so is marked as BootCritical to allow ABL's AVB verification to pass. Test: tab complete and flashall Bug: 171280178 Change-Id: Ie4cc478de25a945bc510488d87c2bee3aa5031f2
2020-11-09fastboot: add casefold/projid/compress optionsJaegeuk Kim
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-09-16Merge changes from topic "revert-1413808-modules_partition-UXSIXCGPHZ"Yifan Hong
* changes: Revert "rootdir: Add modules directory" Revert "fastboot: add modules partition"
2020-09-15fastboot: switch to ZipEntry64.Elliott Hughes
Test: treehugger Change-Id: I17a023f113590e469f69174f7004c4579255c6ed
2020-09-15Revert "fastboot: add modules partition"Yifan Hong
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-08-25fastboot: add modules partitionYifan Hong
Test: none Bug: 163543381 Change-Id: I4200d0cf525ca7b350fdf468c4f3795a8c5015c9
2020-07-15fastboot: Add odm_dlkmYifan Hong
Test: add odm_dlkm partition and flash Bug: 156020364 Change-Id: I577b4420f2be8e8141d967f0d9107cae381c7675
2020-07-09fastboot: Add vendor_dlkmYifan Hong
Test: add vendor_dlkm partition and flash Bug: 156020364 Change-Id: If6794ca5a76613a1a3337a4637edd1d364eff5dd
2020-06-18fastboot: copy AVB footer on boot image to end of partitionSteve Muckle
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-10fastboot: don't print anything in Status() if the input is emptyTom Cherry
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-05Fix `fastboot flash-all` on Nexus 7.Elliott Hughes
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-05-28fastboot: Allow fastboot to asynchronously differentiate between fastboot ↵David Anderson
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-03-18fastboot: add support for v3 boot header formatSteve Muckle
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
2019-12-10fastboot: Flashall does proper snapshot cancelYifan Hong
Fix typo. Test: flashall Change-Id: I54a51a489aef2e1de5e682f5e97b95b2278085ec
2019-11-10fastbootd: Disallow certain operations during snapshot updates.David Anderson
When a snapshot is applied or is merging, requests to erase or flash userdata, metadata, or misc must be protected. In addition, the set_active command must be restricted when a merge is in progress. In addition, introduce a "snapshot-update merge" command for assisting with erase requests when a merge is in progress. As in recovery, this will force a merge to complete. Bug: 139154945 Test: apply update fastboot erase userdata fastboot erase metadata fastboot erase misc fastboot set_active Change-Id: I152446464335c62c39ffb4cc6366be9de19eac30
2019-10-31fastboot: Implement helper commands for Virtual A/B.David Anderson
This introduces two new commands to the fastboot protocol: - getvar snapshot-update-status - Return "none", "snapshotted", or "merging" depending on the current status set by the boot control HAL. - snapshot-update [cancel] - Cancel any pending snapshot-based updates via the boot control HAL. After this, the HAL should return MergeStatus::CANCELLED and "update-merge-status" should be "none". If no argument is specified, the snapshot-update-status is returned via an INFO response. Bootloaders are expected to implement this in a manner consistent with the boot control HAL. Fastboot-based tooling should expect wipes of userdata to fail when update-merge-status returns "merging". Thus, the force flag now cancel any pending snapshots. Bug: 139154945 Test: fastboot getvar snapshot-update-status fastboot snapshot-update cancel fastboot snapshot-update Change-Id: Idc423fe7656b212e929e64eb0e6b85b453e0e8dc
2019-09-24Allow --disable-verification when top-level vbmeta is in 'boot'Chin-Ting Kuo
If top-level vbmeta struct is in 'boot' partition, the "flags" element offset of top-level vbmeta header from the beginning of boot partition is 123 plus top-level vbmeta offset recorded in the boot image footer. Bug: 139639521 Test: m fastboot Test: fastboot --disable-verification flashall Test: fastboot --disable-verification flash boot boot.img, checks the flag isn't changed if the device has vbmeta partition Test: fastboot --disable-verification flash vbmeta vbmeta.img Change-Id: Ibf73c9330639e971ee3873ac19f072cf7baed55b
2019-09-17fastboot: don't use sparse_file_import_auto() in load_buf_fd()Tom Cherry
load_buf_fd() attempts to find the size of the file that it is about to load by first calling sparse_file_import_auto() then using sparse_file_len() upon success or falling back to the file size on the filesystem on failure. This is problematic however as sparse_file_import_auto() creates a sparse_file out of the normal file, but does not resparse it, so an assertion fails during the sparse_file_len() call. This is fixed by using sparse_file_import() instead. This will fail in the case that the file is not sparse and the call to sparse_file_len() will be properly skipped. Bug: 140538105 Test: flash blueline factory image with assertions enabled in libsparse/sparse.cpp Change-Id: I0283be33563a3301ce5b09bde41105a20f91086c
2019-08-29fastboot: preserve partition_type if wants_wipe=truecfig
originally if wants_wipe=true, program will erase and format partitions, but after fb->Erase(), partition type should be raw(all 0xFFs), then following fb_perform_format() will miss its original partition_type Now we call fb_perform_format() with original fs type to keep the partition consistent after wiping. Change-Id: Ic778850588d5dd6fee23169d20c26bcbaa510627
2019-08-21fastboot: add vendor_boot to list of imagesSteve Muckle
The vendor_boot partition has been created, so add it to the list of images which may be flashed. Bug: 137297791 Change-Id: I27eaa16656a83dbcb8289680844bf58dd1fccf24
2019-07-09Rename product_services to system_extJustin Yun
Update adb, fastboot and mount point Bug: 134359158 Test: build and check if system_ext.img can be flashed Change-Id: I6219f72242c5fe42a508008c0b1fd218d74da5b6
2019-06-28fastboot: add a wipe-super command.David Anderson
Usage: fastboot wipe-super [super_empty.img] This command will read the given super_empty.img (using the default one in ANDROID_PRODUCT_OUT if not specified), and flash by generating a temporary super.img with no partition data. This command will even work on retrofit devices. This command is intended to be used either during device bringup or with scripts that will manually flash individual dynamic partitions, in place of using "fastboot flashall". Bug: 136282057 Test: fastboot wipe-super on retrofit and non-retrofit device Change-Id: Icab368a63ff36fcce9ac9304eb3966dd38bd78c4
2019-05-20Merge "Get max-download-size from device during fastbootd for flashall/update"Treehugger Robot
2019-05-20Get max-download-size from device during fastbootd for flashall/updateHridya Valsaraju
Currently, during a 'fastboot flashall/fastboot update', the 'getvar max-download-size' command is issued once to the device when it is in bootloader mode and the same value is used even after the device boots into fastbootd. If the max-download-size returned by bootloader is greater than the max-download-size in fastbootd, this could break flash as large images are broken down into chunks before downloading by using the max-download-size variable. This will cause fastbootd to return an error since it checks whether the buffer being downloaded has a size greater than the max-download-size limit. Test: fastboot flashall Bug: 536870912 Change-Id: Ife7c1ec0583d80d4a31ecf01f1fc14a8365afe0d
2019-05-04libziparchive: report errors on over-long names.Elliott Hughes
Switch FindEntry and the ZipString constructor to std::string_view. This lets us accept an over-long name so that we can reject it as too long. Also fastboot changes to track the API change. Bug: http://b/129068177 Test: treehugger Change-Id: I7df7acd1fe2c46380b789c25f8909e0553e2d55e
2019-04-04Merge "Open image files in binary mode"Treehugger Robot
2019-04-03Open image files in binary modeHridya Valsaraju
This is required for read() to function correctly in Windows since it behaves differently in text mode and binary mode and may cause unpredictable behavior depending on the contents of the image file. Bug: 129281908 Test: fastboot.exe flashall Change-Id: I64370af44a050bafea60ff1b0b2be18cc531480a
2019-03-26fastboot: Avoid extra std::string copiesGreg Kaiser
The function do_for_partitions() takes a const std::string reference, so it's inefficient to pass a std::string::c_str(). Test: TreeHugger Change-Id: Ia84ed9ec691ee2f524c61dd25a81b2995bb0bb33
2019-01-29fastboot: Fix "fastboot gsi".David Anderson
This command erroneously reports that no GSI is installed, because /metadata is not mounted in recovery. To address this, temporarily mount /metadata when the gsi command is invoked. Bug: 122556707 Test: fastboot gsi disable fastboot gsi wipe Change-Id: Ib21971b49b46fd580b902ff75f01cfb96192afc0
2019-01-25Make 'fastboot boot' command support boot header version 2Hridya Valsaraju
New arguments 'dtb' and 'dtb-offset' have been added to support boot image header version 2 for the 'fastboot boot' and 'fastboot flash:raw boot' commands. Test: fastboot boot Image.lz4 --dtb <dtb_path> --header-version 2 Test: fastboot flash:raw boot Image.lz4 --dtb <dtb_path> --header-version 2 Bug: 111136242 Change-Id: Idf5c2eb138609dc7e915e80c4db64677c89f24b6
2019-01-17fastbootd: Add command to remove GSI installsDavid Anderson
Note: this only removes the bootable marker, since we're unable to remove the userdata files within recovery. Bug: 121210348 Test: fastboot gsi wipe fastboot gsi disable Change-Id: I64fe848c787d426ae9d18a1557a9d6b340bfc2cf
2018-12-08Merge "fastboot: Wait for reboot-fastboot to complete before signaling success."David Anderson
2018-12-07fastboot: Wait for reboot-fastboot to complete before signaling success.David Anderson
Bug: N/A Test: manual test Change-Id: I07495c1befcf63607c9996d6da6b4df05c060641