Hovatek Forum DEVELOPMENT Android [Development] How to root the Teclast M40
Try our Online TWRP Builder..its free!
Can't login? Please, reset your password.


[Development] How to root the Teclast M40

[Development] How to root the Teclast M40

hovatek
hovatek
hovatek
Administrator
49,570
26-12-2020, 10:26 PM
#1



The Teclast M40 runs on Android 10 Q and Unisoc T618 Processor. Rooting this model is pretty much like rooting the Teclast P80X except there are some important differences.

Things to note when trying to root the Teclast M40


  1. This model doesn't seem to play nice when flag is set to 2 i.e brick so set flag to 0
    The command to run is:

    Code:

    python avbtool make_vbmeta_image --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096 --flag 0 --chain_partition boot:1:keys/your-key.bin --chain_partition dtbo:5:keys/dtbo_key.bin --chain_partition recovery:2:keys/your-key.bin --chain_partition socko:6:keys/socko_key.bin --chain_partition odmko:7:keys/odmko_key.bin --chain_partition vbmeta_system:3:keys/vbmeta_system_key.bin --chain_partition vbmeta_vendor:4:keys/vbmeta_vendor_key.bin --chain_partition l_modem:8:keys/l_modem_key.bin --chain_partition l_ldsp:9:keys/l_ldsp_key.bin --chain_partition l_gdsp:10:keys/l_gdsp_key.bin --chain_partition pm_sys:11:keys/pmsys_key.bin --chain_partition l_agdsp:12:keys/l_agdsp_key.bin --chain_partition l_cdsp:13:keys/l_cdsp_key.bin --padding_size 20480 --output vbmeta-sign-custom.img

    Replace your-key.bin at boot and recovery partitions with your public key

  2. Padding is 20480
    This model has 00 50 00 00 padding. According to this guide, this translates to 20480 as seen in the command above. You should also download the vbmeta_pad.py for devices with 00 50 00 00 padding @ https://www.hovatek.com/forum/thread-32664.html

  3. Flash custom vbmeta using
    Code:

    fastboot --disable-verification flash vbmeta vbmeta.img

    where vbmeta.img is your vbmeta image's name. Skip --disable-verification if flashing is stuck

  4. If you'll be gaining root by patching boot.img then the magisk canary version seems a better bet. Maybe future magisk versions will change that. You could also choose to root via recovery partition but this is more difficult

  5. You sign your magisk canary patched boot using
    Code:

    python avbtool add_hash_footer --image boot_magisk_patched_repack.img --partition_name boot --partition_size 36700160 --key your-key.pem --algorithm SHA256_RSA4096

    where your-key.pem is your custom private key and boot_magisk_patched_repack.img is your magisk canary patched boot image

  6. If you encounter an error like avbtool: Image size of 36700160 exceeds maximum image size of 36630528 in order to fit in a partition size of 36700160 , simply unpack and repack your magisk patched boot image using Android Image Kitchen. This will reduce the size.

  7. If you encounter fastboot: error: Couldn't parse partition size '0x' when trying to flash the signed boot then flash your signed boot image using:

    Code:

    fastboot flash:raw boot boot.img

    where boot.img is your boot image's name


    Thanks to snow43 for testing

    [Image: root-teclast-m40.jpg]
This post was last modified: 26-12-2020, 10:43 PM by hovatek.

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
fra2110
fra2110
fra2110
Enthusiastic Member
6
28-02-2021, 10:16 PM
#2
Hi, when I try to sign my magisk canary patched boot using your command, I obtain this error:
Code:

usage: avbtool add_hash_footer [-h] [--image IMAGE]
                               [--partition_size PARTITION_SIZE]
                               [--partition_name PARTITION_NAME]
                               [--hash_algorithm HASH_ALGORITHM] [--salt SALT]
                               [--calc_max_image_size]
                               [--output_vbmeta_image OUTPUT_VBMETA_IMAGE]
                               [--do_not_append_vbmeta_image]
                               [--algorithm ALGORITHM] [--key KEY]
                               [--signing_helper APP]
                               [--signing_helper_with_files APP]
                               [--public_key_metadata KEY_METADATA]
                               [--rollback_index ROLLBACK_INDEX]
                               [--append_to_release_string STR]
                               [--prop KEY:VALUE] [--prop_from_file KEY:PATH]
                               [--kernel_cmdline CMDLINE]
                               [--setup_rootfs_from_kernel IMAGE]
                               [--include_descriptors_from_image IMAGE]
                               [--print_required_libavb_version]
                               [--chain_partition PART_NAME:ROLLBACK_SLOT:KEY_PATH]
                               [--flags FLAGS] [--set_hashtree_disabled_flag]
                               [--use_persistent_digest] [--do_not_use_ab]
avbtool add_hash_footer: error: argument --image: invalid FileType('rab+') value: 'boot.img'

The file name is right... How can I solve?
This post was last modified: 01-03-2021, 09:51 AM by X3non.
X3non
X3non
X3non
Recognized Contributor
22,062
01-03-2021, 09:51 AM
#3
(28-02-2021, 10:16 PM)fra2110 Hi, when I try to sign my magisk canary patched boot using your command, I obtain this error:
...
The file name is right... How can I solve?

use a linux OS instead of windows
mikrotik1000
mikrotik1000
mikrotik1000
Newbie
4
09-03-2021, 02:19 PM
#4
(26-12-2020, 10:26 PM)hovatek ...


Any youtube video with clear instruction on how to reduce the boot.img size for this sole purpose?

Its so beautiful to reference such complicated tut with an existing video that was done by Hovatek or X3non.
This post was last modified: 10-03-2021, 08:53 AM by X3non.
X3non
X3non
X3non
Recognized Contributor
22,062
10-03-2021, 08:55 AM
#5



(09-03-2021, 02:19 PM)mikrotik1000 Any youtube video with clear instruction on how to reduce the boot.img size for this sole purpose?

Its so beautiful to reference such complicated tut with an existing video that was done by Hovatek or X3non.

no video for this, simply download android image kitchen from xda forum
to unpack : drag the *.img onto unpackimg.bat
to repack : double click on repackimg.bat
This post was last modified: 10-03-2021, 09:05 AM by X3non.
rwk
rwk
rwk
Newbie
4
27-05-2021, 09:23 AM
#6
When I run the command (from above):

python avbtool make_vbmeta_image --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096 --flag 0 --chain_partition boot:1:keys/your-key.bin --chain_partition dtbo:5:keys/dtbo_key.bin --chain_partition recovery:2:keys/your-key.bin --chain_partition socko:6:keys/socko_key.bin --chain_partition odmko:7:keys/odmko_key.bin --chain_partition vbmeta_system:3:keys/vbmeta_system_key.bin --chain_partition vbmeta_vendor:4:keys/vbmeta_vendor_key.bin --chain_partition l_modem:8:keys/l_modem_key.bin --chain_partition l_ldsp:9:keys/l_ldsp_key.bin --chain_partition l_gdsp:10:keys/l_gdsp_key.bin --chain_partition pm_sys:11:keys/pmsys_key.bin --chain_partition l_agdsp:12:keys/l_agdsp_key.bin --chain_partition l_cdsp:13:keys/l_cdsp_key.bin --padding_size 20480 --output vbmeta-sign-custom.img

It references the following keys:

dtbo_key.bin
socko_key.bin
odmko_key.bin
vbmeta_system_key.bin
vbmeta_vendor_key.bin
l_modem_key.bin
l_ldsp_key.bin
l_gdsp_key.bin
pmsys_key.bin
l_agdsp_key.bin
l_cdsp_key.bin

Yet the file "[Hovatek] generic_spd_unisoc_public_keys.zip" contains the following keys:

generic_spd_unisoc_public_keys/key_boot.bin
generic_spd_unisoc_public_keys/key_dtb.bin
generic_spd_unisoc_public_keys/key_dtbo.bin
generic_spd_unisoc_public_keys/key_gdsp.bin
generic_spd_unisoc_public_keys/key_ldsp.bin
generic_spd_unisoc_public_keys/key_lmodem.bin
generic_spd_unisoc_public_keys/key_pmsys.bin
generic_spd_unisoc_public_keys/key_product.bin
generic_spd_unisoc_public_keys/key_recovery.bin
generic_spd_unisoc_public_keys/key_system.bin
generic_spd_unisoc_public_keys/key_vendor.bin

Which do not correspond to the keys mentioned in the python command.

For example, I get the error message:

FileNotFoundError: [Errno 2] No such file or directory: 'keys/socko_key.bin'

Please advise...

P.S. I am targeting a Teclast M40 with standard keys.
This post was last modified: 27-05-2021, 11:18 AM by rwk.
X3non
X3non
X3non
Recognized Contributor
22,062
28-05-2021, 11:30 AM
#7
(27-05-2021, 09:23 AM)rwk When I run the command (from above):
...
P.S. I am targeting a Teclast M40 with standard keys.

you're supposed to extract the keys from your stock vbmeta ; see the guide @ https://www.hovatek.com/forum/thread-32667.html
then you can use the keys you extracted along with the make_vbmeta command
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
YtWhTl
live chat
whatsapp telegram instagram