Replace stock recovery image on Xiaomi POCO F1 with TWRP using Magisk
I decided to replace MIUI 12.0.3 on my POCO F1 with a custom ROM because the phone will get no further update from Xiaomi. I have written the entire procedure in three parts:
- Unlock bootloader
- Replace stock recovery image with TWRP using Magisk
- Install (or flash) custom ROM using TWRP
How
This step is to replace the stock recovery image with the venerable Magisk android application. The reason for using Magisk is to replace the recovery image on the phone permanently. Otherwise, MIUI will replace TWRP with the stock recovery image every time the phone reboots, in which case, I will have to re-run steps below to boot into TWRP image.
Watch the video to get an idea the entire procedure using MS Windows, https://www.youtube.com/watch?v=ZKEHRco06Eo Below I describe what I had to do differently using Fedora 34 Workstation.
Also important as emphasised in the video is that I have decided to retain “Encryption and Credentials” encrypted on the phone. This will mean having to perform backup and restore personal files if I opt for a custom ROM which does not support OTA and want to update it.
-
Download the latest Magisk APK from https://github.com/topjohnwu/Magisk/releases and save the APK file on the phone
-
Download the latest Android platform tools from https://developer.android.com/studio/releases/platform-tools
-
Unzip the package anywhere, e.g. /tmp/platform-tools
-
Download the latest TWRP specific to the phone from https://twrp.me/xiaomi/xiaomipocophonef1.html I was actually confused by the instructions given on the page. In the end, what really mattered was to download the image file and do nothing else. At this time, the file was
twrp-3.5.2_9-0-beryllium.img
-
Copy the image file to /tmp/platform-tools and rename it as
twrp.img
for convenience, and also copy it to the phone. -
On the phone, go to Developer Options to enable USB debugging
-
Connect the phone to the computer using the original (or fully USB2 compliant) cable
-
Test connectivity between them. The output should display one device detected. If not, try other USB ports on the computer. Avoid USB-3 ports if possible because there’s reported issues involving USB Hub.
cd /tmp/platform-tools sudo ./adb devices
-
Use adb to reboot to “fastboot” mode. After the command, the phone should reboot to a static “fastboot” image.
sudo ./adb reboot bootloader
-
Test connectivity again to be sure but using
fastboot
command this time. Again, the phone should be listed.sudo ./fastboot devices
-
Boot to TWRP image. When TWRP main menu shows up on the phone, disconnect the USB cable. From here on, follow every step exactly given in the video which I have listed below for convenience.
sudo ./fastboot boot twrp.img
-
On TWRP main menu, select “Install image” and browse to the TWRP image file previously copied to the phone, and select “Recovery”. When complete, select Home option to return to main TWRP menu, select Reboot - Recovery
-
Rebooting back to TWRP main menu, select Install and browse to Magisk APK file previously copied to the phone. Reason for doing this step is well explained in the video. When done, Reboot System.
-
Test that TWRP has replaced the stock recovery image successfully, switch off the phone. Press Volume-up and Power button at the same time to go into recovery mode. It should show TWRP main menu now.