Modifying Xiaomiβs operating system is a powerful tool to expand the functionality of a smartphone, but it requires understanding the basic processes of interacting with the system partition. Installing a custom bootloader such as TWRP or OrangeFox is the first and critical step to gaining superuser rights, installing modified firmware or creating full backups. The process is not limited to simply downloading a file, it requires precise execution of a sequence of actions in Fastboot mode.
Many users are afraid to perform such manipulations because of the risk of turning the device into a βbrickβ, but with all the safety rules, the procedure is successful in the vast majority of cases. It is important to realize that unlocking the Xiaomi bootloader automatically erases all user data, so pre-backup is a mandatory step that can not be ignored. We will consider all the nuances of preparation, setting up the environment and direct firmware of the image.
π‘
Before starting any work, make a full backup of important data to an external medium or to the cloud storage, as the process of unlocking the bootloader is guaranteed to delete all files from the internal memory of the device.
To successfully complete the task, you will need not only the smartphone itself, but also a high-quality one. USB-cable, preferably original, and a computer running Windows, Linux or macOS. Lack of stable connection or use of a damaged cable can lead to interruption of data transmission, which is fraught with firmware errors. Below we will discuss in detail each stage of preparation and execution of the operation.
Tools and environment preparation required
Before we get to the practical steps, we need to prepare software that will provide communication between the computer and the smartphone. The basic element is the ADB and Fastboot package, which contains executable files to send commands to the device. Without this set of utilities, interaction with the bootloader mode is impossible, so installing it is the foundation of the entire procedure.
Also critical are the right drivers that allow the computerβs operating system to correctly recognize the smartphone in various modes of operation. Xiaomi devices often require the installation of specific Qualcomm or MediaTek drivers, as well as drivers for Fastboot mode. Lack of the right driver will cause the device manager to display the phone as βUnknown deviceβ with a yellow exclamation mark.
- π± Xiaomi smartphone with a charged battery of at least 60% to prevent sudden shutdown.
- π» Computer or laptop with Windows operating system installed 10/11 or Linux distribution.
- π Original. USB-cable with data transfer support, not just charging.
- π Downloaded Recovery image file (usually with.img extension) compatible with your model.
It is recommended to use ports USB 2.0 or 3.0 located on the motherboard (back of the system unit), as ports on the front panel or through USB-Hubs can give you unstable voltages. The stability of the power at the time of writing data to the memory of the device is crucial. If you use a laptop, make sure it's connected to the power grid.
β οΈ Note: Using damaged or cheap charging-only cables will cause a connection error.The computer just won't see the device in Fastboot mode, and you'll spend time looking for a problem in the drivers, although it will be a physical connection.
βοΈ Firmware readiness
Activation of the developer mode and unlocking the bootloader
Xiaomiβs standard security policy prohibits modifying system partitions without special permission. The first step is to activate the hidden menu for developers. To do this, go to Settings β About phone and quickly click on the MIUI or HyperOS version several times until the notification βYou became a developerβ appears.
After activating the menu in the section Additional β For developers, you need to enable two options: Factory unlock and USB debugging. These settings allow the computer to send commands to the device and give permission to change the system partitions. Without the factory unlock enabled, the Fastboot team will return the access error.
Xiaomi devices require the Mi Account to be linked to the device and permission is obtained through the official Mi Unlock Tool utility. This process can take from several hours to 7 days (168 hours) of waiting, during which you cannot log out of the account on the device.
There is an important caveat for new models: after unlocking the bootloader and first booting into the system, it may take 7 to 168 hours to wait before re-locking or installing custom Recovery. If you try to flash TWRP immediately after unlocking, the device may not allow Recovery mode or reset it on the first boot.
β οΈ Note: Unlocking the bootloader through the Mi Unlock Tool completely clears the device's internal memory (Factory Reset).All photos, contacts and applications will be deleted without the possibility of recovery by standard means.
Downloading the smartphone in Fastboot mode
Fastboot mode (often referred to as bootloader mode) is a state of the device in which it is ready to receive low-level commands to firmware partitions of memory. Unlike normal mode, the operating system does not boot here, allowing you to safely overwrite system files, including the Recovery partition.
To enter this mode on a switched-off Xiaomi smartphone, you need to press the Volume Down and Power buttons simultaneously. Hold them until an image with a hare repairing an android appears on the screen or the inscription "FASTBOOT". Some new models without physical buttons or with a changed logic of operation may require connecting the cable to the computer at the moment of button clamping.
Once the device is in mode, connect it to your computer. In the command line or terminal where ADB/Fastboot is running, check the visibility of the device.
fastboot devicesIf you see a string with a set of numbers and letters (device serial number) and the word "fastboot", then the connection is established successfully. If the screen remains empty, check the drivers in Windows Device Manager. The device should be defined as "Android Bootloader Interface". If "Unknown Device" is used, you will need to manually install drivers.
- π Connect the switched off smartphone to the PC through USB-cable.
- π½ Press the volume down button and the on button at the same time.
- π° Wait for the Fastboot logo to appear (hare or inscription).
- π» Check the display of the device by the command fastboot devices.
It's important to note that in Fastboot mode, the screen can go out after a while to save energy. This is normal and doesn't interrupt the connection. Just press any volume button to wake up the screen if you need to visually control the process, although commands will be executed when the screen is gone.
Recovery image installation process via Fastboot
When the device is connected, the drivers are installed, and an image file (such as twrp.img) is downloaded and placed in the tool folder, you can go to the firmware process itself. The command to write an image to the Recovery section looks universal for most Android devices, but requires accuracy in writing the path to the file.
Open the command line in the Fastboot folder. Make sure the image file is in the same directory, or specify the full path to it.
Fastboot flash recovery name file.imgInstead of the file name.img, substitute the real name of your file, for example. twrp-3.7.0_9-0-vayu.img. Once you enter the command, press Enter. The terminal will see a progress bar showing the recording process. This usually takes a few seconds. Successful completion will be marked by the message "Finished. Total time: X.XXXs".
| Team team. | Description of action | The result |
|---|---|---|
| fastboot devices | Connection check | Display of the serial number |
| fastboot flash recovery twrp.img | Recording the image in the section | Successful firmware (OK) |
| fastboot boot twrp.img | Temporary launch without recording | Starting TWRP without installation |
| fastboot reboot | Rebooting the device | Exit from Fastboot |
There is an important nuance for devices with encrypted data partition and a new partition scheme (A/B On such smartphones, a simple flash command may not be enough, as the standard recovery system can be replaced by a simple flash command. recovery_ramdisk In such cases, the command fastboot boot is used. twrp.img For the primary entrance, and already inside TWRP permanent installation.
What happens if the flash command returns an error?
First Launch and Save Custom Recovery
After successful firmware, many users make the critical mistake of simply restarting the device to normal mode. On Xiaomi smartphones with an active bootloader verification (AVB) mechanism and system integrity protection, the standard Android shell checks the integrity of the Recovery partition when booting. If a modified (custom) Recovery is detected, the regular system can automatically rewrite it back to the stock one to ensure security.
To avoid this, immediately after firmware is completed, you need to force reboot directly to Recovery mode, this is done by a combination of buttons or commands. Press Volume Up and Power immediately after the firmware is completed, without releasing the cable until the device vibrates. Or use the command:
fastboot reboot recoveryIf it goes well, you'll see the interface of the installed TWRP or OrangeFox. At this point, it's important to do the initial setup: select the language and, most importantly, allow modification of the system partition (Swipe to Allow Modifications). If you don't, the next time you restart, the system can try to restore the original bootloader again.
- π Immediately after the firmware, execute the command fastboot reboot recovery.
- π On the menu. TWRP Swipe the slider to resolve changes (Allow Modifications).
- π If required, set the screen unlock password in TWRP data-access.
- π Restart to the system only after confirming successful installation.
π‘
The most important point is not to let the system boot into normal Android mode immediately after firmware, but to force Recovery to activate it and prevent the system from rolling back changes.
β οΈ Attention: If after installation TWRP You booted up to Android, and when you re-enter Recovery, you saw the Xiaomi stock menu, which means that the system has restored the original partition.
Possible errors and methods of their elimination
During the installation process, various technical problems can arise, related to hardware compatibility, driver versions or the state of the device itself. One of the most common errors is FAILED (remote: device is locked), which means that the device bootloader is still locked, in which case you need to return to the unlock stage through the Mi Unlock Tool and complete it.
Another common problem is error. FAILED (remote: Unknown command) or Partition does not exist. This is common on devices with a new file system or dynamic partitions. In such cases, the partition name may differ from the standard recovery (A/B), like-minded recovery_a or recovery_b, Use boot instead of flash for the first run.
If the computer stops seeing the device while it's running the firmware (the fastboot device command doesn't show anything), it's likely that the cable has been turned off or the drivers have crashed. Don't panic. Unplug the cable, remove the battery (if possible), or press the power button on the 10-15 For a second to force reboot, then re-enter Fastboot mode and check the connection. USB-port on the back of the PC.