[GUIDE][GRUS]How to flash TWRP and GSI ROMs on MI 9 SE

Search This thread

Flounderist

Senior Member
Jan 7, 2016
836
407
Cork
# I assume you are confident with ADB and Fastboot commands and you know what you are doing. :D #
# If you don't, search on Google before messing with your device. #
# I am not responsible for...you know what I mean. On the other hand, please feel free to point out any error in this guide. #
# Lots of useful information can be found on Telegram Group for Mi 9 SE #

# If you already unlocked your bootloader and flashed TWRP, go directly to part 2 of this guide #

PART 1 - UNLOCK DEVICE AND FLASH TWRP

# Before starting, be sure that you can unlock your bootloader and you have these files: #​

- Mi Unlock tool (http://en.miui.com/unlock/)
- Minimal ADB & Fastboot 1.4.3 (https://forum.xda-developers.com/showthread.php?t=2317790)
- TWRP recovery for your device (please check the development section).
Install ADB and Fastboot drivers on your PC, if you don't have them already.

- enable developer options on device, allow OEM unlock and ADB debug.
- install Minimal ADB & Fastboot tool and run a command window. PLEASE DON'T USE WINDOWS 10 POWER SHELL. Double click on "cmdhere.dll" in root folder instead.
- move twrp image in the same folder where Minimal ADB & Fastboot is installed.
- for your convenience, rename twrp file as "twrp" only.
- connect your device to your PC USB port, pair it with PC then reboot it to bootloader (power + volume down combo).

Unlock bootloader using Mi Unlock tool (full unlocking guide at https://c.mi.com/thread-1635834-1-1.html)
Unlocking bootloader will erase all of your data, including storage.
Once you unlocked:

- reboot and setup device
- enable developer options again
- double check bootloader status and allow ADB debug
- connect to USB port and pair device with PC for ADB debug bridge then type in command window:
Code:
adb devices
Code:
adb reboot bootloader
once in bootloader screen code:
Code:
fastboot devices
Code:
fastboot flash recovery twrp.img
- don't give fastboot command "fastboot boot recovery twrp" or "fastboot reboot recovery twrp". Just press and hold power+volume up for about 10 seconds to reboot to recovery.
- swipe to allow twrp modifications.
- I would suggest to NOT format data to get rid of encryption unless you actually need it. Encryption does not slow down your device or harm your battery life.
- I would also suggest to NOT wipe system and reboot to recovery because it could lead to a fastboot bootloop.
 
Last edited:

Flounderist

Senior Member
Jan 7, 2016
836
407
Cork
PART 2 - HOW TO FLASH A GSI ROM​

# IMPORTANT #

When flashing a GSI ROM, it is recommended to use a Stable firmware as base.
If device is running different builds, flash latest Global or China Stable before starting using MiFlash tool.
Beware that device could have the anti-rollback enabled, so be careful when flashing another firmware.

Mi 9 SE is a system-as-root device, so you must flash A/B type GSI ROMs.

You will need these files:

- GSI A/B ROM (FlokoROM at https://treble.andro.plus/ or choose one at https://forum.xda-developers.com/project-treble/trebleenabled-device-development)
- vbmeta.img (https://androidfilehost.com/?fid=818070582850505317)
- gapps for Google services (https://opengapps.org/) - select ARM64 - 9.0 - I would suggest nano or pico package.
- magisk for root and modules (https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445)
- MiFlash flashable STABLE stock firmware (http://en.miui.com/download or https://mirom.ezbox.idv.tw/en/phone/grus/)
- MiFlash tool (https://www.xiaomiflash.com/)

If you are already running a Stable firmware start from here, if you don't, flash a Stable firmware.

- move GSI and vbmeta images in the same folder where Minimal ADB & Fastboot is installed.
- for your convenience, rename GSI file as "system" only.
- reboot device to bootloader, ensure you are connected with your PC properly
- to double check it, run a command window and type:
Code:
fastboot devices

once you get the device recognized type:
Code:
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
this command will disable dm-verity and AVB on device. PLEASE DON'T USE WINDOWS 10 POWER SHELL to disable vbmeta or you will get an error feedback. Double click on "cmdhere.dll" in root folder instead.
then:
Code:
fastboot flash system system.img
this command will flash system.img
Code:
fastboot -w
this command will wipe data on device

Reboot your device in recovery using button combo and resize system partition to install Gapps.
From TWRP Wipe menu > advanced wipe > system > repair or change file system > resize system > swipe to resize

- move magisk and gapps from PC to device
- go to mount menu and tick mount system
- go back to install menu and flash gapps
- once you flashed gapps unmount system
- go to install and flash magisk
- go to wipe menu and swipe for factory reset
- reboot

once rebooted, complete the device setup.

be aware that some GSI could bootloop or not boot at all even if you followed the guide properly.
in case rely on GSI devs for assistance or fixes.
 
Last edited:

Flounderist

Senior Member
Jan 7, 2016
836
407
Cork
Of course you can flash a GSI ROM using TWRP.
The only fastboot command you need to perform is to disable dm-verity and AVB.
If you already disabled it while flashing TWRP for the first time, you can follow these steps to flash a GSI using TWRP:
- Tap on advanced Wipe menu and wipe cache, dalvik, data and system
- Tap on Install > Install Image > select image and flash it to system
- Install Gapps with the same process shown above.
- Swipe for factory reset and reboot.

-----------------------------------------------------------------------------------------------------------------------------------------------

If updating GSIs builds from the same branch (e.g. Floko 060219 to Floko 060919) you are not required to wipe data. You can update flashing system.img on TWRP and Gapps time by time.
If you are moving from unofficial builds to official, or if you are moving between branches (e.g. Floko to Havoc), you need to wipe data as well.
 
Last edited:

Flounderist

Senior Member
Jan 7, 2016
836
407
Cork
If you flashed a GSI ROM, you are basically using a system.img flashed on top of your stock firmware so, unless you performed modifications to vendor or boot partition, you can revert to stock using fastboot or TWRP.
You need to extract system.img (and boot and vendor, if needed) from the stock firmware.
You will need the vbmeta file as well to re-enable AVB and dm-verity otherwise the device will reboot in fastboot mode only.
Beware: you must flash EXACTLY the same system.img of the firmware you were running before flashing a GSI
Once you have both files, you can follow these steps to go back to stock using fastboot:
- place the files on Minimal ADB & Fastboot root folder
- reboot bootloader
- start a command window from Minimal ADB and type: fastboot devices
once your device has been recognized type the following commands:
- fastboot -w
- fastboot flash system system.img
- (optional) fastboot flash vendor vendor.img
- (optional) fastboot flash boot boot.img
- fastboot flash vbmeta vbmeta.img
- fastboot reboot

You can also revert to stock using TWRP, by the way you will still need fastboot to flash vbmeta partition.
These are the steps to follow if you are using TWRP:
- place system.img on your device and vbmeta.img in Minimal ADB & Fastboot root folder.
- reboot to twrp and wipe dalvik, cache and data
- flash system.img to system partition
- (optional) flash vendor.img to vendor partition
- (optional) flash boot.img to boot partition
- reboot to bootloader
Start a command window in Minimal ADB & Fastboot, then type:
- fastboot devices
- fastboot flash vbmeta vbmeta.img
- fastboot reboot
 
Last edited:
  • Like
Reactions: bilal.fanatic

scorpionredblack

Senior Member
Apr 25, 2009
126
9
Lazio
www.tuttoandroid.net
Today I had some time and I tried to install the latest Havoc Gsi, unfortunately the result was negative, I ran the guide both from xda and from here, my basic rom was 10.2.3.0, arrived at the command fastboot -w performs the various wipes, but then it does not allow me to go into recovery, it always and only goes in fastboot, and the only way to make the smartphone work is to use miflash and put the official version back.
 

jimmy16

Senior Member
Sep 5, 2009
194
41
Brasov
Today I had some time and I tried to install the latest Havoc Gsi, unfortunately the result was negative, I ran the guide both from xda and from here, my basic rom was 10.2.3.0, arrived at the command fastboot -w performs the various wipes, but then it does not allow me to go into recovery, it always and only goes in fastboot, and the only way to make the smartphone work is to use miflash and put the official version back.

Try to flash vbmeta.
For me is not necesary.
Try like this from twrp:
- Wipe cache, dalvik cache, system, data
- Flash latest weekly eu firmware as base xiaomi.eu_multi_MI9SE_9.6.5_v10-9.zip
- Than flash havoc as system
Optional: flash magisk and custom kernel
 
  • Like
Reactions: sky104hk

krispuniq

Senior Member
Oct 21, 2008
533
71
Birmingham
Before I flash this, I world like to know from those already using this rom: How is the camera quality and finger print unlock response /speed?

I'm pissed at the frequent snow down of the miui system because I run vpn all day on my phone.

Sent from my Mi 9 SE using Tapatalk
 

Flounderist

Senior Member
Jan 7, 2016
836
407
Cork
Before I flash this...

Generally speaking, all the GSIs ROMs are based on Phhusson AOSP GSI ROM, so they have more or less the same performance and bugs.
At he moment FOD is not working well. You cannot unblock the device while on screen off or while on AOD.
For camera, you can install BSG Google Camera mod, that is working quite good.
 
  • Like
Reactions: krispuniq

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    # I assume you are confident with ADB and Fastboot commands and you know what you are doing. :D #
    # If you don't, search on Google before messing with your device. #
    # I am not responsible for...you know what I mean. On the other hand, please feel free to point out any error in this guide. #
    # Lots of useful information can be found on Telegram Group for Mi 9 SE #

    # If you already unlocked your bootloader and flashed TWRP, go directly to part 2 of this guide #

    PART 1 - UNLOCK DEVICE AND FLASH TWRP

    # Before starting, be sure that you can unlock your bootloader and you have these files: #​

    - Mi Unlock tool (http://en.miui.com/unlock/)
    - Minimal ADB & Fastboot 1.4.3 (https://forum.xda-developers.com/showthread.php?t=2317790)
    - TWRP recovery for your device (please check the development section).
    Install ADB and Fastboot drivers on your PC, if you don't have them already.

    - enable developer options on device, allow OEM unlock and ADB debug.
    - install Minimal ADB & Fastboot tool and run a command window. PLEASE DON'T USE WINDOWS 10 POWER SHELL. Double click on "cmdhere.dll" in root folder instead.
    - move twrp image in the same folder where Minimal ADB & Fastboot is installed.
    - for your convenience, rename twrp file as "twrp" only.
    - connect your device to your PC USB port, pair it with PC then reboot it to bootloader (power + volume down combo).

    Unlock bootloader using Mi Unlock tool (full unlocking guide at https://c.mi.com/thread-1635834-1-1.html)
    Unlocking bootloader will erase all of your data, including storage.
    Once you unlocked:

    - reboot and setup device
    - enable developer options again
    - double check bootloader status and allow ADB debug
    - connect to USB port and pair device with PC for ADB debug bridge then type in command window:
    Code:
    adb devices
    Code:
    adb reboot bootloader
    once in bootloader screen code:
    Code:
    fastboot devices
    Code:
    fastboot flash recovery twrp.img
    - don't give fastboot command "fastboot boot recovery twrp" or "fastboot reboot recovery twrp". Just press and hold power+volume up for about 10 seconds to reboot to recovery.
    - swipe to allow twrp modifications.
    - I would suggest to NOT format data to get rid of encryption unless you actually need it. Encryption does not slow down your device or harm your battery life.
    - I would also suggest to NOT wipe system and reboot to recovery because it could lead to a fastboot bootloop.
    8
    PART 2 - HOW TO FLASH A GSI ROM​

    # IMPORTANT #

    When flashing a GSI ROM, it is recommended to use a Stable firmware as base.
    If device is running different builds, flash latest Global or China Stable before starting using MiFlash tool.
    Beware that device could have the anti-rollback enabled, so be careful when flashing another firmware.

    Mi 9 SE is a system-as-root device, so you must flash A/B type GSI ROMs.

    You will need these files:

    - GSI A/B ROM (FlokoROM at https://treble.andro.plus/ or choose one at https://forum.xda-developers.com/project-treble/trebleenabled-device-development)
    - vbmeta.img (https://androidfilehost.com/?fid=818070582850505317)
    - gapps for Google services (https://opengapps.org/) - select ARM64 - 9.0 - I would suggest nano or pico package.
    - magisk for root and modules (https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445)
    - MiFlash flashable STABLE stock firmware (http://en.miui.com/download or https://mirom.ezbox.idv.tw/en/phone/grus/)
    - MiFlash tool (https://www.xiaomiflash.com/)

    If you are already running a Stable firmware start from here, if you don't, flash a Stable firmware.

    - move GSI and vbmeta images in the same folder where Minimal ADB & Fastboot is installed.
    - for your convenience, rename GSI file as "system" only.
    - reboot device to bootloader, ensure you are connected with your PC properly
    - to double check it, run a command window and type:
    Code:
    fastboot devices

    once you get the device recognized type:
    Code:
    fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
    this command will disable dm-verity and AVB on device. PLEASE DON'T USE WINDOWS 10 POWER SHELL to disable vbmeta or you will get an error feedback. Double click on "cmdhere.dll" in root folder instead.
    then:
    Code:
    fastboot flash system system.img
    this command will flash system.img
    Code:
    fastboot -w
    this command will wipe data on device

    Reboot your device in recovery using button combo and resize system partition to install Gapps.
    From TWRP Wipe menu > advanced wipe > system > repair or change file system > resize system > swipe to resize

    - move magisk and gapps from PC to device
    - go to mount menu and tick mount system
    - go back to install menu and flash gapps
    - once you flashed gapps unmount system
    - go to install and flash magisk
    - go to wipe menu and swipe for factory reset
    - reboot

    once rebooted, complete the device setup.

    be aware that some GSI could bootloop or not boot at all even if you followed the guide properly.
    in case rely on GSI devs for assistance or fixes.
    3
    Of course you can flash a GSI ROM using TWRP.
    The only fastboot command you need to perform is to disable dm-verity and AVB.
    If you already disabled it while flashing TWRP for the first time, you can follow these steps to flash a GSI using TWRP:
    - Tap on advanced Wipe menu and wipe cache, dalvik, data and system
    - Tap on Install > Install Image > select image and flash it to system
    - Install Gapps with the same process shown above.
    - Swipe for factory reset and reboot.

    -----------------------------------------------------------------------------------------------------------------------------------------------

    If updating GSIs builds from the same branch (e.g. Floko 060219 to Floko 060919) you are not required to wipe data. You can update flashing system.img on TWRP and Gapps time by time.
    If you are moving from unofficial builds to official, or if you are moving between branches (e.g. Floko to Havoc), you need to wipe data as well.
    2
    What do I have to do if I just want to install magisk?
    Just flash Magisk zip in twrp :laugh:
    2
    Great guide. It will help a lot of people to flash and test roms. And us by extension to find the best rom for our device :p !
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone