Moving Fastboot to Userspace
Android 10 and higher support resizable partitions by relocating the fastboot implementation from
bootloader to userspace. This relocation enables moving the flashing code into a maintainable and
testable common location with only the vendor-specific parts of fastboot implemented by a hardware
abstraction layer (HAL)
Unifying fastboot and recovery
Because userspace fastboot and recovery are similar, you can merge them into one partition/binary.
Advantages include less space use and fewer partitions overall, as well as the ability for fastboot and
recovery to share their kernel and libraries.
To support fastbootd, the bootloader must implement a new boot control block (BCB) command of boot -
fastboot. To enter fastbootd mode, bootloader should write boot -fastboot into the command field of the
BCB message and leave the recovery field of BCB unchanged (to enable restart of interrupted recovery
tasks). The status, stage, and reserved fields remain unchanged as well. The bootloader is expected to
load and boot into the recovery image upon seeing boot-fastboot in the BCB command. Recovery then
parses the BCB message and switches to fastbootd mode.
ADB commands
This section describes the adb command for integrating fastbootd. The command has different behavior
depending on whether system or recovery executes the command.
Command Description
reboot fastboot + Reboots into fastbootd (system).
+ Enters fastbootd directly without a reboot (recovery).
Fastboot commands
This section describes the fastboot commands for integrating fastbootd, including new commands for
flashing and managing logical partitions. Some commands have different behavior depending on whether
bootloader or fastbootd executes the command,
Command Description
reboot recovery —« Reboots into recovery (bootloader).
+ Enters recovery directly without a reboot (Fastbootd)
reboot fastboot —_Reboots into Fastbootd.
getvar is-userspace . Retums yes (fastbootd).
+ Retums no (bootloader)
hitpsiource android. com/éevices/boolladertfastooatd 13srt6r2021
getvar super-
partition-nane
create-logical-
partition
delete-logical-
partition
resize-logical-
partition
update-super
flash
[ ]
erase
getvar |
‘all
set_active
reboot
reboot-
Moving Fastooot to Userspace | Android Open Source Project
Kketums yes i ine given parution 1s a logical patton, no omerwise, Logical partons support
all of the commands listed below.
Returns the name of the super partition. The name includes the current slot suffix if the super
partition is an A/B partition (itis usually not).
Creates a logical partition with the given name and size. The name must not already exist as a
logical partition.
Deletes the given logical partion (effectively wiping the partition).
Resizes the logical partition to the new size without changing its contents. Fails if not enough
space is available to perform the resize.
Merges changes to the super partition metadata. If a merge isn't possible (for example, the
format on the device is an unsupported version), then this command fails. An
optional wipe parameter overwrites the device's metadata rather than performing a merge.
Writes a file to a flash partition. Device must be in unlocked state.
Erases a partition (not required to be secure erase). Device must be in unlocked state.
Displays a bootloader variable, or all variables. If the variable doesn't exist, returns an error,
Sets the given A/B booting slot as active. On the next boot attempt, the system boots from the
specified slot.
For A/B support, slots are duplicated sets of partitions that can be booted from independently
Slots are named a, b, etc, and differentiated by adding the suffixes _a, _b, etc, to the partition
name.
Reboots device normally
Reboots device into bootloader.
boot Loader (or reboot.
bootloader)
Fastboot and bootloader
The bootloader flashes the boot loader, radio, and boot/recovery partitions, after which the device boots
into fastboot (userspace) and flashes all other partitions. The bootloader should support the following
commands.
Command
download
Description
Downloads the image to flash.
flash recovery / flash boot Flashes recovery/boot partition and bootloader.
/ Flash bootloader
Dynamic partitions
Reboots to fastboot.
Reboots to recovery,
Gets a bootloader variable that is required for flashing of recovery/boot,
image (for example, current -slot and max-download-size)
‘Command defined by OEM.
The bootloader must not allow the flashing or erasing of dynamic partitions and must return an error if
these operations are attempted. For retrofitted dynamic partition devices, the fastboot tool (and bootloader)
supports a force mode to directly flash a dynamic partition while in bootloader mode. For example,
if system is a dynamic partition on the retrofitted device, using fastboot --force flash system allows the
bootloader to flash the partition instead of fastbootd.
Note: Force mode is intended to provide flexibility in factory flashing and isn't recommended for developers.
Off-mode charging
Ifa device supports off-mode charging or otherwise autoboots into a special mode when power is applied,
the fastboot oem off-mode-charge @ command should bypass these special modes and the device
should boot as if the user had pressed the power button.
hips: source android.comidevices/boolloadertiastbootd
a