Fastboot and OTA Package Generation for A/B Devices

Fastboot and OTA Package Generation for A/B Devices

In this article, we will discuss the usage of fastboot and the generation of over-the-air (OTA) packages for A/B devices.

Fastboot Variables

To get all variables, you can run fastboot getvar all. This command returns a list of all available variables, including those related to the A/B system.

The following are some important variables:

  • slot-successful:<slot-suffix>: Returns 'yes' if the slot boots successfully, and 'no' otherwise.
  • slot-unbootable:<slot-suffix>: Returns 'yes' if the slot is unbootable, and 'no' otherwise.
  • slot-retry-count: The number of remaining slot boot retries.

OTA Package Generation

The OTA package tool is used to create A/B OTA packages. The tool automatically identifies and generates packages in the format required for A/B updates.

To generate a full OTA package, run the following command:

../build/make/tools/releasetools/ota_from_target_files \
 dist_output/tardis-target_files.zip \
 ota_update.zip

To generate an incremental OTA package, run the following command:

../build/make/tools/releasetools/ota_from_target_files \
 -i PREVIOUS-tardis-target_files.zip \
 dist_output/tardis-target_files.zip \
 incremental_ota_update.zip

Partition Configuration

The update_engine can update all A/B partitions defined on the same disk. Partition pairs include a common prefix (e.g., "system" or "boot") and a slot-specific suffix (e.g., "_a" or "_b"). The list of partitions to be updated is configured by the AB_OTA_PARTITIONS make variable.

For example, if you want to update the bootloader_a and bootloader_b partition pairs, you would specify:

AB_OTA_PARTITIONS := \
 boot \
 system \
 bootloader

Post-Installation Configuration

You can use key-value pair sets to configure different post-installation steps for each partition. To run a program on the new image, such as /system/usr/bin/postinst, you would specify:

AB_OTA_POSTINSTALL_CONFIG += \
 RUN_POSTINSTALL_system=true \
 POSTINSTALL_PATH_system=usr/bin/postinst \
 FILESYSTEM_TYPE_system=ext4

Compilation

For security reasons, the system_server cannot use just-in-time (JIT) compilation. Instead, you must compile the odex file and minimize dependencies. Other options are available.

To compile in the background for an app, add the following to your device.mk file:

PRODUCT_PACKAGES += otapreopt_script

# A/B OTA dexopt update_engine hookup
AB_OTA_POSTINSTALL_CONFIG += \
 RUN_POSTINSTALL_system=true \
 POSTINSTALL_PATH_system=system/bin/otapreopt_script \
 FILESYSTEM_TYPE_system=ext4 \
 POSTINSTALL_OPTIONAL_system=true

Notes

  • To install a pre-selected file on the second system partition without using the DEX_PREOPT file, see the initial boot installation documentation.
  • The otapreopt_script package is used to run the post-installation script during the update process.

I hope this helps! Let me know if you have any questions or need further clarification.

Leave a comment