Installing TWRP on Xiaomi Mi5: a complete guide to unlocking the bootloader

Why install TWRP on Xiaomi Mi5

Xiaomi Mi5 (codenamed gemini), released in 2016, is still popular among custom firmware enthusiasts. Installing TWRP (Team Win Recovery Project) gives access to advanced features: creating full backups, firmware for informal ROMs (like LineageOS or Pixel Experience), root rights through Magisk, and removing embedded MIUI applications. Without TWRP, many operations with the system are simply impossible.

However, the Mi5 installation process has nuances: it requires unlocking the bootloader, which is officially supported by Xiaomi, but takes up to 720 hours of latency. In addition, improper actions can lead to a device β€œbrick” when the phone stops loading. In this article, we will discuss the current method of installing TWRP on the Mi5 in 2026, taking into account changes in Xiaomi policy and model features.

Before you start, make sure your Mi5 meets the following criteria:

  • πŸ“± Model: Xiaomi Mi5 (gemini, do not confuse with Mi5s or Mi5s Plus – they use other files. TWRP!
  • πŸ”‹ Battery charge: at least 60% (process can take up to 30 minutes).
  • πŸ’» Computer: Windows 10/11 Linux (for Mac, additional drivers will be required).
  • πŸ”Œ Cable: original USB Type-C, undamaged.

Step 1: Unlock bootloader on Xiaomi Mi5

You can't install TWRP without an unlocked bootloader. Xiaomi officially allows unlocking, but the process requires linking your Mi Account to your device and waiting. In 2026, the wait time is 360 hours (15 days) for new accounts. If your account is created long ago and has previously unlocked other devices, the time limit can be reduced to 72 hours.

Instructions for unlocking:

  1. Activate Developer Options: Go to Settings β†’ About Phone and click on MIUI 7 times.
  2. Back to Settings β†’ Additionally. β†’ For developers and include: πŸ”“ Unlocking OEM (It may not be available on some versions. MIUI). πŸ”Œ Debugging by USB.

Mi Account

Settings β†’ Xiaomi Account β†’ Synchronization

Mi Unlock Tool

Sign in to the tool under the same account as on the phone.

Mi5

Fastboot

Loudness down + Nutrition

Unlock

⚠️ Note: If the "Couldn't unlock" error appears when unlocking, check: πŸ”Ή Mi Account is linked to phone and confirmed by SMS/email. πŸ”Ή The phone is synchronized with Mi Cloud. πŸ”Ή You use the original cable and port. USB 2.0 (USB 3.0 malfunction).

πŸ“Š How long are you willing to wait for the bootloader to unlock?
Up to 72 hours.
Up to 15 days.
Any deadline
Already unlocked before.

Step 2: Prepare tools and files

Before the firmware TWRP You need to download and prepare all the required files. Using outdated versions can cause crashes or a soft breeze (when the phone loads, but with errors:

ComponentVersion.ReferenceNotes
TWRP for Mi5 (gemini)3.7.0_12-0Official websiteUse the file. twrp-3.7.0_12-0-gemini.img
ADB & Fastboot33.0.3Android DevelopersUnpack into the root of the disk C:\platform-tools\
Xiaomi drivers2026Mi PC SuiteInstall before connecting the phone
Magisk (optional)26.4GitHubTo obtain root rights after installing TWRP

After downloading the files:

  1. Place it. twrp-3.7.0_12-0-gemini.img folder C:\platform-tools\.
  2. Rename the file to twrp.img for convenience.
  3. Open the command prompt in this folder: click Shift + PCM β†’ Open the PowerShell window here.

bootloader unlocked | Download TWRP for gemini| Installed drivers Xiaomi| Battery Charge >60%| Antivirus disabled (can block fastboot)

-->

Step 3: Install TWRP via Fastboot

Now, to the firmware itself, this process takes no more than 5 minutes, but requires precise execution of commands, and errors at this stage can lead to data loss or the need to flash through the firmware. EDL-regime.

Step-by-step:

  1. Turn off the Mi5 and press Volume Down + Power to enter the Fastboot.
  2. Connect your phone to your PC. Make sure the Android Bootloader Interface is displayed in the Device Manager.
  3. In the command line (in the platform-tools folder), run the command: fastboot devices Should appear serial number of the device. If not, check the drivers.
  4. Squeeze TWRP temporarily (for one-time download): fastboot boot twrp.img The phone will reboot to TWRP.
  5. In TWRP, select Advanced β†’ ADB Sideload and swipe for confirmation.
  6. On PC, run the command for permanent installation: fastboot flash recovery twrp.img
  7. Reboot your phone in TWRP with the command: fastboot reboot recovery

⚠️ Note: If after restarting the phone starts in standard recaveri MIUI, So the firmware is not going to work. It's because of the anti-rollback feature in the newer versions. MIUI. Decision: πŸ”Ή Repeat the command fastboot flash recovery twrp.img. πŸ”Ή Immediately after the firmware, perform fastboot reboot recovery, preventing the system from booting.

πŸ’‘

If TWRP asks for a password when downloading, it means that data encryption is enabled. To get around it, reset to factory settings in a standard recap before installing TWRP (but this will delete all data!).

Step 4: Solving Common Mistakes

Even with the exact instructions, errors can occur, and the following are the most common problems and solutions that will be relevant for the Xiaomi Mi5 in 2026:

Mistake.Reason.Decision
FAILED (remote: 'Flashing is not allowed in Lock State')The bootloader is not unlockedRepeat the unlocking process with the Mi Unlock Tool
Invalid sparse file format at headerTWRP file damagedDownload the image again, check the checksum (MD5)
Phone is not defined in fastboot devicesProblems with drivers or cableTry another one. USB-port, disable antivirus, install drivers manually through Device Manager
TWRP asks for a password, but it doesn’t existEncryption of data in MIUIFormat /data to TWRP (all data will be deleted!)

If after installing TWRP, the phone boots to bootloop (cyclic reboot), follow the following steps:

  1. Press Volume Up + Power to enter TWRP.
  2. Go to Wipe β†’ Format Data, enter Yes and confirm.
  3. Reboot to TWRP and flash Magisk (if root is needed) or custom firmware.

What if TWRP is not installed at all?
If all attempts are made TWRP fail "FAILED (remote: 'Not allowed in Locked State') even after unlocking, the reason may lie in the: πŸ”Ή Incompatible version MIUI: Some global firmware is blocking custom recavery installation. MIUI via fastboot, then repeat the installation TWRP. πŸ”Ή Hardware locking: on some batches Mi5 (Xiaomi introduced additional protection, in which case only the firmware through the EDL (emergency mode) using an authorized account.

Step 5: Additional settings after installing TWRP

Successful TWRP installation is only half the battle, and to avoid future problems, a few additional steps are recommended:

  • πŸ”§ Disable Forced Encryption: In TWRP Go to Wipe. β†’ Format Data and format the partition /data. This will delete all data, but prevent problems with accessing internal memory.
  • πŸ“¦ Create a backup: in the main menu TWRP Select Backup and save copies of Boot, System, Data partitions. SD-card.
  • πŸ”‘ Install Magisk for root: download the latest version of Magisk (see table above) and run through Install β†’ Select Zip.
  • πŸ”„ Turn off the updates MIUI: If you plan to use custom firmware, freeze the Updater app via Magisk or remove it in the app. TWRP.

If you plan to flash custom firmware (for example, LineageOS or Pixel Experience), before you do it, you must:

  1. Check the firmware compatibility with the gemini model.
  2. Make sure that the firmware version of Android is not lower than the current one on the phone (otherwise the risk of β€œbrick”).
  3. First, go to vendor and firmware (if they are separate).

πŸ’‘

After installation TWRP never take it OTA-update MIUI This will lead to a replacement of the recaveri with stock and possible root loss. TWRP manually.

Step 6: How to return stock Recovery (if needed)

If you need to return the original recovery (for example, for warranty repairs or for selling your phone), follow the following steps:

  1. Download the stock firmware for Mi5 official website: 🌐 MIUI Downloads πŸ” Choose a model. Mi5 (gemini) and the latest stable version.

recovery.img

Fastboot

fastboot flash recovery recovery.img
fastboot reboot

After that, the standard Recovery will be restored, but the bootloader unlock will remain, to fully return the phone to the factory state:

  1. Enter the stock Recovery (Loudness up + Nutrition).
  2. Choose Wipe Data β†’ Wipe All Data.
  3. Fly the full stock firmware through fastboot: fastboot flash all [name file].tgz

Solution: boot into TWRP (Loudness Up + Power), back up and reflash the system.

❓ How to update TWRP on Mi5?
The update is done in the same way as the original installation: Download the new version of twrp.img. Download to the current TWRP. Select Advanced β†’ Install Recovery Ramdisk and specify the new file. Reboot to the reclaims. Don't update TWRP through apps like the Official TWRP App - this can cause crashes!
❓ Can I stitch it? TWRP through ADB Sideload?
Yes, but it's less reliable than fastboot. For this: Boot into stock receptacles. Select Apply update from ADB. On PC, run adb sideload twrp.zip, but on Mi5, this method often leads to the error "E:footer is wrong" due to signature verification.
❓ Where to get a stock firmware for Mi5, If the official website is not working?
Official firmware for Mi5 also available: πŸ”— Xiaomi Firmware Updater (archived versions). πŸ”— XDA Developers (section for the Mi5). Before downloading, check the hash file (MD5) reviews from other users.