Build Pixel kernels

This guide provides step-by-step instructions on how to download, compile, and flash a custom Pixel kernel for development. Due to GKI, it's now possible to update the kernel independently of the Android platform build. These steps are only applicable for Pixel 6 and later devices. This is because Pixel 5 and earlier devices require updating the kernel modules on the vendor partition, which is dependent on the Android platform build for those devices. The GKI supported Pixel kernel branches table includes the kernel repository manifest branch for each GKI supported Pixel device. Refer to the Legacy Pixel Kernels section for the Pixel 5 and earlier kernel manifest branches.

GKI supported Pixel kernel branches
Device Binary path in AOSP tree Repository branches GKI Kernel
Pixel 9 Pro Fold (comet) device/google/comet-kernels/6.1 android-gs-comet-6.1-android15-qpr1 android15-6.1
Pixel 9 (tokay)
Pixel 9 Pro (caiman)
Pixel 9 Pro XL (komodo)
device/google/caimito-kernels/6.1 android-gs-caimito-6.1-android15-qpr1 android15-6.1
Pixel 8a (akita) device/google/akita-kernels/5.15 android-gs-akita-5.15-android15-qpr1 android15-5.15
Pixel 8 (shiba)
Pixel 8 Pro (husky)
device/google/shusky-kernels/5.15 android-gs-shusky-5.15-android15-qpr1 android15-5.15
Pixel Fold (felix) device/google/felix-kernels/5.10 android-gs-felix-5.10-android15-qpr1 android15-5.10
Pixel Tablet (tangorpro) device/google/tangorpro-kernels/5.10 android-gs-tangorpro-5.10-android15-qpr1 android15-5.10
Pixel 7a (lynx) device/google/lynx-kernels/5.10 android-gs-lynx-5.10-android15-qpr1 android15-5.10
Pixel 7 (panther)
Pixel 7 Pro (cheetah)
device/google/pantah-kernels/5.10 android-gs-pantah-5.10-android15-qpr1 android15-5.10
Pixel 6a (bluejay) device/google/bluejay-kernels/5.10 android-gs-bluejay-5.10-android15-qpr1 android15-5.10
Pixel 6 (oriole)
Pixel 6 Pro (raven)
device/google/raviole-kernels/5.10 android-gs-raviole-5.10-android15-qpr1 android15-5.10

In addition to the factory supported kernels, the Pixel 6 and 6 Pro devices are supported for GKI development purposes only on the Android Common kernel branches included in the Supported Pixel 6/6 Pro Android Platform and Kernel Combinations table. Due to vendor UAPI differences between the Android platform HALs and Pixel kernel drivers, the table provides the supported build combinations.

Supported Pixel 6/6 Pro Android platform and kernel combinations
Pixel Kernel Manifest Branch GKI Branch Android Platform Build aosp-main support?
gs-android-gs-raviole-mainline android-mainline (v6.12) BP11.241025.006 (12620009) Yes
android-gs-raviole-6.1-android15-qpr2-beta android14-6.1 BP11.241025.006 (12620009) Yes
gs-android13-gs-raviole-5.15 android13-5.15 TQ1A.230205.002 (9471150) No

Prepare your Pixel device

The following flow chart describes the process for updating the kernel on Pixel 6 and later devices:

**Figure 1.** Kernel Update Flow Chart

Flash the device using flash.android.com

  1. Navigate to flash.android.com
  2. Pick the Android build based on the supported Android Platform and Kernel combinations.
  3. Select the following options:
    • Wipe Device
    • Force Flash all Partitions
    • Disable Verification
  4. Press the Install build button to flash the device.

**Figure 2.** Flash Station Example

Download and compile the kernel

Sync the kernel repository

Run the following commands to download the kernel source code. Refer to the Supported Pixel 6/6 Pro Android Platform and Kernel Combinations table for the Pixel KERNEL_MANIFEST_BRANCH.

repo init -u https://android.googlesource.com/kernel/manifest -b KERNEL_MANIFEST_BRANCH
repo sync -c --no-tags

Update the vendor ramdisk

Update the file vendor_ramdisk-DEVICE.img in the kernel repository to match the Android platform build that is flashed on the device. There are a couple of options to update the vendor_ramdisk-DEVICE.img file. Use option (1) if you are using Android 15 QPR2 (BP11.241025.006) or later. Otherwise, use option (2).

  • Option 1) Update only the DTB and DLKM ramdisk bits of the vendor_boot partition

    Starting with fastboot version 35.0.2-12583183, you can directly flash the DTB and DLKM ramdisk on the vendor_boot partition. Download and extract sdk-repo-HOST_OS-platform-tools-12583183.zip from the v35.0.2-12583183 artifacts to your host machine's environment for use.

    Follow the instructions to flash DTB and vendor_boot:dlkm in the Flash the kernel images.

  • Option 2) Extract the vendor ramdisk image from the Pixel factory image.

    1. Download the supported factory image for your device from https://developers.google.com/android/images.

    2. Extract the vendor_boot.img:

      The following commands use the Pixel 6 Pro AP1A.240505.004 as an example. Replace the zipfile name with the filename of the factory image you downloaded.

        unzip raven-ap1a.240505.004-factory-9d783215.zip
      
        cd raven-ap1a.240505.004
      
        unzip image-raven-ap1a.240505.004.zip vendor_boot.img
      
    3. Unpack the vendor_boot.img to obtain the vendor ramdisk.

        KERNEL_REPO_ROOT/tools/mkbootimg/unpack_bootimg.py --boot_img vendor_boot.img \
            --out vendor_boot_out
      
    4. Copy the extracted vendor-ramdisk-by-name/ramdisk_ file to the Pixel kernel repository.

      Device DEVICE_RAMDISK_PATH
      Pixel 6 (oriole)
      Pixel 6 Pro (raven)
      prebuilts/boot-artifacts/ramdisks/vendor_ramdisk-oriole.img
      Pixel 6a (bluejay) private/devices/google/bluejay/vendor_ramdisk-bluejay.img
        cp vendor_boot_out/vendor-ramdisk-by-name/ramdisk_ \
            KERNEL_REPO_ROOT/DEVICE_RAMDISK_PATH
      

Compile the kernel (Kleaf)

In Android 13, the build.sh script was replaced with a new kernel build system called Kleaf. For devices using android13-5.15 and later, the kernel should be built using Kleaf.

For Pixel 6 and 6 Pro with android13-5.15 kernels, run the Kleaf build command:

tools/bazel run --lto=thin //gs/google-modules/soc-modules:slider_dist

For all other Pixel kernels, run the build_DEVICE.sh script found at KERNEL_REPO_ROOT. In most cases, DEVICE needs to be the code name that matches the code name used in the Binary path in AOSP tree column of the table GKI supported Pixel kernel branches. This can be the code name of one device, such as "akita" (Pixel 8a), or a code name that represents a group of related devices that share a kernel, such as "caimito" which means Pixel 9 (tokay), Pixel 9 Pro (caiman), and Pixel 9 Pro XL (komodo). For android14 and earlier releases, use build_slider.sh for Pixel 6 and Pixel 6 Pro, and build_cloudripper.sh for Pixel 7 and Pixel 7 Pro.

For example, to build the kernel for Pixel 6 on the branch android-gs-raviole-5.10-android14, you would run the command:

build_slider.sh

By default on the production kernel branches, the build_DEVICE.sh scripts use the prebuilt GKI kernel to speed up the build process. If you want to modify the core kernel, then set the environment variable BUILD_AOSP_KERNEL=1 to build the kernel from the local sources instead. The development kernel branches directly build the kernel source by default.

For more details about the kernel build system and how to customize the build, refer to the Kleaf - Building Android Kernels with Bazel.

Flash the kernel images

Note: If you haven't disabled verification, you need to do it before flashing the custom kernel. Here is the command to do so:
fastboot oem disable-verification
WARNING: If you are flashing a custom kernel on top of a platform build, then you may need to wipe your device if there is a security patch level (SPL) downgrade associated with the new kernel. This process erases all of your personal data. Be sure to back up your data before wiping.
fastboot -w

To flash the kernel images, run the fastboot flash command for each kernel partition listed for your device. For dynamic partitions, you need to reboot into fastbootd mode before flashing.

Device Kernel Partitions
Pixel 6 (oriole)
Pixel 6 Pro (raven)
Pixel 6a (bluejay)
boot
dtbo
vendor_boot
vendor_dlkm (dynamic partition)
Pixel 8 (shiba)
Pixel 8 Pro (husky)
Pixel Fold (felix)
Pixel Tablet (tangorpro)
Pixel 7a (lynx)
Pixel 7 (panther)
Pixel 7 Pro (cheetah)
boot
dtbo
vendor_kernel_boot
vendor_dlkm (dynamic partition)
system_dlkm (dynamic partition)

For Pixel 6/6 Pro/6a, if you skipped downloading the vendor_ramdisk in the Update the vendor ramdisk section, then use the following command to update the DTB and DLKM ramdisk instead of flashing the vendor_boot.img image:

fastboot flash  --dtb out/DEVICE/dist/dtb.img vendor_boot:dlkm out/slider/dist/initramfs.img

Here are the flashing commands for Pixel 6 on android-mainline:

fastboot flash boot        out/slider/dist/boot.img
fastboot flash dtbo        out/slider/dist/dtbo.img
fastboot flash vendor_boot out/slider/dist/vendor_boot.img
fastboot reboot fastboot
fastboot flash vendor_dlkm out/slider/dist/vendor_dlkm.img

The kernel images can be found in the DIST_DIR.

Kernel branch DIST_DIR
v5.10 out/mixed/dist
v5.15 and later out/DEVICE/dist
Note: If you have a serial dongle and want to enable serial logs, the command is:
fastboot oem uart enable
fastboot oem uart config 3000000
Example command to connect from the host:
screen -fn /dev/ttyUSB* 3000000

Restore the factory images

To restore your device back to the factory images, you can use flash.android.com.

Legacy Pixel kernels

As a reference, the legacy Pixel kernel branches table provides the kernel repository branches for Pixel 5 and earlier devices. These are non-GKI supported devices.

Legacy Pixel kernel branches
Device Binary path in AOSP tree Repository branches
Pixel 5a (barbet)
Pixel 4a (5G) (bramble)
Pixel 5 (redfin)
device/google/redbull-kernel android-msm-redbull-4.19-android14-qpr3
Pixel 4a (sunfish) device/google/sunfish-kernel android-msm-sunfish-4.14-android13-qpr3
Pixel 4 (flame)
Pixel 4 XL (coral)
device/google/coral-kernel android-msm-coral-4.14-android13
Pixel 3a (sargo)
Pixel 3a XL (bonito)
device/google/bonito-kernel android-msm-bonito-4.9-android12L
Pixel 3 (blueline)
Pixel 3 XL (crosshatch)
device/google/crosshatch-kernel android-msm-crosshatch-4.9-android12
Pixel 2 (walleye)
Pixel 2 XL (taimen)
device/google/wahoo-kernel android-msm-wahoo-4.4-android10-qpr3
Pixel (sailfish)
Pixel XL (marlin)
device/google/marlin-kernel android-msm-marlin-3.18-pie-qpr2