summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
AgeCommit message (Collapse)Author
2018-04-19Move fastboot over to ParseByteCount.Elliott Hughes
Bug: N/A Test: `fastboot flashall` and `fastboot -S 100m flashall` Change-Id: I1f55c6e10be74780bbf8dc30b2d4be3f362ac662
2018-04-16Remove header version check for command "fastboot boot boot.img"Hridya Valsaraju
The header version argument is meant for creation of boot images using boot and flash:raw commands. It is unnecessary to specify the same while using the boot command with a complete boot image. Bug: 77920157 Test: fastboot boot boot.img Change-Id: Ia8fca4180e15906a3ae7c732496a744eb4b15e91 Merged-In: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
2018-04-10Remove unused variable.Elliott Hughes
Bug: N/A Test: builds Change-Id: I983f361d3d5a779600077a78b121c4ee399089db
2018-04-10Remove -i vendor id matching.Elliott Hughes
We removed this from adb years ago. Bug: N/A Test: N/A Change-Id: I899c8433665e64a0c0302d2c30a8e689b8c83d65
2018-04-10Remove legacy slot-suffix support.Elliott Hughes
Bug: N/A Test: flashed Pixel Change-Id: Ic3cb9c8225c75697099723347f7fd820bcadca6e
2018-04-10Add fastboot_test.cpp and test --os-version/--os-patch-level parsing.Elliott Hughes
Also switch all remaining headers over to #pragma once, and actually use FB_COMMAND_SZ. Bug: http://b/77340848 Test: ran tests Change-Id: I27107d054c206e66c39208099e36a55df604e08f
2018-04-09Minimal changes to build fastboot as a library.Elliott Hughes
Bug: http://b/77809061 Test: builds Change-Id: I0c388334d643a0a2abf0c03a29f336dc3af2f83f
2018-04-09Add fastboot --os-version and --os-patch-level.Elliott Hughes
Also move -c to --cmdline to match the python mkbootimg tool. Remove the short options for these rarely-used options. Remove #if 0 cruft from <bootimg/bootimg.h>. Bug: http://b/77340848 Test: manual testing (need to fix http://b/77809061 for unit tests) Change-Id: Ieaa795566611bd89ba3fee39a1d9f6ad0713a587
2018-04-05Remove the "needs_erase" workaround.Elliott Hughes
This workaround shouldn't be necessary now we're using mke2fs. Bug: http://b/25429933 Test: `fastboot -w flashall` Change-Id: I577ad445a02a448102fb49674360a732aa3d153c
2018-04-04Remove lock_bootloader/unlock_bootloader.Elliott Hughes
These were implemented on Nexus 5X/6P, but the infrastructure for the challenge-response system isn't available. Bug: N/A Test: N/A Change-Id: I50e27f469ea7c668de1af314f83f5171376ccda4
2018-04-04Remove `reboot emergency`.Elliott Hughes
This isn't in the bootloader requirements doc, and the internet implies that you actually need to use `fastboot oem edl` or `fastboot oem reboot-edl` anyway. Bug: N/A Test: N/A Change-Id: I0b7cd9839fbd06fc104d029e92d5986dc3c6eda3
2018-04-03Clean up fastboot help:Elliott Hughes
After: usage: fastboot [OPTION...] COMMAND... flashing: update ZIP Flash all partitions from an update.zip package. flashall Flash all partitions from $ANDROID_PRODUCT_OUT. On A/B devices, flashed slot is set as active. Secondary images may be flashed to inactive slot. flash PARTITION [FILENAME] Flash given partition only. basics: devices [-l] List devices in bootloader (-l: with device paths). getvar NAME Display given bootloader variable. reboot [bootloader] Reboot device. locking/unlocking: flashing lock|unlock Lock/unlock partitions for flashing flashing lock_critical|unlock_critical Lock/unlock 'critical' bootloader partitions. flashing get_unlock_ability Check whether unlocking is allowed (1) or not(0). advanced: erase PARTITION Erase a flash partition. format[:FS_TYPE[:SIZE]] PARTITION Format a flash partition. set_active SLOT Set the active slot. oem [COMMAND...] Execute OEM-specific command. boot image: boot KERNEL [RAMDISK [SECOND]] Download and boot kernel from RAM. flash:raw PARTITION KERNEL [RAMDISK [SECOND]] Create boot image and flash it. -c CMDLINE Override kernel command line. --base ADDRESS Set kernel base address (default: 0x10000000). --kernel-offset Set kernel offset (default: 0x00008000). --ramdisk-offset Set ramdisk offset (default: 0x01000000). --tags-offset Set tags offset (default: 0x00000100). --page-size BYTES Set flash page size (default: 2048). --header-version VERSION Set boot image header version. Android Things: stage IN_FILE Sends given file to stage for the next command. get_staged OUT_FILE Writes data staged by the last command to a file. options: -w Wipe userdata. -u Do not erase partition first when formatting. -s SERIAL Specify a USB device. -s tcp|udp:HOST[:PORT] Specify a network device. -i VENDOR_ID Filter devices by USB vendor id. -S SIZE[K|M|G] Use sparse files above this limit (0 to disable). --slot SLOT Use SLOT; 'all' for both slots, 'other' for non-current slot (default: current active slot). --set-active[=SLOT] Sets the active slot before rebooting. --skip-secondary Don't flash secondary slots in flashall/update. --skip-reboot Don't reboot device after flashing. --disable-verity Sets disable-verity when flashing vbmeta. --disable-verification Sets disable-verification when flashing vbmeta. --wipe-and-use-fbe Enable file-based encryption, wiping userdata. --unbuffered Don't buffer input or output. --verbose, -v Verbose output. --version Display version. --help, -h Show this message. Bug: N/A Test: `fastboot --help` Change-Id: I3639fdee68de544f12e75004ccbb03b8386e64ed
2018-04-03Merge "Add a header-version argument to fastboot"Treehugger Robot
2018-04-02Add a header-version argument to fastbootHridya Valsaraju
The argument would set the boot header version for flash:raw and boot commands when they are used for boot image creation. Bug: 77154616 Test: Dumped the created boot image and checked the header version using unpack_bootimg Change-Id: I2c458996817615f4351db102b4234984108d47c0 Merged-In: I2c458996817615f4351db102b4234984108d47c0 (cherry picked from commit 88de5556eccdc378084b037413bbece01ddee52d)
2018-04-02Improve fastboot verbose output.Elliott Hughes
Move some verbose messages so they're only output with -v. Remove some misleading verbose messages altogether (such as "wiping userdata..."). Properly log all the commands sent and responses received. Example: $ fastboot -v flashall ... Sending sparse 'system' 2/2 (443712 KB) fastboot: verbose: sending command "download:1b1500d0" fastboot: verbose: received DATA 1b1500d0 fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (165596160 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (267762688 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (20978688 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (7168 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (3072 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (3072 bytes) fastboot: verbose: sending data (1024 bytes) fastboot: verbose: sending data (3072 bytes) fastboot: verbose: sending data (208 bytes) fastboot: verbose: received OKAY OKAY [ 13.871s] Writing sparse 'system' 2/2 fastboot: verbose: sending command "flash:system" fastboot: verbose: received OKAY OKAY [ 3.228s] Rebooting fastboot: verbose: sending command "reboot" fastboot: verbose: received OKAY Finished. Total time: 36.939s Bug: http://b/30953083 Bug: http://b/74444116 Test: `fastboot -v flashall` Change-Id: I2cca198daa062fd1fb732218343263803b111e38
2018-04-02Modernize fastboot output format.Elliott Hughes
After: -------------------------------------------- Bootloader Version...: 0.5 Baseband Version.....: 0.5 Serial Number........: serialv1.0 -------------------------------------------- Checking product OKAY [ 0.032s] Sending 'boot' (9962 KB) OKAY [ 0.350s] Writing 'boot' OKAY [ 0.143s] Sending 'dts' (14 KB) OKAY [ 0.068s] Writing 'dts' OKAY [ 0.048s] Sending sparse 'system' 1/2 (460796 KB) OKAY [ 14.383s] Writing sparse 'system' 1/2 OKAY [ 4.138s] Sending sparse 'system' 2/2 (443712 KB) OKAY [ 13.871s] Writing sparse 'system' 2/2 OKAY [ 3.246s] Rebooting Finished. Total time: 36.962s For a failure: extracting android-info.txt (0 MB) to RAM... -------------------------------------------- Bootloader Version...: 0.5 Baseband Version.....: 0.5 Serial Number........: serialv1.0 -------------------------------------------- Checking product FAILED Device product is 'hikey960'. Update requires 'marlin' or 'sailfish'. fastboot: error: requirements not met! This change also adds a -v/--verbose flag, but doesn't make much use of it yet (http://b/30953083 will need it). Bug: N/A Test: manual Change-Id: I7d19f5775859ffad5f3be5707b37dcb6e180917f
2018-03-28Merge "Add "require partition-exists=" support."Elliott Hughes
2018-03-28Add "require partition-exists=" support.Elliott Hughes
The Pixel 2 system images release was a bit of a disaster because anyone using an old version of fastboot would blindly flash too few partitions, potentially bricking their device. This change lets us add a line to the android-info.txt file for a device with a new partition. Also error out sooner in such cases by checking the requirements immediately, rather than optimistically unpacking everything first. Switch Action over to C++ to fix memory issues. Bug: http://b/77158188 (partition checking) Bug: http://b/74444116 (error out sooner) Test: manual testing with a modified android-info.txt Change-Id: I58b426cad410107e368f35f5725216d07281dd97
2018-03-29Adding odm.img for `fastboot flashall`Bowgo Tsai
Bug: 64195575 Test: fastboot flashall Change-Id: Ie6c20a1004867e7c9cfa1894abab9252316a9154
2018-03-26Adding product.img for `fastboot flashall`Bowgo Tsai
Bug: 64195575 Test: fastboot flashall Change-Id: Ifd119650dd3316508870df0dfc770099e95ae1d1
2018-01-18Fix fastboot memory corruption.Elliott Hughes
Bug: http://b/68664649 Test: echo 'ANDROID!' > fake.img ; fastboot -c `python -c "print 'A'*4000"` boot fake.img Change-Id: I3299e0fba24a6c1f6178c994731a94cea68f7254
2017-11-10fastboot: show how long extraction takes.Elliott Hughes
Before: extracting android-info.txt (0 MB)... extracting boot.img (29 MB)... target reported max download size of 536870912 bytes archive does not contain 'boot.sig' archive does not contain 'boot_other.img' archive does not contain 'dtbo.img' archive does not contain 'dt.img' archive does not contain 'recovery.img' extracting system.img (1928 MB)... archive does not contain 'system.sig' extracting system_other.img (574 MB)... archive does not contain 'system.sig' archive does not contain 'vbmeta.img' After: extracting android-info.txt (0 MB) to RAM... extracting boot.img (29 MB) to disk... took 0.232s target reported max download size of 536870912 bytes archive does not contain 'boot.sig' archive does not contain 'boot_other.img' archive does not contain 'dtbo.img' archive does not contain 'dt.img' archive does not contain 'recovery.img' extracting system.img (1928 MB) to disk... took 10.122s archive does not contain 'system.sig' extracting system_other.img (574 MB) to disk... took 3.424s archive does not contain 'system.sig' archive does not contain 'vbmeta.img' Bug: http://b/69128980 Test: ran manually Change-Id: Ib190d1cc56ad9da06a4f9a9e822f7dad4a9a53b7
2017-11-03Merge "fastboot: handle small flash block sizes correctly"Connor O'Brien
2017-11-02fastboot: Don't give parsing error for unsupported 'getvar erase-block-size'.Tao Bao
Couldn't parse erase-block-size '0x'. Couldn't parse logical-block-size '0x'. mke2fs 1.43.3 (04-Sep-2016) ... Some bootloaders explicitly return error on failed query (e.g. walleye), while others return empty message (e.g. bullhead). We should just return zero for empty message, instead of giving a misleading parsing error. Test: `fastboot format userdata` on bullhead, with no parsing error. Test: `fastboot format userdata` on walleye still works. Change-Id: I194d41d24679929eccc65bfe895d6ab2a26315b7
2017-11-02fastboot: handle small flash block sizes correctlyConnor O'Brien
Erase block sizes smaller than the ext4 block size may be valid, but can incorrectly result in a stripe width smaller than the stride size. Instead of reporting these sizes as invalid, add a check to enforce that raid_stripe_width >= raid_stride. Bug: 68770797 Test: Hack fb_getvar to report small erase block size, run fastboot -w and confirm it does not print a warning or set stripe_width smaller than stride. Signed-off-by: Connor O'Brien <connoro@google.com> Change-Id: I689ce4bdd5b38bd0952bb6de54785cca39176010
2017-10-27fastboot should fail if it runs out of space while unzipping.Elliott Hughes
Previously fastboot would carry on regardless if decompression failed: fastboot: archive does not contain 'vbmeta.img' fastboot: extracting vendor.img (260 MB)... fastboot: W/ziparchive(56777): Zip: unable to allocate 272781472 bytes at offset 0 : No space left on device fastboot: failed to extract 'vendor.img': I/O error fastboot: archive does not contain 'vendor_other.img' fastboot: wiping userdata... This is because all but "boot" and "system" are considered "optional", and the implementation of "optional" was "ignore any failures". What it _should_ have meant was "it's okay if these don't exist, but if they do, failures matter". Fix this logic, use die() more aggressively, and remove spurious "\n"s from die() format strings. Also fix spurious whitespace in the libziparchive format string. Before: Zip: unable to allocate 272781472 bytes at offset 0 : No space left on device After: Zip: unable to allocate 272781472 bytes at offset 0: No space left on device Bug: http://b/68383022 Test: `fastboot update` on marlin Change-Id: I3cbf55f1a33ca125f293f873eafbcfb86c880ba8
2017-08-23fastboot: bail out if failed to generate fs imageJin Qian
we don't want to continue fastboot process if failed to generate fs image. Print an error message and exit early. Bug: 64915319 Change-Id: I5506d2a7a5063c188685633d6c3890239f9d658e
2017-08-07fastboot: Add --disable-verity and --disable-verification options.David Zeuthen
This can be used to disable verity and/or verification when flashing a build to a device. It works with both 'fastboot flashall' and 'fastboot flash vbmeta /path/to/vbmeta.img'. Bug: 62903976 Test: Manually tested. Change-Id: Iad22d42a9dd5befd70ecd0224803721a10a28d90
2017-05-31fastboot: use filename instead of fd to generate filesystem imageJin Qian
mke2fs tool takes a filename and has its own open function to handle output file. Change fastboot in preparation to switch from make_ext4 to mke2fs. Test: fastboot format:ext4 userdata Bug: 35219933 Change-Id: I7a31cb215f443a4a7cb0bfc23ec28c121a6101e6
2017-05-15Fix "fastboot flashing".Elliott Hughes
...without breaking "fastboot oem". Turns out the bootloader actually needs to know whether it's getting a "flashing" or "oem" command. Bug: http://b/38321935 Test: "fastboot flashing unlock" "fastboot oem uart enable" Change-Id: I2b3c0b42b01e3c884aa794fa273034a366985089
2017-05-15fastboot: Add DTS partition support for 'flashall' commandDmitry Shmidt
Hikey960 has DTS partiton for DT image Test: Manual Bug: 38310807 Change-Id: I9f8e9b27ed40ebdd225f3c4e4b30f53e7cdb5ee7 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-05-11Fix "fastboot oem".Elliott Hughes
Broken by d6365a70527275f700b9594452020715a0c52510. Bug: https://issuetracker.google.com/38216236 Test: "fastboot oem uart enable" Change-Id: I672d5b96bb16fd77e7af61115b8a38606c691ea8
2017-05-10Merge "Show the "platform tools" version in adb/fastboot --version."Treehugger Robot
2017-05-09Show the "platform tools" version in adb/fastboot --version.Elliott Hughes
Annoyingly folks parse the "adb --version" output so we have the less-interesting protocol version first. But at least now we'll have the "real" version somewhere... Bug: N/A Test: "adb --version"/"fastboot --version" Change-Id: Ia85b561bd8d84c6fd6995923730d36f53b2f800b
2017-05-09Make fastboot command-line parsing a bit more like adb.Elliott Hughes
Only show all the help if asked to, and have a few more descriptive syntax errors. Also show the help on stdout rather than stderr. Bug: N/A Test: manually ran "fastboot flash"/"fastboot update"/"fastboot flashall" Change-Id: I59abd60e58a56fe7e44da5116a702087c36e14ce
2017-05-05Merge "Clean up the partition name mapping in fastboot."Elliott Hughes
2017-05-03Clean up the partition name mapping in fastboot.Elliott Hughes
Also remove -p. Bug: N/A Test: builds Change-Id: Iea55affc7262323c0d341003359d3175580efbfd
2017-05-03Remove bogus _LARGEFILE_SOURCE.Elliott Hughes
Bug: N/A Test: builds Change-Id: I145a521a58dc8f838ce188540b02bcda4e81b610
2017-05-03Add dtbo image support for device tree overlayYueyao Zhu
Test: Used the built fastboot tool to run flashall on a device Bug: 32969430 Bug: 36813951 Change-Id: If2db3055bb7250a57d9a78b0534df491b68b6224
2017-04-28Merge changes I5b1a1ce0,I483a18f9Treehugger Robot
* changes: fastboot: Add 'get_staged' command fastboot: Add 'stage' command
2017-04-27fastboot: Add 'get_staged' commandJocelyn Bohr
(cherry-picked from internal nyc-iot-dev to AOSP) New user-level command usage: * fastboot get_staged <outfile> Reads staged data from the last command handled by the device. If the last command did not result in staged data, this command will fail. This enables data staged by OEM commands to be transferred from device to host. get_staged wraps new device command "upload". Fastboot clients are not required to support "upload", so get_staged won't work on all devices. Bug: 36002804 Test: Implemented "upload" in fastboot on imx6ul. Verified that uploading ~100K data from the device works. Change-Id: I5b1a1ce023f362062505ee62746ea8ab6f36bfbf (cherry-picked from commit 83a875de994bf48f0faa2a8a23ceb0b8f52b6b04)
2017-04-26Make "fastboot update" respect $TMPDIR.Elliott Hughes
Bug: http://b/32701538 Test: TMPDIR=/ fastboot update Change-Id: I06d1bc8d43b306855dfe19bc736513d3336df287
2017-04-26fastboot: Add 'stage' commandJocelyn Bohr
(cherry-picked from internal nyc-iot-dev to AOSP) New user-level command usage: * fastboot stage <infile> Sends the contents of <infile> to the device to stage for use in the next command. This enables OEM commands to use data downloaded from host to device. Bug: 35811075 Test: Manual test on imx6ul Change-Id: I483a18f9f4205d3289ee524656b9d741b16e9fe6 (cherry-picked from commit 001c75c6c0fe6a70a1db2a65253ab3c43ec17d46)
2017-04-17fastboot: Support larger transfers during flashChris Fries
Adding methods to queue and download flashable images by fd instead of by pointer, so that we can deal with sending large (up to 4GB) files on windows and linux. This gets past limitations on linux to read more than 2GB from a file at a time, as well as memory limitations on win32, in order to download up to 4GB in a single transfer. Test: fastboot -w Test: "flash-all" from nexus factory images site (incl. fastboot -w update) Test: fastboot flash with large and small image, large and small max-download-size Test: Sanity check flashing on win32, darwin, linux. Test: Sanity check 3GB image download (with 3GB max-download-size) on win32, darwin, linux. Bug: 36810152 Change-Id: I528d739d344eb080d59d721dadf3b3b34d4b375e
2017-04-14fastboot: Cap max size sent to libsparseChris Fries
This is required for large (>INT_MAX) sparse limit reported by the target. Also, patch up return chains of "int" that need to deal with sizes bigger than 2GB as well as return negative error codes. Test: -S works with large max-download-size Test: Flash 3GB system.img with max-download-size 2.5GB Bug: 36810152 Change-Id: I562a50eabd706bd5b97c71a1aef07c1ffd1a2e5c
2017-04-04Merge "Show install path in "adb --version" and "fastboot --version"."Elliott Hughes
2017-03-31Add vbmeta image support for verified bootVineeta Srivastava
2017-03-30Show install path in "adb --version" and "fastboot --version".Elliott Hughes
Bug: http://b/36766455 Bug: http://b/34691048 Test: ran tests Change-Id: I4b67ec54d41a281fe7a33c017d3cfbc8055e3b43
2017-03-15Move "fastboot oem" to std::string.Elliott Hughes
Not sure how this code got missed when we moved everything else off C string handling... $ adb reboot bootloader $ fastboot oem `perl -e 'print "x"x1024;'` Before: <crashes> After: error: Command length (1028) exceeds maximum size (64) (The error says 1028 instead of 1024 because it includes the "oem ".) Bug: http://b/36232671 Test: fastboot oem `perl -e 'print "x"x1024;'` Change-Id: Ib4664e49222bd2b71be5aa3fe81f386d6073414f
2017-02-08Fastboot: use flash erase & logical block size for building userdataConnor O'Brien
If the bootloader provides erase-block-size and logical-block-size getvar variables, then pass these to libext4_utils when building a new userdata image. This info is used to tune stride and stripe-width. Bug: 33243520 Test: Modify fb_getvar to return values for "erase-block-size" and "logical-block-size" and check that fastboot -w sets userdata parameters correctly. Signed-off-by: Connor O'Brien <connoro@google.com> Change-Id: Id48b7a3ebb9074983a4422a79a64dcb437c0f888