Running a smartphone through a receptacle is one of the most reliable ways to upgrade or restore Xiaomi when standard methods donโt work, a method that is suitable for installing custom firmware (like LineageOS), returning to stock MIUI after failed experiments, and correcting critical errors when the phone doesnโt boot, but the process requires caution: wrong actions can turn the device into a brick.
In this article, weโll look at all the steps from preparing and unlocking the bootloader to choosing the right firmware and installing it through TWRP or standard MIUI Recovery. Focusing on common bugs (e.g. Error 7 or Failed to mount /data) and how to fix them. If youโre a beginner, donโt skip the backup and file compatibility sections, which will save you hours to recover data later.
Important: the instruction is relevant for Xiaomi, Redmi and POCO models based on Qualcomm and Mediatek processors (including Redmi Note 10 Pro, Xiaomi 12T, POCO F4, etc.). For devices running Snapdragon 8 Gen 2/3 (for example, Xiaomi 13 Ultra) additional steps may be required due to the changed security policy Mi Bootloader.
1.Preparation: What to do before the firmware
The first step is to save all the important data. Firmware through the backpacks results in a full reset 90 percent of the time, even if you're installing the same version of MIUI. Use cloud services (Google Drive, Mi Cloud) or physical copying on your PC.
- ๐ฑ Contact and SMS (Export through Settings โ Google โ Backup)
- ๐ท Photos and videos (check folders) DCIM and Pictures on hidden files)
- ๐ Logins and passwords (use Bitwarden or KeePassDX for export)
- ๐ฎ Game saving (Genshin Impact, Honkai: Star Rail, etc. require binding to the miHoYo account)
Next, check the firmware compatibility with your model. Xiaomi has two key features:
- The device code name (e.g., surya for POCO X3 or alioth for POCO F3) can be found through the adb shell command getprop ro.product.device or in the CPU-Z application.
- Installing Global ROM on a China ROM device (and vice versa) without first unlocking the bootloader will result in an Anti-rollback check error.
๐ก
If you are flashing a device with Dynamic RAM (e.g. Redmi Note 12 Pro+), you may need to re-activate the feature after installing the firmware via Settings โ About Phone โ Memory.
It is equally important to charge the phone to at least 60%.When the charge is below 30% during firmware, some models (such as the Xiaomi 11T Pro) automatically turn off, causing damage to the /system partition.
- ๐ฅ๏ธ Windows computer 10/11 Linux (for fastboot commands)
- ๐ Cable USB Type-C (original, undamaged)
- ๐ Firmware in.zip format (for TWRP) or.tgz (for MIUI Recovery)
2 Unlocking the bootloader: a mandatory stage for custom firmware
Stock recovery MIUI Recovery allows you to install only official firmware Xiaomi. For custom solutions (TWRP, LineageOS, Pixel Experience) you need to unlock the bootloader through the Mi Unlock Tool. The process takes from 7 to 30 days due to Xiaomi policy (mandatory wait for new accounts).
Step-by-step:
- Link the device to your Mi Account in Settings โ Xiaomi Account.
- Activate OEM Unlock in Settings โ For developers (if there is no item, tap 7 times on the MIUI version).
- Turn off your phone and press the power. + Volโ for the entrance to the Fastboot.
- Connect the device to your PC, launch the Mi Unlock Tool and follow the instructions.
โ ๏ธ Warning: Factory Reset will be activated after unlocking the bootloader and Xiaomi warranty will be cancelled. On some models (for example, Xiaomi 13 Pro), unlocking can lead to locking the camera or module. NFC before re-authorization in the service center.
3.Recovery pick: TWRP vs MIUI Recovery
The type of recaveri depends on which firmware you can install and which features are available.
| Parameter | MIUI Recovery | TWRP |
|---|---|---|
| Type of firmware | Only official.tgz | Any.zip (including custom) |
| Backup | No. | Yes (sections /data, /system, etc.) |
| Installation without PC | Yes (via Choose Update Package) | Yes (via Install) |
| Support A/B-section | Yes (automatically) | Partially (manual slot indication required) |
| Risk of "brick" | Low. | Medium (for errors in firmware scripts) |
To install TWRP, use the command:
fastboot flash recovery twrp-3.7.0_12-0-surya.img
fastboot boot twrp-3.7.0_12-0-surya.imgReplace surya with your device's codename. After first downloading to TWRP, be sure to run Format Data (if encryption is required) and restart back to the recavator, otherwise the stock MIUI will overcharge TWRP.
What is it? A/B-Sections and Why It Matters?
4. Step-by-step firmware installation via TWRP
If you choose TWRP, Follow this instruction. Pre-copy the firmware (.zip) and, if necessary, Magisk for root into internal memory or on the computer. SD-map.
โ๏ธ Preparation for firmware through TWRP
Installation steps:
- Download to TWRP (press Power + Vol+ after shutdown).
- Press the Wipe. โ Advanced Wipe and mark: ๐๏ธ Dalvik / ART Cache ๐ System ๐ Data (if a complete reset is required) ๐ฑ Cache
Install
aroma-installer
Reboot System
โ ๏ธ Note: If after firmware the device loads into Fastboot with an error Invalid partition table, then the firmware is not compatible with your version MIUI (For example, trying to install Android 13 on an Android 12 device without first updating firmware:
fastboot flash modem NON-HLOS.bin
fastboot flash fsdg fsdg.mbn5. Install firmware through MIUI Recovery
MIUI stock recavers are easier to use, but have limitations, and are suitable for returning to official firmware after failed experiments or upgrades without a computer.
Algorithm of action:
- Download the firmware in.tgz format from the official Xiaomi website (Download โ Select device section).
- Rename the file to update.zip and place it in the root of internal memory.
- Turn off your phone and press Power + Vol+ to log in to MIUI Recovery.
- Select the language, then Install update.zip to System.
- Confirm installation. Once completed, select Reboot to System.
Critical feature: MIUI Recovery does not check firmware compatibility with the device model. Installing firmware from Redmi Note 11 on POCO X4 Pro (even if they have the same hardware) will lead to a Status 7 error and the need to restore via fastboot.
๐ก
If, after the firmware is through MIUI Recovery phone is stuck on startup logo MI more 20 minutes, so there was an error in the section mounting /data. The solution is to repeat the installation with a pre-reset (Wipe Data) or flash through fastboot with the addition of a flag. --disable-verity.
Typical errors and their solutions
Even with the exact following of the instructions, there can be problems.
| Mistake. | Reason. | Decision |
|---|---|---|
| Error 7 | Disparity between the device model and firmware | Check ro.product.device in TWRP (Mount โ System โ open /system/build.prop) |
| Failed to mount /data (Invalid argument) | Encrypting /data or partition damage | In TWRP, execute Format Data โ Yes (results in data loss!) |
| E3004: This package is for "ingres" devices; this is a "surya" | Firmware for another code name | Download the correct firmware version (check through fastboot getvar product) |
| Hanging on the MI logo | Incorrect firmware or no vendor | Switch firmware and vendor separately through fastboot |
If the device doesnโt boot even after re-routing, try emergency recovery via fastboot:
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash system system.img
fastboot --wipe-super super.imgFor models with Dynamic Partitions (e.g. Xiaomi 12), use super.img instead of system.img.
7. After firmware: setup and optimization
After successful firmware installation, follow a few steps to work stably:
- ๐ Reset network settings in Settings โ SIM-maps and mobile networks โ Resetting settings (solves problems with the 4G/5G).
- ๐ Calibrate the battery: completely discharge and charge the device 2-3 times (relevant for custom firmware).
- ๐ก๏ธ Disable Mi Cloud Sync in the first settings if you use custom firmware (may cause lags).
- ๐ก Update firmware and modem through TWRP (If new versions are available).
To check the stability of the system, use the following commands:
adb shell dumpsys meminfo
adb shell top -n 1If you see processes with high CPU consumption (such as mediaserver or surfaceflinger) in the output, then the firmware is not optimized for your device.
๐ก
On devices with AMOLED-screens (for example, Xiaomi 13, POCO F4 GT) After the firmware, the color calibration may be lost. Restore it through the engineering menu: type ##36446337## and select the sRGB profile or DCI-P3.