If you've flashed a ROM before, it's exactly the same. Unlock the device, flash TWRP, install ROM. Exceptions:
- Make sure to securely backup EFS using the TWRP backup function and persist.img using
adb shell dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/persist.img
while you are still in TWRP. - Unlocking your device requires a Mi Account. You can find instructions on how to do this in developer settings.
- You may get stuck in recovery until you format data when you try to boot into your ROM after flashing.
- Read the full instructions to know when to wipe
- Android Platform Tools (for ADB and fastboot): https://developer.android.com/studio/releases/platform-tools
- TWRP img file, your ROM zip, and optionally gapps and/or magisk
- Create and login with a Mi Account, and enable find device and add phone number (AFAIK, might need more steps)
- Enable developer options by going to About phone and tapping the MIUI-version 7 times
- Go to additional settings -> developer settings -> enable OEM unlocking and go to Mi unlock status, register for unlocking
- Wait a week. To check how long you have to wait, continue following these steps.
- Download and run the latest xiaomi flash tool
- Reboot to bootloader (for fastboot):
adb reboot bootloader
- run
fastboot flash recovery recovery.img
- Press and hold volume up & power until you see the TWRP logo
- If prompted, enter your password
- backup persist.img:
adb shell dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/persist.img
- then retrieve the file from your phone using
adb pull /sdcard/persist.img
. important: back up this persist.img file, preferably on two or more locations! - Backup EFS: on your phone, tap backup and only select EFS. Backing up other parts is optional.
- Retrieve the EFS backup:
adb pull /sdcard/TWRP
- Tap wipe on your phone and swipe to factory reset
- Start sideload:
adb shell twrp sideload
- Sideload ROM:
adb sideload <your ROM zip file>
, for example:adb sideload lineageOS.zip
- Optionally: install magisk and/or gapps.
- Go to wipe, tap format data and type 'yes'
- Run
adb reboot
to boot to your new ROM.