It's been some time since I bought the Cubot KingKong Mini 2. It's been working pretty well all these years, but the battery life is not so good any longer, the phone is scratched from all sides, modern android apps are quite often very slow (e.g. windy is almost non-usable,...). So it's time to get a new phone, but which one? I quite got used to the small form factor of a 4 inch phone. The small android phones market is still as small as it was few years ago. There are only few phones below 5 inches and they all are quite similar when it comes to dimensions.
The Smini looked best from the phones I've found, but there were only few reviews and no discussion of xda, so I've ordered it, hoping it will look and work nice, without knowing if it could be rooted and if any unofficial firmware would work on it. It was a bit risky step as I refuse to use anything that runs google services or is not under my complete control. There were no mentions on the internet about rooting or flashing this phone, the firmware was not available anywhere, so the chances were quite low. So inhale deeply and follow my quest of rooting and flashing this beast.
The phone is a bit taller than the old King Kong Mini 2 and a bit thicker, as a result, the phone feels heavier and won't fit my hand as good, but the size is still ok. The narrow screen is weird, adding few mm to width instead of height would be better... The system is quite fast and responsive, the camera is ok, the second screen is pretty useless as it shows only the data downloaded from the internet.
Pros:
Cons:
To see if flashing this phone was even remotely possible, I've done several steps:
system.img
, boot.img
, vbmeta_system.img
, scatter, etc.). The Czech firmware version is available here if anyone is interested. Thanks to this, I have a good way to resurrect my device if I happen to brick it.So, it seems it won't be that hard after all, I have the factory firmware files, the phone supports Project Treble, has A/B partition schema and bootloader unlock seems to be possible.
It's a good custom to make a backup of the phone before actually changing anything so there's a way back in case of any issues, e.g. when the phone refuses to boot the custom ROM and you decide to give up and return the phone back to the seller within the 14 days for refund (it's possible in Europe). Also the user data partition gets wiped (factory reset) during the process, no problem for me (brand new phone), but a huge problem for anyone who was using the phone for a while - don't forget to backup your data!
The MediaTek based phones can be backed up in few ways:
The mtkclient tool. It's a pretty powerful tool that can even unlock the bootloader when unlocking is not supported by vendor. However the G99 (MT6789) SOC is not fully supported yet and I was only able to read some basic phone information before it throw an error. If anyone's interested, the backup process is:
python mtk rl --skip userdata <folder_to_put_backupt_to>
(user data are skipped - way too huge)The SPFlashToolV6 is an standard way to write and read firmware of the MTK base phones, it requires a scatter file (partition map). It can be usually found on the internet, or in our case, it was provided as part of the binary released by the vendor - MT6789_Android_scatter.txt. I was able to configure the tool to flash the vendor provided firmware files, but the readout was somewhat broken and I was too lazy to dig deeper.
The adb
tool can be used to dump the block device from the phone directly, but a root is required, so this won't work in our case. But just for your information, run e.g. adb pull /dev/block/platform/soc/11270000.ufshci/by-name/boot_a ./
The huge advantage of modern android phones with A/B partition map is that you can damage one of the partition in any way and the phone will still boot from the second one with the stock firmware. And as I had no luck after a hour or so of trying to dump my partitions, I gave up and started experimenting without backup (I was not that worried after obtaining factory image from vendor).
The flashing process is quite straightforward, similar to most of the MediaTek based devices:
fastboot
and adb
is needed. It's usually available in a package manager. If you are running windows, get a better OS or live the pain of installing all the USB drivers and other stuff downloaded from random places on the internet.
adb reboot bootloader
fastboot flashing unlock
and pressing volume up on phone to confirm the process - this will wipe all the user data!Orange state
on every boot and hang there for 5 seconds. And you have invalidated your warranty, btw.See what slot is currently active by fastboot getvar current-slot
and optionally switch to a different slot by running fastboot --set-active=a
Flash vbmeta
partition to disable the rom integrity checking, either use the generic image from google or use the image from vendor provided firmware files
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
vbmeta_a
or vbmeta_b
, but the smini bootloader is a little fishy, it has always written to vbmeta_a
for me, regardless of the active slot.fastboot
command hangs), just disconnect the USB cable and connect again.vbmeta
shall probably be flashed from fastbootd mode (part of recovery firmware), but for some reason, the fastbootd on smini always fails with File doesn't exist
when writing anything else than system
partition.adb reboot bootloader
and fastboot reboot fastboot
, the phone sometimes enters a strange fastboot mode that worked everytime for me when flashing the vbmeta.img
Now the phone shall accept any modifications to system, boot and other partitions without bootlooping. If you messed up something, it shall boot up the factory firmware stored in a second slot (if there's any) - happened to me few times...
There are basically two options how to root the phone:
su
binary and some app that would manage access to this binary.boot.img
and flash this modified image.The magisk is a pretty standard way to root your phone, it not only provides a root access to your apps, but it's also able to hide itself and the fact the phone is rooted from rest of the system, which is quite handy if you banking app is way too picky about the security and has no opt-out for rooted phones... The process is simple:
boot.img
from vendor provided firmware files (or dump it from your phone if you manage to - see the backup section above) and push it to your phone: adb push boot.img /storage/emulated/0/DCIM/
boot.img
binary in the magisk appadb pull /storage/emulated/0/Download/magisk_patched-27000_RQmSG.img
adb reboot bootloader
, fastboot flash boot magisk_patched-27000_RQmSG.img
The root is optional and not necessary if you don't need it, but it's a great way how to install system wide adblocker, application firewall, etc.
The GSI images were originally designed for development purposes and testing, but the community quickly adapted the GSI flashing process to modify the phones in the wild. There are may GSI images that can be used to replace the stock system - see the Generic System Images list.
I've started with the LineageOS from the Andy Yan's builds. There are several variants, I used one for the A/B partition scheme, vanilla (no google apps) and no superuser version - lineage-20.0-20240516-UNOFFICIAL-arm64_bvN.img
. However the battery was draining like hell, the phone lost like 25 % over a single night. The crDroid in Android 13 variant was much better when it comes to battery life, but after flashing Android 14 variant, the battery drain was back. After several days of flash-let run for 10 hours and repeat I've finally settled down on the LineageOS 21 Light from Andy, the battery life is quite good and it works nicely.
The flashing is quite simple (don't forget to flash the same partition as you flashed with vbmeta
):
fastboot flash systemlineage-21.0-20240518-UNOFFICIAL-gsi_arm64_vN
(will flash to a currently selected slot)fastboot reboot
I'm not very fond of google spying on everyone, therefore I don't install google apps and rather use alternatives, if you want google for some reason, see the opengapps. To make the android usable without google and to utilize the root access, I usually do:
microG Services
, microG Companion
and microG Services Framework Proxy
Local NLP Backend
as it doesn't use online data but rather creates it's own database during life of the phonemicroG
app and make sure all items under Self Check
in menu are checkedThe phone with Andy Yan's build of LineageOS in Light version pretty well, it's my daily driver and so far, no crashes or other instabilities appeared.
Generic notes:
What does not work:
I don't like a blind copy-paste approach when doing stuff, therefore I've done a small research and shared it here.
The android boot process is quite similar to other embedded linux base system:
1) Primary bootloader - stored in a Boot ROM of the SoC itself, written by a chip manufacturer. It does some basic device initialization and loads a second stage. It also usually verifies the secondary bootloader (integrity, authorization...). If something fails (corrupted secondary image) an emergency mode is entered - it's usally called EDL
, BROM mode
on MTK devices,... This mode can be used to reflash the device (if proper software is available).
2) Secondary bootloader - resides in storage external from the CPU (flash), it basically initializes TrustZone and loads a stage 3 bootloader
3) Stage 3 bootloader - finally something interesting, it's called Aboot
(The android Bootloader), it implements the fastboot
interface. The Aboot verifies authenticity of the boot
and recovery
partitions, decides which one to boot (from the buttons pressed during boot or from adb reboot
target) and finally loads the RAM with the Linux kernel, device tree, and ramdisk from boot
or recovery
partition.
4) Linux/Android - The linux kernel finally executes, verifies the integrity of all the partitions being mounted and spawns the zygote process. The Zygote parent of all the android processes, it finally launches the Android itself.
Back before the android 8, all the necessary drivers and other software was stored in a single partition, each vendor had to create a complete Linux/Android system, include all the drivers, etc. Therefore any vendor ROM update or alternative ROM had to contain all the drivers, firmware blobs and other stuff, which made modding pretty hard and complex task. I
It also meant that creating an upgrade for your phone when a new security fix or android version appeared was a pretty complex and time consuming task, which was one of the reasons the cheap Chinese phones had to live their life with only very few or none updates after the initial release.
Then with Android O, the Project Treble appeared. The Project Treble came with a good idea - the vendor specified software got separated from the Android itself. So now, the Android OS could be replaced without touching the vendor specific software libraries.
In theory, any GSI (Generic System Image) of same or newer Android version (no backward compatibility of vendor libraries interface is required) could be flashed to a Project Treble compatible phone and it should just work(tm). After few years, the reality is still not there, the basic peripherals usually work under GSI, but the more exotic one (fingerprint sensor) still tend to have issues, also the power consumption can be inferior to the stock ROM, etc.
There are (assuming a Project Treble compatible phones) two possible partition schemes, the older scheme with only a single system partition (old, A only,...) and a dual system partitions (called A/B). The A/B scheme was designed to allow seamless system updates. The old scheme required OTA process to boot into a special recovery
partition to reflash the other partitions (requiring a loooooong reboot), during the process the phone could get bricked or something else could go wrong with no way to go back.
The new (A/B) scheme doubles the important partitions (system
, vendor
,...) into so called slots (slot A and slot B). During the OTA process, the system can be running normally from the current slot, while the other, unused, partition is being overwritten. Once it's done a simple and short reboot is enough needed to bring the phone to a newly flashed firmware. If one of the partitions gets corrupted, the phone simply boots the previous one.
Common partitions on both schemes:
boot
and recovery
, determines slot to boot for A/B schemes, decides if recovery shall be booted and finally loads the selected kernel and ramdisk into RAM and executes it. A only:
system
partitionA/B - the slot specific partitions (replace x by either a or b):
There are much more stuff on the common android system, if interested, run ls -l /dev/block/platform/soc/11270000.ufshci/by-name/
on your phone. The path can be slightly different, based on your phone.
The bootloader of the android system checks integrity and validity of the data it's loading into the memory. Without getting manufacturer private key used for signing the stock rom files, it's impossible to run a custom software on your device. You would need to modify the bootloader itself or even somehow hack the keys storage on the SoC which could be close to impossible.
Fortunately, the bootloaders of many phones can be unlocked, it basically means some flag is set inside the bootloader to skip the verification. Sometimes all that's needed it's a simple fastboot command and a button press, sometimes you need to explicitly ask the vendor for unlocking key, install some insane chinese software, register, wait for month (looking at you, Xiaomi) to get the key,... And sometimes it's disabled completely, so unless you are a gifter hacker with months of free time, it's better to just sell the phone.
Once the bootloader is unlocked, it will report the orange
state and halt for 5 seconds before booting. See the Boot Flow documentation for more details.
The android uses a linux feature DM-Verity to check for integrity of the data partitions (system and other read-only parts in the flash). It uses a cryptographic hash tree to do it - there's a hash stored for each 4K block of the storage, these hashes and hashed and so on until a single hash is obtained - the root hash. This way the android can e.g. detect when a malicious software modifies something in the system partition (insert a virus or something).
The hashed have to be stored somewhere, and that's when the vbmeta partitions come in play. This partition holds hashes for boot
and other stuff. Additionally, the content of the vbmeta is cryptographically signed to allow any tampering with the data.
The vbmeta
partitions can (and usually are) be chained, so usually there's a vbmeta_system
partition with hashes for system
partition, etc. Once you break any part of the chain (by changing one of the vbmeta
partitions or the data which are protected by the dm-verify
), the system won't boot.
To flash a custom rom, the vbmeta
partition needs to be flashed with a modified content to disable the integrity checking. As the vbmeta
contains a root of the chain of trust, only this partition needs to be written, the others (vbmeta_system
) will be simply ignored as the root is gone.
It would be nice to flash a valid vbmeta
content to allow integrity checking of your ROM, but as the vbmeta
content is usually signed by the vendor, it's not easy to do it, therefore people usually tend to ignore it.
The fastboot
is a little confusing term. It's
When the phone boots into a bootloader
, it will be accessible over the USB by fastboot
application on computer. This mode is used to flash critical and static partitions of the flash memory - like recovery
. The bootloader itself is really simple and doesn't necessarily support access to dynamic partitions (system_a
for example).
A more advanced fastbootd mode is accessible in a dedicated fastboot
mode, usually accessible from the recovery
, by calling adb reboot fastboot
or by a special combination of button presses during power on. The fastbootd
is almost the same as the bootloader
one, but in this case, it runs as an userspace app inside the recovery
system and usually has much more capabilities - it can flash dynamic partitions. The same fastboot
application on computer is used for communication.