This makes the following changes to the images array:
* The "optional_if_no_partition" flag is removed, as it was a temporary
workaround for super.img.
* The "flashall" flag is removed.
* The "needed_for_fastbootd" flag is now an ImageType enum.
Bug: N/A
Test: fastboot builds, flashall works
Change-Id: Id000ea20cf83639cec2c9ae94f28c799b34606f1
Userspace fastboot is required when flashing logical partitions. If for
some reason userspace fastboot is broken, the user may be stuck with
bootloader fastboot. To address this scenario, we now flash "boot",
"vbmeta", "recovery", "dtbo", and "dts" before booting into userspace
fastboot, using whatever fastboot is currently active.
Bug: 78793464
Test: fastboot flashall with device in bootloader fastboot
Change-Id: I773707bbbe9235c560416c70976e32fd8e52a5a3
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
Add "super" to the table of known images so that automatic file
resolution can occur. Add a flag to indicate if the image should
be flashed with flashall and set it to false for the new "super"
image, all else true.
Test: 'fastboot flash super' works.
'fastboot flashall' does not flash super
Bug: 78793464
Change-Id: I5b85536b1d4890264531af357aba84a061d6df44
Currently, fastboot flashall will try to flash every partition in the
image list. For devices with logical partitions, this will cause those
partitions to be flashed twice (once via super.img, and again for each
individual image). Additionally, super.img is needed to synchronize the
logical partition list, but it is only generated with "make dist",
making it inconvenient for most workflows.
This patch removes automatic flashing of super.img. Instead, devices
with a super partition must now generate a "super_empty.img"
describing the super geometry and logical partition layout. Before
flashing any other partitions, this image is used to ensure the device
has created all necessary logical partitions.
Additionally, before flashing (but after updating super), all logical
partitions that will be flashed are resized to 0. This ensures that
logical partitions will receive more optimal space allocation.
Finally, during flashing of individual images, logical partitions are
resized to the image size, since they do not have hardcoded sizes in the
build.
Bug: 78793464
Test: fastboot flashall can flash vendor, product, product_services
without a make dist/super.img.
Change-Id: I18c2291e0d0cb10de729c5646b75ac84dde8c871
This change introduces an "update-super" command to the fastboot
protocol. Unlike the "flash" command, which copies raw or sparse data to
a partition, the "update-super" command requires the data to be a super
image generated by lpmake.
If the super partition is not yet formatted (or is corrupt), then it
will be formatted using the given image. Otherwise, "update-super" will
preserve the existing partition layout, and only ensure that logical
partition entries exist for all the new partitions in the given image.
All new partitions added this way will have a zero size, and it is the
host's responsibility to size them as needed afterwards with the
"resize-logical-partition" command.
In addition, the "update-super" command supports a "wipe" argument,
which will force the super partition to be reformatted with the given
image, overwriting any existing partition tables.
Bug: 78793464
Test: fastboot flashall with a super partition
Change-Id: If37d839a03e396e11b6c08a9c32984106613d1dc
Attempting to reduce the number of different spellings we have for
"product services" partition in the codebase.
Bug: 112431447
Test: m
Change-Id: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
Merged-In: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
Some OEM commands can take quite a while.
The current 10 second timeout is too small.
Test: fastboot tool
Change-Id: Icf59615919c92dc85807abe3ec5793504cf7a162
When flashing logical partitions, we read the "super" partition metadata
corresponding to the current slot. We then temporarily create a
device-mapper device for that partition, and immediately destroy the
device after all operations are complete. We do not mount partitions
ahead of time, or keep them mounted, because a fastboot operation may
change the layout of the logical partition table (or change which slot
is current).
Bug: 78793464
Test: fastboot flash a logical partition under "super"
Change-Id: Id2a61d3592decabeebfd283c4fd6e6cbe576a18c
Currently a few getvar handlers will return invalid strings when an
error occurs. This change allows those handlers to instead send a proper
failure message.
Bug: 78793464
Test: N/A
Change-Id: I7ff7d036c1e6fb0a3d700ecf21b1103ab77278d2
The size of `fastbootd` goes down from 64088-byte to 38488-byte
(aosp_taimen-userdebug) after the change.
Bug: 78793464
Test: `m -j installclean && m -j fastbootd`. Check that
$OUT/recovery/root/system/lib64/libadbd.so exists and
$OUT/recovery/root/system/bin/fastbootd depends on that.
Change-Id: Ic36c98da1a0dda4e0d86e671f858c42578f53f90
The build system generates a partition name of "product_services" for
the product-services partition, so fastboot's image list must reflect
this.
Bug: 78793464
Test: fastboot flash product_services works with fastbootd
Change-Id: I348f970c9584fd3dd4369e8cded66b6e39eee2b2
Bug: 112108453
Test: fastboot flashall with super.img and product-services.img in $OUT,
fastboot update with super.img and product-services.img in image.zip.
Change-Id: I5718b5e60c546c55af74292895b3f7fe169e4f02
Fastbootd is started by recovery, and communicates
over usb with the fastboot protocol.
Add additional fastboot commands to move in and out of
fastbootd. "fastboot reboot recovery" and "fastboot reboot fastboot"
Bug: 78793464
Test: fastboot reboot recovery, fastboot reboot fastboot
Change-Id: Iffb77b2d3ceefb7335c38aa9fba7bd17821484f0
This CL is largely and adaptation of
Ifd119650dd3316508870df0dfc770099e95ae1d1
Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.
Change-Id: I204a831e052d018018ab124d70ad1ff1610ee007
When host fastboot sends sparse blocks to the device, it tries to only
send blocks in multiples of 1024 bytes. If a block is not aligned to this
size, the excess bytes are prepended to the next write operation. This
is implemented by doing the write in two steps: first the previous
excess from the last write (plus new data up to alignment), then a
second write for the aligned remainder of the new data.
This logic has a bug if the final block plus the previous excess data
contains >= 1024 but < 2048 bytes. In this case the first write will
drain 1024 bytes from the data, and the second write will not have 1024
bytes to write. Instead of retaining this data for the next write, it
tries to write 0 chunks (and thus 0 bytes), which hangs the ioctl() call.
Bug: N/A
Test: "fastboot flash super super.img" where super.img is generated by
lpmake, containing system and product_services partitions and
images.
Change-Id: I9e8523c976ec84d5a57b36a28f4b1ca800edb7e7
USB Reset() allows simulating unplugging and replugging device.
Test: build and run fastboot on mac 10.13.3
Test: glinux build and run fastboot
Change-Id: Id924d063e549a4cca9dda03afd8f8fe266f6d2ab
This reverts commit ceb7cbf5fd.
Reason for revert: Broke mac builds:
system/core/fastboot/usb_osx.cpp:513:35: error: use of undeclared identifier 'USB_TRANSACTION_TIMEOUT'
USB_TRANSACTION_TIMEOUT, USB_TRANSACTION_TIMEOUT);
^
Change-Id: Ibe2f9ff2d5c63f9d33f4bd6d9ba962604cf8caeb
For testing there needs to be a way to simulate unplugging and
replugging a device. This change adds support for a USB reset
method that does this.
Also add timeouts, so USB reads/writes don't block forever
on an unresponsive device.
Test: glinux, fastboot tool still works
Test: Reset confirmed working via wireshark Linux URB captures
Change-Id: I7213a2395d4ef1c0238810e4929ab966e78c8b55
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
Builtin command "type" in zsh doesn't support -t option and this
is resolved by checking the shell type prior to sourcing them.
Instead of using "type -t" explicitly, check_type() knows the the
type of the current shell and behaves accordingly.
Bug: 110629292
Test: (zsh) source build/envsetup.sh && lunch aosp_arm
(bash) source build/envsetup.sh && lunch aosp_arm
Change-Id: Ie39e130e9cc87135cfd522abedba11ad5ac25261
This allows them to be shared between host and device
implementations.
Test: fastboot works
Bug: 78793464
Change-Id: I79271687850ade2a904fd03d6a97dad1a9ab8e1c
Bug: http://b/69933090
Bug: http://b/69933068
MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf. So just use the default that's used for
other platforms. This also mirrors upstream commit
015e637b4b/.
Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
Fix some bit-rotten instances of printf("%d", size_t), add more
logging for device selection.
Test: fastboot.exe devices
Change-Id: I4683fab8f88805e1ac88e193a1e84821be8bfa4c
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
The header version argument is meant for creation of boot images
using boot and flash:raw commands. It is unnecessary to specify the same
while using the boot command with a complete boot image.
Bug: 77920157
Test: fastboot boot boot.img
Change-Id: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
Merged-In: Ia8fca4180e15906a3ae7c732496a744eb4b15e91
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
We've got an internal target 'static_sdk_tools' that attempts to ensure
that both adb and fastboot are distributed as artifacts. It's
essentially a loop calling dist-for-goals on
$(HOST_OUT_EXECUTABLES)/{adb,fastboot}.
The dist-for-goals macro has de-duplication checks, but both the src and
dest needs to be identical. Currently adb is using the installed
executable, fastboot is using the built executable, and static_sdk_tools
is trying to use the installed versions of both.
This causes an overriding commands for target warning, which I recently
turned into a warning.
Maybe everything should be converted over to using the built
executables, but that requires a bunch more checks everywhere, and most
places are already using the installed version.
Bug: 77775726
Test: check treehugger, fastboot is dist
Test: m BUILD_HOST_static=1 static_sdk_tools dist
Change-Id: If45fb9706fa75a812610224708b5f95f65b1f1bf
Also move -c to --cmdline to match the python mkbootimg tool. Remove
the short options for these rarely-used options.
Remove #if 0 cruft from <bootimg/bootimg.h>.
Bug: http://b/77340848
Test: manual testing (need to fix http://b/77809061 for unit tests)
Change-Id: Ieaa795566611bd89ba3fee39a1d9f6ad0713a587
This workaround shouldn't be necessary now we're using mke2fs.
Bug: http://b/25429933
Test: `fastboot -w flashall`
Change-Id: I577ad445a02a448102fb49674360a732aa3d153c
These were implemented on Nexus 5X/6P, but the infrastructure for the
challenge-response system isn't available.
Bug: N/A
Test: N/A
Change-Id: I50e27f469ea7c668de1af314f83f5171376ccda4
This isn't in the bootloader requirements doc, and the internet implies
that you actually need to use `fastboot oem edl` or `fastboot oem
reboot-edl` anyway.
Bug: N/A
Test: N/A
Change-Id: I0b7cd9839fbd06fc104d029e92d5986dc3c6eda3
After:
usage: fastboot [OPTION...] COMMAND...
flashing:
update ZIP Flash all partitions from an update.zip package.
flashall Flash all partitions from $ANDROID_PRODUCT_OUT.
On A/B devices, flashed slot is set as active.
Secondary images may be flashed to inactive slot.
flash PARTITION [FILENAME]
Flash given partition only.
basics:
devices [-l] List devices in bootloader (-l: with device paths).
getvar NAME Display given bootloader variable.
reboot [bootloader] Reboot device.
locking/unlocking:
flashing lock|unlock Lock/unlock partitions for flashing
flashing lock_critical|unlock_critical
Lock/unlock 'critical' bootloader partitions.
flashing get_unlock_ability
Check whether unlocking is allowed (1) or not(0).
advanced:
erase PARTITION Erase a flash partition.
format[:FS_TYPE[:SIZE]] PARTITION
Format a flash partition.
set_active SLOT Set the active slot.
oem [COMMAND...] Execute OEM-specific command.
boot image:
boot KERNEL [RAMDISK [SECOND]]
Download and boot kernel from RAM.
flash:raw PARTITION KERNEL [RAMDISK [SECOND]]
Create boot image and flash it.
-c CMDLINE Override kernel command line.
--base ADDRESS Set kernel base address (default: 0x10000000).
--kernel-offset Set kernel offset (default: 0x00008000).
--ramdisk-offset Set ramdisk offset (default: 0x01000000).
--tags-offset Set tags offset (default: 0x00000100).
--page-size BYTES Set flash page size (default: 2048).
--header-version VERSION Set boot image header version.
Android Things:
stage IN_FILE Sends given file to stage for the next command.
get_staged OUT_FILE Writes data staged by the last command to a file.
options:
-w Wipe userdata.
-u Do not erase partition first when formatting.
-s SERIAL Specify a USB device.
-s tcp|udp:HOST[:PORT] Specify a network device.
-i VENDOR_ID Filter devices by USB vendor id.
-S SIZE[K|M|G] Use sparse files above this limit (0 to disable).
--slot SLOT Use SLOT; 'all' for both slots, 'other' for
non-current slot (default: current active slot).
--set-active[=SLOT] Sets the active slot before rebooting.
--skip-secondary Don't flash secondary slots in flashall/update.
--skip-reboot Don't reboot device after flashing.
--disable-verity Sets disable-verity when flashing vbmeta.
--disable-verification Sets disable-verification when flashing vbmeta.
--wipe-and-use-fbe Enable file-based encryption, wiping userdata.
--unbuffered Don't buffer input or output.
--verbose, -v Verbose output.
--version Display version.
--help, -h Show this message.
Bug: N/A
Test: `fastboot --help`
Change-Id: I3639fdee68de544f12e75004ccbb03b8386e64ed
The argument would set the boot header
version for flash:raw and boot
commands when they are used for boot
image creation.
Bug: 77154616
Test: Dumped the created boot image and checked
the header version using unpack_bootimg
Change-Id: I2c458996817615f4351db102b4234984108d47c0
Merged-In: I2c458996817615f4351db102b4234984108d47c0
(cherry picked from commit 88de5556ec)
The argument would set the boot header
version for flash:raw and boot
commands when they are used for boot
image creation.
Bug: 77154616
Test: Dumped the created boot image and checked
the header version using unpack_bootimg
Change-Id: I2c458996817615f4351db102b4234984108d47c0
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
(cherry picked from commit 5620d224b6)
Change-Id: Ib97af6f9392f7672430ff71228484e6ee7af6fbf
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
The following three modules aren't defined for Windows
builds:
e2fsdroid mke2fs.conf sload_f2fs
Which leads to the following errors:
build/make/core/main.mk:586: warning: Missing required dependency host_cross_e2fsdroid from module host_cross_fastboot defined in system/core/fastboot/Android.mk
build/make/core/main.mk:586: warning: Missing required dependency host_cross_mke2fs.conf from module host_cross_fastboot defined in system/core/fastboot/Android.mk
build/make/core/main.mk:586: warning: Missing required dependency host_cross_sload_f2fs from module host_cross_fastboot defined in system/core/fastboot/Android.mk
Here, I've removed their requirement for the Windows build and
only included the requirement for the Linux build.
Bug: 7456955
Test: above errors no longer present
Change-Id: I14fdb880d868f893fa5899ea200820bd885a3bc1