Question How to compile and run custom kernel for Pixel 6

Search This thread

barbito

New member
May 1, 2018
3
0
Hello!

I'm trying to compile and run a custom Android kernel on my Pixel 6. I did this multiple times in the past but with Android 12 it seems things have changed.
I'm following the usual "Building Kernels" page https://source.android.com/setup/build/building-kernels?hl=en

In more details these are the commands that I run:

mkdir android-kernel && cd android-kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-gs-raviole-5.10-android12-d1
./build/build.sh

However when I try to boot the boot.img using the "fastboot boot boot.img" command, I get immediately redirected back to the bootloader. I suspect this is due to a bad image file format.

I also tried to compile as follow
BUILD_BOOT_IMG=1 SKIP_VENDOR_BOOT=1 KERNEL_BINARY=Image \
GKI_RAMDISK_PREBUILT_BINARY=gki-ramdisk.lz4 \
BUILD_CONFIG=private/gs-google/build.config.gki.aarch64 \
./build/build.sh
where gki-ramdisk.lz4 is the ramdisk extracted from the prebuilt images found here https://developers.google.com/android/images#oriole
With this last setup I get a boot-loop, so at least the boot.img file format seems to be ok.

I think that these issues are related to the new GKI format, however I cannot find any information online on how to compile a custom GKI kernel.
Does any of you know how to build and run custom kernels for the Pixel 6?

Thanks!
 

acuicultor

Recognized Contributor / Recognized Developer
Jan 3, 2013
3,198
11,665
44
Palma de Mallorca
Google Pixel 6 Pro
Hello!

I'm trying to compile and run a custom Android kernel on my Pixel 6. I did this multiple times in the past but with Android 12 it seems things have changed.
I'm following the usual "Building Kernels" page https://source.android.com/setup/build/building-kernels?hl=en

In more details these are the commands that I run:



However when I try to boot the boot.img using the "fastboot boot boot.img" command, I get immediately redirected back to the bootloader. I suspect this is due to a bad image file format.

I also tried to compile as follow

where gki-ramdisk.lz4 is the ramdisk extracted from the prebuilt images found here https://developers.google.com/android/images#oriole
With this last setup I get a boot-loop, so at least the boot.img file format seems to be ok.

I think that these issues are related to the new GKI format, however I cannot find any information online on how to compile a custom GKI kernel.
Does any of you know how to build and run custom kernels for the Pixel 6?

Thanks!
You just need to run build_slider.sh script on the root of the repo you cloned for compile stock source
 
  • Like
Reactions: abalam

barbito

New member
May 1, 2018
3
0
Ah thanks! build_slider works but you need to specify to compile the kernel otherwise it uses the prebuilt kernel

BUILD_KERNEL=1 ./build_slider.sh
 

barbito

New member
May 1, 2018
3
0
I had the same issue. I can no more compile it correctly.
They constantly change everything. I even tried to checkout to older branches where I was sure I managed to compile it but still no success. Maybe the sub cloned repository were not in sync
 

shaoyang

New member
Apr 14, 2022
4
0
I had the same issue. I can no more compile it correctly.
They constantly change everything. I even tried to checkout to older branches where I was sure I managed to compile it but still no success. Maybe the sub cloned repository were not in sync
[email protected]:/mnt/code/shaoyang/aosp_kernel$ ls
build build_slider.sh prebuilts tools
build.config common-modules prebuilts-master update_symbol_list.sh
build_mixed.sh kernel private
[email protected]:/mnt/code/shaoyang/aosp_kernel$ BUILD_KERNEL=1 ./build_slider.sh
Building GKI kernel using aosp/build.config.gki.aarch64...
realpath: /mnt/code/shaoyang/aosp_kernel/aosp/build.config.gki.aarch64: No such file or directory
ERROR: Failed to compile GKI kernel: retval=1
ERROR: Failed to create mixed build: retval=1


there is no aosp folder any more, the older branches you mentioned is ?
 

Mason_lee

Member
Apr 1, 2022
10
0
hey,

try doing this.
Return to the ClockworkMod Recovery main menu. Choose "install zip from sdcard" and press "N." Choose "choose zip from sdcard" and press "N." Scroll through the list of ROMs, updates and kernels located on your SD card. Select the custom kernel you want to flash to the Nook.
 

shaoyang

New member
Apr 14, 2022
4
0
I am trying to build AOSP 12 and kernel and unable to get it working on the Pixel 6.

my AOSP branch is android-12.1.0_r2 and my kernel branch is android-gs-raviole-5.10-android12L.

Pixel 6 works well if only flash the AOSP images I build, however, it won't boot up if I flash the boot.img build with kernel.

Here is my step:

1. mkdir android-kernel && cd android-kernel

2. repo init -u https://android.googlesource.com/kernel/manifest -b android-gs-raviole-5.10-android12L

3. repo sync

4. build/build.sh

I could see the logs below after I build successfully.
--------------------------------------------------------------------------------------------------------------------------
Files copied to /mnt/code/shaoyang/kernel/out/android-gs-pixel-5.10/dist
vendor_ramdisk-oriole.img is LZ4 compressed boot image created at boot.img
Signing the boot.img...
vendor boot image created at /mnt/code/shaoyang/kernel/out/android-gs-pixel-5.10/dist/vendor_boot.img
--------------------------------------------------------------------------------------------------------------------------

Note that the boot.img and vendor_boot.img had already been generated, then I use “fastboot flash boot boot.img” and “fastboot flash vendor_boot vendor_boot.img”to flash the boot.img and vendor_boot.img.

Unfortunately, the Pixel6 couldn’t boot up, it always stay in the fastboot mode.


I am also tried that copy all the files from out/android-gs-pixel-5.10/dist to the folder AOSP/device/google/raviole-kernel/
export TARGET_PREBUILT_KERNEL=out/android-gs-pixel-5.10/dist/Image.lz4
make bootimage

after that I flash the boot.img , Pixel 6 couldn't boot up.

I have compared the good boot.img and the bad boot.img, looks like there is no ramdisk in the bad boot.img .

I have also tried to do the below steps:

Building a Boot Image​

It's possible to build a boot image using the kernel build environment. To do this you need a ramdisk binary, which you can obtain by downloading a GKI boot image and unpacking it. Any GKI boot image from the associated Android release will work.

tools/mkbootimg/unpack_bootimg.py --boot_img=boot-5.4-gz.img
mv tools/mkbootimg/out/ramdisk gki-ramdisk.lz4

The target folder is the top-level directory of the kernel tree (the current working directory).
If you're developing with AOSP master, you can instead download the ramdisk-recovery.img build artifact from an aosp_arm64 build on ci.android.com and use that as your ramdisk binary.
When you have a ramdisk binary and have copied it to gki-ramdisk.lz4 in the root directory of the kernel build, you can generate a boot image by executing:

BUILD_BOOT_IMG=1 SKIP_VENDOR_BOOT=1 KERNEL_BINARY=Image GKI_RAMDISK_PREBUILT_BINARY=gki-ramdisk.lz4 BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
That file is located in the artifact directory $KERNEL_ROOT/out/$KERNEL_VERSION/dist.

The boot image is located at out/<kernel branch>/dist/boot.img.

looks like the boot.img still don't have the ramdisk.
the pixel 6 couldn't boot up after flashed the boot.img
 

shaoyang

New member
Apr 14, 2022
4
0
I had the same issue. I can no more compile it correctly.
They constantly change everything. I even tried to checkout to older branches where I was sure I managed to compile it but still no success. Maybe the sub cloned repository were not in sync
Hi , we don't need to build the whole kernel, just replace the KO file and build your vendor_boot.img and flash it. that will works for your mofiy in kernel source.
 

buzhishishi

New member
Apr 21, 2022
3
0
I am trying to build AOSP 12 and kernel and unable to get it working on the Pixel 6.

my AOSP branch is android-12.1.0_r2 and my kernel branch is android-gs-raviole-5.10-android12L.

Pixel 6 works well if only flash the AOSP images I build, however, it won't boot up if I flash the boot.img build with kernel.

Here is my step:

1. mkdir android-kernel && cd android-kernel

2. repo init -u https://android.googlesource.com/kernel/manifest -b android-gs-raviole-5.10-android12L

3. repo sync

4. build/build.sh

I could see the logs below after I build successfully.
--------------------------------------------------------------------------------------------------------------------------
Files copied to /mnt/code/shaoyang/kernel/out/android-gs-pixel-5.10/dist
vendor_ramdisk-oriole.img is LZ4 compressed boot image created at boot.img
Signing the boot.img...
vendor boot image created at /mnt/code/shaoyang/kernel/out/android-gs-pixel-5.10/dist/vendor_boot.img
--------------------------------------------------------------------------------------------------------------------------

Note that the boot.img and vendor_boot.img had already been generated, then I use “fastboot flash boot boot.img” and “fastboot flash vendor_boot vendor_boot.img”to flash the boot.img and vendor_boot.img.

Unfortunately, the Pixel6 couldn’t boot up, it always stay in the fastboot mode.


I am also tried that copy all the files from out/android-gs-pixel-5.10/dist to the folder AOSP/device/google/raviole-kernel/
export TARGET_PREBUILT_KERNEL=out/android-gs-pixel-5.10/dist/Image.lz4
make bootimage

after that I flash the boot.img , Pixel 6 couldn't boot up.

I have compared the good boot.img and the bad boot.img, looks like there is no ramdisk in the bad boot.img .

I have also tried to do the below steps:

Building a Boot Image​

It's possible to build a boot image using the kernel build environment. To do this you need a ramdisk binary, which you can obtain by downloading a GKI boot image and unpacking it. Any GKI boot image from the associated Android release will work.

tools/mkbootimg/unpack_bootimg.py --boot_img=boot-5.4-gz.img
mv tools/mkbootimg/out/ramdisk gki-ramdisk.lz4

The target folder is the top-level directory of the kernel tree (the current working directory).
If you're developing with AOSP master, you can instead download the ramdisk-recovery.img build artifact from an aosp_arm64 build on ci.android.com and use that as your ramdisk binary.
When you have a ramdisk binary and have copied it to gki-ramdisk.lz4 in the root directory of the kernel build, you can generate a boot image by executing:

BUILD_BOOT_IMG=1 SKIP_VENDOR_BOOT=1 KERNEL_BINARY=Image GKI_RAMDISK_PREBUILT_BINARY=gki-ramdisk.lz4 BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
That file is located in the artifact directory $KERNEL_ROOT/out/$KERNEL_VERSION/dist.

The boot image is located at out/<kernel branch>/dist/boot.img.

looks like the boot.img still don't have the ramdisk.
the pixel 6 couldn't boot up after flashed the boot.img
Hi,I went through the same steps as you,“the Pixel6 couldn’t boot up, it always stay in the fastboot mode.” How to solve and finally successful?
environment:Unbutu 20.04
 
Last edited:

buzhishishi

New member
Apr 21, 2022
3
0
Hello!

I'm trying to compile and run a custom Android kernel on my Pixel 6. I did this multiple times in the past but with Android 12 it seems things have changed.
I'm following the usual "Building Kernels" page https://source.android.com/setup/build/building-kernels?hl=en

In more details these are the commands that I run:



However when I try to boot the boot.img using the "fastboot boot boot.img" command, I get immediately redirected back to the bootloader. I suspect this is due to a bad image file format.

I also tried to compile as follow

where gki-ramdisk.lz4 is the ramdisk extracted from the prebuilt images found here https://developers.google.com/android/images#oriole
With this last setup I get a boot-loop, so at least the boot.img file format seems to be ok.

I think that these issues are related to the new GKI format, however I cannot find any information online on how to compile a custom GKI kernel.
Does any of you know how to build and run custom kernels for the Pixel 6?

Thanks!
Hi,I went through the same steps as you ,I had the same problem as you; How to solve and finally successful? am looking forward to your early reply
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hello!

    I'm trying to compile and run a custom Android kernel on my Pixel 6. I did this multiple times in the past but with Android 12 it seems things have changed.
    I'm following the usual "Building Kernels" page https://source.android.com/setup/build/building-kernels?hl=en

    In more details these are the commands that I run:



    However when I try to boot the boot.img using the "fastboot boot boot.img" command, I get immediately redirected back to the bootloader. I suspect this is due to a bad image file format.

    I also tried to compile as follow

    where gki-ramdisk.lz4 is the ramdisk extracted from the prebuilt images found here https://developers.google.com/android/images#oriole
    With this last setup I get a boot-loop, so at least the boot.img file format seems to be ok.

    I think that these issues are related to the new GKI format, however I cannot find any information online on how to compile a custom GKI kernel.
    Does any of you know how to build and run custom kernels for the Pixel 6?

    Thanks!
    You just need to run build_slider.sh script on the root of the repo you cloned for compile stock source