0

I'm trying to modify the kernel of a Pixel 4a 5g phone. For that, I've downloaded the stock boot.img from https://developers.google.com/android/images. I've also got a kernel src code (https://android.googlesource.com/kernel/common/+/refs/heads/android-4.19-stable) and compiled it. It results into an Image and Image.gz files.

In my understanding, I have to unpack the boot.img file, replace the kernel it contains with my Image.gz and pack it. Using unmkbootimg, I get zImage and initramfs.cpio.gz but I think they are corrupted. Below is what I get:

unmkbootimg version 1.2 - Mikael Q Kuisma <kuisma@ping.se>
Kernel size 11562794
Kernel address 0xd7719f
Ramdisk size 369099082
Ramdisk address 0x62c
Secondary size 0
Secondary address 0x0
Kernel tags address 0x0
Flash page size 0
Board name is ""
Command line ""

*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_KERNEL_ADDR is 0x00D7729F
OFF_RAMDISK_ADDR is 0x0000072C
OFF_SECOND_ADDR is 0x00000100
Please modify mkbootimg.c using the above values to build your image.
****************

Extracting kernel to file zImage ...
Extracting root filesystem to file initramfs.cpio.gz ...
%Premature end-of-file saving initramfs.cpio.gz.

Can somebody tell me a good and easy way of doing this?

jorge
  • 45
  • 5
  • You have to dive into understanding boot header and how `mkbootimg` works (it is all easy part). Then you will get answers not only for the above question, but also for some further you will definitely have. – 0andriy Dec 25 '20 at 13:55

1 Answers1

0

This github repo is exactly what you need: https://github.com/cfig/Android_boot_image_editor

Main steps:

  1. extract the stock boot.img
cp <original_boot_image> boot.img
./gradlew unpack
  1. replace the kernel with your locally built one, and then
  2. repack boot.img
./gradlew pack

Cheers!

cfig
  • 31
  • 1