Owners of Xiaomi smartphones on the basis MIUI 12 often face the need to return stock recavers after installing custom firmware or modified versions TWRP. This may be required to obtain OTA-But the process of returning the original backup comes with risks ranging from data loss to complete buildup of the device, unless you consider the key nuances.
In this article, we will discuss three officially supported methods of restoring stock recavators (via Fastboot, Mi Flash Tool and ADB), as well as consider common errors, such as Invalid sparse file format at header or Anti-rollback check fail.
Why you should return stock recavators to MIUI 12
Stock Recovery is the original recovery environment pre-installed by the manufacturer, and Xiaomi is responsible not only for resetting, but also for:
- π Integrity verification OTA-packets before installing updates "over the air." Custom recavers (for example, TWRP) This feature is often blocked, resulting in the error Can't verify update.
- π Verification of firmware digital signatures. Without a stock recavator, the device may refuse to boot after installing official updates.
- π± Service functions such as EDL-Emergency Firmware mode or Mi Assistant for diagnosis.
- π‘οΈ Compliance with the anti-rollback policy). MIUI 12 tightly controls firmware versions, and an attempt to roll back to an older version through a custom recavery can block the device.
In addition, some banking applications (such as Sberbank Online or Tinkoff) check the integrity of system partitions. The presence of a modified backup can lead to errors such as Device is rooted or Insecure Environment, even if root access is not activated.
Device Preparation: Unlocking the bootloader and Backup
Before returning the stock recavator, two critical steps must be taken: unlock the bootloader (if it is blocked) and back up key partitions, which can result in loss of IMEI, idle Wi-Fi/Bluetooth modules, or a βbrickβ.
1. Checking the status of the loader
To see if the bootloader is unlocked, turn off your smartphone and press Volume Down + Power. If the screen says This device is unlocked with an open lock, the bootloader is unlocked. If the lock is closed or says This device is locked, you will need to unlock through the Mi Unlock Tool.
π‘
If the Mi Unlock Tool gives you a βCouldnβt unlockβ error when unlocking, try linking your Mi Account to your device in the settings (Settings β Xiaomi Account β Mi Cloud β Find the device) and try again after 72 hours.
Backup of sections
With ADB or TWRP, save the following sections (commands for ADB):
adb pull /dev/block/bootdevice/by-name/modem modem.img
adb pull /dev/block/bootdevice/by-name/persist persist.img
adb pull /dev/block/bootdevice/by-name/nvram nvram.imgThese sections contain data about IMEI, camera calibration, and modem settings, and their loss can make the device unsuitable for calls or network connections.
Battery charge β₯ 50%|Backups of modem, persist, nvram|Unlocked loader|Installed drivers Mi Flash Tool and ADB|Mi Account protection disabled (if you plan to reset completely)-->
Method 1: Fastboot Recovery (Recommended)
This method is suitable for most Xiaomi models on MIUI 12 and does not require deep knowledge. The essence of the method is to flash only the recovery section without affecting user data.
- π₯οΈ PC Windows/Linux and installed Xiaomi drivers.
- π± Smartphone with unlocked bootloader and enabled debugging USB (Settings β The phone. β Version. MIUI (7 times) β Additionally. β For developers β Debugging by USB).
- π Official firmware for your model (download from Xiaomi website).
Step-by-step instruction
- Unpack the downloaded firmware (.tgz or.zip format) and find the recovery.img file in the images folder.
- Connect your smartphone to your PC in Fastboot mode (turn off the device, then press Volume Down + Power).
- Open the command line in the folder with recovery.img and execute: fastboot flash recovery.img fastboot reboot
If the recavery has not changed after the reboot, try flashing boot.img (from the same firmware):
fastboot flash boot boot.imgπ‘
Firmware only. recovery.img If you want a full return to the stock firmware, use the Mi Flash Tool (method). 2).
Method 2: Complete firmware with the Mi Flash Tool
This method is suitable if the stock recavator is not restored via Fastboot or a clean installation of MIUI 12 is required. Mi Flash Tool flashes all partitions, including system, vendor and userdata, so all data will be deleted.
Instructions
- Download the Mi Flash Tool from the official website and install it.
- Unpack the firmware (.tgz format) in a folder without Cyrillic characters.
- Launch the Mi Flash Tool, press Select and specify the path to the firmware folder.
- Connect your smartphone in Fastboot mode and press Refresh. the device should determine how to COM-port.
- Select firmware mode: Clean all β clean (recommended); Clean all and lock β clean + lock the bootloader (only if you are sure that you will no longer use custom firmware!); Save user data β save data (may lead to errors).
Press Flash and wait until it is completed (5-10 minutes).
What to do if the Mi Flash Tool gives you a Flash Not Done error
Table: Common mistakes and decisions
| Mistake. | Reason. | Decision |
|---|---|---|
| Invalid sparse file format | A firmware file or incompatible version of the Mi Flash Tool is damaged. | Download the firmware again or use the Mi Flash Tool 2020.3.14.0 version. |
| Anti-rollback check fail | Trying to sew an older version of MIUI. | Update to the latest stable firmware via Fastboot. |
| This miui version cannot be downgraded | Prohibition of rollback version (policy of Xiaomi). | Use the same or newer version of the firmware. |
| Device not found | Drivers are not installed or USB-port. | Install drivers via Mi PC Suite or try another cable. |
Method 3: Recovery through ADB (for power users)
If the Fastboot and Mi Flash Tool don't work, you can try flashing stock Recovery through ADB in sideload mode, which requires a working custom Recovery (e.g., TWRP).
Instructions
- Download the official firmware for your model and extract recovery.img.
- Move it. recovery.img file ADB and rename it in stock_recovery.img.
- Load to TWRP (Loudness up + Power on).
- Connect your smartphone to your PC and do: Adb push stock_recovery.img /sdcard/ adb shell dd if=/sdcard/stock_recovery.img of=/dev/block/bootdevice/by-name/recovery
- Reboot: reboot system.
If there are problems after firmware, follow the following steps:
- No network or lost IMEI: Restore modem and persist partitions from backup: fastboot flash modem modem.img fastboot flash persist persist.img
- The device is fixated on the Mi logo: Perform a reset through a stock Recovery (Loud up + Power β Wipe Data).
- OTA-Updates do not come: Reset network settings (Settings) β SIM-maps and mobile networks β Reset network settings) and check the firmware region (should match the device region).
β οΈ Warning: If the device stops turning on after the stock recap is returned (black screen, vibration without image), do not try to stitch it again - this may be a sign of damage to the preloader partition. EDL-mode (only for experienced users or service centers).