MIUI is a haunting ghost operating system. Requesting unblocking the bootloader is an act of war against the Xiaomi corporate. They’ll do anything to keep you in. If they cannot they’ll make your life miserable by pushing you to give up.

This was not the first time I replaced a stock Android. This was not the first time I replaced a Xiaomi stock Android. But this time was the toughest.

Warning: The experimend described here is risky. Act wisely and take upon yourself any risk.

I plugged in the phone into a pc. I use linux so other operating system is beyond the scope of this material. I have adb and fastboot installed. I installed in ~/adb-fastboot.

I installed on a Xiaomi Redmi Note 8 Pro. Codename begonia. It is important to identify correct the codename: the non-Pro codname is ginkgo and is not compatible.

Either LineageOs (non-official) or one of the list

Veryfy the signature sha256sum custom-rom-package.zip.

Download the new recovery. I used TWRP but there are others. Another one is Orange Fox. The latest can update OTA from within the recovery.

In anycase you need to follow instructions on that page because there are particular challenges. Here they are:

This device uses Android Verified Boot (AVB). Get read of it. First look inside your ROM’s archive and extract vbmet.img. Then flash the avb: fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

Recovery refers to the dedicated, bootable partition that has the recovery console installed The stock recovery is pretty limited by design. Custom Android recoveries more. They allow for backup and restore functions, selective deletion of data so you don’t have to wipe everything, and modified to allow update packages that have not been digitally signed by official sources. You also can mount various partitions.

You can boot your phone via command line in 3 states: normal (that is your OS): adb reboot either in recovery adb reboot recovery or fastboot adb reboot fastboot, same effect with adb reboot bootloader

Boot into fastboot mode.

adb reboot fastboot

Checking connectivy:

sudo fastboot devices
lbfmzpgu4pofmjso	fastboot

Flash recovery sudo fastboot flash recovery twrp.img

fastboot --disable-verity --disable-verification flash flash vbmeta vbmeta.img

Rename the image to twrp.img and type: fastboot flash recovery twrp.img then fastboot reboot.

Important!

Note many devices will replace your custom recovery automatically during first boot. To prevent this, you need to enter the proper key combo to enter recovery. After typing fastboot reboot, hold the key combo and boot to TWRP. Once TWRP is booted, TWRP will patch the stock ROM to prevent the stock ROM from replacing TWRP. If you don’t follow this step, you will have to repeat the install.

The combo key for begonia is: Hold Up + Power keys for 5 sec then when logo appears release the power key. You only do that first time.

After fastboot reboot and holding the combo keys you must be now in the Recovery mode (twrp)

If your phone is in fastboot mode: fastboot reboot recovery. Some phones do not respond to it, try adb reboot recovery.

With the device powered off, hold Volume Down + Power. Wait 5 sec.

You have two ways to install the package manually with adb push or automatic with adb sideload

Manually: adb push custom-rom-package.zip /sdcard/ and then from TWRP menu install and select package. Some packages do not include gapps so you need to add it separately.

Automatic: From TWRP select Advanced>Sideload then run command on pc adb sideload custom-rom-package.zip

In both cases when installing Ressurection Remix OS I run into an infamous error: “Zip Treble Compatibility Error !Invalid zip file formate!”. After browsing the internet I found I need to remove the package compatibility.zip from inside the custom ROm package. I could not delete it from inside archive so I had to rearchive it.

unzip RROS-Q-8.5.9-20200824-begonia-Official.zip 
rm -rf compatibility.zip
zip -r RROS.zip *

The device kept restarting.

So I tried with Pixel Experience OS Official. The device kept restarting again.

The phone’s OS was instable and kept starting over and over. So I tried with Evolution X Official package. Same fate. Then Lineage OS Unofficial (official was not available). Yep, finally stable. With Open Gapps on. Except one blocking issue. The Revolut App was not available in the Google Play. Perhaps the system was not reliable (official) for them.

While trying to fix this issue, I run into the same big dump: phone started again suddenly.

Now was the time to read carefully the instruction details.

Some novelties. I went dipper and I realize I had to deal with A10 Custom Firmware, CFW for short, a set of custom firmware packages It is a combination of multiple Xiaomi firmware packages. You need to have it installed. So I copied CFW in the sideload folder.

I installed the package prior to installing the operating system from TWRP > Install

Now, a very interesting operation (not fully sure is necessary) but it is recommended to copy the following packages outside the OS packages and run the following commands from fastboot. This is the “anti-brick” factory preloaders. See warnings and recommendations on the link below.

fastboot flash preloader preloader_begonia.bin
fastboot flash lk lk.img
fastboot flash lk2 lk.img

Finally I ended in getting rid of Xiaomi MIUI and having a full fledged Xiaomi Redmi Note 8 Pro custom ROMed.

A lot of adeventure.

References: XDA Forum.