summaryrefslogtreecommitdiff
path: root/fastboot/engine.cpp
AgeCommit message (Collapse)Author
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-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-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-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-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-07-16fastboot: Refactor string constants to constants.hJerry Zhang
This allows them to be shared between host and device implementations. Test: fastboot works Bug: 78793464 Change-Id: I79271687850ade2a904fd03d6a97dad1a9ab8e1c
2018-04-09Minimal changes to build fastboot as a library.Elliott Hughes
Bug: http://b/77809061 Test: builds Change-Id: I0c388334d643a0a2abf0c03a29f336dc3af2f83f
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-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-01-09fastboot: fix log print type mismatchChangrong Jin
Test: mma -j8 Change-Id: I8b4373f4a044b802fc9f1dd4f998e880f7843b4a
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-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-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
2016-06-28Remove unnecessary ARRAY_SIZE macros.Elliott Hughes
Use the canonical one instead. Change-Id: Id80f19455f37fd2a29d9ec4191c1a0af80c5c0e7
2016-06-22Fix misc-macro-parentheses warnings in system/core.Chih-Hung Hsieh
Add parentheses around macro arguments used beside operators. Bug: 28705665 Change-Id: I9226f319e283be640eddc31687f75b51a8ef0ac6
2016-04-29Use more std::string in fastboot.Elliott Hughes
Change-Id: Ic8c77eac1e0088627ab650050d9c97c5749e5c39
2016-01-19fastboot: show progress when sending sparse images.Josh Gao
Bug: http://b/25443220 Change-Id: Ica0c88aea2a0661f39ff1415ebba464c037651da
2015-11-16fastboot: create Transport object (take 2).David Pursell
(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
2015-11-14Revert "fastboot: create Transport object."David Pursell
This broke some stuff, will look into it Monday. This reverts commit 6f233a7799a681e65c539e9c8287db0814c8948f. Change-Id: I155bc85d21fda3b0ba1e5e17839059797fb15509
2015-11-13fastboot: create Transport object.David Pursell
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
2015-11-05Fastboot changes to support A/B partitioningDaniel Rosenberg
Introduce support for -slot option for specifying slots, and set_active, for changing the current slot. Change-Id: Ib3b2a75491c0d0413534dd0c1d7bcb52555bba66
2015-11-02Clarify and fix the intent of the partition-type checking code.Elliott Hughes
Change-Id: I202dab4ee91208b632bc2086d1e5c387a4c29edd
2015-10-30fastboot shouldn't erase non-existent cache partitions.Elliott Hughes
Check that the cache partition exists before trying to erase it. Also clean up some of the C string handling and int booleans. Bug: http://b/25375777 Change-Id: I1880e542b729f2026ab3a2943d4bee9d659b1eeb
2015-08-25Fix missing <stdarg.h>.Elliott Hughes
system/core/fastboot/engine.cpp:84:5: error: use of undeclared identifier 'va_start' Change-Id: I8aff9a40d33f403c0d0d91a15638863fe24dca2e
2015-08-25Use 64-bit file sizes in fastboot.Elliott Hughes
Bug: 20110580 Change-Id: I5d3718103ff581ff3b5241c8b0e52b585b4f37e5
2015-06-23Move fastboot to C++.Elliott Hughes
Minimal conversion. Change-Id: I32cbf125be481a8757720d10fa303c38a7fd5e38