We're hiring! Apply Now

Hovatek Forum DEVELOPMENT Android How to flash a GSI to Unisoc devices with Super partition

How to flash a GSI to Unisoc devices with Super partition

How to flash a GSI to Unisoc devices with Super partition

hovatek
hovatek
hovatek
Administrator
49,789
12-04-2024, 02:57 AM
#1



This guide will explain how to flash a Generic System Image (GSI) to a Unisoc Android device which has a Super partition. This guide is specific to those models that require an unlock token to unlock the bootloader and also create custom vbmeta to flash modified files. 

The idea is to generate a custom vbmeta_system.img so that the system_ext.img and system.img will pass verification then create a custom vbmeta.img so that vbmeta_system.img will also pass verification. vbmeta.img will pass verification if generated with the same private key the OEM used.

This guide assumes you're a bit familiar with generating vbmetas so you might need to make a few modifications.

Requirements


  1. GSI (system.img)
  2. system_ext.img (You can extract this from firmware's super.img using simg2img and lpunpack)
  3. avbtool
  4. Private key the OEM used to sign the vbmeta partition (e.g rsa4096_vbmeta.pem)

How to flash a GSI to Unisoc Android devices



  1. Generate a public key from the private key using the command:
    Code:

    python avbtool.py extract_public_key --key rsa4096_vbmeta.pem --output rsa4096_vbmeta.bin

  2. Generate a custom vbmeta_system.img

    Code:

    python avbtool.py make_vbmeta_image --algorithm SHA256_RSA4096 --key rsa4096_vbmeta.pem --include_descriptors_from_image system.img --include_descriptors_from_image system_ext.img --padding_size 4096 --output vbmeta_system_custom.img

  3. Generate a custom vbmeta.img (similar to stock vbmeta except you swap the public key for vbmeta_system to the bin generated at the beginning

    Code:

    python avbtool.py make_vbmeta_image --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096 --flag 0 --chain_partition boot:1:keys/boot_key.bin --chain_partition vendor_boot:18:keys/vendor_boot_key.bin --chain_partition dtbo:6:keys/dtbo_key.bin --chain_partition vbmeta_system:2:keys/rsa4096_vbmeta.bin --chain_partition vbmeta_vendor:4:keys/vbmeta_vendor_key.bin --chain_partition vbmeta_odm:7:keys/vbmeta_odm_key.bin --chain_partition vbmeta_system_ext:3:keys/vbmeta_system_ext_key.bin --chain_partition vbmeta_product:5:keys/vbmeta_product_key.bin --chain_partition l_modem:11:keys/l_modem_key.bin --chain_partition l_ldsp:12:keys/l_ldsp_key.bin --chain_partition l_gdsp:13:keys/l_gdsp_key.bin --chain_partition pm_sys:14:keys/pm_sys_key.bin --chain_partition l_agdsp:15:keys/l_agdsp_key.bin --prop com.android.build.boot.os_version:13 --prop com.android.build.boot.security_patch:2023-09-05 --prop com.android.build.system.os_version:13 --prop com.android.build.system.security_patch:2023-09-05 --prop com.android.build.vendor.os_version:13 --prop com.android.build.vendor.security_patch:2023-09-05 --padding_size 20480 --output vbmeta-sign-custom.img

    You could apply its padding python script too

  4. Flash the GSI using
    Code:

    adb reboot fastboot
    fastboot flash vbmeta vbmeta-sign-custom.img
    fastboot flash vbmeta_system vbmeta_system_custom.img
    fastboot erase system_ext
    fastboot flash system_ext system_ext.img
    fastboot erase system
    fastboot flash system system.img
    fastboot -w

    If you can, go to recovery mode and do a factory reset before rebooting.

Important Notice
The values used in the commands are for demo purposes. Ensure to study the relevant guides.
This post was last modified: 12-04-2024, 03:02 AM by hovatek.

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
735394006
735394006
735394006
Enthusiastic Member
6
05-06-2024, 10:23 AM
#2
“python avbtool.py make_vbmeta_image --algorithm SHA256_RSA4096 --key rsa4096_vbmeta.pem --include_descriptors_from_image system.img --include_descriptors_from_image system_ext.img --padding_size 4096 --output vbmeta_system_custom.img”


avbtool: Given image does not look like a vbmeta image. Error prompt
hovatek
hovatek
hovatek
Administrator
49,789
05-06-2024, 01:43 PM
#3
(05-06-2024, 10:23 AM)735394006 “python avbtool.py make_vbmeta_image --algorithm SHA256_RSA4096 --key rsa4096_vbmeta.pem --include_descriptors_from_image system.img --include_descriptors_from_image system_ext.img --padding_size 4096 --output vbmeta_system_custom.img”


avbtool: Given image does not look like a vbmeta image.    Error prompt

Ensure the images (system.img and system_ext.img) are present in the avbtool folder

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
andforce111
andforce111
andforce111
Newbie
3
31-07-2024, 04:54 AM
#4
how to flash when super.img contains A/B partions:

-rw-r--r-- 1 dy dy 271257600 7月 29 17:39 product_a.img
-rw-r--r-- 1 dy dy 0 7月 29 17:39 product_b.img
-rw-r--r-- 1 dy dy 654548992 7月 29 17:39 system_a.img
-rw-r--r-- 1 dy dy 0 7月 29 17:39 system_b.img
-rw-r--r-- 1 dy dy 343097344 7月 29 17:39 system_ext_a.img
-rw-r--r-- 1 dy dy 0 7月 29 17:39 system_ext_b.img
-rw-r--r-- 1 dy dy 805707776 7月 29 17:39 vendor_a.img
-rw-r--r-- 1 dy dy 0 7月 29 17:39 vendor_b.img
-rw-r--r-- 1 dy dy 15613952 7月 29 17:39 vendor_dlkm_a.img
-rw-r--r-- 1 dy dy 0 7月 29 17:39 vendor_dlkm_b.img
justshez
justshez
justshez
Intern
2,428
31-07-2024, 11:30 AM
#5



(31-07-2024, 04:54 AM)andforce111 how to flash when super.img contains A/B partions:

-rw-r--r-- 1 dy dy    271257600 7月  29 17:39 product_a.img
-rw-r--r-- 1 dy dy            0 7月  29 17:39 product_b.img
-rw-r--r-- 1 dy dy    654548992 7月  29 17:39 system_a.img
-rw-r--r-- 1 dy dy            0 7月  29 17:39 system_b.img
-rw-r--r-- 1 dy dy    343097344 7月  29 17:39 system_ext_a.img
-rw-r--r-- 1 dy dy            0 7月  29 17:39 system_ext_b.img
-rw-r--r-- 1 dy dy    805707776 7月  29 17:39 vendor_a.img
-rw-r--r-- 1 dy dy            0 7月  29 17:39 vendor_b.img
-rw-r--r-- 1 dy dy    15613952 7月  29 17:39 vendor_dlkm_a.img
-rw-r--r-- 1 dy dy            0 7月  29 17:39 vendor_dlkm_b.img

Try flashing to both partitions, do for a then do for b

fastboot erase system_ext_a
fastboot flash system_ext_a system_ext_a.img
fastboot erase system_a
fastboot flash system_a system_a.img
fastboot -w

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
Join us
WhTlYt