Commit graph

1062 commits

Author SHA1 Message Date
Chun-Wei Wang
62051237a2 Merge "Add a fastboot command to show GSI status" into main 2023-09-05 22:18:40 +00:00
Chun-Wei Wang
671a2a551a Add a fastboot command to show GSI status
The command will be used by RMA tool to skip
device wiping when it is already in GSI mode.

This change also makes it easier to add more
gsi commands in the future without needing to
update the host side tool (fastboot).

Bug: 298130522
Bug: 298138572
Test: 1. reboot into fastboot mode
      2. fastboot gsi status
Change-Id: Ic81f89a93b854f9ec70aebe2d209bfd1f98e3645
2023-09-05 23:31:01 +08:00
Dmitrii Merkurev
f667b6d8ba Merge "fastboot: get rid of manual transport memory management" into main 2023-09-05 14:04:54 +00:00
Dmitrii Merkurev
0b627d92c4 fastboot: get rid of manual transport memory management
Existing code has transport memory leaks. Use smart pointers
for transport to get rid of those cases and manual memory
management

Test: atest fastboot_test
Test: manually checked transport isn't leaking anymore
Bug: 296629925
Change-Id: Ifdf162d5084f61ae5c1d2b56a897464af58100da
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-09-03 17:30:46 +01:00
Daniel Zheng
1ef66b70ff Fixing optimization logic
Adding a hard pattern check for optimized task formation. To keep
behavior consistent, we will remove the old initialization path and add
resize tasks after attempting optimization.

Test: fastboot_test
Bug: 297085098
Change-Id: Ie0e656af9be7abdd130290fe547ffbf385ce75d6
2023-08-30 09:39:30 -07:00
Daniel Zheng
2326e056bd Add documentation to README
adding documentation on how to use fastboot-info inside of fastboot
README

Test: na
Bug: 297084293
Change-Id: Ic2d17c92a776f1cae9ef80f6b615ddbc841afb74
2023-08-22 14:27:16 -07:00
Keith Mok
eb2165079a Merge "Adding force_flash functionality" into main 2023-08-09 20:45:24 +00:00
Daniel Zheng
720007ba43 Merge "Adding flag to flash only static partitions" into main 2023-08-09 18:09:00 +00:00
Daniel Zheng
376b70423d Adding force_flash functionality
aosp/2452605 might've accidentally omitted force flash functionality
from fastboot. Some users need to flash dynamic partitions from
bootloader, so we are readding this feature back into fastboot

Test: adb reboot bootloader, fastboot flash system --force

Change-Id: I37a51ebbe38b27ed428c38068d30c0febd7db09c
2023-08-09 10:54:14 -07:00
Alexander Koskovich
6367e8953a core: fastboot: Fix data not being wiped on do_update
* With platform-tools-34.0.4 if you try to wipe data
   as apart of the fastboot update command it will not
   work, will just reboot to userspace without running
   the wipe task.

Test: fastboot -w update image.zip, observe that data
      gets wiped. Also verified 'fastboot update image.zip'
      does *not* wipe data.
Change-Id: I57a2c64029fd4f78968324bdf60251e1e962b3fd
2023-08-05 00:39:10 -04:00
Daniel Zheng
b0f9c07590 Merge "Adding include to functional" into main 2023-07-28 20:00:44 +00:00
Daniel Zheng
750fe6a37b Adding include to functional
adding include to functional since we use it in this file. Some users
are reporting build issues due to missing this include

Test: m fastboot
Change-Id: I9ba11bdaf7dcedf5f9ebfb6fa50013be50738f48
2023-07-28 11:00:16 -07:00
Daniel Zheng
cbda2c038b Adding flag to flash only static partitions
adding in --exclude-dynamic-partitions to flash only bootloader
partitions and skip the rest. Super optimization will be turned off as
well when this flag is enabled

Test: fastboot flashall --exclude-dynamic-partitions

Change-Id: I4b9d70b7f6179bf079991bf3a20aade64cfe9935
2023-07-24 13:54:49 -07:00
Daniel Zheng
f161ee2771 Merge "Adding documentation" into main 2023-07-19 00:20:59 +00:00
Daniel Zheng
658182b8e7 Adding documentation
adding --help documentation to fastboot for --disable-super-optimization
and --disable-fastboot-info

Test: fastboot -h
Change-Id: Ia8993b3894d302a63cc97796d66e0af3fb004eef
2023-07-18 15:36:26 -07:00
Treehugger Robot
1c77579a06 Merge "Look for radio.img and bootloader.img in ANDROID_PRODUCT_OUT" into main 2023-07-17 21:51:01 +00:00
Paul Lawrence
556c46bfb9 Look for radio.img and bootloader.img in ANDROID_PRODUCT_OUT
Test: fastboot flash bootloader and fastboot flash radio both work
Change-Id: I79674469c0df3dd592e5fcf840fef0dcc3f11d33
2023-07-17 14:05:21 -07:00
Daniel Zheng
6acfe9bcd0 Turning on fastboot-info
turning on fastboot-info by default again

Test: fastboot flashall
Change-Id: I6b8bb0d145af37d437419a5e6cee70158ed553ae
2023-07-11 12:53:30 -07:00
Daniel Zheng
63dfeaae7a Adding flag to disable fastboot_info
Adding flag to override fastboot_info for a quick fix in case
fastboot_info format is wrong

Test: fastboot flashall
Change-Id: I1f41646f14d747ce7ac7636ca9ced7279e13f7b0
2023-07-11 12:53:30 -07:00
Daniel Zheng
eabfe272c3 Fastboot-info testing
adding test to compare task list formed from fastboot-info vs list
formed from image list. To test, we need to set sparse_limit in flashing
plan and turn off update-super-optimization. The list of partitions to
be flashed by parsing fastboot-info should be a superset of the
partitions flashed by the hardcoded list. Changing is_retrofit_device()
to also take in a fastboot driver so we can pass in a mock

Test: fastboot_test
Bug: 194686221
Change-Id: Ib860c24c85779de1fbaa6bec8778e1f5ebb9475a
2023-07-11 12:53:29 -07:00
Daniel Zheng
59589d47db Asserting flashing plan is used in do_flash
Adding check to ensure flashing plan is used in do_flash. FlashingPlan
should never be null

Test: fastboot flashall -w
Change-Id: I8e69326c59b31c7b54d6d2e04c8ce5c0f12693a7
2023-07-11 12:44:13 -07:00
Daniel Zheng
a0d2401d23 Mocking get_uint_var()
Changing implementation to have mock fastboot driver return a the
sparse_limit rather than modifying the variable inside of flashing plan

Test: fastboot_test
Change-Id: I850ccd5bd09b6a8479ccc8cf7bf1d227abb87e3a
2023-07-11 12:44:13 -07:00
Daniel Zheng
c97eeed5e4 Adding parsing for fastboot-info
Adding back the parsing for fastboot info

Test: m fastboot, fastboot flashall
Change-Id: I0075266bad5d45dcb99dbf91aa431008ca336216
2023-07-05 13:17:39 -07:00
Daniel Zheng
3e04857a59 Changing name of flash super layout
OptimizedFlashSuper makes more sense and is more consistent with
should-optimize-super

Test: m fastboot
Change-Id: I6ceb31144dce591e0a53faec68b932112d9cd360
2023-06-27 10:19:58 -07:00
Daniel Zheng
ba07ef5732 Change HardcodedFlash to add flashtasks
Changing Hardcoded FLash to add flash tasks, also modifying do_flash to
download signature data if a source is provided

Test: fastboot flashall
Change-Id: Ic33bc4076f269d0d48146a3de457a72eedd5e6df
2023-06-22 09:52:08 -07:00
Daniel Zheng
5769b268bf use FlashingPlan sparse_limit for testing
Have get_sparse_limit() return FlashingPlan's sparse limit if set. Used
for testing to compare task lists

Test: fastboot_test
Change-Id: I7ac1eb4dc83a53b3d7aa59aa668a780b4b550664
2023-06-22 09:52:06 -07:00
Daniel Zheng
d62002cf06 Add flag to disable super optimization
Adding flag to turn off the super optimization. Makes for easier testing
as dynamic partitions flash tasks won't be replaced by one flash super
layout task

Test: fastboot flashall --disable-super-optimization
Bug: 194686221
Change-Id: I9142490ecfe587725872e4b734486d3db1728aa7
2023-06-22 09:49:09 -07:00
Daniel Zheng
59c22c33a0 Removing local image lookup from load_buf
The initial logic for adding this in was incorrect. This changed had
allowed us to do fastboot flash dts dt.img on command line. But really
we should enforce that we pass in the path to the image. This change was
added so the command line tool with resemble fastboot-info format which
will support flash dts dt.img (situation where image name and partition
name don't match).

Test: fastboot flash {partition}, fastboot flashall
Bug: 194686221
Change-Id: I62f170e14860d865453ab52793e346fe4066c6d4
2023-06-22 09:49:09 -07:00
Daniel Zheng
7f8fff0360 Moving source class declaration
Moving zipImageSource and localImageSource to header file to be used for
testing purposes

Test: m fastboot
Bug: 194686221
Change-Id: I689e73eb0102d3b2cdd0c4fc232b2b60b9022c47
2023-06-21 14:23:56 -07:00
Roy Luo
d1d5f5ab69 fastboot: remove retries on invalid IO iterator in OSX
When IOServiceGetMatchingServices returns an invalid
iterator, IOIteratorReset doesn't help. Break the loop
to prevent being stuck in the reset loop forever.
This should be fine as the open_device() call in the
upper layer is already doing retries.

Bug: 286495045
Test: fastboot update
Change-Id: Ia58fa9285640be34aa22cd77e4f58cc9092679a4
2023-06-20 21:44:53 +00:00
Treehugger Robot
18c531984c Merge "Removing duplicate CollectImages()" 2023-06-13 23:18:50 +00:00
Daniel Zheng
3dc7fcc0b6 Removing duplicate CollectImages()
images are being flashed twice, because of an additional collectImages.
This is resulting in a ~50% increase in flashing time

Test: fastboot flashall -w
Change-Id: I6c271e1e1456cd789f37ebd67cefd221cabc6e7a
2023-06-13 14:57:25 -07:00
David Anderson
1347d3407e Merge "fastboot: Include header for ostream_iterator and istream_iterator" 2023-06-12 22:26:44 +00:00
Treehugger Robot
929a665f02 Merge "fastboot: Introduce FASTBOOT_DEVICE alias for ANDROID_SERIAL environment variable" 2023-06-12 22:01:54 +00:00
Biswapriyo Nath
816480b56e fastboot: Include header for ostream_iterator and istream_iterator
This fixes the following compiler errors with gcc

storage.cpp:45:20: error: 'ostream_iterator' is not a member of 'std'
storage.cpp:50:10: error: 'istream_iterator' is not a member of 'std'

Change-Id: I570e332d100bb18e445644a9d57dc14d80f104b5
2023-06-13 00:28:24 +05:30
Biswapriyo Nath
214f37c249 fastboot: Add header that declares std::function
This fixes the following compiler error with gcc
fastboot_driver.h:51:10: error: ‘function’ in namespace ‘std’ does not name a template type

Change-Id: I3a4d9b48bfdc2c76e443e2efe1761ec9503c6dc5
2023-06-10 20:08:29 +05:30
John Stultz
9d2fb9ca3c fastboot: Introduce FASTBOOT_DEVICE alias for ANDROID_SERIAL environment variable
The ANDROID_SERIAL env is useful for managing multiple
directly connected devices at one time.

Unfortunately for network connected devices, its harder to use.

This is because both adb and fastboot use the same ANDROID_SERIAL
environment value to identify the device to use, and while that
one value works for directly connected devices, when using
network connected devices, the fastboot and adb port numbers may
differ for the same device.

So if I set: `ANDROID_SERIAL="tcp:127.0.0.1:44403"`
fastboot will work, but when I type `adb shell`, I'll get:
 adb: device 'tcp:127.0.0.1:44403' not found

As `adb devices` outputs:
List of devices attached
localhost:36697 device

To resolve this, we need separate environment variables,
so introduce a FASTBOOT_DEVICE variable for fastboot.

If FASTBOOT_DEVICE is set, it will use that, and if not
it will fall back to the ANDROID_SERIAL if it is set.

Using an explicit -s argument will still override both.

Change-Id: Icd7db6f29e51ed2decd219e35537f6ed98d698b8
Signed-off-by: John Stultz <jstultz@google.com>
2023-06-09 22:54:09 +00:00
Daniel Zheng
95303da18e Merge "Adding GetInfo method for tasks" 2023-06-06 17:16:35 +00:00
Daniel Zheng
665a460e8a Adding GetInfo method for tasks
Using for easier debugging. Replacing old getter methods in flash task
with GetInfo(key)

Test: fastboot_test
Change-Id: If42df86c4b0278c3dc5525b1058f1947f0b34794
2023-06-05 14:40:50 -07:00
Daniel Zheng
819a3529b5 Merge "Adding in wipe tasks before other tasks run." 2023-06-05 19:15:30 +00:00
Daniel Zheng
303fb49cc0 Adding in wipe tasks before other tasks run.
if we call -w and a reboot task runs beforehand, we don't actually wipe
the given partitions. We want the wipe to occur before reboots.

Test: fastboot flashall -w
Change-Id: If327c5de0858e222cf5fc14531bc20fb741c2960
2023-06-05 10:30:44 -07:00
Dmitrii Merkurev
6c008ff888 Avoid creating a storage folder for fastboot devices command
Bug: 284267164
Bug: 284786311
Test: fastboot devices doesn't create a .fastboot folder
Change-Id: I3e44c2a838e4287e6220c18f6e805cc71e0c9669
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-06-02 12:44:31 +01:00
Daniel Zheng
2a56592d58 Reverting code to old flashing code
Falling back on old flashing code until fastboot-info is fixed

Test: m fastboot, fastboot flashall
Change-Id: I10146ec75f75d57d4a4049d35def370533619401
2023-05-31 11:20:08 -07:00
Daniel Zheng
3c962eee3a Merge changes Ib72f6a1c,I46d798fa
* changes:
  Update add resizetasks to work in update
  Keeping naming consistent
2023-05-30 20:26:06 +00:00
Daniel Zheng
997ce15d5e Update add resizetasks to work in update
Old should_flash_in_userspace doesn't work if $ANDROID_PRODUCT_OUT is
not set. Also adding in a check to see if resizetasks were added
correctly

Test: fastboot update update.zip without $ANDROID_PRODUCT_OUT and
removing the flashsuperlayout code.
Bug: 283330320

Change-Id: Ib72f6a1cf07745daf70fffae3d1a6b8352e3f79c
2023-05-30 09:24:46 -07:00
Daniel Zheng
437fb0c606 Merge "Removing should_flash_in_userspace check" 2023-05-30 15:34:50 +00:00
Daniel Zheng
30e648b346 Keeping naming consistent
Test: m fastboot
Change-Id: I46d798fa2ce78a255dc0ea414f5e25782f45c4d1
2023-05-25 15:56:29 -07:00
Daniel Zheng
2775df617e Removing should_flash_in_userspace check
This check isn't needed as super_flash_helper.cpp calls a different
should_flash_in_userspace that isn't reliant on $ANDROID_PRODUCT_OUT
being set. Current code will fail when calling fastboot update

Test: fastboot update update.zip without calling lunch
Bug: 283330320
Change-Id: Icefe6092befb747b7f419ea997e0834602808d69
2023-05-25 15:14:59 -07:00
Treehugger Robot
059954a6b2 Merge "Chang flash task to take in source" 2023-05-25 21:46:01 +00:00
Daniel Zheng
791a83bb45 Chang flash task to take in source
Old changes didn't actually take into account sources. fastboot update
{update.zip} should read fastboot-info from the update package. It was
instead flashing local images + reading local fastboot-info.txt

Test: m fastboot, fastboot update, fastboot flashall
Bug: 283330320

Change-Id: I9587a7735ddfbfb661153eb12ebc3caa7c32f141
2023-05-25 13:29:16 -07:00