summaryrefslogtreecommitdiffstats
path: root/fastboot/protocol.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor libfastbootAaron Wisner2018-07-191-370/+0
| | | | | | | | | | | | | | | 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
* fastboot: Refactor string constants to constants.hJerry Zhang2018-07-161-18/+23
| | | | | | | | | This allows them to be shared between host and device implementations. Test: fastboot works Bug: 78793464 Change-Id: I79271687850ade2a904fd03d6a97dad1a9ab8e1c
* fastboot: Track the libsparse API change.Tao Bao2018-04-251-15/+11
| | | | | | | Bug: 78432315 Test: Successfully flash a previously failing (huge) sparse image. Test: `fastboot update` existing marlin-img.zip. Change-Id: I09c9a06109769882d26be56d4a0d2a2b7b62cb5f
* fastboot: sparse_file_len() returns int64_t.Tao Bao2018-04-241-3/+3
| | | | | | | | | | | | 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
* Add quotes to -v INFO/OKAY/FAIL for clarity.Elliott Hughes2018-04-101-3/+3
| | | | | | | | This makes it easier to see which part came from the device. Bug: N/A Test: fastboot -v flashall Change-Id: Ie6f4b02933cab21f343998b5fc84f8e487dd3984
* Add fastboot_test.cpp and test --os-version/--os-patch-level parsing.Elliott Hughes2018-04-101-3/+3
| | | | | | | | | 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
* Improve fastboot verbose output.Elliott Hughes2018-04-021-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add "require partition-exists=" support.Elliott Hughes2018-03-281-12/+12
| | | | | | | | | | | | | | | | | 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
* fastboot: Add 'get_staged' commandJocelyn Bohr2017-04-271-9/+52
| | | | | | | | | | | | | | | | | | | | | (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)
* fastboot: Support larger transfers during flashChris Fries2017-04-171-6/+43
| | | | | | | | | | | | | | | | | | 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
* fastboot: Cap max size sent to libsparseChris Fries2017-04-141-10/+11
| | | | | | | | | | | | | | 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
* Use more std::string in fastboot.Elliott Hughes2016-04-291-16/+16
| | | | Change-Id: Ic8c77eac1e0088627ab650050d9c97c5749e5c39
* GCC compiler warning fix for sprintf into snprintfRaja M2016-04-241-11/+11
| | | | | | To fix GCC WARNINGS while building. or To support error free -D_FORTIFY_SOURCE=2 strict mode compilation.
* fastboot: create Transport object (take 2).David Pursell2015-11-161-58/+59
| | | | | | | | | | | | | | | | | (Second upload of this CL; original upload had the wrong version of usb_windows.cpp that caused a compilation error. Fixed error and re-tested.) This CL creates a Transport object to provide a generic interface for various transports. Specifically this is designed to be able to add UDP support to fastboot in an upcoming CL without changing the main program logic. Also includes some minor code style fixes and replaces malloc/free in the USB implementation files with smart pointers and std::string. Bug: http://b/22029765 Change-Id: I1175bbce08690fbd15f51e68166be9b3e9973ea0
* Revert "fastboot: create Transport object."David Pursell2015-11-141-59/+58
| | | | | | | | This broke some stuff, will look into it Monday. This reverts commit 6f233a7799a681e65c539e9c8287db0814c8948f. Change-Id: I155bc85d21fda3b0ba1e5e17839059797fb15509
* fastboot: create Transport object.David Pursell2015-11-131-58/+59
| | | | | | | | | | | | | This CL creates a Transport object to provide a generic interface for various transports. Specifically this is designed to be able to add UDP support to fastboot in an upcoming CL without changing the main program logic. Also includes some minor code style fixes and replaces malloc/free in the USB implementation files with smart pointers and std::string. Bug: http://b/22029765 Change-Id: I68641af0da7d13db4647f5e20a18d04d67f0b327
* Use 64-bit file sizes in fastboot.Elliott Hughes2015-08-251-84/+46
| | | | | Bug: 20110580 Change-Id: I5d3718103ff581ff3b5241c8b0e52b585b4f37e5
* Move fastboot to C++.Elliott Hughes2015-06-231-0/+314
Minimal conversion. Change-Id: I32cbf125be481a8757720d10fa303c38a7fd5e38