Commit graph

353 commits

Author SHA1 Message Date
Chun-Wei Wang
9c48951d91 Add help text for fastboot gsi status
Bug: 298533290
Test: fastboot -h
Change-Id: Icf91a980059aaa8e74e41af4036778fbbfbf1bd2
2024-01-02 15:29:21 +08:00
David Anderson
adb91b0e59 remount: Detect when flashall has happened in the bootloader.
This adds a new metadata header flag to the super partition. This flag
is set when "adb remount" is used, and is implicitly cleared when
flashing.

If there is a scratch partition present on /data, we require that the
flag be set in order to proceed using overlays. If not set, scratch is
not mapped in first-stage init, and scratch images are removed later
during startup.

Bug: 297923468
Test: adb remount -R, touch file in out/, sync, flashall
Change-Id: I9cc411a1632101b5fc043193b38db8ffb9c20e7f
2023-12-14 16:00:27 -08:00
Dmitrii Merkurev
e20438f83b fastboot: fix network connected device status
Bug: 303236495
Change-Id: Iceac3509531af1af65b455b1a3d5f5ab9029fda6
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-12-09 01:55:20 +00:00
David Anderson
0bc02bfe71 fastboot: Fix flashing failure when a sparse image has an avb footer.
Trying to move the AVB footer on a sparse file will corrupt the sparse
format. Rather than implement this properly, for now, have the
copy_avb_footer() function gracefully fail by skipping the operation.

Bug: 304574023
Test: fastboot flash sparse image with avb footer
Change-Id: Ia6f0711789a04897ec266ad604a3d243c7184082
2023-10-20 11:20:53 -07:00
Daniel Zheng
3e9b88d504 Removing is_retrofit code path
This code path was never invoked. is_logical will return false on
secondary partitions in retrofit devices, so nothing actually is ever
deleted. If we manage to call the delete, the device side code will
fail with "cannot open the super partition"

Test: fastboot flashall on sargo device
Change-Id: I20b430c5c30bf992506190ea4e00b0b69c7b1005
2023-10-05 12:37:57 -07:00
Christopher Ferris
9dabc9ef32 Change source to be a unique_ptr.
The current code keeps a pointer to a local variable which doesn't
work too well. Change this to a unique_ptr and allocate the source
object that will be used instead.

Test: All unit tests pass.
Test: fastboot -w flashall on a mokey which crashed without this change.
Change-Id: Ief5437374181e514928c45dd540b42898901a137
2023-10-02 17:02:51 -07:00
Daniel Zheng
7a8f82acbd should_flash_in_userspace signature change
We should change should_flash_in_userspace to work without
$ANDROID_PRODUCT_OUT being set and fall back on $OUT directory when
source isn't specified

This also fixes the flashing issue of flashing retrofit devices without
$ANDROID_PRODUCT_OUT set. If we
call fastboot update on a retrofit device, copy_avb_footer will resize
buf->sz of secondary partitions to the partition size, causing us to
send the unsparsed payload to the device -> "Invalid Size" issue.

This is because secondary partitions are considered physical partitions
on retrofit devices && should_flash_in_userspace wouldn't work if
$ANDROID_PRODUCT_OUT is set, so our first return clause in
copy_avb_footer doesn't catch this edge case causing us to resize the
buf-> sz incorrectly.

Did some testing, and also observed a case where flashing is able to
succeed despite $ANDROID_PRODUCT_OUT not being set before, so there
might still be some other edge case that we are still missing.

Test: fastboot update on sargo without $ANDROID_PRODUCT_OUT

Change-Id: I0e4781d96709b712f7d71657ec0d16d99b90214d
2023-09-26 16:55:06 -07:00
Daniel Zheng
5cbcdfae4e is_retrofit_device to work in bootloader
Changing is_retrofit_device() to work in bootloader. Previously flashall
flow was to boot into fastbootd and then  make a call to get
"super-image-name", however this does not work in bootloader. Since all
tasks are generated ahead of time, this old check will now fail and we
will fail to add the correct delete tasks in collectTasks(). This change
does make it so that is_retrofit check only works during fastboot
flashall + fastboot update (since this function is only used here,
nothing is currently affected).

To determine if a device is retrofit, it must satisfy two conditions -> Has
dynamic partitions && does not contain a super partition. The check for
if source has super_empty.img is sufficient for determining if a device
has dynamic partitions and if any single partition has
LP_PARTITION_ATTR_SLOT_SUFFIXED it is determined to be retrofit

Test: logs from fastboot update on sargo device confirms this check
returns true. Fastboot update on sargo
Bug: 300287332

Change-Id: Iadf5c56de51993a79307c60e45d6cc4988436f23
2023-09-22 13:22:57 -07:00
Daniel Zheng
8aba6d022c Removing headers + using string
Removing some unused headers and swapping out std::string_literal to
strings

Test: fastboot flashall
Change-Id: I343272f4a678398a0446660a639c525e42e25891
2023-09-19 17:01:23 -07:00
Daniel Zheng
2e6aee5316 Removing double delete from flashall
From aosp/2475604 the functionality of deleting retrofit partitions
wasn't added back correctly. aosp/837186 adds this logic in. We should
only have one delete that exists if the image is secondary and is
dynamic.

Unfortunately don't have a retrofit device to test on, but from an eye
test this logic seems to match the old functionality and should be
working

Test: m fastboot
Change-Id: I5481893ab1638541d21813efe1c4aab5219e1dcd
2023-09-19 16:17:52 -07:00
Daniel Zheng
7d8ac7f122 Merge "Adding testing for optimized flash super" into main 2023-09-07 16:12:30 +00:00
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
1fff690c18 Adding testing for optimized flash super
Adding test cases for correct formation of optimized flash super task.
We are adding an explicit pattern match for this task to be correctly
formed. Changing Optimized flash task to only remove the reboot to
userspace as a user might want to reboot back to bootloader after
flashing. We also need to change a couple functions to take a
IFastbootDriver to mock up the initialization path.

Test: fastboot_test
Bug: 297085098
Change-Id: Ic5c63bd4057ca6d64647134e5ce33fef12077fdb
2023-08-30 12:59:26 -07: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
720007ba43 Merge "Adding flag to flash only static partitions" into main 2023-08-09 18:09:00 +00: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
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
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
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
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
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
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
30e648b346 Keeping naming consistent
Test: m fastboot
Change-Id: I46d798fa2ce78a255dc0ea414f5e25782f45c4d1
2023-05-25 15:56:29 -07: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
Daniel Zheng
d441d52540 Fail on fastboot-info.txt format error
If fastboot-info.txt has wrong format we should not fall back on
hardcoded list silently. Instead we should LOG(FATAL) and fail.
Hardcoded list should only be used when fastboot-info.txt is not found
or is empty 

Test:  fastboot flashall 
Bug: 194686221
Change-Id: I1cada102f3ff12c1f3002d0b61d3785fc25543c1
2023-05-05 10:50:17 -07:00
Daniel Zheng
451e46f1ae Adding fastboot-info version to host tool
Replacing check with PLATFORM_TOOLS_VERSION with FASTBOOT_INFO_VERSION
to indicate waht version of fastboot_info.txt we currently support. This
makes mor sense since PLATFORM_TOOLS_VERSION won't be updated every time
me make a change to the host tool

Test: fastboot flashall
Bug: 194686221
Change-Id: I621b62c92ba129f402857463dae9112a0797ab07
2023-05-01 14:04:13 -07:00
Daniel Zheng
630f29e0db Updating fastboot-info version check
Updating version to just be a single number.  Reason for updating is
to keep format the same as Flashstation's

Test: fastboot_test
Bug: 194686221
Change-Id: I21ab0747e620d3f6d05c5170c3e55707eed0288a
2023-05-01 14:04:12 -07:00
Daniel Zheng
39b1de953f Merge "Moving FlashallTool Definition" 2023-04-19 21:12:37 +00:00
Daniel Zheng
b7d14facd2 Merge "Changing flashall to parse fastboot-info.txt" 2023-04-19 21:12:29 +00:00