chenxiaolong / avbroot

Sign (and root) Android A/B OTAs with custom keys while preserving Android Verified Boot
GNU General Public License v3.0
534 stars 42 forks source link

KernelSU fails to update image_size field in AVB metadata #345

Closed joyX3 closed 2 months ago

joyX3 commented 2 months ago

Telefone: Pixel 7 pro 12/512. Avbroot on ubuntu. LineageOS. Doesn't work. On the pixel I patch with kernelsu init_boot and boot images. Then I sent result to ubuntu. The comand is: ./avbroot ota patch --input lineage.zip --key-avb avb.key --key-ota ota.key --cert-ota ota.crt --prepatched boot.img --replace init_boot init_boot.img --clear-vbmeta-flags

It passed without errors and I get lineage.zip.patched file. From it I make directory extracted. Flash with fastboot all files from extracted directory except system.img. With sideloade I flash lineage.zip.patched. then erase and flash avb_custom_key. All it passed without any errors.

When I lock bootloader and boot, I get something like this: there is no bootable image. If I maintain bootloader unlock I can boot os. But it has no root. But if I flash boot.img and init_boot.img exactly which I get after patching them with kernelsu (before sending them to avbroot) I get kernelsu lkm rooted os.

I did this about 20 times with different OS and changing the sequence of actions with the same result

chenxiaolong commented 2 months ago

Can you please rerun that with --log-level trace and post the output here? And if you could upload the boot and init_boot files you get from patching with KernelSU, that would be great too.

joyX3 commented 2 months ago
~/lineage# ./avbroot ota patch --input lineage-21.0-20240820-nightly-cheetah-signed.zip --key-avb avb.key --key-ota ota.key --cert-ota ota.crt --prepatched boot_ptch.img --replace init_boot init_boot_ptch.img --clear-vbmeta-flags Enter passphrase for "avb.key": Enter passphrase for "ota.key": 11.811s INFO Replacing zip entry: META-INF/com/android/otacert 11.811s INFO Copying zip entry: apex_info.pb 11.811s INFO Copying zip entry: care_map.pb 11 root@vps2798674:~/lineage# ./avbroot ota patch --input lineage-21.0-20240820-nightly-cheetah-signed.zip --key-avb avb.key --key-ota ota.key --cert-ota ota.crt --prepatched boot_ptch.img --replace init_boot Init_boot_ptch.img --clear-vbmeta-flags --log-level trace 0.000s DEBUG cli=Cli { command: Ota(OtaCli { command: Patch(PatchCli { input: "lineage-21.0-20240820-nightly-cheetah-signed.zip", output: None, key_avb: "avb.key", key_ota: "ota.key", cert_ota: "ota.crt", pass_avb_env_var: None, pass_avb_file: None, pass_ota_env_var: None, pass_ota_file: None, signing_helper: None, replace: ["init_boot", "Init_boot_ptch.img"], root: RootGroup { magisk: None, prepatched: Some("boot_ptch.img"), rootless: false }, magisk_preinit_device: None, magisk_random_seed: None, ignore_magisk_warnings: false, ignore_prepatched_compat: 0, dsu: false, clear_vbmeta_flags: true, boot_partition: None }) }), log_level: Level(Trace), log_format: Short } Enter passphrase for "avb.key": Enter passphrase for "ota.key": 7.983s INFO zip{entry="META-INF/com/android/otacert"}: Replacing zip entry: META-INF/com/android/otacert 7.983s INFO zip{entry="apex_info.pb"}: Copying zip entry: apex_info.pb 7.983s INFO zip{entry="care_map.pb"}: Copying zip entry: care_map.pb 7.983s INFO zip{entry="payload.bin"}: Patching zip entry: payload.bin 7.984s INFO zip{entry="payload.bin"}:image{name="vbmeta_vendor"}: Extracting from original payload: vbmeta_vendor 7.985s INFO zip{entry="payload.bin"}:image{name="vbmeta_system"}: Extracting from original payload: vbmeta_system 7.985s INFO zip{entry="payload.bin"}:image{name="system"}: Extracting from original payload: system 21.843s INFO zip{entry="payload.bin"}:image{name="vendor_boot"}: Extracting from original payload: vendor_boot 23.633s INFO zip{entry="payload.bin"}:image{name="boot"}: Extracting from original payload: boot 25.160s INFO zip{entry="payload.bin"}:image{name="vbmeta"}: Extracting from original payload: vbmeta 25.160s INFO zip{entry="payload.bin"}:image{name="init_boot"}: Opening external image: init_boot: "Init_boot_ptch.img" 25.160s INFO zip{entry="payload.bin"}: Patching boot images: boot, init_boot, vendor_boot 25.392s TRACE zip{entry="payload.bin"}:image{name="boot"}: Loaded 67108864 byte boot image: boot 25.456s TRACE zip{entry="payload.bin"}:image{name="vendor_boot"}: Loaded 67108864 byte boot image: vendor_boot 25.717s TRACE zip{entry="payload.bin"}:image{name="init_boot"}: Loaded 8388608 byte boot image: init_boot 25.963s TRACE zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Loaded Lz4Legacy ramdisk with 476 entries 25.972s TRACE zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Loaded Lz4Legacy ramdisk with 30 entries 25.973s DEBUG zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Found patcher targets: ["vendor_boot"] 28.756s DEBUG zip{entry="payload.bin"}:patcher{name="PrepatchedImagePatcher"}: Found patcher targets: ["boot"] 28.757s DEBUG zip{entry="payload.bin"}: All patcher targets: [["vendor_boot"], ["boot"]] 28.757s TRACE zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Generated new 1887 byte otacerts.zip 28.855s TRACE zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Loaded Lz4Legacy ramdisk with 476 entries 29.078s TRACE zip{entry="payload.bin"}:patcher{name="OtaCertPatcher"}: Wrote Lz4Legacy ramdisk with 476 entries 29.480s DEBUG zip{entry="payload.bin"}:image{name="boot"}: Signing boot image 29.510s INFO zip{entry="payload.bin"}:image{name="system"}: Patching system image: system 29.510s TRACE zip{entry="payload.bin"}:image{name="system"}: Parallel heuristics search for otacerts.zip with 546 chunks 29.529s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=589299712 eocd_offset_rel=1514256}: Found zip bounds: 1490944..1514278 29.529s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=589299712 eocd_offset_rel=1514256}: Excluded due to invalid name: "classes.dex" 29.529s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=589299712 eocd_offset_rel=2088199}: Found zip bounds: 1523712..2088221 29.529s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=589299712 eocd_offset_rel=2088199}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=22932}: Found zip bounds: 8192..22954 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=22932}: Excluded due to invalid name: "classes.dex" 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=34396}: Found zip bounds: 32768..34418 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=34396}: Excluded due to invalid name: "classes.dex" 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=50160}: Found zip bounds: 40960..50182 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=50160}: Excluded due to invalid name: "classes.dex" 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=170916}: Found zip bounds: 61440..170938 29.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=591396864 eocd_offset_rel=170916}: Excluded due to invalid name: "classes.dex" 29.551s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=12582912 eocd_offset_rel=1982792}: Found zip bounds: 1974272..1982814 29.561s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=12582912 eocd_offset_rel=1982792}: Excluded due to invalid name: "resources.arsc" 29.561s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=12582912 eocd_offset_rel=2037860}: Found zip bounds: 1880064..2037882 29.564s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=14680064 eocd_offset_rel=1630737}: Found zip bounds: 49152..1630759 29.570s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=14680064 eocd_offset_rel=1630737}: Excluded due to invalid name: "AndroidManifest.xml" 29.567s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=633339904 eocd_offset_rel=1603892}: Found zip bounds: 1150976..1603914 29.570s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=633339904 eocd_offset_rel=1603892}: Excluded due to invalid name: "classes.dex" 29.570s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=633339904 eocd_offset_rel=1902836}: Found zip bounds: 1622016..1902858 29.570s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=633339904 eocd_offset_rel=1902836}: Excluded due to invalid name: "resources.arsc" 29.572s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=635437056 eocd_offset_rel=340756}: Found zip bounds: 327680..340778 29.572s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=635437056 eocd_offset_rel=340756}: Excluded due to invalid name: "classes.dex" 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=788572}: Found zip bounds: 778240..788594 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=788572}: Excluded due to invalid name: "classes.dex" 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=813244}: Found zip bounds: 798720..813266 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=813244}: Excluded due to invalid name: "classes.dex" 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=841340}: Found zip bounds: 823296..841362 29.594s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=656408576 eocd_offset_rel=841340}: Excluded due to invalid name: "classes.dex" 29.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=660602880 eocd_offset_rel=1796764}: Found zip bounds: 1417216..1796786 29.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=660602880 eocd_offset_rel=1796764}: Excluded due to invalid name: "classes.dex" 29.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=660602880 eocd_offset_rel=1853376}: Found zip bounds: 1806336..1853398 29.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=660602880 eocd_offset_rel=1853376}: Excluded due to invalid name: "classes.dex" 29.611s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=662700032 eocd_offset_rel=553160}: Found zip bounds: 548864..553182 29.611s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=662700032 eocd_offset_rel=553160}: Excluded due to invalid name: "classes.dex" 29.632s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=41943040 eocd_offset_rel=2010704}: Found zip bounds: 909312..2010726 29.632s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=41943040 eocd_offset_rel=2010704}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 29.675s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=62914560 eocd_offset_rel=1974803}: Found zip bounds: 1716224..1974825 29.676s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=62914560 eocd_offset_rel=1974803}: Excluded due to invalid name: "AndroidManifest.xml" 29.708s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=67108864 eocd_offset_rel=684795}: Found zip bounds: 655360..684817 29.708s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=67108864 eocd_offset_rel=684795}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 29.708s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=67108864 eocd_offset_rel=764864}: Found zip bounds: 688128..764886 29.708s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=67108864 eocd_offset_rel=764864}: Excluded due to invalid name: "classes.dex" 30.073s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=81788928 eocd_offset_rel=1741192}: Found zip bounds: 1720320..1741214 30.073s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=81788928 eocd_offset_rel=1741192}: Excluded due to invalid name: "classes.dex" 30.121s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=83886080 eocd_offset_rel=640528}: Found zip bounds: 249856..640550 30.121s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=83886080 eocd_offset_rel=640528}: Excluded due to invalid name: "classes.dex" 31.115s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=136314880 eocd_offset_rel=729618}: Found zip bounds: 352256..729640 31.115s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=136314880 eocd_offset_rel=729618}: Excluded due to invalid name: "AndroidManifest.xml" 31.402s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=176160768 eocd_offset_rel=586227}: Found zip bounds: 491520..586249 31.402s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=176160768 eocd_offset_rel=586227}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.403s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=176160768 eocd_offset_rel=630172}: Found zip bounds: 589824..630194 31.403s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=176160768 eocd_offset_rel=630172}: Excluded due to invalid name: "classes.dex" 31.448s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=186646528 eocd_offset_rel=870048}: Found zip bounds: 839680..870070 31.448s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=186646528 eocd_offset_rel=870048}: Excluded due to invalid name: "classes.dex" 31.449s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=186646528 eocd_offset_rel=2020234}: Found zip bounds: 880640..2020256 31.449s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=186646528 eocd_offset_rel=2020234}: Excluded due to invalid name: "META-INF/androidx.annotation_annotation-experimental.version" 31.503s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=199229440 eocd_offset_rel=623127}: Found zip bounds: 520192..623149 31.503s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=199229440 eocd_offset_rel=623127}: Excluded due to invalid name: "AndroidManifest.xml" 31.503s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=199229440 eocd_offset_rel=1354807}: Found zip bounds: 1347584..1354829 31.503s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=199229440 eocd_offset_rel=1354807}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.503s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=199229440 eocd_offset_rel=1502385}: Found zip bounds: 598016..1503232 31.531s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=213909504 eocd_offset_rel=524628}: Found zip bounds: 471040..524650 31.532s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=213909504 eocd_offset_rel=541000}: Found zip bounds: 532480..541022 31.532s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=213909504 eocd_offset_rel=541000}: Excluded due to invalid name: "resources.arsc" 31.597s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1049119}: Found zip bounds: 806912..1049141 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1049119}: Excluded due to invalid name: "classes.dex" 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1119343}: Found zip bounds: 1056768..1119365 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1119343}: Excluded due to invalid name: "classes.dex" 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1627497}: Found zip bounds: 1126400..1627519 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1627497}: Excluded due to invalid name: "classes.dex" 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1967071}: Found zip bounds: 1642496..1967093 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=1967071}: Excluded due to invalid name: "classes.dex" 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=2007774}: Found zip bounds: 1974272..2007796 31.598s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=968884224 eocd_offset_rel=2007774}: Excluded due to invalid name: "classes.dex" 31.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=970981376 eocd_offset_rel=1647737}: Found zip bounds: 876544..1647759 31.599s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=970981376 eocd_offset_rel=1647737}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1282868}: Found zip bounds: 753664..1282890 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1282868}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1503975}: Found zip bounds: 1290240..1503997 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1503975}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1667557}: Found zip bounds: 1511424..1667579 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1667557}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1704328}: Found zip bounds: 1675264..1704350 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1704328}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1769864}: Found zip bounds: 1712128..1769886 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1769864}: Excluded due to invalid name: "classes.dex" 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1810824}: Found zip bounds: 1777664..1810846 31.604s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=985661440 eocd_offset_rel=1810824}: Excluded due to invalid name: "classes.dex" 31.614s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=996147200 eocd_offset_rel=98696}: Found zip bounds: 73728..98718 31.614s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=996147200 eocd_offset_rel=98696}: Excluded due to invalid name: "classes.dex" 31.616s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1002438656 eocd_offset_rel=476960}: Found zip bounds: 167936..476982 31.616s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1002438656 eocd_offset_rel=476960}: Excluded due to invalid name: "classes.dex" 31.616s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1002438656 eocd_offset_rel=1712755}: Found zip bounds: 483328..1712777 31.616s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1002438656 eocd_offset_rel=1712755}: Excluded due to invalid name: "META-INF/services/kotlinx.coroutines.CoroutineExceptionHandler" 31.618s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1008730112 eocd_offset_rel=263044}: Found zip bounds: 167936..263066 31.618s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1008730112 eocd_offset_rel=263044}: Excluded due to invalid name: "classes.dex" 31.619s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1010827264 eocd_offset_rel=1790344}: Found zip bounds: 1769472..1790366 31.619s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1010827264 eocd_offset_rel=1790344}: Excluded due to invalid name: "classes.dex" 31.620s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1012924416 eocd_offset_rel=1155464}: Found zip bounds: 1138688..1155486 31.620s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1012924416 eocd_offset_rel=1155464}: Excluded due to invalid name: "classes.dex" 31.620s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1012924416 eocd_offset_rel=1686940}: Found zip bounds: 1163264..1686962 31.620s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1012924416 eocd_offset_rel=1686940}: Excluded due to invalid name: "META-INF/services/kotlinx.coroutines.CoroutineExceptionHandler" 31.621s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1017118720 eocd_offset_rel=1104677}: Found zip bounds: 540672..1104699 31.621s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1017118720 eocd_offset_rel=1104677}: Excluded due to invalid name: "META-INF/androidx.activity_activity.version" 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=906167}: Found zip bounds: 479232..906189 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=906167}: Excluded due to invalid name: "classes.dex" 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=950664}: Found zip bounds: 913408..950686 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=950664}: Excluded due to invalid name: "classes.dex" 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=1131182}: Found zip bounds: 958464..1131204 31.633s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=1042284544 eocd_offset_rel=1131182}: Excluded due to invalid name: "classes.dex" 31.650s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=289406976 eocd_offset_rel=853083}: Found zip bounds: 765952..853105 31.650s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=289406976 eocd_offset_rel=853083}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1164397}: Found zip bounds: 978944..1164419 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1164397}: Excluded due to invalid name: "res/drawable-hdpi-v4/preview.png" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1192321}: Found zip bounds: 1171456..1192343 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1192321}: Excluded due to invalid name: "resources.arsc" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1217239}: Found zip bounds: 1200128..1217261 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1217239}: Excluded due to invalid name: "resources.arsc" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1257857}: Found zip bounds: 1224704..1257879 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1257857}: Excluded due to invalid name: "resources.arsc" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1762892}: Found zip bounds: 1265664..1762914 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1762892}: Excluded due to invalid name: "META-INF/androidx.annotation_annotation-experimental.version" 31.655s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1950657}: Found zip bounds: 1769472..1950679 31.656s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=293601280 eocd_offset_rel=1950657}: Excluded due to invalid name: "assets/quantum_ic_warning_amber_96.png" 31.658s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=295698432 eocd_offset_rel=2048816}: Found zip bounds: 401408..2048838 31.658s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=295698432 eocd_offset_rel=2048816}: Excluded due to invalid name: "META-INF/services/kotlinx.coroutines.CoroutineExceptionHandler" 31.661s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=297795584 eocd_offset_rel=971137}: Found zip bounds: 958464..971159 31.661s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=297795584 eocd_offset_rel=971137}: Excluded due to invalid name: "resources.arsc" 31.661s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=297795584 eocd_offset_rel=1004039}: Found zip bounds: 978944..1004061 31.661s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=297795584 eocd_offset_rel=1004039}: Excluded due to invalid name: "resources.arsc" 31.669s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=790913}: Found zip bounds: 778240..790935 31.669s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=790913}: Excluded due to invalid name: "resources.arsc" 31.669s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=815489}: Found zip bounds: 798720..815511 31.669s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=815489}: Excluded due to invalid name: "resources.arsc" 31.669s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1014982}: Found zip bounds: 823296..1015004 31.670s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1014982}: Excluded due to invalid name: "META-INF/androidx.annotation_annotation-experimental.version" 31.670s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1725678}: Found zip bounds: 1019904..1725700 31.670s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1725678}: Excluded due to invalid name: "res/drawable-hdpi-v4/ic_menu_savetopdf.png" 31.670s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1823105}: Found zip bounds: 1740800..1823127 31.670s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=306184192 eocd_offset_rel=1823105}: Excluded due to invalid name: "resources.arsc" 31.674s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=310378496 eocd_offset_rel=319880}: Found zip bounds: 290816..319902 31.674s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=310378496 eocd_offset_rel=319880}: Excluded due to invalid name: "classes.dex" 31.716s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=463470592 eocd_offset_rel=1609956}: Found zip bounds: 1605632..1609978 31.716s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=463470592 eocd_offset_rel=1609956}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=52728}: Found zip bounds: 40960..52750 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=52728}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=88792}: Found zip bounds: 61440..88814 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=88792}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=129604}: Found zip bounds: 98304..129626 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=129604}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=198988}: Found zip bounds: 139264..199010 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=198988}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=305544}: Found zip bounds: 208896..305566 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=305544}: Excluded due to invalid name: "classes.dex" 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=320944}: Found zip bounds: 315392..320966 31.717s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=465567744 eocd_offset_rel=320944}: Excluded due to invalid name: "classes.dex" 31.740s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=507510784 eocd_offset_rel=1658688}: Found zip bounds: 1626112..1658710 31.740s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=507510784 eocd_offset_rel=1658688}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=834076}: Found zip bounds: 827392..834098 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=834076}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=849116}: Found zip bounds: 843776..849138 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=849116}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=887880}: Found zip bounds: 860160..887902 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=887880}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=906404}: Found zip bounds: 897024..906426 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=906404}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=920360}: Found zip bounds: 917504..920382 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=920360}: Excluded due to invalid name: "classes.dex" 31.741s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=934536}: Found zip bounds: 925696..934558 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=934536}: Excluded due to invalid name: "classes.dex" 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=965208}: Found zip bounds: 946176..965230 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=509607936 eocd_offset_rel=965208}: Excluded due to invalid name: "classes.dex" 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1248823}: Found zip bounds: 1245184..1248845 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1248823}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1605135}: Found zip bounds: 1253376..1605157 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1605135}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1810411}: Found zip bounds: 1613824..1810689 31.742s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=511705088 eocd_offset_rel=1810411}: Excluded due to invalid name: "META-INF/MANIFEST.MF" 31.743s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1221006}: Found zip bounds: 1200128..1221028 31.743s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1221006}: Excluded due to invalid name: "resources.arsc" 31.743s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1234410}: Found zip bounds: 1232896..1234432 31.743s DEBUG zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1234410}: Found otacerts.zip candidate 31.743s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1234410}: Attempting to create 1536 byte otacerts.zip: OtaCertBuildFlags(0x0) 31.744s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1234410}: Attempting to create 1536 byte otacerts.zip: OtaCertBuildFlags(COMPRESS_DEFLATE) 31.744s TRACE zip{entry="payload.bin"}:image{name="system"}:otacerts{offset=375390208 eocd_offset_rel=1234410}: Padding 1456 byte otacerts.zip to 1536 41.226s INFO zip{entry="payload.bin"}:image{name="system"}: Patched otacerts.zip offsets in system: [376623104..376624640] 41.228s INFO zip{entry="payload.bin"}: Patching vbmeta images: vbmeta_system, vbmeta_vendor, vbmeta 41.297s INFO zip{entry="payload.bin"}:image{name="system"}: Compressing partial image: system: [376623104..376624640, 1144573952..1162724160, 1163014080..1163014144] 48.193s INFO zip{entry="payload.bin"}:image{name="vendor_boot"}: Compressing full image: vendor_boot 51.020s INFO zip{entry="payload.bin"}:image{name="vbmeta_system"}: Compressing full image: vbmeta_system 51.022s INFO zip{entry="payload.bin"}:image{name="init_boot"}: Compressing full image: init_boot 52.304s INFO zip{entry="payload.bin"}:image{name="boot"}: Compressing full image: boot 55.287s INFO zip{entry="payload.bin"}:image{name="vbmeta"}: Compressing full image: vbmeta 55.289s INFO zip{entry="payload.bin"}: Generating new OTA payload 120.558s INFO zip{entry="payload_properties.txt"}: Patching zip entry: payload_properties.txt 120.559s INFO Generating new OTA metadata 120.578s INFO Verifying metadata offsets 120.581s INFO Successfully patched OTA
joyX3 commented 2 months ago

Init_boot_ptch.txt txt->img

joyX3 commented 2 months ago

[Uploading boot_ptch.img.zip…]()

joyX3 commented 2 months ago

[Uploading boot_ptch.img.zip…]()

chenxiaolong commented 2 months ago

Thanks for uploading init_boot. (The boot image didn't upload successfully, but I assume it has the same problem as init_boot.)

The problem is that KernelSU's patching process fails to update the fields properly in the AVB footer:

Original LineageOS image:

❯ avbroot avb info -i extracted/init_boot.img
...
                HashDescriptor {
                    image_size: 2670592,
...
        Footer {
            original_image_size: 2670592,

KernelSU patched image:

❯ avbroot avb info -i Init_boot_ptch.txt
...
                HashDescriptor {
                    image_size: 2670592,
                                ^^^^^^^
                   # KernelSU fails to update this
...
        Footer {
            original_image_size: 3002368,
                                 ^^^^^^^
                   # KernelSU updates this properly

So when you boot, the checksum does not match because the incorrect size is telling the bootloader to only verify a part of the image instead of the whole image. That's why you get the no bootable image error.


This is a KernelSU bug, but you can work around it by manually using avbroot to update the AVB fields instead of KernelSU:

  1. Extract the AVB metadata:

    avbroot avb unpack -i init_boot.img

    This will split the file into avb.toml and raw.img. raw.img no longer contains AVB metadata so KernelSU can't mess it up.

  2. Patch raw.img with KernelSU.

  3. Replace raw.img with the patched file.

  4. Create init_boot_ptch.img:

    avbroot avb pack -o init_boot_ptch.img
  5. (Repeat with boot.img)

joyX3 commented 2 months ago

Thx, I will try. IMHO u and kernelsu people have to work together.

joyX3 commented 2 months ago

After this command: avbroot avb pack -o init_boot_ptch.img I get this error: ERROR Need to sign new AVB header, but no private key was specified

Patching get error ERROR Failed to patch OTA zip

Caused by: 0: Failed to patch payload: payload.bin 1: Failed to patch boot images: boot, init_boot, vendor_boot 2: AVB error 3: Invalid VBMeta header magic: [65, 78, 68, 82]

Which key I have to use?

joyX3 commented 2 months ago

I used command avbroot avb pack --output boot_patched.img --key avb.key

Thank u very much without ur it would be impossible

chenxiaolong commented 2 months ago

I used command avbroot avb pack --output boot_patched.img --key avb.key

Thank u very much without ur it would be impossible

Glad you got it working! Yep, that's the right way to do it.