Join us on Tl   Wh

Hovatek Forum DEVELOPMENT Android Issue signing system image using avbtool

Issue signing system image using avbtool

Issue signing system image using avbtool

romelley
romelley
romelley
Enthusiastic Member
6
23-12-2020, 12:00 PM
#1



Ive got a Teclast P80X (G5K6) tablet, and have followed the guides on this site to unlock bootloader, root (using magisk on boot), create a custom vbmeta, and sign images. Everything has gone fine so far. But I have an issue when trying to sign a system image.

When gaining information on the original/stock system image using python avbtool info_image -:

Code:

$ python avbtool info_image --image ../OrigFirmware/system.img
Footer version:           1.0
Image size:               2936012800 bytes
Original image size:      2889601024 bytes
VBMeta offset:            2935390208
VBMeta size:              2624 bytes
--
Minimum libavb version:   1.0
Header Block:             256 bytes
Authentication Block:     576 bytes
Auxiliary Block:          1792 bytes
Algorithm:                SHA256_RSA4096
Rollback Index:           0
Flags:                    0
Release String:           'avbtool 1.1.0'
Descriptors:
    Hashtree descriptor:
      Version of dm-verity:  1
      Image Size:            2889601024 bytes
      Tree Offset:           2889601024
      Tree Size:             22761472 bytes
      Data Block Size:       4096 bytes
      Hash Block Size:       4096 bytes
      FEC num roots:         2
      FEC offset:            2912362496
      FEC size:              23027712 bytes
      Hash Algorithm:        sha1
      Partition Name:        system
      Salt:                  53ba0caa0522fdd899acbe2a86675e173e9236c5262bbce0af54fc9c3410f28d
      Root Digest:           0c0d26c3936a1b9999fbf2578dd611104cc8d158
      Flags:                 0
    Kernel Cmdline descriptor:
      Flags:                 1
      Kernel Cmdline:        'dm="1 vroot none ro 1,0 5643752 verity 1 PARTUUID=$(ANDROID_SYSTEM_PARTUUID) PARTUUID=$(ANDROID_SYSTEM_PARTUUID) 4096 4096 705469 705469 sha1 0c0d26c3936a1b9999fbf2578dd611104cc8d158 53ba0caa0522fdd899acbe2a86675e173e9236c5262bbce0af54fc9c3410f28d 10 $(ANDROID_VERITY_MODE) ignore_zero_blocks use_fec_from_device PARTUUID=$(ANDROID_SYSTEM_PARTUUID) fec_roots 2 fec_blocks 711026 fec_start 711026" root=/dev/dm-0'
    Kernel Cmdline descriptor:
      Flags:                 2
      Kernel Cmdline:        'root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)'

I then try to sign a system image I'd like to use, in the same way I signed boot, with a few adjustments (size and partition name) -:

Code:

$ python avbtool add_hash_footer --image lineage_signed.img --partition_name system --partition_size 2936012800 --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096
$

No error message is given, and the img file is modified. But the result is a file that is completely the wrong size. Instead of being padded up to 2936012800 bytes from its original 1905398040 bytes, it instead ends up at a size of 1874698496 bytes, as can be seen here -:

Code:

$ls -l lineage_signed.img ../OrigFirmware/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img ../OrigFirmware/system.img
-rw-r--r-- 1 x x 1874698496 Dec 23 16:34 lineage_signed.img
-rw-r--r-- 1 x x 1905398040 Dec 23 14:43 ../OrigFirmware/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img
-rw-r--r-- 1 x x 2936012800 Dec 23 15:25 ../OrigFirmware/system.img

Where lineage_signed.img is the result of signing the lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img file. I've got the stock/factory system firmware file (system.img) there also for reference.

When trying to flash the modified file it fails (obviously I have created a vbmeta that will allow the signed system image). Any help or tips on how to correctly sign the lineage system image would be appreciated. Including any information on why it isnt being padded/expanded to the correct size.
hovatek
hovatek
hovatek
Administrator
49,755
25-12-2020, 10:10 AM
#2
(23-12-2020, 12:00 PM)romelley ...
When trying to flash the modified file it fails (obviously I have created a vbmeta that will allow the signed system image).  Any help or tips on how to correctly sign the lineage system image would be appreciated.  Including any information on why it isnt being padded/expanded to the correct size.

Without signing the system image, try this command

Code:

fastboot flash -S 100M system system.img
fastboot erase userdata

Let me know what happens
This post was last modified: 08-01-2021, 08:03 AM by hovatek.

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
xufa
xufa
xufa
Junior Member
20
25-12-2020, 11:40 PM
#3
Hi.

I have the same G5K6, I have unlocked the bootloader, then created the custom vbmeta with the custom key for the boot partition, then created the boot image with magisk and signed with avbtool preserving the stock boot.img size,l then I flashed smoothly both images however I always get a boot loop, I havent managed to boot the tablet after flashing.

Can you send me your vbmeta and boot images? maybe these work also in my tablet.

I am desperated, keep trying and following all the guides in this webpage however there is nothing that works in my tablet.

I also tried this

fastboot -S 100M system system.img

after signing vbmeta for the system partition, and again I get a boot loop.

Am I missing something?
This post was last modified: 25-12-2020, 11:42 PM by xufa.
hovatek
hovatek
hovatek
Administrator
49,755
04-01-2021, 01:03 PM
#4
(25-12-2020, 11:40 PM)xufa Hi.

I have the same G5K6, I have unlocked the bootloader, then created the custom vbmeta with the custom key for the boot partition, then created the boot image with magisk and signed with avbtool preserving the stock boot.img size,l then I flashed smoothly both images however I always get a boot loop, I havent managed to boot the tablet after flashing.

Can you send me your vbmeta and boot images? maybe these work also in my tablet.

I am desperated, keep trying and following all the guides in this webpage however there is nothing that works in my tablet.

I also tried this

fastboot -S 100M system system.img

after signing vbmeta for the system partition, and again I get a boot loop.

Am I missing something?

firmware for g5k6 is listed @ https://www.hovatek.com/forum/thread-20913.html ; should be able to fix and root your device using the firmware
xufa
xufa
xufa
Junior Member
20
05-01-2021, 01:30 PM
#5



(04-01-2021, 01:03 PM)X3non
(25-12-2020, 11:40 PM)xufa Hi.

I have the same G5K6, I have unlocked the bootloader, then created the custom vbmeta with the custom key for the boot partition, then created the boot image with magisk and signed with avbtool preserving the stock boot.img size,l then I flashed smoothly both images however I always get a boot loop, I havent managed to boot the tablet after flashing.

Can you send me your vbmeta and boot images? maybe these work also in my tablet.

I am desperated, keep trying and following all the guides in this webpage however there is nothing that works in my tablet.

I also tried this

fastboot -S 100M system system.img

after signing vbmeta for the system partition, and again I get a boot loop.

Am I missing something?

firmware for g5k6 is listed @ https://www.hovatek.com/forum/thread-20913.html ; should be able to fix and root your device using the firmware

...
This post was last modified: 05-01-2021, 04:37 PM by xufa.
xufa
xufa
xufa
Junior Member
20
05-01-2021, 04:36 PM
#6
(25-12-2020, 10:10 AM)hovatek
(23-12-2020, 12:00 PM)romelley ...
When trying to flash the modified file it fails (obviously I have created a vbmeta that will allow the signed system image).  Any help or tips on how to correctly sign the lineage system image would be appreciated.  Including any information on why it isnt being padded/expanded to the correct size.

Without signing the system image, try this command

Code:

fastboot -S 100M system system.img
fastboot erase userdata

Let me know what happens

I tried exactly as you said without signing system.img with the same G5K6, and I got a bootloop. the vbmeta had the custom hovatek key.
Code:

sudo ./fastboot -S 100M flash system /media/ubuntu/writable/test/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img
sending sparse 'system' 1/19 (102396 KB)...
OKAY [  5.621s]
writing 'system' 1/19...
OKAY [  3.616s]
sending sparse 'system' 2/19 (102396 KB)...
OKAY [  5.703s]
writing 'system' 2/19...
OKAY [  3.628s]
sending sparse 'system' 3/19 (102396 KB)...
OKAY [  5.892s]
writing 'system' 3/19...
OKAY [  3.600s]
sending sparse 'system' 4/19 (102396 KB)...
OKAY [  5.741s]
writing 'system' 4/19...
OKAY [  3.630s]
sending sparse 'system' 5/19 (102396 KB)...
OKAY [  5.955s]
writing 'system' 5/19...
OKAY [  3.606s]
sending sparse 'system' 6/19 (102396 KB)...
OKAY [  5.725s]
writing 'system' 6/19...
OKAY [  3.604s]
sending sparse 'system' 7/19 (102396 KB)...
OKAY [  5.643s]
writing 'system' 7/19...
OKAY [  3.641s]
sending sparse 'system' 8/19 (102396 KB)...
OKAY [  6.020s]
writing 'system' 8/19...
OKAY [  3.605s]
sending sparse 'system' 9/19 (96964 KB)...
OKAY [  5.735s]
writing 'system' 9/19...
OKAY [  3.423s]
sending sparse 'system' 10/19 (102396 KB)...
OKAY [  5.985s]
writing 'system' 10/19...
OKAY [  3.603s]
sending sparse 'system' 11/19 (102396 KB)...
OKAY [  5.875s]
writing 'system' 11/19...
OKAY [  3.600s]
sending sparse 'system' 12/19 (102396 KB)...
OKAY [  6.133s]
writing 'system' 12/19...
OKAY [  3.637s]
sending sparse 'system' 13/19 (102396 KB)...
OKAY [  5.946s]
writing 'system' 13/19...
OKAY [  3.606s]
sending sparse 'system' 14/19 (102396 KB)...
OKAY [  5.982s]
writing 'system' 14/19...
OKAY [  3.602s]
sending sparse 'system' 15/19 (102396 KB)...
OKAY [  6.053s]
writing 'system' 15/19...
OKAY [  3.618s]
sending sparse 'system' 16/19 (102396 KB)...
OKAY [  6.105s]
writing 'system' 16/19...
OKAY [  3.605s]
sending sparse 'system' 17/19 (102396 KB)...
OKAY [  6.076s]
writing 'system' 17/19...
OKAY [  3.601s]
sending sparse 'system' 18/19 (95452 KB)...
OKAY [  5.647s]
writing 'system' 18/19...
OKAY [  3.387s]
sending sparse 'system' 19/19 (29988 KB)...
OKAY [  1.781s]
writing 'system' 19/19...
OKAY [  1.128s]
finished. total time: 173.360s


sudo ./fastboot erase userdata
erasing 'userdata'...
OKAY [  0.208s]
finished. total time: 0.208s
xufa
xufa
xufa
Junior Member
20
05-01-2021, 04:47 PM
#7
(25-12-2020, 10:10 AM)hovatek
(23-12-2020, 12:00 PM)romelley ...
When trying to flash the modified file it fails (obviously I have created a vbmeta that will allow the signed system image).  Any help or tips on how to correctly sign the lineage system image would be appreciated.  Including any information on why it isnt being padded/expanded to the correct size.

Without signing the system image, try this command

Code:

fastboot -S 100M system system.img
fastboot erase userdata

Let me know what happens

And now signing the image I get another bootloop.

Code:

python avbtool add_hash_footer --image /media/ubuntu/writable/test/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img --partition_name system --partition_size 2936012800 --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096

python avbtool info_image --image /media/ubuntu/writable/test/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img
Footer version:           1.0
Image size:               2936012800 bytes
Original image size:      1937219584 bytes
VBMeta offset:            1937219584
VBMeta size:              2112 bytes
--
Minimum libavb version:   1.0 (Sparse)
Header Block:             256 bytes
Authentication Block:     576 bytes
Auxiliary Block:          1280 bytes
Algorithm:                SHA256_RSA4096
Rollback Index:           0
Flags:                    0
Release String:           'avbtool 1.1.0'
Descriptors:
    Hash descriptor:
      Image Size:            1937219584 bytes
      Hash Algorithm:        sha256
      Partition Name:        system
      Salt:                  d0e07645d02fe4868daa1b8c29f198c2fee08b7bbbb80cf7aa14163b81b1f0c6
      Digest:                481005bd79b46c1b51ee8a31794ab7b507a2ea93f7e55b31aa609497da1c927e
      Flags:                 0
python avbtool info_image --image /media/ubuntu/writable/test/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img
Footer version:           1.0
Image size:               2936012800 bytes
Original image size:      1937219584 bytes
VBMeta offset:            1937219584
VBMeta size:              2112 bytes
--
Minimum libavb version:   1.0 (Sparse)
Header Block:             256 bytes
Authentication Block:     576 bytes
Auxiliary Block:          1280 bytes
Algorithm:                SHA256_RSA4096
Rollback Index:           0
Flags:                    0
Release String:           'avbtool 1.1.0'
Descriptors:
    Hash descriptor:
      Image Size:            1937219584 bytes
      Hash Algorithm:        sha256
      Partition Name:        system
      Salt:                  d0e07645d02fe4868daa1b8c29f198c2fee08b7bbbb80cf7aa14163b81b1f0c6
      Digest:                481005bd79b46c1b51ee8a31794ab7b507a2ea93f7e55b31aa609497da1c927e
      Flags:                 0


sudo ./fastboot flash vbmeta ../vbmeta_custom.img
target didn't report max-download-size
sending 'vbmeta' (1024 KB)...
OKAY [  0.053s]
writing 'vbmeta'...
OKAY [  0.377s]
finished. total time: 0.430s

sudo ./fastboot -S 100M flash system /media/ubuntu/writable/test/lineage-17.1-20201215-UNOFFICIAL-treble_arm64_avS.img
sending sparse 'system' 1/18 (102396 KB)...
OKAY [  6.124s]
writing 'system' 1/18...
OKAY [  3.618s]
sending sparse 'system' 2/18 (102396 KB)...
OKAY [  5.976s]
writing 'system' 2/18...
OKAY [  3.647s]
sending sparse 'system' 3/18 (102396 KB)...
OKAY [  5.962s]
writing 'system' 3/18...
OKAY [  3.632s]
sending sparse 'system' 4/18 (102396 KB)...
OKAY [  5.891s]
writing 'system' 4/18...
OKAY [  3.629s]
sending sparse 'system' 5/18 (102396 KB)...
OKAY [  5.887s]
writing 'system' 5/18...
OKAY [  3.623s]
sending sparse 'system' 6/18 (102396 KB)...
OKAY [  6.114s]
writing 'system' 6/18...
OKAY [  3.647s]
sending sparse 'system' 7/18 (102396 KB)...
OKAY [  5.834s]
writing 'system' 7/18...
OKAY [  3.631s]
sending sparse 'system' 8/18 (102396 KB)...
OKAY [  6.143s]
writing 'system' 8/18...
OKAY [  3.620s]
sending sparse 'system' 9/18 (96964 KB)...
OKAY [  5.701s]
writing 'system' 9/18...
OKAY [  3.431s]
sending sparse 'system' 10/18 (102396 KB)...
OKAY [  5.899s]
writing 'system' 10/18...
OKAY [  3.639s]
sending sparse 'system' 11/18 (102396 KB)...
OKAY [  6.045s]
writing 'system' 11/18...
OKAY [  3.616s]
sending sparse 'system' 12/18 (102396 KB)...
OKAY [  5.926s]
writing 'system' 12/18...
OKAY [  3.635s]
sending sparse 'system' 13/18 (102396 KB)...
OKAY [  5.993s]
writing 'system' 13/18...
OKAY [  3.656s]
sending sparse 'system' 14/18 (102396 KB)...
OKAY [  6.137s]
writing 'system' 14/18...
OKAY [  3.633s]
sending sparse 'system' 15/18 (102396 KB)...
OKAY [  6.111s]
writing 'system' 15/18...
OKAY [  3.655s]
sending sparse 'system' 16/18 (102396 KB)...
OKAY [  6.011s]
writing 'system' 16/18...
OKAY [  3.658s]
sending sparse 'system' 17/18 (102396 KB)...
OKAY [  5.818s]
writing 'system' 17/18...
OKAY [  3.634s]
sending sparse 'system' 18/18 (95460 KB)...
OKAY [  5.692s]
writing 'system' 18/18...
OKAY [  3.441s]
finished. total time: 172.313s

sudo ./fastboot erase userdata
erasing 'userdata'...
OKAY [  0.613s]
finished. total time: 0.613s
hovatek
hovatek
hovatek
Administrator
49,755
06-01-2021, 10:56 AM
#8
(05-01-2021, 04:47 PM)xufa ...

stick to your thread @ https://www.hovatek.com/forum/thread-37618.html
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
Join us
WhTlYt