Develop Android kernels

This page describes how to develop Android kernels on Cuttlefish devices.

Supported kernel manifests

Cuttlefish supports the following kernel manifests on main and AOSP GSI releases.

  • On aosp-main
    • common-android-mainline
    • common-android16-6.12
    • common-android15-6.6
    • common-android14-6.1
    • common-android14-5.15
  • On aosp-android13-gsi
    • common-android13-5.15
    • common-android13-5.10
  • On aosp-android12-gsi
    • common-android12-5.10
    • common-android12-5.4
    • common-android-4.19-stable
  • On aosp-android11-gsi
    • common-android11-5.4
    • common-android-4.19-stable
    • common-android-4.14-stable

The following are kernel sources for kernel development on Cuttlefish devices.

Develop Android kernels

To develop kernels on Cuttlefish devices, follow these steps:

  1. Clone the appropriate kernel repo manifest for your Cuttlefish device and make any changes.

    mkdir common-android-mainline
    cd common-android-mainline
    repo init -u https://android.googlesource.com/kernel/manifest -b common-android-mainline
    repo sync -c -j$(nproc) -q
  2. Build the kernel and ramdisk. For more information, see Building the Vendor Modules for the Virtual Device.

    tools/bazel run //common-modules/virtual-device:virtual_device_x86_64_dist

    If using common-android-4.19-stable, common-android-4.14-stable, or common-android11-5.4 kernel manifests, run:

    BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh && BUILD_CONFIG=common-modules/virtual-device/build.config.cuttlefish.x86_64 build/build.sh

    Instead of building locally (to avoid downloading the kernel source, setting up a kernel development environment), you can download the relevant artifacts at ci.android.com.

  3. Launch the kernel and ramdisk with Cuttlefish.

    cvd create \
        -kernel_path=./out/virtual_device_x86_64/dist/bzImage \
        -initramfs_path=./out/virtual_device_x86_64/dist/initramfs.img

    If launching a non-GKI kernel (anything at or under 4.19), omit the -initramfs_path argument.

    If you're launching the kernel on an aarch64 version of Cuttlefish, use the aarch64 build configuration and use the Image artifact instead of bzImage.

    cvd create \
        -kernel_path=./out/virtual_device_aarch64/dist/Image \
        -initramfs_path=./out/virtual_device_aarch64/dist/initramfs.img