Reinstalling the operating system on smartphones Xiaomi is a procedure that may be required in case of critical failures, virus attacks, or the desire to install custom firmware. Unlike a regular factory reset, a full flashing affects system partitions, which allows you to eliminate deep software errors or update the device to the latest version of MIUI (or an alternative OS type LineageOS). However, the process is fraught with risks: from data loss to โbrickingโ the phone if you break the sequence of actions.
In this article we will look at three main scenarios: recovery via official Mi Flash Tool, installation of global/stable firmware over Chinese and manual deployment of custom software via TWRP. We will pay special attention to preparation - unlocking the bootloader (bootloader), without which most operations are impossible. You will also find a firmware compatibility table for popular models Redmi, POCO and Mi, current at the time of publication.
Before you begin, answer the key question: why do you need to reinstall? If the goal is to eliminate lags or free up memory, a reset via Settings โ About phone โ Reset settingsmay be enough. Reflashing is justified when:
- ๐ The smartphone does not turn on or only boots into mode
Fastboot/Recovery - ๐ System applications constantly crash, and updates via OTA are not available
- ๐ You need to change the regional firmware (for example, from Chinese to global)
- ๐ ๏ธ Requires root access or an alternative OS (like Pixel Experience)
1. Preparation: backing up and unlocking the bootloader
The first stage - saving dataReinstalling Android erases the internal one. device memory, including photos, contacts and messages. Use:
- ๐ฑ Mi Cloud (for contacts, notes, SMS) - check that synchronization is enabled in
Settings โ Xiaomi Account โ Mi Cloud - ๐ฅ๏ธ PC and a USB cable - copy files from folders
DCIM,Downloads,WhatsApp(if any) - ๐ง Applications like Swift Backup (requires root) to save the list of installed apps
Next - unlocking the bootloader. Xiaomi blocks it by default to protect against unauthorized changes. To unlock:
- Link your account Mi to the device in
Settings โ Xiaomi account. - Activate option
OEM UnlockinSettings โ For developers(if there is no option, tap 7 times onMIUI versionin the "About phone" section). - Reboot into
Fastboot(pressPower + Volume down) and connect the phone to the PC. - Download official tool Mi Unlock Tool, log in and follow the instructions.
โ ๏ธ Attention: After The smartphone will unlock the bootloader full data reseteven if you have not started flashing the firmware. Also Xiaomi can block unlocking for 7-30 days for new accounts (depending on the model and region).
If Mi Unlock Tool gives an error type "Couldnโt unlock", check:
- ๐ USB cable - use an original or certified one (cheap cables often do not transfer data to
Fastboot) - ๐ฅ๏ธ Version of the tool - download the latest from the official website
- ๐ฑ Account status - new devices may require linking the SIM card to the account Mi for 72 hours
Save all important data to PC/cloud|
Link the Mi account to the device|
Enable OEM Unlock in the developer settings|
Downloaded Mi Unlock Tool and drivers for Fastboot|
Prepared a USB cable (preferably original)-->
2. Selecting firmware: official vs custom
The functionality of the device after reinstallation depends on the type of firmware. options:
| Firmware type | Advantages | Disadvantages | Who is it suitable for |
|---|---|---|---|
| Official MIUI (Fastboot) | Stability, support for OTA updates, maintaining the warranty* | Limited customization, advertising in system applications | Beginners, those who want to return the "factory" state |
| Official MIUI (Recovery) | Easy installation via stock recovery, no need to unlock the bootloader** | Not all versions are available in this format, risk of errors when updating | To fix minor glitches without data loss |
| Custom (TWRP + ZIP) | Without unnecessary water, advanced settings, current versions of Android | Loss of warranty, possible bugs with hardware (camera, NFC) | Advanced users who want an alternative to MIUI |
* The warranty is valid only when using official firmware via Mi Flash Tool. Installing custom software will void the warranty.
** Firmware via Recovery without unlocking is only possible to update the current version of MIUI, and not to change the region or downgrade.
Where to download firmware:
- ๐ Official: MIUI Downloads site (select the version for your model by code, for example davinci for Redmi K20)
- ๐ Custom: XDA Developers (look for themes for your model with marked
[ROM]) - ๐ Alternative builds of MIUI: xiaomi.eu (firmware without unnecessary water, but with the risk of bootloader blocking)
โ ๏ธ Attention: Firmware from the site xiaomi.eu are not official and can lead to account blocking Mi when using some functions (for example, Mi Pay). For models with a processor MediaTek (for example, Redmi Note 11), additional authorization is required to unlock the bootloader.
How find out the code name of your Xiaomi model?
Open the "Phone" application and enter the code ##4636##. In the "Phone Information" menu, find the line "Device model" - this is the code name (for example, raphael for Redmi K20 Pro). Alternatively, check on the box or under the battery (for models with a removable cover).
3. Installing official firmware via Mi Flash Tool
This method is suitable for restoring the "factory" state or changing the regional version of MIUI. You will need:
- ๐ฅ๏ธ Computer with Windows (7/10/11)
- ๐ Unlocked bootloader (see section 1)
- ๐ USB cable (preferably original)
- ๐ฆ Firmware in format
.tgzor.zip(downloaded from the official website)
Step-by-step guide:
- Unpack the archive with the firmware into a folder without Cyrillic characters (for example,
C:\MIUI\). - Install Mi Flash Tool and drivers for
Fastboot. - Switch the phone to
Fastbootmode (pressPower + Volume downwith the device turned off). - Connect your smartphone to the PC. Press Mi Flash Tool click
Refresh- the device should be detected. - In the field
Selectspecify the path to the folder with firmware. Select the firmware method:Clean allโ full cleaning (recommended in case of failures)Clean all and lockโ cleaning + bootloader lock (for selling the phone)Save user dataโ saving user data (risky when switching between MIUI versions)
Flash and wait for completion (usually 5-15 minutes). The phone will reboot automatically.If the process is frozen at the stage flashing..:
- ๐ Try another USB port (preferably
USB 2.0on the back panel PC). - ๐ Replace the cable - cheap cables may not provide a stable connection.
- ๐ฅ Redownload the firmware - errors may occur when downloading the archive.
If after the firmware the phone is stuck on the logo Mi, press Power + Volume up for 10โ15 seconds to force a reboot. If this does not help, repeat the firmware by selecting the option Clean all.
4. Installing custom firmware via TWRP
To install alternative OSs (for example, LineageOS, Pixel Experience), you will need custom recovery - TWRP. The process is more complicated than with official firmware, and includes additional risks.
What you need to prepare:
- ๐ฑ Unlocked bootloader
- ๐ฆ Firmware in format
.zip(for example, lineage-20.0-20231210-nightly-davinci.zip) - ๐ ๏ธ File
TWRPfor your model (download from official website) - ๐ Battery charge at least 60%
Instructions:
- Download
TWRPfor your model (for example,twrp-3.7.0_9-0-davinci.img) and place the file in the folder withADB(or use 15 Seconds ADB Installer). - Move the phone to
Fastbootand connect to PC. - In the command line (in the folder with
ADB) run:fastboot flash recovery twrp-3.7.0_9-0-davinci.imgfastboot boot twrp-3.7.0_9-0-davinci.imgThis will flash
TWRPand immediately load the phone into it. - B
TWRPexecutWipe โ Format Data(enteryesto confirm). This will remove encryption and prevent errors. - Transfer the firmware file to the phone via
MTP(inTWRPis optionMount โ Enable MTP). - Click
Install, select the firmware file and confirm installation. After completion, clickReboot System.
โ ๏ธ Attention: Some custom firmware require additional steps:
- ๐ง Installations
GApps(Google Services) in a separate ZIP file (if they are not in the assembly).- ๐ง Patch for
DM-Verity(otherwise the phone may not boot).- ๐ง Disablements
Force Encryption(for older devices).These nuances are usually described in the instructions for the specific firmware on XDA.
Custom firmware often does not support proprietary functions Xiaomisuch as IR Blaster (remote control) or Game Turbo. Before installation, check the list of working/non-working hardware in the firmware thread on the forum.
5. Common mistakes and their solutions
Even if you follow the instructions, problems may arise. Let's consider typical situations:
| Error | Cause | Solution |
|---|---|---|
Fastboot: FAILED (remote: 'Flashing is not allowed in Lock State') |
Bootloader is not unlocked | Use Mi Unlock Tool (section 1). option |
| Phone stuck on logo Mi after flashing | Incompatible firmware or error when writing the system partition | Repeat the firmware with the option Clean all or return to the previous version |
TWRP: Unable to mount /data |
Encryption is enabled TWRP cannot decrypt the partition |
Run Format Data in TWRP (erases all data!) |
| There is no network after the firmware | The firmware does not contain modems for your region | Install the correct one modem firmware via TWRP or return to stock MIUI |
If the phone stops turning on after unsuccessful firmware:
- Try to go to
Fastboot(Power + Volume Down) and repeat the firmware. - If the screen is black, but the PC recognizes the device as
Qualcomm HS-USB QDLoader 9008, use EDL mode (requires an authorized account Xiaomi and a special cable). - For models on MediaTek (for example, Redmi Note 8 Pro) firmware via SP Flash Toolcan help, but this is risky without experience.
If nothing helps, contact a service center. In some cases (for example, if damaged EMMC), restoration is only possible using a soldering station.
6. System optimization after reinstallation
After successful firmware it is recommended:
- ๐ Reset to factory settings (even if the firmware was โcleanโ) through
Settings โ Advanced โ Recovery and reset. - ๐ฑ Update all applications via Google Play or Mi App Store.
- ๐ Enable
Find My Device(for Android) orMi Cloud(for MIUI) in case you lose your phone. - ๐ก๏ธ Disable unnecessary system applications (for example, Mi Video, Mi Music) via
ADB:adb shell pm uninstall -k --user 0 com.miui.video
For custom firmware:
- ๐ง Install a kernel with support
GCam(if the camera works incorrect). - ๐ Configure
Thermal Engineto reduce overheating (through applications like Kernel Auditor). - ๐ถ Check operation
VoLTEiWi-Fi Callingโsome assemblies require manual activation via##4636##.
โ ๏ธ Attention: The function Mi Account (including Mi Cloud and Find Device) will not work. Use alternatives like Google Find My Device.
7. questions
Is it possible to reinstall Android on Xiaomi without unlocking the bootloader?
Yes, but with serious restrictions You can:
- Update the current version of MIUI via
Recovery(without changing the region or downgrading). - Reset to factory settings via
Settings โ Reset.
For a complete reinstallation (changing firmware, region or installing a custom OS) unlocking is required.
How to return the official MIUI after custom firmware?
You can return to the stock firmware via Mi Flash Tool:
- Download the official firmware
Fastbootfor your model. - Unlock the bootloader (if it was locked after custom firmware).
- Flash through
Mi Flash Toolwith the optionClean all and lock.
If the bootloader is locked and Mi Unlock Tool does not work, you may need to wait (up to 30 days) or use EDL mode (only for experienced users).
Why does the camera or NFC not work after the firmware?
This is a typical problem with custom firmware due to the lack of proprietary drivers. Solutions:
- Install a special patch for the camera (for example, ANX Camera for GCam).
- Check whether your model supports NFC in the selected firmware (information is in the topic on XDA).
- Return to the official MIUI if the functionality is critical.
How long does it take to reinstall Android?
Time depends on the method:
- Official firmware in
Mi Flash Tool: 5โ15 minutes + time to unlock the bootloader (up to 30 days for new accounts). - Custom firmware in
TWRP: 20โ40 minutes (including setup and installationGApps). - Recovery in
Recovery: 10โ20 minutes.
The longest preparation usually takes: downloading firmware, backup and unlocking.
Is it possible to reinstall Android on Xiaomi using a PC on Mac/Linux?
Yes, but with reservations:
- For
Mi Flash Toolyou will need Windows (you can use a virtual machine). - To work from
ADB/Fastbootto Mac or Linux install packages viabrew install android-platform-toolsorsudo apt install adb fastboot. TWRPand custom firmware is installed identically on all platforms, but manual configuration of access rights to/dev.