How to install firmware on Xiaomi via recovery: from unlock to final settings

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:

  1. 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.
  2. 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:

  1. Link the device to your Mi Account in Settings โ†’ Xiaomi Account.
  2. Activate OEM Unlock in Settings โ†’ For developers (if there is no item, tap 7 times on the MIUI version).
  3. Turn off your phone and press the power. + Volโˆ’ for the entrance to the Fastboot.
  4. 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.

๐Ÿ“Š What type of firmware do you plan to install?
Official MIUI
LineageOS (Pixel Experience)
Stock Global ROM for regional device
Other

3.Recovery pick: TWRP vs MIUI Recovery

The type of recaveri depends on which firmware you can install and which features are available.

ParameterMIUI RecoveryTWRP
Type of firmwareOnly official.tgzAny.zip (including custom)
BackupNo.Yes (sections /data, /system, etc.)
Installation without PCYes (via Choose Update Package)Yes (via Install)
Support A/B-sectionYes (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.img

Replace 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?
Devices with A/B-partitions (e.g. Xiaomi) 12, POCO F5) They have two identical sets of partitions: a and b. When you update, the system writes data to an inactive partition, and after you restart, it switches to it. This reduces the risk of a "brick", but requires a special approach to the partition. TWRP: You need to manually specify the active slot through fastboot --set-active=a or fastboot --set-active=b.

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

Done: 0 / 4

Installation steps:

  1. Download to TWRP (press Power + Vol+ after shutdown).
  2. 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.mbn

5. 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:

  1. Download the firmware in.tgz format from the official Xiaomi website (Download โ†’ Select device section).
  2. Rename the file to update.zip and place it in the root of internal memory.
  3. Turn off your phone and press Power + Vol+ to log in to MIUI Recovery.
  4. Select the language, then Install update.zip to System.
  5. 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 7Disparity between the device model and firmwareCheck ro.product.device in TWRP (Mount โ†’ System โ†’ open /system/build.prop)
Failed to mount /data (Invalid argument)Encrypting /data or partition damageIn TWRP, execute Format Data โ†’ Yes (results in data loss!)
E3004: This package is for "ingres" devices; this is a "surya"Firmware for another code nameDownload the correct firmware version (check through fastboot getvar product)
Hanging on the MI logoIncorrect firmware or no vendorSwitch 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.img

For 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 1

If 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.

FAQ: Frequent questions about Xiaomi firmware

Can I use Xiaomi without unlocking the bootloader?
Yes, but only official firmware via MIUI Recovery or fastboot signed by Xiaomi. For custom firmware (TWRP, LineageOS), unlocking is mandatory.
Why is the camera or NFC not working after the firmware?
This is a typical problem when installing GSI-Generic System Image or firmware for another model. Solution: Sweep through the original vendor and firmware. ANX Camera for camera or NFC Fix via Magisk.
How to return stock recap after TWRP?
Download the official recovery for your model (recovery.img file) and run through fastboot: fastboot flash recovery.img fastboot reboot recovery After that, MIUI will automatically lock the bootloader after 24-48 hours, unless you have disabled OEM Unlock.
What if the phone asks for a password after the firmware, but it never existed?
It's a consequence of encryption. /data. Decisions: B TWRP Do Format Data (delete all data!). If you want to save data, try entering the old one. PIN-code or pattern lock (sometimes works). for Android 12+ Disable Force Encryption (installed via the TWRP firmware).
Can I use Xiaomi without a computer?
Yes, if you already have it. TWRP or you're using MIUI Recovery for official firmware. Algorithm: Download the firmware directly to your phone through your browser. Reboot to the power. + Vol+). V TWRP select Install, in MIUI Recovery โ€“ Choose update package. Specify the path to the file and confirm the installation. โš ๏ธ Without a computer, it is impossible to unlock the bootloader or flash firmware in case of critical errors.