lineage-18.1(Android 11)からboot.imgの仕様が変わっているらしい。
従来boot.imgにはヘッダーの箇所にはANDORID!の文字列、マジックと呼ばれるものから
カーネルやramdiskなどのアドレスなど最小限のものしか入っていなかったが、
11からバージョンやセキュリティの日付が入るようになったらしい。
https://source.android.com/docs/core/architecture/bootloader/boot-image-header?hl=ja
boot.imgのヘッダーはバージョンが0,1,2,3,4と変更されてつづけており、 とうとう11では従来のboot.imgの加工ツールが使えなくなっている。
boot.imgのヘッダーバージョン
・バージョン0:Android 8以前
・バージョン1:Android 9
・バージョン2:Android 10
・バージョン3:Android 11
バージョン2まではヘッダーはサイズが拡張されて続けており、 内容の羅列も同じなので強引に従来のboot.imgの加工ツールが使える
しかし11以降は、新ツールで再作成が必要になってくる
新ツールのダウンロード
$ git clone -b lineage-18.1 https://github.com/LineageOS/android_system_tools_mkbootimg.git $ git clone https://github.com/osm0sis/bootimg-info.git
カーネルのビルド
$ cd jf $ make VARIANT_DEFCONFIG=jf_dcm_defconfig lineageos_jf_defconfig $ make -j4
カーネルのロードモジュールのインストール
$ mkdir ../modules $ export INSTALL_MOD_PATH=$PWD/../modules $ make modules_install $ cd ../modules $ find . -name '*.ko' -exec mv {} . \; $ find . -name 'modules.alias' -exec mv {} . \; $ find . -name 'modules.dep' -exec mv {} . \; $ find . -name 'modules.softdep' -exec mv {} . \; $ rm -rf lib $ tar cfv ../modules.tar *.ko modules.* $ cd ..
差し替えるboot.imgの情報取得
$ ~/bootimg-info/bootimg-info boot.img Android Boot Image Info Utility Printing information for "boot.img" Header: magic : ANDROID! kernel_size : 4384264 (0042e608) kernel_addr : 0x80208000 ramdisk_size : 665444 (000a2764) ramdisk_addr : 0x82200000 second_size : 0 (00000000) second_addr : 0x00000000 tags_addr : 0x80200100 page_size : 2048 (00000800) header_version : 0 (00000000) os_version : 11.0.0 (1600016a) (os_patch_level) : 2022-10 name : cmdline : androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 buildvariant=userdebug id : 33e2e7d6de691762a64017cc3c48b1c0208e2fc1000000000000000000000000 extra_cmdline : Other: magic offset : 0x00000000 base address : 0x80200000 kernel offset : 0x00008000 ramdisk offset : 0x02000000 second offset : 0x7fe00000 tags offset : 0x00000100
jfltexxのboot.imgのバージョンは0らしい。Android8と同じ。
boot.imgの展開 $ mkdir boot $ cd android_system_tools_mkbootimg $ ./unpack_bootimg.py --boot_img ../boot.img --out ../boot boot_magic: ANDROID! kernel_size: 4384264 kernel load address: 0x80208000 ramdisk size: 665444 ramdisk load address: 0x82200000 second bootloader size: 0 second bootloader load address: 0x0 kernel tags load address: 0x80200100 page size: 2048 os version: 11.0.0 os patch level: 2022-10 boot image header version: 0 product name: command line args: androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 buildvariant=userdebug additional command line args: $ cd ..
boot配下にkernelとramdiskファイルが生成される
差し替え
$ cp jf/arch/arm/boot/zImage boot/kernel
再作成
$ cd android_system_tools_mkbootimg $ chmod +x mkbootimg.py $ ./mkbootimg.py \ --kernel ../boot/kernel \ --ramdisk ../boot/ramdisk \ --cmdline 'androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 buildvariant=userdebug' \ --base 0x80200000 \ --ramdisk_offset 0x02000000 \ --os_version '11.0.0' \ --os_patch_level '2022-10' \ -o ../boot.img.new
出来たboot.img.newをboot.imgにして元のzipに入れるだけである。