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-kernel android-gs-comet-6.1-android14-qpr3-d1 android14-6.1
Pixel 9 (tokay)
Pixel 9 Pro (caiman)
Pixel 9 Pro XL (komodo)
device/google/caimito-kernel android-gs-caimito-6.1-android14-qpr3-d1 android14-6.1
Pixel 8a (akita) device/google/akita-kernel android-gs-akita-5.15-android14-qpr3 android14-5.15
Pixel 8 (shiba)
Pixel 8 Pro (husky)
device/google/shusky-kernel android-gs-shusky-5.15-android14-qpr3 android14-5.15
Pixel Fold (felix) device/google/felix-kernel android-gs-felix-5.10-android14-qpr3 android13-5.10
Pixel Tablet (tangorpro) device/google/tangorpro-kernel android-gs-tangorpro-5.10-android14-qpr3 android13-5.10
Pixel 7a (lynx) device/google/lynx-kernel android-gs-lynx-5.10-android14-qpr3 android13-5.10
Pixel 7 (panther)
Pixel 7 Pro (cheetah)
device/google/pantah-kernel android-gs-pantah-5.10-android14-qpr3 android13-5.10
Pixel 6a (bluejay) device/google/bluejay-kernel android-gs-bluejay-5.10-android14-qpr3 android13-5.10
Pixel 6 (oriole)
Pixel 6 Pro (raven)
device/google/raviole-kernel android-gs-raviole-5.10-android14-qpr3 android13-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.8) AP1A.240505.004 (11583682) Yes
android14-gs-pixel-6.1 android14-6.1 AP1A.240505.004 (11583682) 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 few options you can following.

Option 1) 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
    
Option 2) Copy the vendor_ramdisk from a locally built Android platform 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 ANDROID_ROOT/out/target/product/DEVICE/vendor_ramdisk-debug.img \
   KERNEL_REPO_ROOT/DEVICE_RAMDISK_PATH/vendor_ramdisk-DEVICE.img

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 android14 and later kernels, run the Kleaf build command:

tools/bazel run --config=fast --config=stamp //private/google-modules/soc/gs:slider_dist

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, 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.

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)

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