Installing custom TWRP on Xiaomi smartphones provides access to advanced features: system backup, firmware informal ROM and even recovery of bricks. However, the process requires care - an error at any stage can lead to locking the device requiring authorization Mi Account even after reset. In this guide, we will discuss the official method of installation via PC using ADB and Fastboot, relevant for models 2020-2026.
Itβs important to understand that Xiaomi actively blocks unauthorized modifications. The consequences can range from loss of warranty to complete loss of functionality of the device. For example, new models (for example, Xiaomi 13 Series or Redmi Note 12 Pro+) require additional unlocking of Anti-Rollback protection. We will discuss all the nuances in detail, including driver preparation, choosing the correct version of TWRP and bypassing typical errors like Invalid sparse file format at header.
Preparation of the device: unlocking the loader
The first and mandatory step is to unlock the bootloader, without which no custom recavator will boot. Xiaomi requires official confirmation through the Mi Account, and on new devices (released after 2021), the waiting period can reach 720 hours (30 days).
To start the process:
- π± Go to Settings. β The phone. β Version. MIUI and tap 7 times on the line to activate Developer Mode.
- π Back to Settings β Additionally. β For developers and include OEM-unlocking and debugging USB.
- π Attach the device to Mi Account in Settings β Xiaomi account β Mi Cloud (required to confirm email and phone number!).
- π₯οΈ Install Mi Unlock Tool on PC and log in under the same account.
β οΈ Attention: On Redmi models K50, POCO F5 Xiaomi may request confirmation via SMS If the device was purchased on credit or lease, unlocking may not be possible due to the operator's binding.
After sending the unblocking request:
- Connect your phone to your PC in Fastboot mode (turn off the device, then press Volume Down + Power).
- Run the Mi Unlock Tool and follow the instructions. If you see a "Couldn't unlock" error, check that the OEM Unlock option is included in the For Developers.
2. Installation of drivers and tools on the PC
To work with ADB and Fastboot, you will need:
- π₯οΈ Windows 10/11 (on Linux/Mac The commands are similar, but the paths to drivers are different).
- π Xiaomi drivers for Fastboot (download from the official website).
- π οΈ Google Platform Tools (includes adb.exe and fastboot.exe).
Installation instructions:
- Unpack Platform Tools at the root of the disk C:\platform-tools\ (pathless!).
- Connect your phone in Fastboot mode and check for device detection by command: fastboot devices If the list is empty, install drivers manually through Device Manager (select Android Bootloader Interface).
- For models on Qualcomm Snapdragon (e.g., POCO F4), download the QDLoader HS-USB Driver.
β οΈ Note: Antiviruses (such as Avast or Kaspersky) can block adb.exe as a "suspicious file." Add the platform-tools folder to the exceptions.
π‘
If the fastboot device command doesnβt show the device, try another one. USB-port (preferably) USB 2.0 on the back of the PC) or cable from the package.
3.Selecting the Right Version of TWRP
Mistake in choosing the version of the Recaveri is the main reason for the βbricks". TWRP must be appropriate:
- π± Device models (e.g. Redmi Note 11 Pro) 5G β Redmi Note 11 Pro+ 5G).
- π’ Codename (e.g., vili for Xiaomi) 11T Pro).
- π Versions MIUI (Newer scaling may be required TWRP dm-verity).
Where to download:
- π Official website: twrp.me/Devices (Look for the device code).
- π₯ Telegram channels: @TWRP_Xiaomi or @XiaomiFirmwareUpdater (current builds for new models).
- π§ Forum XDA Developers (for example, a branch for Xiaomi).
| Xiaomi model | Code name | TWRP reference | Notes |
|---|---|---|---|
| Redmi Note 10 Pro | sweet | Download | Supports MIUI 13/14 |
| POCO X3 Pro | vayu | Download | Requires AVB 2.0 shutdown |
| Xiaomi 12T Pro | diting | XDA | Only for firmware on Android 12 |
Before downloading, check the hash file (MD5) - fake TWRP builds may contain malicious code.
certUtil -hashfile twrp-3.7.0_12-vili.img MD54. TWRP firmware via Fastboot
Now, to the most critical point, the important thing is that if your device has Anti-Rollback enabled (e.g., on the Redmi K40 or Xiaomi 11 Lite NE), the firmware of the old version of TWRP will lead to locking. Always use the latest build!
Step-by-step:
βοΈ Firmware TWRP via Fastboot
- Place the twrp version-name-img file in the folder C:\platform-tools\ and rename it in twrp.img.
- Open the command line in this folder (press Shift + PCM β Open in the terminal).
- Check the connection of the device: fastboot devices should display the serial number of the phone.
- Please. TWRP: fastboot flash recovery twrp.img For partition devices recovery_ramdisk (for example, POCO F3) Use: Fastboot Flash recovery_ramdisk twrp.img
- Reboot to Recavers without releasing the volume button up: fastboot boot twrp.img
β οΈ Note: On some models (for example, Xiaomi 12 Pro) after firmware TWRP The system can automatically overwrite it to the stock Recovery, so to avoid that, right after you enter the system. TWRP Go to Advanced. β Flash Current TWRP.
What to do if TWRP does not start?
5. Typical errors and their solutions
Even if you follow the instructions accurately, you can get errors.
| Mistake. | Reason. | Decision |
|---|---|---|
| FAILED (remote: 'Flashing is not allowed in Lock State') | The bootloader is not unlocked | Repeat the unlocking process with the Mi Unlock Tool |
| Invalid sparse file format at header | A damaged TWRP file or incompatible version | Download the file again, check it out. MD5-hash |
| The device is loaded into a stock Recovery | MIUI overwrites TWRP when downloading | In TWRP, run Advanced β Flash Current TWRP |
| fastboot: error: Cannot generate image for userdata | There is not enough space in the userdata section | Use the command fastboot flash recovery twrp.img parameterless --slot=all |
If the phone doesnβt turn on after installing TWRP (black screen or logo hover), try:
- π Fastboot: Fastboot Flash Recovery recovery.img (file recovery.img You can get it from the official firmware).
- π₯ Swipe the full stock firmware through the Mi Flash Tool (select Clean All mode).
- π§ On models with Dynamic Partition (e.g. Xiaomi 12 Series), you may need to manually change the partition table via fastboot resize-logical-partition.
π‘
If TWRP It's successfully installed, but it doesn't hold up after it's restarted, and the problem is that it automatically overwrites the system. TWRP file disable_dm-verity_forceencrypt.zip (download XDA).
6. Additional settings after installing TWRP
After successful installation, it is recommended to follow several steps for stable operation:
- π Turn off data encryption (if you donβt plan to use it): TWRP Go to Wipe. β Format Data and enter yes. This will prevent partition mounting problems.
- π Create a backup: in the main menu TWRP Select Backup and select Boot, System, Data, Vendor. SD-card.
- π Install Magisk for root rights: download the latest version Magisk.zip from GitHub and run through Install β Select Zip.
For models with AB-sections (e.g, POCO F4 Xiaomi 11T) After the Magisk firmware is necessary:
- Download Magisk.apk and rename it Magisk.zip.
- Swipe it in both slots: fastboot --slot=all flash boot magisk_patched.img
- Reboot and wait for application optimization.
If after installing Magisk, the device is stuck on the boot, try:
- Swipe boot.img from stock firmware on top of the patched one.
- Disable all Magisk modules in the superuser settings.
- Use an alternative root method via KernelSU (relevant to Android 13+).
7.Restore the device after a failed firmware
If something goes wrong and the phone turns into a brick, don't panic. In most cases, Xiaomi can be restored. The main thing is not to try to stitch random files, this can make things worse.
Algorithm of action:
- Identify the type of "brick": π΄ Soft-brick: The device is turned on but stuck on the logo or downloaded to Fastboot. β« Hard-brick: phone doesnβt respond to buttons, doesnβt detect PC.
- For Soft-brick: Flip the stock firmware through the Mi Flash Tool (clean all mode). If the bootloader is locked, unlock it again through the Mi Unlock Tool.
Hard-brick
- Try to pinch Volume up + Volume down + Power for 20-30 seconds (hardware reset).
- Use it. EDL-Mode (requires an authorized Xiaomi account and Qualcomm boxing).
β οΈ Note: On devices with a MediaTek chipset (e.g., Redmi) 10C or POCO M4 Pro) for restoration through SP Flash Tool will require Auth-file, which can only be obtained from official Xiaomi service centers.
If the device requires Mi Account authorization after resetting and you do not remember your account details:
- Try to restore access via account.xiaomi.com.
- If your account is linked to a phone number, request an SMS with a recovery code.
- On some models (e.g. Redmi 9A) you can bypass the lock via Fastboot command: fastboot erase frp But this will only work if the bootloader is unlocked!