Modifying the Android operating system on Xiaomi smartphones gives owners access to advanced features not available in the standard shell of MIUI or HyperOS. By installing the custom TWRP (Team Win Recovery Project) recaps, the user can create full backups of the system, remove system debris, obtain root rights and install modified firmware. This process requires care, but the result is worth it, especially if you want to extend the life of an old device or get a clean Android.
However, there are always risks involved in interfering with the software code of the device: Incorrect actions can lead to loss of warranty, software errors or, in the worst case, turn the smartphone into a brick that cannot be turned on. It is critical to understand that firmware through TWRP is possible only after the official unlocking of the bootloader, which requires a wait of 7 to 168 hours after filing. Before proceeding with active actions, you need to carefully weigh the pros and cons and prepare the workplace.
In this guide, we will take a look at the entire process, from tool preparation to the first boot to the new system. We will look at the nuances of working with partitions, the features of file systems and recovery methods in case of failures. Remember that technological progress does not stand still, and the methods that worked a year ago may differ today, so follow the current instructions for your model.
Preparation of the workplace and necessary files
The success of the operation depends on the quality of preparation, 90% of the time. USB-cable (preferably original or certified) and a computer running Windows, macOS or Linux. ADB And Fastboot, and Qualcomm or MediaTek drivers, depending on your device's processor, and without those components, your computer won't see your smartphone in the right mode.
The next step is to find and download the correct firmware files, and you need an image of the recovery (a file with the.img extension) that matches your smartphone model, and using a file from another model is guaranteed to cause the device to fail, and you should also download the zip archive with the desired operating system (for example, LineageOS, Pixel Experience) or the Magisk patch to obtain root rights, if that is your ultimate goal.
βοΈ Firmware readiness check
Remember to make a complete backup of all important data. TWRP And then you'll have to clear the internal memory of the device, transfer the photos, documents and contacts to an external medium or to the cloud. It's also recommended that you turn off all antiviruses and firewalls while you're working with them. ADB-commands so that they do not block the connection with the smartphone.
Unlock the bootloader and log into Fastboot mode
Without unlocked Bootloader, installing third-party software is impossible. The standard procedure requires the use of the official Mi Unlock Tool utility. First, in the smartphone settings, you need to activate the developer mode by clicking on the build number several times in the About Phone section. Then in the menu "For developers" should include the items "factory unlocking" and "Debugging by USBΒ».
Once you have attached your Mi Account to your device and waited for a set time (usually 168 hours), you can run the Mi Unlock Tool on your PC. The smartphone is put into Fastboot mode by pressing down the power and volume button combination. If it goes well, the bootloader will be unlocked and the device will restart, completely clearing user data.
β οΈ Attention: The process of unlocking the bootloader permanently deletes all data from the device. Make sure that the backup is made in advance, as it will not be possible to restore files after this step using standard methods.
What if the Mi Unlock Tool is 99% locked?
To enter Fastboot mode on the device turned off, press the volume button and connect USB-The cable to the computer should show a sign on the screen. FASTBOOT If you don't, check the volume buttons, and in this mode, the device is ready to receive commands through the console.
Install TWRP via ADB and Fastboot
Now, we're going to go directly to the Recovery. Open the command line (CMD) or PowerShell in the folder where the downloaded image file is located twrp.img. For convenience, rename the file to twrp.img. Enter the command to check the connection: fastboot devices. If you see the serial number of the device in response, then the drivers are installed correctly and the smartphone is determined.
The installation process itself takes a few seconds. The firmware command is as follows:
fastboot flash recovery twrp.imgAfter successfully executing the command, do not press the power button for normal boot.On Xiaomi devices with activated function A/B-Partitions or verification protection (standard download can overwrite the just installed recap with the stock. Instead, use a combination of buttons to immediately enter the recovery mode.
To enter the newly installed TWRP, press the volume button and hold it, connect the cable or press the power button (depending on the model). You should see the TWRP interface. If the standard MIUI Recovery with the Mi logo boots, then the system has overwritten the recoveries, and the fastboot flash procedure must be repeated, immediately after which you manually go to Recovery.
Setup of sections and data formatting
The first start of TWRP may require you to enter the unlock password of the screen you used in the system. If the password is not accepted or you do not remember it, you will have to format the Data section. In the main menu, select Wipe (Clean up), then Format Data. In the input field, you will need to type in the word yes and confirm the action.
This procedure is necessary to remove the encryption that interferes with the custom backup file system. After formatting, the device can restart. If this happens, re-enter Recovery mode. Now in the Mount section, you should see that the partitions are available for mounting, and there are no encryption errors in the logs.
| Section | Appointment | Should I format? | Risk of data loss |
|---|---|---|---|
| Data | User files, photos, applications | Yes (to unencrypt) | High (all removed) |
| System | Operating system files | No (usually) | High (OS breaks) |
| Cache | Temporary system files | Recommended | Low (safe) |
| Dalvik / ART | Cash compilation applications | Yeah (when changing firmware) | Low (recreated) |
It is important to choose the right file system when formatting. For modern versions of Android (11, 12, 13, 14), Xiaomi often uses the F2FS file system, which is faster than standard EXT4, but requires support from the firmware kernel. If you install custom firmware, check the author's requirements: which file system he recommends to use.
The process of installing an operating system or patches
Now that the partitions are ready, you can proceed to install the new OS. Copy the firmware zip archive to the internal memory of your smartphone or a connected microSD card. From the TWRP menu, select Install, find the file and swipe for confirmation. The process will take from 2 to 10 minutes depending on the memory speed and amount of data you install.
If you install firmware based on Android 11 and above, youβll likely need to flash a compatible kernel or Vendor partition before installing the system itself. Often firmware archives contain scripts that do this automatically, but in some cases (for example, switching from MIUI to LineageOS) you need to manually firmware vendor.img via Fastboot or a separate zip archive via TWRP.
π‘
When installing firmware, always put the system first, then GApps (if necessary), and only at the very end, Magisk for root rights, which minimizes conflicts and errors on the first boot.
After installing all the necessary components (System, GApps, Root), you need to clear the Dalvik and Cache cache. Select Wipe -> Advanced Wipe, tick Dalvik / ART Cache and Cache, then swipe. Do not touch the Internal Storage and Data sections if you do not want to lose files. Now you can click Reboot System.
Possible errors and recovery methods
Even with careful preparation, there may be failures. A common problem is a bootloop (cyclic reboot) or a black screen. If the device gets stuck on the logo, try logging back into TWRP and performing Wipe Dalvik/ART Cache. If that doesn't help, it may be that the firmware is incompatible with your bootloader version or the regional version of the device (Global vs China).
Another common bug is Error 7 when installed, which means that the installation script checks the device model and doesn't find any matches. This often happens if you're trying to put global firmware on the Chinese version or vice versa. In such cases, you can try editing updater script inside the firmware archive by removing the model check, but this requires advanced knowledge.
β οΈ Note: If the touch screen or Wi-Fi has stopped working after the firmware is installed, this is a sign of installing firmware from another model or region. Do not ignore these symptoms, as using a device with incorrect drivers can lead to overheating or damage to communication modules.
In the event of a critical failure, when the phone is not even included in Recovery, Emergency Download (EDL) mode for Qualcomm processors or BROM for MediaTek will help. Signing into EDL often requires disassembling the smartphone and closing test points on the board. In this mode, the device can only be restored through an authorized Mi Account account and Mi Flash Pro program, which sometimes requires contacting a service center.
π‘
The rule of modification is never to interrupt the process of recording data. If the battery or cable has gone down during firmware, the risk of getting a brick is almost 100%.