Reflashing Xiaomiβs smartphone via TWRP using a computer is a process that requires careful and understanding of each step. Many users resort to custom firmware to get advanced features, current updates for outdated models or get rid of preinstalled MIUI software. However, the wrong actions can turn the device into a βbrickβ, so it is important to follow proven algorithms.
This guide will take a look at all the steps from tool preparation to the final system setup, and not only the standard scenario, but also the typical errors that users encounter when working with fastboot, ADB and TWRP itself. We will pay special attention to the nuances of unlocking the bootloader, a key step without which custom firmware installation is impossible.
If youβve never done firmware before, we recommend you study each section carefully. For experienced users, the firmware and Xiaomi model compatibility tables, as well as ways to solve rare bugs that are not covered in the standard guides, will be useful.
1. Firmware Preparation: What to Do Before Starting
Before you start installing TWRP and new firmware, you need to follow a few critical steps, and ignoring them can lead to data loss, device lockdown, or even physical smartphone failure.
The first is to back up all your data. TWRP firmware is full-wipe, so contacts, photos, messages and apps will be deleted. Use Mi Cloud, Google Drive or local copying on your PC. Pay special attention to the DCIM (photo/video) and WhatsApp/Databases (if you use the messenger).
Second, check your Xiaomi model and its encoding, for example, the Redmi Note 10 Pro may have versions of sweet (global) and sweetin (Indian), a mismatch in the firmware model will lead to an error Error 7 in TWRP.
- π± In Settings menu β About Phone β Version MIUI (click multiple times on "Kerole")
- π» Using the adb shell command getprop ro.product.device (by connecting the phone to the PC)
- π On the Xiaomi Firmware website at IMEI
Third, get your computer ready. Install the latest versions.
- π₯οΈ Android SDK Platform-Tools (includes fastboot and adb)
- π Xiaomi Drivers (download from official website)
- π Firmware and TWRP for your model (from verified sources only!)
β οΈ Warning: Never download firmware from torrent trackers or obscure forums. Viruses in custom firmware can steal bank card details or passwords. Use only XDA Developers or official project repositories (like LineageOS).
2. Unlocking the Xiaomi bootloader: bypassing the limitations of MIUI
Xiaomi blocks the bootloader on all its devices to prevent unofficial software from being installed. Unlocking is a mandatory step before firmware is installed via TWRP. The process takes between 3 and 360 hours (depending on Xiaomi policy).
To unlock, follow the following steps:
- Link your Mi Account to your phone in Settings β Xiaomi Account.
- Activate USB debugging: Settings β About Phone β MIUI version (click 7 times), then Settings β Additional β For Developers β Debugging over USB.
- Connect the phone to the PC and confirm the debugging permission.
- Download Mi Unlock Tool and log in to the program.
- Turn the phone into fastboot mode (turn it off, then press Volume Down + Power).
- In Mi Unlock Tool, press Unlock and wait until it is completed (it may take several attempts).
Once successfully unlocked, the phone will display Unlocked in fastboot mode, and you can now start installing TWRP.
β οΈ Warning: If the Mi Unlock Tool is giving a Couldn't unlock error, check: π Mi Account is linked to the phone and confirmed by SMS/email. π At least 168 hours (7 days) have passed since the account was linked. π‘ The phone is connected to the Internet via a SIM- card (Wi-Fi may not work). If the error persists, try using alternative tools (at your own risk!).
π‘
If unlocking is delayed, try connecting the phone to another USB- port (preferably USB 2.0 on the back of the PC) or using the original Xiaomi cable.Some users solve the problem by disabling the antivirus on the PC.
3. Install TWRP on Xiaomi via fastboot
TWRP (Team Win Recovery Project) is a custom recovery that allows you to install firmware, create backups and manage memory partitions.
Installation instructions:
- Download the current version of TWRP for your model from the official website (file with the extension.img).
- Place the file in the folder with the platform-tools (where fastboot.exe and adb.exe are located).
- Open the command prompt in this folder (click Shift + PCM β Open the PowerShell window here).
- Connect your phone in fastboot mode and execute the command: fastboot flash recovery twrp-3.7.0_12-0-sweet.img (replace twrp-3.7.0_12-0-sweet.img with your file name).
- After a successful recording, run: fastboot boot twrp-3.7.0_12-0-sweet.img This will temporarily boot TWRP without overwriting stock recovery.
If TWRP is replaced with stock recovery after the reboot, then your device is active anti-rollback protection.
- π Re-scan TWRP and immediately after installation (without turning off the phone!) run to TWRP: Wipe β Format Data β type "yes" This will remove encryption and prevent the recovery of the stock recovery.
- π¦ Install firmware with disable_forceencrypt support (e.g. OrangeFox or modified TWRP).
Uploaded the correct.img file for your model | Phone in fastboot mode | ADB/Fastboot drivers installed on PC | Secure Boot disabled in BIOS (for some PCs) |Data backup made-->
4. Selection and download of firmware for Xiaomi
The firmware choice is the key to the stability of the phone, bugs and hardware compatibility. There are several types of firmware for Xiaomi:
| Type of firmware | Features | Who's right for? | Recommended projects |
|---|---|---|---|
| Official MIUI | Stock firmware from Xiaomi, stable, but with Blaatware | For beginners who want a warranty and OTA- updates | Official website |
| Castomic (AOSP) | Pure Android without MIUI shell, more settings | Advanced users, fans of βvanillaβ Android | LineageOS, Pixel Experience |
| MIUI custom | Modified MIUI with remote bloatware and additional features | Those who love MIUI but want to optimize | Xiaomi.EU, RevengeOS |
| GSI (Generic System Image) | Universal firmware, works on most devices with Project Treble | For experiments or unofficially supported models | XDA GSI |
When choosing a firmware, pay attention to:
- π Build Date β The latest versions contain fewer bugs and up-to-date security patches.
- π§ Installation type β some firmware requires a vendor to be installed.
- π Camera support β Custom firmware may not support all camera modules (check on forums).
Critical: Firmware for MediaTek devices (such as the Redmi Note 11) often requires additional patching boot.img via Magisk for sensors and mobile network to work properly.
5. The firmware process through TWRP: step-by-step instruction
Now that the TWRP is installed and the firmware is downloaded, you can start installing it, and it takes 15 to 40 minutes, depending on the speed of your PC and phone.
Algorithm of action:
- Copy the firmware file (.zip) and, if necessary, Magisk (for root) into the phone's memory.
- Boot to TWRP (Put Volume Up + Power on).
- Run Wipe: Wipe β Advanced Wipe β Mark Dalvik, Cache, Data, System β Swipe to Wipe β οΈ Warning: If you install firmware on top of an existing one (such as an update), just clear Dalvik and Cache. Full wipe wipes all data!
- Install β Select.zip β Swipe to Confirm Flash
- If required, file Magisk (for root rights) or Disable Force Encrypt (for disabling encryption).
- Reboot your phone: Reboot β System.
The first download can take up to 10 minutes, which is normal, and if the phone has been stuck on the logo for longer than 15 minutes, it means there's been an error.
- π Return to TWRP and re-install.
- π‘ Check if the firmware is suitable for your model (Error 7 indicates incompatibility).
- π§ Try another version of TWRP (e.g. OrangeFox).
What if TWRP doesnβt see internal memory?
Typical errors and their solutions
Even with strict adherence to the instructions, errors can occur, and let's consider the most common ways to eliminate them:
| Mistake. | Reason. | Decision |
|---|---|---|
| Error 7 in TWRP | The firmware is not suitable for your model or MIUI version. | Download the correct firmware version or edit updater-script in the archive |
| Fastboot mode starts but no device detected | Problems with drivers or cable | Reinstall the drivers, try another one. USB-port |
| The phone does not turn on after firmware (black screen) | Incompatible firmware or interrupted process | Repeat the firmware via fastboot with the official MIUI |
| Invalid sparse file format at header | A damaged firmware file or an incorrect TWRP | Download the firmware, check the checksum (MD5) |
| No network after firmware | There is no vendor module or incorrect firmware | Install the appropriate firmware for your firmware |
If the camera, Wi-Fi or Bluetooth stopped working after the firmware, the problem is most likely the lack of proprietary drivers.
- πΈ For Camera: Set up the ANX Camera or GCam with the settings for your model.
- πΆ For Wi-Fi/Bluetooth: Fold firmware from stock MIUI through TWRP.
π‘
If the phone doesnβt detect the SIM- card after firmware is installed, check if your firmware supports your region. Some custom builds (e.g., Redmi Note 9 Pro) require manual modem selection in settings.
7.Setup of the system after firmware
After successful firmware installation, several steps must be taken to ensure the system works correctly:
Initial setting:
- Go through the Initial Configuration wizard (select language, connect to Wi-Fi, log in to Google account).
If the firmware is based on AOSP, you may need to manually install Google services (Open GAPPS).
Verification of functionality:
Test in turn: calls, mobile Internet, Wi-Fi, Bluetooth, camera, sensors.
If something doesnβt work, go back to TWRP and install the missing components (e.g., vendor or firmware).
Optimization:
Disable unnecessary background processes in Settings β Applications.
For firmware on AOSP, install Magisk for root rights and modules (e.g. ViPER4Android for sound).
The new system's backup:
- V TWRP Create a full backup (Backup) β Select sections β Swipe to Backup).
Save a copy on a PC, it will save you in future experiments.
- Charge the phone to 100%.
- In TWRP, clear Battery Stats (Wipe β Battery Stats).
- Discharge the phone before automatically turning off, then charge back to 100% without interruptions.
-->
8 How to Get Back the MIUI Stock Firmware
If custom firmware does not suit you or critical errors occur, you can return the official MIUI.
- π₯ Download the official firmware for your model (select the Fastboot version).
- π₯οΈ Install Mi Flash Tool on PC.
- π§ Unlock the bootloader (if it was blocked after firmware).
Recovery process:
- Unpack the downloaded firmware in a folder without spaces in the title.
- Download the phone to fastboot mode.
- In the Mi Flash Tool, specify the path to the firmware folder and press Refresh (the phone must be determined).
- Select Clean All mode and press Flash.
Once complete, the phone will reboot to stock MIUI. All data will be erased, so pre-backup!
β οΈ Warning: If you want to log in to Mi Account after you return to your firmware, and you don't remember it, you'll have to go to Xiaomi's service center to unlock it, which is called FRP (Factory Reset Protection) and it works if you've linked your account to your device.