Generic system images

A generic system image (GSI) is a system image with adjusted configurations for Android devices. It's considered a pure Android implementation with unmodified Android Open Source Project (AOSP) code that any Android device running Android 9 or higher can run successfully.

GSIs are used for running VTS and CTS-on-GSI tests. The system image of an Android device is replaced with a GSI then tested with the Vendor Test Suite (VTS) and the Compatibility Test Suite (CTS) to ensure that the device implements vendor interfaces correctly with the latest version of Android.

To get started with GSIs, review the following sections for details on GSI configurations (and allowed variances) and types. When you're ready to use a GSI, download and build the GSI for your device target, then flash the GSI to an Android device.

GSI configuration and variances

The current Android GSI has the following configuration:

The current Android GSI includes the following major variances:

  • CPU architecture. Support for different CPU instructions (ARM, x86, etc.) and CPU bitness (32 bit or 64 bit).

GSI targets for Treble compliance tests

The GSI used for compliance testing is determined by the Android version that the device launches with.

Device type Build target
Devices launching with Android 12 gsi_$arch-user (Signed)
Devices launching with Android 11 gsi_$arch-user (Signed)
Devices launching with Android 10 gsi_$arch-user (Signed)
Devices launching with Android 9 gsi_$arch-userdebug

All GSIs are built from the Android 12 codebase, and each CPU architecture has a corresponding GSI binary (see the list of build targets in Building GSIs).

Android 12 GSI changes

Devices launching with or updated to Android 12 must use Android 12 GSIs for compliance testing. This includes the following major changes from earlier GSIs:

  • Target name. The GSI target name for compliance tests is changed to gsi_$arch. The GSI with target name aosp_$arch is kept for Android app developers. The test plan CTS-on-GSI is also reduced for testing vendor interface.
  • Legacy GSI is phased out. GSI 12 removes the workarounds accommodating Android 8.0 or 8.1 devices that are not fully Treblized.
  • Userdebug SEPolicy. The GSI gsi_$arch contains userdebug_plat_sepolicy.cil. When flashing the OEM-specific vendor_boot-debug.img or boot-debug.img, /system/bin/init will load userdebug_plat_sepolicy.cil from the GSI system.img. Reference VTS Testing with Debug Ramdisk for the detail.

Android 11 GSI changes

Devices launching with or updated to Android 11 must use Android 11 GSIs for compliance testing. This includes the following major changes from earlier GSIs:

  • system_ext contents. Android 11 defines a new partition system_ext. GSI puts the system extension contents under the folder system/system_ext.
  • APEXes. GSI contains both flattened and compressed APEXes. Which one to use is determined by the system property ro.apex.updatable in the vendor partition at run time. Reference Configuring system to support APEX updates for the detail.

Android 10 GSI changes

Devices launching with or updated to Android 10 must use Android 10 GSIs for compliance testing. This includes the following major changes from earlier GSIs:

  • User build. GSI has user build from Android 10. In Android 10, the user build GSI can be used in CTS-on-GSI/VTS compliance testing. Reference VTS Testing with Debug Ramdisk for details.
  • Unsparsed format. GSI with targets aosp_$arch are built with unsparsed format. You can use img2simg to convert an unsparsed GSI to sparse format if necessary.
  • System-as-root. The legacy GSI build target named aosp_$arch_a had been phased out. For the devices upgraded from Android 8 or 8.1 to Android 10 with ramdisk and non-system-as-root, use the legacy GSI aosp_$arch_ab. The upgraded init in ramdisk supports OEM system.img with system-as-root layout.
  • Verify boot. Using GSI you only need to unlock the device. It's not necessary to disable verify boot.

Android 9 GSI changes

Devices launching with or updated to Android 9 must use Android 9 GSIs for compliance testing. This includes the following major changes from earlier GSIs:

  • Merges GSI and emulator. GSIs are built from the system images of emulator products, for example, aosp_arm64 and aosp_x86.
  • System-as-root. In previous versions of Android, devices that didn't support A/B updates could mount the system image under the /system directory. In Android 9, the root of the system image is mounted as the root of the device.
  • 64-bit binder interface. In Android 8.x, 32-bit GSIs used the 32-bit binder interface. Android 9 doesn't support the 32-bit binder interface, so both 32-bit GSIs and 64-bit GSIs use the 64-bit binder interface.
  • VNDK enforcement. In Android 8.1, VNDK was optional. Starting from Android 9, VNDK is mandatory, so BOARD_VNDK_VERSION must be set.
  • Compatible system property. Android 9 enables the access check for a compatible system property (PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true).

Android 9 Keymaster changes

In earlier versions of Android, devices implementing Keymaster 3 or lower were required to verify that the version info (ro.build.version.release and ro.build.version.security_patch) reported by the running system matched the version info reported by bootloader. Such information was typically obtained from the boot image header.

In Android 9 and higher, this requirement has changed to enable vendors to boot a GSI. Specifically, Keymaster shouldn't perform verification because the version info reported by the GSI may not match the version info reported by vendor's bootloader. For devices implementing Keymaster 3 or lower, vendors must modify the Keymaster implementation to skip verification (or upgrade to Keymaster 4). For details on Keymaster, refer to Hardware-backed Keystore.

Downloading GSIs

You can download prebuilt GSIs from the AOSP continuous integration (CI) website at ci.android.com. If the GSI type for your hardware platform is unavailable for download, refer to the following section for details on building GSIs for specific targets.

Building GSIs

Starting with Android 9, each Android version has a GSI branch named DESSERT-gsi on AOSP (for example, android12-gsi is the GSI branch on Android 12). GSI branches include the content of Android with all security patches and GSI patches applied.

To build a GSI, set up the Android source tree by downloading from a GSI branch and choosing a GSI build target. Use the build target tables below to determine the correct GSI version for your device. After the build completes, the GSI is the system image (that is, system.img) and appears in the output folder out/target/product/generic_arm64.

For example, to build the GSI build target gsi_arm64-userdebug on the GSI branch android12-gsi, run the following commands.

$ repo init -u https://android.googlesource.com/platform/manifest -b android12-gsi
$ repo sync -cq
$ source build/envsetup.sh
$ lunch gsi_arm64-userdebug
$ make -j4

Android GSI build targets

The following GSI build targets are for devices launching on Android 9 or higher.

GSI name CPU arch Binder interface bitness System-as-root Build target
gsi_arm ARM 64 Y gsi_arm-user
gsi_arm-userdebug
gsi_arm64 ARM64 64 Y gsi_arm64-user
gsi_arm64-userdebug
gsi_x86 x86 64 Y gsi_x86-user
gsi_x86-userdebug
gsi_x86_64 x86-64 64 Y gsi_x86_64-user
gsi_x86_64-userdebug

Requirements for flashing GSIs

Android devices can have different designs, so there is no generic command or set of instructions for flashing a GSI to apply to all devices. Check with the manufacturer of the Android device for explicit flashing instructions. Use the following steps as a general guideline:

  1. Ensure that the device has the following:
    • Treblized
    • A method for unlocking devices (so they can be flashed using fastboot)
    • An unlocked state to make it flashable via fastboot (To ensure that you have the latest version of fastboot, build it from the Android source tree.)
  2. Erase the current system partition, then flash the GSI to the system partition.
  3. Wipe the user data and clear the data from other necessary partitions (for example, user data and system partitions).
  4. Reboot the device.

For example, to flash a GSI to any Pixel device:

  1. Boot to fastboot mode and unlock the bootloader.
  2. The devices supporting fastbootd also need to boot into fastbootd by:
    $ fastboot reboot fastboot
  3. Erase and flash the GSI to the system partition:
    $ fastboot erase system
    $ fastboot flash system system.img
    
  4. Wipe the user data and clear the data from other necessary partitions (for example, user data and system partitions):
    $ fastboot -w
  5. Reboot:
    $ fastboot reboot
On Android 10 or newer devices that have smaller system partitions, the following error message might appear when flashing the GSI:
    Resizing 'system_a'    FAILED (remote: 'Not enough space to resize partition')
    fastboot: error: Command failed
Use the following command to delete the product partition and free up space for the system partition. This provides extra space to flash the GSI:
$ fastboot delete-logical-partition product_a
The postfix _a should match the slot id of the system partition, such as system_a in this example.

Contributing to GSIs

Android welcomes your contributions to GSI development. You can get involved and help improve the GSI by:

  • Creating a GSI patch. DESSERT-gsi is not a development branch and accepts only cherrypicks from the AOSP main branch, so to submit a GSI patch, you must:
    1. Submit the patch to the AOSP main branch.
    2. Cherrypick the patch to DESSERT-gsi.
    3. File a bug to get the cherrypick reviewed.
  • Reporting GSI bugs or making other suggestions. Review the instructions in Reporting bugs, then browse or file GSI bugs.

Tips

Changing the navigation bar mode using adb

When booting with GSI, the navigation bar mode is configured by vendor overriding. You can change the navigation bar mode by running the following adb command in runtime.

adb exec-out cmd overlay enable-exclusive com.android.internal.systemui.navbar.mode

Where mode can be threebutton, twobutton, gestural, and so on.