Skip to content

Instantly share code, notes, and snippets.

@2zqa
Created April 29, 2020 17:06
Show Gist options
  • Save 2zqa/3276ffa42818d870648a54829c721a3e to your computer and use it in GitHub Desktop.
Save 2zqa/3276ffa42818d870648a54829c721a3e to your computer and use it in GitHub Desktop.

Flashing a ROM on Mi 9T from start to end

TLDR

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

Prerequisites

  1. Android Platform Tools (for ADB and fastboot): https://developer.android.com/studio/releases/platform-tools
  2. TWRP img file, your ROM zip, and optionally gapps and/or magisk

Unlocking device

  1. Create and login with a Mi Account, and enable find device and add phone number (AFAIK, might need more steps)
  2. Enable developer options by going to About phone and tapping the MIUI-version 7 times
  3. Go to additional settings -> developer settings -> enable OEM unlocking and go to Mi unlock status, register for unlocking
  4. Wait a week. To check how long you have to wait, continue following these steps.
  5. Download and run the latest xiaomi flash tool

Flashing

  1. Reboot to bootloader (for fastboot): adb reboot bootloader
  2. run fastboot flash recovery recovery.img
  3. Press and hold volume up & power until you see the TWRP logo
  4. If prompted, enter your password
  5. backup persist.img: adb shell dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/persist.img
  6. 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!
  7. Backup EFS: on your phone, tap backup and only select EFS. Backing up other parts is optional.
  8. Retrieve the EFS backup: adb pull /sdcard/TWRP
  9. Tap wipe on your phone and swipe to factory reset
  10. Start sideload: adb shell twrp sideload
  11. Sideload ROM: adb sideload <your ROM zip file>, for example: adb sideload lineageOS.zip
  12. Optionally: install magisk and/or gapps.
  13. Go to wipe, tap format data and type 'yes'
  14. Run adb reboot to boot to your new ROM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment