Many users, experimenting with the capabilities of their Xiaomi, install custom TWRP Recovery menu to obtain advanced rights, create full backups or install third-party firmware. However, there comes a time when you need to return the device to its original state, for example, to sell a gadget, pass official updates or eliminate errors in the system. The process of returning a stock loader requires care, since any incorrect actions can lead to locking the device.
Removing a modified environment isnβt just removing an app, itβs replacing the bootloaderβs system partition. If you just reboot without pre-prepared, the phone can go into an endless reboot cycle or hang on the brand logo. In this article, weβll detail the safe action algorithms that will allow you to restore the factory Recovery menu and return the software part warranty.
It is important to understand that the procedure differs depending on whether you have a bootloader unlocked and which version of MIUI or HyperOS is installed. We will look at methods for both fully unlocked devices and when access to the bootloader is limited. A critical step is to fully back up all personal data, since in the process of restoring the drain, the information on the internal drive will be irretrievably destroyed.
β οΈ Note: All of the manipulations described below are at your own risk.The author of the article is not responsible for turning your smartphone into a "brick" in case of violation of the sequence of actions.
Preparation of the workplace and necessary tools
Before you start the active phase of removing TWRP, you need to create the right software environment on your personal computer. Without the tools, trying to flash a stock image can result in a communication error or incorrect data recording. You need a computer running Windows, Linux or macOS with drivers installed for Xiaomi.
First, download and install the package. ADB And Fastboot. It's a basic toolkit that allows your computer to communicate with your phone at a low level. USB-cable, preferably original, since cheap analogues often do not provide stable data transfer, which is critical when firmware partitions.
βοΈ Checklist for firmware preparation
Next, you'll need the stock Recovery file itself. It can be extracted from the full firmware for your model or downloaded separately in recovery.img. Make sure the Recovery version matches the version of your current firmware to avoid version conflict. Place the downloaded file in the ADB tool folder for ease of operation through the command line.
Firmware method through Fastboot Mode
The most reliable and common way to remove TWRP is to use Fastboot mode, which allows you to write data directly to partitions of the device memory, bypassing the operating system. To enter this mode, you usually need to turn off the smartphone and press the power and volume buttons simultaneously.
Once you connect your device to your computer in Fastboot mode (the image of a hare repairing an android or saying FASTBOOT will appear on the screen), open the command line in the tool folder. Enter the command to check the connection: fastboot devices. If you see the serial number of the device in response, then the connection is established correctly and you can get to the firmware.
To replace the recovery menu, use the command:
fastboot flash recovery recovery.imgWhere recovery.img is the name of your stock image file. Once you successfully execute a command, you should immediately reboot to the new menu so that it is not overwritten by the system when you first start.
π‘
The main rule of Fastboot is to use the button combination to log in to Recovery Mode immediately after the recovery firmware, otherwise the Android system can automatically restore TWRP from a backup or update it back.
Use of the OTA-runoff-return
There is a less risky, but longer method - using a regular system update mechanism. MIUI. If you are in a modified TWRP If you want to return to the drain, sometimes it is enough to simply update the firmware through the standard settings menu or through the Recovery menu if it allows you to run it. OTA-packet.
Official updates from Xiaomi often include the current image of stock Recovery. When you install a full firmware package (Full OTA), the system checks the integrity of the partitions and can automatically replace the modified bootloader with the original. To do this, download the full firmware archive, rename it to update.zip and place it in the root of internal memory.
Go to the update menu and select the file manually, and during the installation process, the system will overwrite system partitions, but this method does not always work, especially if you have an unlocked bootloader and you have firmware protection, in which case the system may give an integrity check error.
Why can't OTA work?
Problems with cyclic reboot (Bootloop)
One of the most common problems after removing TWRP is getting the device into a cyclical reboot, which occurs when stock Recovery cannot mount data sections because they were encrypted or changed while using the custom menu.
To solve this problem, you need to clean the Data partition. Enter Recovery mode. If you have already stitched through the stock menu, you will see a standard Xiaomi menu with several items. Select Wipe Data -> Wipe All Data.
- π± This operation will delete all files, photos and contacts.
- π Reset will remove encryption blocking that interferes with the download.
- β After reset, the phone will start as new.
If a standard reset doesnβt help, the cache or dalvik partition may be damaged.In this case, you need to reflash through the Fastboot with a complete cleanup of all partitions, which is guaranteed to return the device to factory state, but will require reconfiguration.
β οΈ Warning: If after the firmware runoff and data reset, the phone continues to go into reboot, check the integrity of the firmware file.
Checking the status of the loader after changes
After successfully removing the TWRP and installing the stock Recovery, it is important to make sure that the device is working correctly. First, check the status of the bootloader. If you plan to leave it unlocked, the system can warn you about this at each boot, and if your goal is a full return to the drain, you may need to lock the Bootloader again.
To check the status, type in Fastboot mode the command fastboot getvar all and find the line (un)locked. If it says unlocked, then the bootloader is open. To block it, use the command fastboot oem lock, but remember that you can only do this on a fully stock firmware without modifications.
| Parameter | Stoke (Blocked) | Maude (Unblocked) |
|---|---|---|
| Security | Tall. | Medium |
| Work of banking applications | Work. | Often not working. |
| Firmware capability | Only off-site methods. | Any method you can use. |
| Guarantee | It's still there. | Maybe lost. |
Locking the bootloader on a modified system will result in a "brick," so make sure all partitions, including boot, recovery, and system, are original.Using commands to check hash sums of files can help with verification.
Frequent errors and ways to fix them
When returning stock Recovery, users often encounter driver errors. If the computer can't see the device in Fastboot mode, try replacing it. USB-Port or cable.May also require manual installation of Xiaomi drivers USB Driver through Windows Device Manager.
Another common problem is the Downgrade anti-rollback error, which occurs when you try to flash Recovery from an older version of firmware than the one installed today, and the Anti-Rollback protection mechanism blocks the rollback of versions to prevent security vulnerabilities.
To solve version problems, always use Recovery from firmware of the same version or later. If the error persists, try using the Mi Flash Tool in Clear All mode, which will completely cross-stitch the phone to bypass the limitations of the command line.
π‘
When using the Mi Flash Tool, be sure to choose the βClean Allβ mode to avoid file system conflicts between the old custom firmware and the new stock Recovery.