cfig / Android_boot_image_editor

Parsing and re-packing Android boot.img/vbmeta.img/payload.bin, supporting Android 15
Apache License 2.0
1.06k stars 234 forks source link

Repacking boot + vbmeta error. #118

Closed bmb7 closed 1 year ago

bmb7 commented 1 year ago

root:Android_boot_image_editor/ (master✗) # ./gradlew pack [16:52:54]

Task :helper:compileKotlin UP-TO-DATE Task :helper:compileJava NO-SOURCE Task :bbootimg:compileKotlin UP-TO-DATE Task :bbootimg:compileJava UP-TO-DATE Task :bbootimg:processResources UP-TO-DATE Task :bbootimg:classes UP-TO-DATE Task :helper:processResources UP-TO-DATE Task :helper:classes UP-TO-DATE Task :helper:jar UP-TO-DATE Task :helper:inspectClassesForKotlinIC UP-TO-DATE Task :bbootimg:jar UP-TO-DATE Task :bbootimg:inspectClassesForKotlinIC UP-TO-DATE Task :aosp:boot_signer:compileJava UP-TO-DATE Task :aosp:boot_signer:processResources NO-SOURCE Task :aosp:boot_signer:classes UP-TO-DATE Task :aosp:boot_signer:jar Task :aosp:boot_signer:assemble Task :aosp:boot_signer:compileTestJava NO-SOURCE Task :aosp:boot_signer:processTestResources NO-SOURCE Task :aosp:boot_signer:testClasses UP-TO-DATE Task :aosp:boot_signer:test NO-SOURCE Task :aosp:boot_signer:check UP-TO-DATE Task :aosp:boot_signer:fatJar Task :aosp:boot_signer:build

Task :pack 16:53:35.522 [main] WARN cfig.packable.PackableLauncher - [boot.img] will be handled by [BootImgParser] 16:53:36.035 [main] WARN cfig.packable.PackableLauncher - 'pack' sequence initialized 16:53:36.048 [main] INFO cfig.packable.BootImgParser - Loading config from build/unzip_boot/boot.json 16:53:37.152 [main] INFO cfig.bootimg.Common - Deleting build/unzip_boot/ramdisk.img.gz ... 16:53:37.156 [main] INFO cfig.bootimg.Common - Deleting build/unzip_boot/ramdisk.img ... 16:53:37.161 [main] INFO cfig.bootimg.Common - Packing rootfs build/unzip_boot/root ... 16:53:37.268 [main] INFO cfig.bootimg.cpio.AndroidCpio - loading build/unzip_boot/ramdisk.img_filelist.txt 16:53:38.080 [main] INFO ZipHelper - compress(gz) done: build/unzip_boot/ramdisk.img.gz 16:53:38.081 [main] INFO cfig.bootimg.Common - build/unzip_boot/ramdisk.img.gz is ready 16:53:38.935 [main] INFO cfig.bootimg.v2.BootV2 - Writing data ... 16:53:39.627 [main] INFO cfig.bootimg.v2.BootV2 - [aosp/system/tools/mkbootimg/mkbootimg.py, --header_version, 2, --base, 0x0, --kernel, build/unzip_boot/kernel, --kernel_offset, 0x40008000, --ramdisk, build/unzip_boot/ramdisk.img.gz, --ramdisk_offset, 0x55000000, --dtb, build/unzip_boot/dtb, --dtb_offset, 0x54000000, --pagesize, 2048, --cmdline, bootopt=64S3,32N2,32N2 buildvariant=user, --os_version, 10.0.0, --os_patch_level, 2021-07-00, --tags_offset, 0x54000000, --id, --output, boot.img.google] 0x8b250571e86030f9526d79ee0d5102d7ee28f4e1000000000000000000000000 16:53:41.581 [main] INFO Helper - boot.img.clear hash e182f795c1574bbf031d940165fd02279c6f2141, boot.img.google hash e182f795c1574bbf031d940165fd02279c6f2141 16:53:41.582 [main] INFO Helper - Hash verification passed: e182f795c1574bbf031d940165fd02279c6f2141 16:53:41.586 [main] INFO cfig.bootimg.Signer - Adding hash_footer with verified-boot 2.0 style 16:53:42.040 [main] INFO cfig.Avb - addHashFooter(boot.img.signed) ... 16:53:42.059 [main] INFO cfig.Avb - max_image_size: 33484800 16:53:42.072 [main] INFO cfig.Avb - original image boot.img.signed doesn't have AVB footer 16:53:42.101 [main] INFO avb.desc.HashDescriptor - preset salt[32] is valid: 9bb937ee032e7d01be7c5b0f75eb4a6f631e3e153273e4929cc9687c341a70cc 16:53:42.102 [main] INFO avb.desc.HashDescriptor - flag: use_ab = 1 16:53:42.672 [main] INFO avb.desc.HashDescriptor - Digest(salt + file): 2911dbf083f94e283b48f12493751f847436f0dd45fe16b8276521a064d3c314 16:53:42.675 [main] INFO cfig.Avb - updated hash descriptor:000000000000000200000000000000b8000000000097c800736861323536000000000000000000000000000000000000000000000000000000000004000000200000002000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000626f6f749bb937ee032e7d01be7c5b0f75eb4a6f631e3e153273e4929cc9687c341a70cc2911dbf083f94e283b48f12493751f847436f0dd45fe16b8276521a064d3c314 16:53:42.941 [main] WARN avb.blob.AuxBlob - Using different key from original vbmeta 16:53:42.942 [main] INFO avb.blob.AuxBlob - no pubkey metadata in auxBlob 16:53:43.962 [main] WARN avb.blob.AuxBlob - Using different key from original vbmeta 16:53:43.963 [main] INFO avb.blob.AuxBlob - no pubkey metadata in auxBlob 16:53:44.261 [main] INFO cfig.Avb - Footer(versionMajor=1, versionMinor=0, originalImageSize=9947136, vbMetaOffset=9949184, vbMetaSize=1472) 16:53:44.266 [main] INFO cfig.Avb - 1/4 Padding image with 2048 bytes ... 16:53:44.276 [main] INFO cfig.Avb - 2/4 Appending vbmeta (4096 bytes)... 16:53:44.277 [main] INFO cfig.Avb - 3/4 Appending DONT CARE CHUNK (23597056 bytes) ... 16:53:44.520 [main] INFO cfig.Avb - 4/4 Appending AVB footer (4096 bytes)... 16:53:44.524 [main] INFO cfig.Avb - addHashFooter(boot.img.signed) done. 16:53:44.541 [main] INFO cfig.bootimg.Signer - [aosp/avb/avbtool.v1.2.py, add_hash_footer, --image, boot.img.signed2, --flags, 2, --partition_size, 33554432, --salt, 9bb937ee032e7d01be7c5b0f75eb4a6f631e3e153273e4929cc9687c341a70cc, --partition_name, boot, --hash_algorithm, sha256, --algorithm, SHA256_RSA2048, --rollback_index, 0, --key, aosp/avb/data/testkey_rsa2048.pem, --prop, com.android.build.boot.os_version:10, --prop, com.android.build.boot.security_patch:2019-06-06, --internal_release_string, avbtool 1.1.0] 16:53:48.551 [main] INFO Helper - boot.img.signed hash 66d3d5f4eb2abe013ac4ee46d98854aaf3478a21, boot.img.signed2 hash f486216f988dd828dd746bc37210804a7b6c66c5 16:53:48.551 [main] ERROR Helper - Hash verification failed Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108) at cfig.packable.PackableLauncherKt.main(PackableLauncher.kt:108) Caused by: java.lang.UnknownError: Do not know why hash verification fails, maybe a bug at cfig.helper.Helper$Companion.assertFileEquals(Helper.kt:336) at cfig.bootimg.Signer$Companion.signAVB(Signer.kt:72) at cfig.bootimg.v2.BootV2.sign(BootV2.kt:556) at cfig.packable.BootImgParser.pack(BootImgParser.kt:87) ... 8 more

Task :pack FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 44s 13 actionable tasks: 3 executed, 10 up-to-date root:Android_boot_image_editor/ (master✗) # la [16:53:51]

cfig commented 1 year ago

Can you attach your "boot.img" here? Also publishing the building process result will also be helpful to check further, it can be done by "./gradlew unpack --scan" Thanks

bmb7 commented 1 year ago

boot+vbmeta.zip Here it is. Actually it is my fault, i changed all occurrences of "flags" : 0" on auto and there were two of em. Once i changed just one in line 19 - all good. Havent patched vbmeta together with boot, said "no need".

cfig commented 1 year ago

Good to know it works.

Since "boot.img" appeared as "chain partition descriptor" in the "vbmeta.img", modifying "boot.img" won't affect anything in "vbmeta.img", as long as boot.img is signed with the same key as before.