summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
AgeCommit message (Collapse)Author
2018-12-04fastboot: Check if super_empty.img exists before reading it.David Anderson
On non-DAP devices, fastboot flash <partition> will spam error messages about not being able to read super_empty.img. We should check that super_empty.img exists before trying to read it. Bug: 120429424 Test: fastboot flash system on non-DAP device Change-Id: I6c4eec19cb3ef8d24595a75e072e1d75baaa8cdd
2018-11-28fastboot: Delete logical "other" partitions on retrofit devices.David Anderson
On retrofit devices, if both slots contain dynamic partition builds, then "flashall" will attempt to write secondary images to dynamic partitions in the other slot. At worst, this can fail with an error. At best, it will result in the "other" partition not being mounted on first boot. This patch therefore deletes logical partitions for secondary images, on retrofit devices only. On a Pixel device on the "b" slot, this means "system_a" and "vendor_a" will be deleted before flashing, and therefore system_other and vendor_other will be flashed to physical partitions instead. Bug: 120034852 Test: fastboot set_active a fastboot flashall fastboot set_active b fastboot flashall Change-Id: I6affe9a6c639b0495bffc77fcf20f329b86ad159
2018-11-28Merge changes Ic4e1a1de,Icfceaa46Treehugger Robot
* changes: fastboot: propagate error for format command fs_mgr: overlayfs: resize scratch should it be too small
2018-11-28fastboot: do not die if ANDROID_PRODUCT_OUT undefinedDavid Anderson
When checking for existence of "super_empty.img" to determine if flash image product set is meant for logical partitions, we die if ANDROID_PRODUCT_OUT environment is unset or empty. This check is done before we look at the flash image name to determine if it is a candidate to look at the logical metadata. Instead, allow this check to conservatively fail for now. Test: export ANDROID_PRODUCT_OUT= fastboot flash bootloader Bug: 120041144 Change-Id: I43f124015f9d26c79a0feb9123522432fe937343 Merged-In: I43f124015f9d26c79a0feb9123522432fe937343
2018-11-27fastboot: propagate error for format commandMark Salyzyn
If fastboot format command fails, return error. Test: adb-remount-test.sh Bug: 109821005 Change-Id: Ic4e1a1dea8861028f19ac7f9c834d26e8adba56c
2018-11-20fastboot: Warn when flashing dynamic partitions in the bootloader.David Anderson
On retrofit devices, it is easy to accidentally overwrite system/vendor/product by flashing system in the bootloader. The reason is that GPT system_a is really the super partition, and the bootloader doesn't know it. Addressing this in bootloaders would require two separate commands: one that rejects flashing system/vendor/product, and another for expert/factory use that would allow direct flashing. This patch introduces protection into the host fastboot tool instead. It's not mutually exclusive with bootloader changes; having protection in the host tool affords us better and consistent UI. However it does rely on users having newer builds. With this change, the following will not work in the bootloader: fastboot flash system # or vendor, product, etc The message is the same whether or not the device is a retrofit. To continue anyway, you can do: fastboot flash --force system If we decide on bootloader protection as well, the --force flag can be re-used. Bug: 119689480 Test: fastboot flash system # disallowed in bootloader, allowed in fastbootd fastboot flash --force system # allowed in bootloader Change-Id: I0861e3f28a15be925886d5c30c7ebd4b20c477cf
2018-11-14switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn
Test: compile Bug: 119313545 Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-06fastboot: Query the name of the super partition.David Anderson
This patch adds a new variable, "super-partition-name", to query the name of the super partition (with a slot suffix if it has one). The fastboot flashing tool has been updated to query this variable. Since the super partition name can no longer be determined without fastbootd, the presence of super_empty.img is used to test for dynamic partition support rather than the presence of a super partition. Bug: 116802789 Test: fastboot flashall on retrofit device Change-Id: If830768eba6de7f31ac3183c64167fae973c77a4
2018-11-06fastboot: Fix flashing both slots with dynamic partitions.David Anderson
When updating the super partition, attempt to preserve partitions from the other slot. If any partition can't be preserved, fail and require a wipe (-w) to proceed. This allows two bootable builds to be flashed to both slots. The preserve operation can fail if the metadata is not compatible with the old partition layout. For example, if the partition references a group that no longer exists, or a group changed its capacity, or the metadata's block device list or list contents changed. Bug: N/A Test: liblp_test gtest fastboot flashall --skip-secondary Change-Id: I53fdd29bc1f0ef132005a93d3cf1cdcd7f2fc05f
2018-10-26Merge "More Mac build fixes."Yuchao Zhou
2018-10-26Merge "fastboot: Resize logical partitions when using the flash command."David Anderson
2018-10-26More Mac build fixes.Elliott Hughes
The libziparchive public headers that refer to `off64_t` also need the Mac workaround. In fastboot, there's a stray `lseek64` but since it's only for offset 0, any kind of seek is fine. Bug: N/A Test: builds Change-Id: I68b4f95202623ebf07ffe6c3e0e21437e7922c5b
2018-10-25Merge "fastboot: Check that reboot to userspace succeeded."Treehugger Robot
2018-10-25fastboot: Resize logical partitions when using the flash command.David Anderson
If an image size changes slightly in between "flashall" and some change in the build, it's inconvenient to have to reflash the whole device again. This patch resizes partitions when using a normal flash command, to improve the developer workflow. Bug: N/A Test: fastboot flash system Change-Id: I349364a4742a0c15748f545fcfda946107720d45
2018-10-25fastboot: Check that reboot to userspace succeeded.David Anderson
After rebooting to userspace fastboot, the first command issued is "update-super". If we wound up in the bootloader by accident (as happened to a few users with a busted vbmeta_system), the resulting error message will be very misleading ("update-super" will be an unrecognized command). Instead, this patch explicitly errors if we did not successfully boot into fastbootd. Bug: N/A Test: fastboot flashall Change-Id: I7d5bd64db540978bd0bae884f40ce8c3df48f856
2018-10-24libbase: add O_CLOEXEC to <android-base/file.h>.Elliott Hughes
We already expose O_BINARY, and O_CLOEXEC seems equally legitimate. Bug: N/A Test: builds Change-Id: I7f07e1bb2a5d6b5c5f293783c39ceab148fabefb
2018-10-23Add a simple MappedFile to libbase and switch fastboot and libziparchive over.Elliott Hughes
This allows us to remove libziparchive's dependency on libutils. Bug: http://b/79112958 Test: ran libbase and libziparchive tests, ran fastboot manually Change-Id: I95c651976dad222863e5b8c37d4514b778f5dce7
2018-10-18Merge "fastboot: use constants.h values"Treehugger Robot
2018-10-18fastboot: use constants.h valuesMark Salyzyn
Cleanup to utilize all the manifest values in constants.h. If the cli command _and_ the protocol name match, use a common source of convenient truth. This should set a pattern for future additional commands. When the command and the protocol differ, we want to introduce resistance as it results in confusion and maintenance issues. Test: compile Change-Id: Idad413c63cbbfcb6e851856105a5d5a9ef53ef29
2018-10-15Rename vbmeta_mainline to vbmeta_system.David Anderson
Bug: 116859651 Test: fastboot flash vbmeta_system Change-Id: Ice65b6f5141ec6da3e1c91d6a3aac58533dc2314
2018-09-25fastboot: remove engine.cpp/engine.hTom Cherry
Replace the remnants of engine.cpp with better functionality in FastBootDriver. Particularly, add prolog() and epilog() callbacks to FastBootDriver for printing actions and their result to the console. Then clean up the rest of fastboot.cpp to directly use FastBootDriver. Test: fastboot works Change-Id: I0ff01d6a10f75e9dc1c82b46c6e9bb3bc4c68638
2018-09-21fastboot: clean up CheckRequirementsTom Cherry
CheckRequirements() had various issues that are cleaned up here, 1) Move from C string parsing to C++ 2) Moved from C data structures to C++, including fixing memory leaks. 3) Removed the 'cur_product' global and the 'query_save' function that stores it 4) Actually writing tests for the parsing function for android-info.txt 5) Check that a variable needs to be checked for a given product before trying to read it. Previously, fastboot would fail if a variable isn't recognized on a device, even if the check should be ignored. A lot of flexibility is allowed for the input strings, to keep backwards compatibility with the previous parsers. Test: fastboot works, unit tests Change-Id: Idc3bba8b8fe829d8eefe5f6c495e63a9441c0b60
2018-09-20Use vector<char> instead of char* and malloc() for imagesTom Cherry
And fix the associated memory leaks in the process. Test: fastboot works Change-Id: I6e41f351ca6cebf79282d30b1eca1506496e0c21
2018-09-17fastboot: Add vbmeta_mainline to the partition list.David Anderson
Bug: 115939310 Test: fastboot flash vbmeta_mainline works fastboot flashall includes vbmeta_mainline Change-Id: I081660cd8437ac66cab750b270f5019230050285
2018-09-05fastboot: remove command queueTom Cherry
There is little advantage and increasingly much disadvantage to queueing up fastboot commands before executing them. This change removes the queue in the most simple way possible to enable further clean up. Test: fastboot works Change-Id: I9abab05df07ed167dbe6a42e1eb9eab8f8d4f157
2018-09-04fastbootd: Fix transport ownership.David Anderson
This change moves Transport ownership back out of FastBootDriver. Callers of set_transport must ensure that the previous transport is destroyed. In addition, deleting a transport now ensures that it is closed. Bug: 78793464 Test: fastboot, fuzzy_fastboot works Change-Id: I8f9ed2f7d5b09fd0820b2677d087a027378f26db
2018-08-30Merge "Convert fastboot to Soong"Dan Willemsen
2018-08-30Convert fastboot to SoongDan Willemsen
Also fix adb's version number to match. See build/soong/README.md for more information. Test: cd system/core/fastboot; mma Test: fastboot --version Test: adb --version Test: out/host/linux-x86/nativetest/fastboot_test/fastboot_test Test: out/host/linux-x86/nativetest64/fastboot_test/fastboot_test Change-Id: I65ea39af9183c602e84f3bc0e4a0d066a30fc464
2018-08-29fastboot: Use a single codepath for flashall and update.David Anderson
This patch extracts the common logic out of the flashall and update command implementations. There is now a FlashAllTool helper class, and an ImageSource class for commands to specify how to find built images. With these paths merged, the update command now supports logical partitions. Bug: 78793464 Test: flashall works with or without a super partition update works with or without a super partition Change-Id: I63a8690bbc4da6ea98a07eb2c07166ddd993a7b7
2018-08-28fastboot: Clean up the image array a bit.David Anderson
This makes the following changes to the images array: * The "optional_if_no_partition" flag is removed, as it was a temporary workaround for super.img. * The "flashall" flag is removed. * The "needed_for_fastbootd" flag is now an ImageType enum. Bug: N/A Test: fastboot builds, flashall works Change-Id: Id000ea20cf83639cec2c9ae94f28c799b34606f1
2018-08-28fastboot: Flash boot partitions before rebooting to fastbootd.David Anderson
Userspace fastboot is required when flashing logical partitions. If for some reason userspace fastboot is broken, the user may be stuck with bootloader fastboot. To address this scenario, we now flash "boot", "vbmeta", "recovery", "dtbo", and "dts" before booting into userspace fastboot, using whatever fastboot is currently active. Bug: 78793464 Test: fastboot flashall with device in bootloader fastboot Change-Id: I773707bbbe9235c560416c70976e32fd8e52a5a3
2018-08-28fastboot: Automatically reboot to userspace fastboot.David Anderson
In order to flash logical partitions, "flashall" must be run against userspace fastboot. When the bootloader supports the "reboot-fastboot" command, we now attempt to automatically reboot into userspace fastboot. We do this by closing the transport, sleeping for one second, and then polling for a new connection until one is available. FastBootDriver is then assigned the new transport. Bug: 78793464 Test: fastboot flashall on device with logical partitions, while booted into bootloader fastboot Change-Id: I6949871b93ab5e352784cabe0963c6ecfc0af36d
2018-08-24fastboot: allow automatic detection of super locationMark Salyzyn
Add "super" to the table of known images so that automatic file resolution can occur. Add a flag to indicate if the image should be flashed with flashall and set it to false for the new "super" image, all else true. Test: 'fastboot flash super' works. 'fastboot flashall' does not flash super Bug: 78793464 Change-Id: I5b85536b1d4890264531af357aba84a061d6df44
2018-08-23Merge changes from topic "fastbootd-flashall"Treehugger Robot
* changes: fastbootd: Support flashall with logical partitions. fastboot: Use _WIN32 instead of WIN32.
2018-08-23fastbootd: Support flashall with logical partitions.David Anderson
Currently, fastboot flashall will try to flash every partition in the image list. For devices with logical partitions, this will cause those partitions to be flashed twice (once via super.img, and again for each individual image). Additionally, super.img is needed to synchronize the logical partition list, but it is only generated with "make dist", making it inconvenient for most workflows. This patch removes automatic flashing of super.img. Instead, devices with a super partition must now generate a "super_empty.img" describing the super geometry and logical partition layout. Before flashing any other partitions, this image is used to ensure the device has created all necessary logical partitions. Additionally, before flashing (but after updating super), all logical partitions that will be flashed are resized to 0. This ensures that logical partitions will receive more optimal space allocation. Finally, during flashing of individual images, logical partitions are resized to the image size, since they do not have hardcoded sizes in the build. Bug: 78793464 Test: fastboot flashall can flash vendor, product, product_services without a make dist/super.img. Change-Id: I18c2291e0d0cb10de729c5646b75ac84dde8c871
2018-08-20s/product-services/product_services/gDario Freni
Attempting to reduce the number of different spellings we have for "product services" partition in the codebase. Bug: 112431447 Test: m Change-Id: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71 Merged-In: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
2018-08-09fastbootd: Add commands for logical partitions.David Anderson
This patch adds the following new commands to fastbootd: getvar is_logical:<partition> create-logical-logical-partition <partition> <size> delete-logical-partition <partition> resize-logicallogical-partition <partition> <size> All of these commands operate on logical partitions only, and require a properly configured "super" partition to operate. Bug: 78793464 Test: fastboot create-logical-partition example 4096 fastboot create-logical-partition example 4096 returns error fastboot getvar is-logical:example returns "yes" fastboot getvar partition-size:example returns "1000" fastboot resize-logicalpartition example 8000 fastboot getvar partition-size:example returns "2000" fastboot delete-logical-partition example fastboot getvar is-logical:example returns error fastboot getvar is-logical:system_a returns "no" Change-Id: Iff323eabcf5c559fa04c7c92574650b01803eb1f
2018-08-07fastboot: Fix product-services typoDavid Anderson
The build system generates a partition name of "product_services" for the product-services partition, so fastboot's image list must reflect this. Bug: 78793464 Test: fastboot flash product_services works with fastbootd Change-Id: I348f970c9584fd3dd4369e8cded66b6e39eee2b2
2018-08-07Merge "Allow existance of partition to be checked before flashall or update"Treehugger Robot
2018-08-07Merge "Add fastbootd."Treehugger Robot
2018-08-06Allow existance of partition to be checked before flashall or updateHridya Valsaraju
Bug: 112108453 Test: fastboot flashall with super.img and product-services.img in $OUT, fastboot update with super.img and product-services.img in image.zip. Change-Id: I5718b5e60c546c55af74292895b3f7fe169e4f02
2018-08-02Add fastbootd.Hridya Valsaraju
Fastbootd is started by recovery, and communicates over usb with the fastboot protocol. Add additional fastboot commands to move in and out of fastbootd. "fastboot reboot recovery" and "fastboot reboot fastboot" Bug: 78793464 Test: fastboot reboot recovery, fastboot reboot fastboot Change-Id: Iffb77b2d3ceefb7335c38aa9fba7bd17821484f0
2018-08-01Merge "Flash super partition with fastboot flashall"Treehugger Robot
2018-08-01Flash super partition with fastboot flashallHridya Valsaraju
Bug: 111763923 Test: fastboot flashall Change-Id: I9b89825bac00d1237972a61715da05f933ac35ce
2018-08-01Add product-services.img for `fastboot flashall`.Dario Freni
This CL is largely and adaptation of Ifd119650dd3316508870df0dfc770099e95ae1d1 Bug: 80741439 Test: Successfully built product-services.img with one module in it, and flashed on device. Also successfully built image with /system/product-services and no dedicated /product-services partition. Change-Id: I204a831e052d018018ab124d70ad1ff1610ee007
2018-07-19Refactor libfastbootAaron Wisner
This change creates a nice and clean API for issuing fastboot commands without using the fastboot tool itself. Test: fastboot tool itself (now using libfastboot2) on sailfish, walleye, and other devices. Test: flash bootloader bootloader.img Test: flash radio radio.img Test: -w update img.zip Test: Manually getvar and reboot commands. Bug: 111126621 Change-Id: I0022536b204ce0c5ad8329367fd522fa3c57877d
2018-05-24Clarify 'fastboot flash' help.Elliott Hughes
Bug: http://b/80206492 Test: `fastboot --help` Change-Id: Idd4305628836eb0bcbcf3d217db0a9fc54a1d6d6
2018-05-21fastboot: better temporary file errors.Elliott Hughes
Bug: http://b/80082652 Test: N/A Change-Id: Ib9f34342157ea3a15fd48504d03f4f3a2c710579
2018-04-25Wipe metadata when we wipe userdata and cache.Paul Crowley
Bug: 78469699 Test: Run "fastboot -w" and see that metadata is wiped Change-Id: I2d795281c48b59c87d4f8f010037d95186f55684
2018-04-24fastboot: sparse_file_len() returns int64_t.Tao Bao
Check that the value fits in uint32_t that's supported by the current protocol. Also fix and sanity check the max_size before passing it to sparse_file_resparse(), which accepts `unsigned int`. This shouldn't happen in practice because of RESPARSE_LIMIT (1 GiB). Test: `fastboot flash` with small and large images. Change-Id: I0a8279fc14c54c40a70ddce65c3b25173c0d0a40