Teclast M40Pro M1A1 custom signed vbmeta 'Wait input time out"
Teclast M40Pro M1A1 custom signed vbmeta 'Wait input time out"
python avbtool.py make_vbmeta_image --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096 --flag 0 --chain_partition boot:1:keys/boot --chain_partition dtbo:6:keys/dtbo --chain_partition socko:13:keys/socko --chain_partition odmko:14:keys/odmko --chain_partition vbmeta_system:2:keys/vbmeta_system --chain_partition vbmeta_system_ext:3:keys/vbmeta_system_ext --chain_partition vbmeta_vendor:4:keys/vbmeta_vendor --chain_partition vbmeta_product:5:keys/vbmeta_product --chain_partition l_modem:7:keys/l_modem --chain_partition l_ldsp:8:keys/l_ldsp --chain_partition l_gdsp:9:keys/l_gdsp --chain_partition pm_sys:10:keys/pm_sys --chain_partition l_agdsp:11:keys/l_agdsp --chain_partition l_cdsp:12:keys/l_cdsp --padding_size 16384 --output vbmeta-sign-custom.img
python vbmeta_pad_10.py
000ffe00: 4448 5442 0100 0000 f75e 36d1 04e3 a298 DHTB.....^6.....
000ffe10: 0e74 4440 c537 ef6b 44c3 6f9e 72d7 5171 .tD@.7.kD.o.r.Qq
000ffe20: fc9f a794 d0f9 1763 0000 0000 0000 0000 .......c........
000ffe30: 0050 0000 0000 0000 0000 0000 0050 0000 .P...........P..
fastboot flash vbmeta vbmeta-signed-custom.img
avbtool info_image
$ diff <(python avbtool.py info_image --image vbmeta-sign-custom.img) <(python avbtool.py info_image --image vbmeta-sign-orig.img)
10c10
< Release String: 'avbtool 1.2.0'
---
> Release String: 'avbtool 1.1.0'
$ diff <(xxd vbmeta-sign-custom.img) <(xxd vbmeta-sign-orig.img)
65505,65508c65505,65508
< 000ffe00: 4448 5442 0100 0000 2585 c152 cd53 1dfd DHTB....%..R.S..
< 000ffe10: 492d d680 72e1 6b9c 2e6c af7e f068 80e2 I-..r.k..l.~.h..
< 000ffe20: fd6b afb8 f45e ccff 0000 0000 0000 0000 .k...^..........
< 000ffe30: 0050 0000 0000 0000 0000 0000 0000 0000 .P..............
---
> 000ffe00: 4448 5442 0100 0000 f75e 36d1 04e3 a298 DHTB.....^6.....
> 000ffe10: 0e74 4440 c537 ef6b 44c3 6f9e 72d7 5171 .tD@.7.kD.o.r.Qq
> 000ffe20: fc9f a794 d0f9 1763 0000 0000 0000 0000 .......c........
> 000ffe30: 0050 0000 0000 0000 0000 0000 0050 0000 .P...........P..
(29-10-2023, 07:00 PM)mikau ......
for the two are the different avbtool version numbers:Code:avbtool info_image
Code:$ diff <(python avbtool.py info_image --image vbmeta-sign-custom.img) <(python avbtool.py info_image --image vbmeta-sign-orig.img)
10c10
< Release String: 'avbtool 1.2.0'
---
> Release String: 'avbtool 1.1.0'
(30-10-2023, 12:18 PM)maxpayneI thought the padding might be wrong. I wrote a small script taking padding bytes off the end and recalculating the hash until I got the same as the original img file. Turns out the correct amount of padding is 10240. After that I still need to change byte 0xFFE3D from 0x00 to 0x50.(29-10-2023, 07:00 PM)mikau ......
for the two are the different avbtool version numbers:Code:avbtool info_image
Code:$ diff <(python avbtool.py info_image --image vbmeta-sign-custom.img) <(python avbtool.py info_image --image vbmeta-sign-orig.img)
10c10
< Release String: 'avbtool 1.2.0'
---
> Release String: 'avbtool 1.1.0'
This difference is because of the avbtool and therefore python you used. You used avbtool for python 3 and python 3. Try using avbtool for python 2 and python 2 instead
I'll check the padding while you're at it
import hashlib
import sys
f = open("vbmeta-sign-custom.img", "rb")
b = f.read()
sha = hashlib.sha256(b).digest()
f.close()
f = open("vbmeta-sign-custom.img", "wb")
f.write(b)
f.seek(1048576 - 512)
f.write(b'\x44\x48\x54\x42\x01\x00\x00\x00')
f.write(sha)
f.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50\x00\x00')
f.seek(0xffe3d)
f.write(b'\x50')
f.seek(1048576 - 1)
f.write(b'\x00')
f.close()
(30-10-2023, 01:33 PM)mikau IT WORKS!!!!
The avbtool version didn't end up mattering, neither did the python version. Using a padding size of 10240 gives a file with size 20480, which gives the correct sha256 hash.
I used a modified vbmeta.py to put that pesky 0x50 in the right place:
...