Commit graph

853 commits

Author SHA1 Message Date
David Anderson
b72fa73ace Merge "fastboot: Support casefolding in ext4 partitions." 2021-08-27 01:18:06 +00:00
Colin Cross
fb66f3d13f Merge "Include sys/select.h for fd_set" 2021-08-17 18:56:16 +00:00
Yi-Yo Chiang
b33cfbfc4b Merge "fastboot/README.md: Update response packet max size to 256" 2021-08-17 14:15:36 +00:00
Colin Cross
cbca269d75 Include sys/select.h for fd_set
socket.cpp fails to compile on musl with a missing definition of
fd_set.  Include sys/select.h for the definition.

Bug: 190084016
Test: m USE_HOST_MUSL=true fastboot
Change-Id: I095a56381a85981f42444f4c39ae8e7786d8640f
2021-08-16 17:20:19 -07:00
Yi-Yo Chiang
a7656fa3b6 fastboot/README.md: Update response packet max size to 256
This change is to update the doc to reflect the current state and it
doesn't affect the runtime behavior.
The max packet size was updated to 256 by aosp/1226715.

Bug: 196676392
Test: Presubmit; doc update doesn't affect build
Change-Id: I73b0a416730d09fdb24ea81bffe52ddd89534132
2021-08-14 22:12:34 +08:00
Christopher Ferris
4a9a79e3ff Merge "Remove jmgao from OWNERS files." 2021-08-11 17:28:27 +00:00
Christopher Ferris
0ef9b4d365 Remove jmgao from OWNERS files.
Josh no longer works on Android, so remove him from OWNERS files.

Test: NA
Change-Id: I676cd803b5e3167db1b5175a630d85d1edfcaaaf
2021-08-10 21:42:14 -07:00
Treehugger Robot
d82efe0bf0 Merge "fastboot: fix --disable-verifiation error message" 2021-08-11 04:09:46 +00:00
Bowgo Tsai
671249a3d2 fastboot: fix --disable-verifiation error message
There is an unclear error message if we run
`fastboot --disable-verification flash boot boot.img` on a
AVB-disabled device without a /vbmeta partition.

Error message:
  terminating with uncaught exception of type std::out_of_range: basic_string
  Aborted

This is because the buf->fd of the loaded boot.img is not reset,
before returning from function copy_boot_avb_footer().

Also reset some changes in copy_boot_avb_footer() from commit
If83f785e235569ee8ef0de2b37f11dbd2a9a71f4, to prevent the
unnecessary read of the boot vbmeta if no need to copy the
boot image avb footer.

Bug: 191903922
Test: `fastboot --disable-verification flash boot boot.img` on a device
      without /vbmeta and without setting BOARD_AVB_ENABLE to true.
Change-Id: If84f08f1b2e12c4c6ded5cafda2bd1d30e75c662
2021-08-10 17:05:17 +08:00
David Anderson
1f670ef7a8 fastbootd: Delete all VAB partitions during "flashall".
With VAB we encourage a smaller super partition, so make sure we delete
"other" slot partitions during flashing. Otherwise, we may not have
enough space in super.

Bug: 195930130
Test: set_active, flashall, ensure other slot is deleted
Change-Id: Ic6a4f60e8f4c7abb8af7b38228753ad8ed85eedf
2021-08-09 12:36:13 -07:00
David Anderson
6f70cc6f92 fastboot: Support casefolding in ext4 partitions.
Bug: 191929411
Test: manual test
Change-Id: I9bd0a906fa9a2605d56cc3f37247fcc2a3d5f858
2021-07-13 17:32:03 -07:00
Treehugger Robot
db14785382 Merge "Remove --wipe-and-use-fbe option from fastboot" 2021-06-16 17:55:36 +00:00
Paul Crowley
47770a1040 Remove --wipe-and-use-fbe option from fastboot
As per the bug, this option has been obsolete for years
and only causes confusion.

Bug: 167694738
Test: fastboot can still wipe
Change-Id: I24a21cb6110d61dec4af800a1fab0bcedc0a3d5c
2021-06-15 16:07:57 -07:00
Pierre-Clément Tosi
96941a0962 fastboot: document second parameter of 'fetch'
Add the OUT_FILE parameter to the documentation of fetch which fails if
used as currently (erroneously) documented:

    $ fastboot fetch boot
    fastboot: usage: expected argument

Test: fastboot help
Change-Id: Ia06d40c2f754e1a55a2052cb84e81f96e71b4573
2021-06-14 12:46:32 +00:00
Bowgo Tsai
a48a78356f fastboot: support vbmeta_vendor.img
Bug: 181909612
Test: build
Change-Id: If61fff1c83513d71605c0cef2737a38f7575d69b
2021-06-04 00:59:43 +00:00
Elliott Hughes
02a83245ef Use libgtest_prod_headers.
Bug: http://b/185916167
Test: treehugger
Change-Id: I9ece5926944b8c881e3a117cda2c99281c59b61e
2021-04-20 15:22:02 -07:00
David Anderson
7723c72cab Merge "Unable to mount filesystem in fastbootd mode on the user build." 2021-04-13 23:45:01 +00:00
David Anderson
9a95ed928f Merge "fastboot: Add a few missing fastboot commands from help" 2021-04-12 21:17:42 +00:00
David Anderson
055f802086 Merge "libsnapshot: Add diagnostics for DM_DEV_REMOVE failures." 2021-04-12 21:04:08 +00:00
Luca Stefani
173667b7e7 fastboot: Add a few missing fastboot commands from help
Test: m, fastboot help
Change-Id: I8c40ad25123470ea214b9d93d7305945973a2b0b
2021-04-12 19:16:52 +02:00
David Anderson
0b903f9910 libsnapshot: Add diagnostics for DM_DEV_REMOVE failures.
Example log line:

    update_engine: Block device was lazily unmounted and is still in-use:
        /dev/block/dm-28; possibly open file descriptor or attached loop device.

This will help diagnose bugs such as b/184715543 in the future.

Bug: N/A
Test: manual test
Change-Id: Ia6b17fe9bd1796d59be7fc0b355218509acfd4af
2021-04-08 11:06:12 -07:00
Andrew Chant
d64b988959 fastboot: use --force to bypass requirements
Allow using --force to bypass flashing requirements
from android-info.txt.

We often provide builds to deviceholders who don't have
an exact matching bootloader or radio image and it is
unimportant.  Having the option to override is useful.

This shouldn't affect bootloader.img so should never
prevent a device from returning to fastboot in case of
gross error.

Test: Downloaded a build w/ different radio.

Got the following output:

...
Checking 'version-baseband'                        FAILED

Device version-baseband is 'xyz'.
Update requires 'abc' or '123'.

requirements not met! but proceeding due to --force
Setting current slot to 'a'                        OKAY [  0.065s]

Bug: 184661990
Change-Id: I8680b8275b854304026cff3b2e663b7ef2594383
2021-04-06 15:28:41 -07:00
joker.yang
09090946a8 Unable to mount filesystem in fastbootd mode on the user build.
for GSI XTS self-test, we need to mount filesystem(/metadata) in fastbootd mode. so we add a qualification since there is no overlayfs on user build anyway.

bug: 181097763
Change-Id: Ie36bd2f5b3981e6774dc4a2123c33180cddb99d1
2021-03-30 01:21:52 +00:00
David Anderson
527cdd4617 Merge "fastboot: Don't fail when unable to get boot partition size" 2021-03-29 18:56:28 +00:00
Oleg Matcovschi
d0a16c20fc fastboot: derive device locked state from Android property
We shall rely on Android property instead of parsing kernel
command line directly: parameters could be originated from
kernel command line or bootconfig.

Bug: 183237066
Bug: 183719613
Signed-off-by: Oleg Matcovschi <omatcovschi@google.com>
Change-Id: Ia70d286646a83a95967ca4293168a6550ffff7f0
2021-03-25 14:45:54 -07:00
Yi-Yo Chiang
ac4a136e59 fastboot: Refactor bootimg_utils.cpp:mkbootimg()
Change mkbootimg() to return void, as we already have a |out| parameter.

Bug: 183455415
Test: Presubmit
Change-Id: I51439e273752ab9e21f8d7138e900ea55bdfdfc0
2021-03-25 04:23:08 +00:00
Yi-Yo Chiang
c0c9e3059c fastboot: [boot] and [flash:raw] command support boot v4
Boot v4 is mostly compatible with boot v3, so these minimal changes
should be sufficient.
The newly introduced field of v4, signature_size, is left zero because
this field is only meant to be read by VTS testcases, so the value
doesn't matter for the debugging purposes of boot and flash:raw.

Bug: 183455415
Test: Manual
Change-Id: I5c2737ce35dd25f318b19a429de805ea16c46607
2021-03-25 04:22:58 +00:00
Treehugger Robot
47229793e5 Merge "fastboot driver: ftrucate64->ftruncate." 2021-03-24 08:34:51 +00:00
Michael Bestas
a495be742c fastboot: Don't fail when unable to get boot partition size
* Some devices don't report boot partition size

Change-Id: If83f785e235569ee8ef0de2b37f11dbd2a9a71f4
2021-03-24 01:18:45 +00:00
Treehugger Robot
4f898d4e33 Merge "fastboot driver: add virtual dtor to ImageSource." 2021-03-24 00:10:31 +00:00
Yifan Hong
c8715002ab fastboot driver: ftrucate64->ftruncate.
Also, -D_FILE_OFFSET_BITS=64 so that off_t is always
64 bits.

This fixes mac build.

Test: forrest

Change-Id: I584e136a5f3ca9874fd5364cc4c93f8b1e8feb19
2021-03-23 11:14:22 -07:00
Treehugger Robot
2af0504896 Merge "fastboot device: Disallow implicit conversion from unique_fd to int." 2021-03-23 06:48:02 +00:00
Treehugger Robot
981f79be3c Merge "fastboot driver: Disallow implicit conversion from unique_fd to int." 2021-03-23 06:47:52 +00:00
Treehugger Robot
15acff029f Merge "fastboot driver: Fix fd ownership." 2021-03-23 05:33:20 +00:00
Yifan Hong
07e947fc5d fastboot device: Disallow implicit conversion from unique_fd to int.
Do not use the implicit cast from unique_fd to int so
that it is clearer to the reader what the ownership model
is.

Test: pass
Change-Id: I66563eb2bd06f6a712a5afd4c6009f9b25a55de6
2021-03-22 19:30:59 -07:00
Yifan Hong
58532dfacd fastboot driver: Disallow implicit conversion from unique_fd to int.
Do not use the implicit cast from unique_fd to int so
that it is clearer to the reader what the ownership model
is.

Test: pass
Change-Id: Iaf40a6eed3fcfd001651980c865ed5efb85ac0eb
2021-03-22 19:30:59 -07:00
Yifan Hong
e9f067b4eb fastboot driver: Fix fd ownership.
load_sparse_files assumes that the client maintains
the lifetime of the input fd is longer than
the output sparse_file handle.

Bug: 183409401
Bug: 183223098
Test: flash super image
Change-Id: I295b912c665577b5767a133f3148e58a22733998
2021-03-22 19:30:59 -07:00
Bob Badour
559488ce17 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  fastboot/testdata/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I32847c8706facb4fe46ea8d4d6089a629cee2321
2021-03-22 19:02:03 -07:00
Yifan Hong
d2e8cb5556 fastboot driver: add virtual dtor to ImageSource.
Test: Treehugger
Change-Id: Ia91d6d344186a07d90e3983c153d8170859eed5b
2021-03-19 11:46:48 -07:00
Greg Kaiser
f4c6ce4a10 fastboot driver: Avoid use after std::move()
Test: TreeHugger
Change-Id: I2857f6d6384c8c80809f21202dbbbfc9ed71beeb
2021-03-19 09:10:18 -07:00
Yifan Hong
f09c1efd0a fuzzy_fastboot: Add tests for fetch:vendor_boot
Test: run test against bootloader
Test: run test against fastbootd
Bug: 173654501
Change-Id: Ia3182b4f4390048139d2cafe9b1654b6fb92eb7b
2021-03-17 15:38:06 -07:00
Yifan Hong
2a7a14bfc4 fuzzy_fastboot: Add conformance test for getvar:max-fetch-size.
Test: run against bootloader
Test: run against fastbootd
Bug: 173654501
Change-Id: Ide38eee6b801110fef52f0f9213c038a72c775f2
2021-03-17 15:38:06 -07:00
Yifan Hong
e71fe2441a fastboot driver: repack vendor boot ramdisk
When a user issues `fastboot flash vendor_boot:foo ramdisk.img`, the fastboot driver
fetches the vendor_boot image from the device,
determines if `foo` is a valid vendor ramdisk fragment,
repacks a new vendor boot image, then
flash the vendor boot image back.
This requires vendor boot header V4.

As a convinent alias, `fastboot flash vendor_boot:default ramdisk.img`
flashes the whole vendor ramdisk image. This works on vendor boot header
V3 & 4.

Fixes: 173654501
Test: pass

Change-Id: I42b2483a736ea8aa9fd9372b960502a642934cdc
2021-03-17 15:38:06 -07:00
Yifan Hong
6d7da63014 fastboot driver: Allow colon in partition name when flashing
If fastboot flash vendor_boot:default, only
call has-slot on the first token, and append slot
to the first token only.

Test: fastboot flash vendor_boot:default
Bug: 173654501
Change-Id: I8ff7b3a0bafb964792ab8a788d64d14bc47ae83d
2021-03-17 15:38:06 -07:00
Yifan Hong
bcd2770207 fastboot driver: add fetch command in driver
The `fastboot fetch` command is a wrapper around
the fetch protocol. It:

- getvar max-fetch-size
- get the size of the partition
- read the data by chunks, chunk size = max-fetch-size.

The name of the partition is passed directly to the device
(with the usual has-slot magic for flashing etc.) If we support
fetching partitions other than vendor_boot in the future, no change
in the driver is needed.

Bug: 173654501
Test: manual

Change-Id: Ie576eea668234df236b096a372e65c5e91c1e48c
2021-03-17 15:38:06 -07:00
Yifan Hong
17d469bd57 fastboot driver: RunAndReadBuffer don't allocate too much mem
Instead of allocating the buffer for the whole
upload (which can be arbitrary number of bytes as
the device determines), read 1 MiB at a time.

Test: pass
Bug: 173654501
Change-Id: Ib601b0341b10b7dccbb429cd21aad86a2d3bfda8
2021-03-17 15:38:06 -07:00
Yifan Hong
bbf374dbd7 fastboot driver: add RunAndReadBuffer helper
Refactor UploadInner and add a new RunAndReadBuffer helper function
that handles the generic procedure of:

1. Sending a command
2. Receiving a DATA response with N bytes
3. Receiving another response

Test: pass
Bug: 173654501

Change-Id: I568bea127315e42d8a111c23602fc582e7bc935b
2021-03-17 15:38:06 -07:00
Yifan Hong
b10d067e0c fastboot driver: Fix ownership of fd in fastboot_buffer.
fastboot_buffer owns the fd. Make ImageSource::Open()
returns a unique_fd and pass ownership all the way
down to the fastboot_buffer to avoid leaking fds.

Test: none
Change-Id: I9e7e176fc1da74c532a86d0fdba0113bdc81a166
2021-03-17 15:38:06 -07:00
Yifan Hong
60de969eff fastboot driver: fix message
Test: pass
Bug: 173654501

Change-Id: I7d5e7ce817a5ec4e3aba6b44bab3149683a46fdd
2021-03-17 15:38:06 -07:00
Yifan Hong
a5cee93b5a fastbootd: add O_CLOEXEC/O_BINARY for OpenPartition
O_CLOEXEC ensures fastbootd does not leak fds to the parent
process (recovery).

O_BINARY has no effect in Linux, but it is explicit that
the file (partition) to read is a binary file.

Test: pass
Bug: 173654501

Change-Id: Idba922965ce666af1b7ee460ec7449fabd511c35
2021-03-17 15:38:06 -07:00