2

I have a fully functional and previously tested official boot.img for my device.

But when I tried to unpack it and repack it again(with no modifications whatsoever), the kernel fails to start as usual.

I get a "Kernel is not seandroid enforcing" text on the top left of my screen when I try to boot the new kernel and the device seems to be stuck showing the logo.

I'm using the bootimg-tools located here: https://github.com/pbatard/bootimg-tools

Here's how I'm unpacking it:

$ ./unmkbootimg -i stock/boot.img 
kernel written to 'kernel' (11273048 bytes)
ramdisk written to 'ramdisk.cpio.gz' (2856269 bytes)

To rebuild this boot image, you can use the command:
  mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x01000000 --second_offset 0x00f00000 --tags_offset 0x00000100 --cmdline 'console=ttyS1,115200n8' --kernel kernel --ramdisk ramdisk.cpio.gz -o stock/boot.img

I'm using the same exact command in the unpack command to re-pack it:

$ ./mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x01000000 --second_offset 0x00f00000 --tags_offset 0x00000100 --cmdline 'console=ttyS1,115200n8' --kernel kernel --ramdisk ramdisk.cpio.gz -o stock/boot.img

I have no idea whats the issue here, I'm not even sure if this is the correct way to make a zImage bootable.

Any help would be greatly appreciated.

Thank you.

Kratos
  • 61
  • 3
  • 5
  • Its possible that thekernel/ramdisk made boot.img too large (>11.0MB) which will make it fail to boot. Try enabling XZ compression instead of LZMA and that should 3MB off the kernel size and allow the build to fit. Also make sure that you are over writing the image and not just adding onto it. – CecilMerrell aka bringrainfire Aug 14 '19 at 05:09
  • https://www.whitewinterwolf.com/posts/2016/08/11/how-to-unpack-and-edit-android-boot-img/ this site also provides some in depth information about puling the boot.img, modding it, and repacking it, then pushing it back – CecilMerrell aka bringrainfire Aug 14 '19 at 05:15

1 Answers1

3

I needed to use up-to-date tools.

It seems the boot.img file format changed in the past few years.

The working tools are located here: https://github.com/GameTheory-/mktool/tree/master/tools . The .jar tool didn't work for me but the backend tools did :)

* To unpack *

$ ./unpackbootimg -i stock/boot.img -o stockoutdir
BOARD_KERNEL_CMDLINE console=ttyS1,115200n8
BOARD_KERNEL_BASE 00000000
BOARD_NAME 
BOARD_PAGE_SIZE 2048
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 01000000
BOARD_SECOND_OFFSET 00f00000
BOARD_TAGS_OFFSET 00000100
BOARD_DT_SIZE 673792

* To pack again *

$ ./mkbootimg --kernel stockoutdir/boot.img-zImage --ramdisk stockoutdir/boot.img-ramdisk.gz --cmdline "console=ttyS1,115200n8" --base 00000000 --pagesize 2048 --dt stockoutdir/boot.img-dt --kernel_offset 00008000 --ramdisk_offset 01000000 --second_offset 00f00000 --tags_offset 00000100 --hash sha1 -o custom.img

Kratos
  • 61
  • 3
  • 5