How to restore Xiaomi smartphone through MiFlash: detailed instructions with error solutions

Recovery of Xiaomi’s smartphone via MiFlash is a last resort when the device stops loading, freezes on the logo or malfunctions after a failed upgrade, a method that allows you to completely reflash the device, return it to factory condition or install custom firmware, but the process requires care: wrong actions can turn the phone into a brick.

Unlike standard Recovery reset, MiFlash firmware works at the bootloader level and allows you to bypass software locks. But there are nuances here, from unlocking Bootloader to choosing the right firmware version for a particular model. In this article, we will discuss the entire process from A to Z, including solving typical errors like Invalid image format or Flash write error.

1. Firmware Preparation: What to Do Before Starting

Before you connect your smartphone to your computer, make sure that all the preliminary steps are taken, without which the firmware will fail or lead to irreversible consequences.

First, check your Xiaomi model. firmware is strictly tied to the device code (e.g., davinci for Redmi). K20 Pro or raphael for Mi 9T Pro. You can find out the code:

  • πŸ” On the device box (barcode sticker)
  • πŸ“± In settings: Settings β†’ The phone. β†’ Version. MIUI β†’ Model code (if the phone is switched on)
  • πŸ’» Through ADB, The phone is loaded in Fastboot: fastboot getvar product.

Second, unlock Bootloader. Without that, MiFlash can't write the firmware. It takes up to 72 hours (as per Xiaomi rules) and requires you to link your Mi Account to your device.

⚠️ Note: If you are flashing a device with a locked bootloader, MiFlash will refuse to work even if you connect the phone correctly in Fastboot mode. Check the lock status with command: fastboot oem device-info Look for the line Device unlocked: true. If there is a false - unlock the bootloader necessarily.

Third, prepare the computer:

  • πŸ–₯️ Install the official Xiaomi drivers (or use Mi) PC Suite)
  • πŸ”Œ Use the original. USB-Cable (cheap cables can cause Wait for device errors)
  • πŸ”‹ Battery charge should be at least 50% (at low charge, the firmware can be interrupted)
πŸ“Š What tool do you use for Xiaomi firmware?
MiFlash
Fastboot via ADB
TWRP
SP Flash Tool
Other

2 Unlocking Bootloader: a mandatory step before firmware

The bootloader on all Xiaomi smartphones is locked by default, a security measure that makes recovery more difficult.

  1. Linking your Mi Account to your device (required!)
  2. Wait 168 hours (7 days) after the first tether.
  3. Use the official Mi Unlock Tool tool.

If you miss this step, MiFlash will make an error:

anti rollback verify failed

Or simply won’t see the device in Fastboot mode.

Step-by-step instructions for unlocking:

  1. Download Mi Unlock Tool (version should match your OS: Windows) 10/11 x64).
  2. Turn on the phone to debug. USB and OEM-unlocking β†’ For developers.
  3. Sign in to your Mi Account on your phone and to your Mi Unlock Tool on your PC (should be one account!).
  4. Connect your phone in Fastboot mode (clip Volume Down + Power when the device is off).
  5. Run the unlock in the Mi Unlock Tool and wait until it is completed (it may take several attempts).

⚠️ Note: After unlocking Bootloader, all data, including photos and apps, will be deleted from the phone.If the phone is not turned on but is determined by the computer in Fastboot mode, try backing up through the phone first. ADB: adb pull /sdcard/ (It does not work on all models).

πŸ’‘

If the Mi Unlock Tool is a β€œCouldn’t unlock” error, try using the 2021 version (3.5.511.27) – it often runs more stable than new releases.

3. Selection of firmware: official vs custom

The type of firmware depends on whether you will be able to use banking applications, Google Pay and other services that are sensitive to system modifications after recovery.

Type of firmwarePlusesConsSuitable for
Official (Fastboot)It maintains the guarantee, supports OTA-Update, no problem with SafetyNetMay contain Bloatware, limited settingsRecovery after a failure, phone sale, warranty repair
Castomic (TWRP + ZIP)More customization options, no extra apps, new versions of AndroidViolates SafetyNet, possible bugs, no OTAEnthusiasts looking for root or informal updates
Stock (Recovery)Easy to install, does not require unlocking BootloaderDoes not treat serious malfunctions, does not remove viruses at the system levelSmall system glitches, update without data loss

For recovery through MiFlash, only Fastboot firmware (files with the extension.tgz or.zip) are suitable.

  • 🌍 Xiaomi official website (select the Fastboot version for your model)
  • πŸ“¦ Xiaomi Firmware Updater (Firmware Archive with Version History)
  • πŸ”§ XDA Developers (Castom firmware, but require experience)

Pay attention to the Anti-Rollback version (ARB). If you stitch through an older version than the one you installed, the phone will turn into a brick. ARB team:

fastboot getvar anti

Compare it to the firmware version (indicated in the file name or file). flash_all.sh).

What is Anti-Rollback and why is it important?
Anti-Rollback (ARB) β€” This is Xiaomi's security mechanism, which prohibits rollbacks to older versions of the firmware. ARB 3 overhead ARB 4, the phone locks at the bootloader level and doesn't turn on. The only solution is to flash the version with the bootloader. ARB not lower than the current one or use an authorized service center.

4. Installation of MiFlash and drivers

MiFlash Tool is the official tool from Xiaomi for firmware devices in Fastboot mode. It works only on Windows (supports) macOS/Linux You can download it from the official website or from reliable sources like XDA.

After downloading:

  1. Unpack the archive into a folder without Cyrillic characters (e.g., C:\MiFlash).
  2. Install drivers from the folder MiFlash\Driver (launch install.bat on behalf of the administrator).
  3. Open MiFlash.exe on behalf of the administrator (otherwise the device will not see it).

If MiFlash doesn’t recognize your phone in Fastboot mode, check:

  • πŸ”Œ Is the phone connected to the port? USB 2.0 (on some PCs) USB 3.0 causes problems).
  • πŸ”„ Try another cable (original from Xiaomi is preferred).
  • πŸ–₯️ Update drivers through Device Manager (look for a device called Android Bootloader Interface).

As a last resort, use the patched version of the Mi Unlock Tool, which bypasses some of the limitations of the official tool.

Install MiFlash in a folder without spaces and Cyrillic|Download Fastboot firmware for your model|Unpack the firmware into a folder (for example, C:\rom)|Install drivers through install.bat|Connect your phone to Fastboot mode-->

5. Step-by-step instructions for firmware through MiFlash

Now, to the process itself, follow the instructions carefully, and an error at any stage can cause the device to fail.

Step 1. Connecting the phone

  1. Turn off the phone.
  2. Hold the Loud down. + Meal and hold for 10 seconds until the hare appears in the hat-eared (Fastboot mode).
  3. Connect the phone to the PC.

Step 2. Set up MiFlash

  1. Open MiFlash.exe on behalf of the administrator.
  2. Press Select and select the folder with unpacked firmware.
  3. Select firmware mode at the bottom: clean all – clean all – clean all and lock – clean all – clean all – clean all + Locking the bootloader (if you want to sell the phone) save user data - saving user data (not always stable)

Step 3. Starting the firmware

  1. Press Refresh – your phone should appear in the list of devices (for example, COM4).
  2. Press Flash and wait until it is completed (usually 5-15 minutes).
  3. When it's done, the phone will automatically reboot. USB, until you see the logo MIUI!

If the process is suspended on Waiting for device:

  • πŸ”„ Reconnect your phone (sometimes changing the port helps) USB).
  • πŸ”§ Reinstall drivers manually through Device Manager.
  • πŸ“₯ Try a different version of MiFlash (e.g. 2018.5.4.0 instead of the latest version).

⚠️ Note: If after firmware the phone hangs on the logo MIUI After 10 minutes, don't panic. You may be setting up the system first. Wait 20 to 30 minutes, and if nothing changes, repeat the firmware with the clean all option.

πŸ’‘

Always check the hash amount (MD5) Compare it to the official Xiaomi website, if the hashes don't match, the firmware can get damaged, leading to errors like Flash not done.

6. Solving Common MiFlash Errors

Even with the correct instructions, errors can occur, and here are the most common ways to correct them:

Mistake.Reason.Decision
Invalid image formatDamaged firmware files or incompatible version of MiFlashDownload the firmware again, check it out. MD5, Use MiFlash 2018.5.4.0
Flash write errorProblems with USB-Connecting or blocking antivirusDisable the antivirus, try another cable/port, run MiFlash from the admin
Device not foundDrivers not installed or phone not in Fastboot modeReinstall drivers manually, check the connection (fastboot devices)
Anti-rollback verify failedTrying to flash the old version of the firmwareUse firmware with ARB less than current or newer
Wait for device (hangs)Conflict with others ADB-toolClose all programs that use ADB (Mi PC Suite, Scrcpy, reboot PC

If none of the solutions worked, try flashing your phone through the phone. EDL-The emergency mode of the loader:

  1. Authorized Xiaomi account with rights EDL (You can get it on forums like this. XDA or 4PDA).
  2. MiFlashPro or QFil (for Qualcomm devices)
  3. Special firmware for EDL (usually in.mbn format).

EDL β€” This is the last chance to restore the phone if the Fastboot doesn't work, but without experience, you should contact the service center.

7.What to do after a successful firmware

If the firmware went smoothly and the phone booted, follow a few important steps:

  • πŸ”’ bootloader lock (optional): If you have been flashing a phone for sale, block Bootloader with the command: fastboot oem lock Attention: after that, unlocking again will take 7 days!
  • πŸ”„ System Update: Check for availability OTA-Updates to Settings β†’ The phone. β†’ Updating the system.
  • πŸ“± Data recovery: If you have backup done through Mi Cloud or ADB, Restore contacts, photos and apps.
  • πŸ›‘οΈ SafetyNet Check: If you plan to use banking applications, check SafetyNet status through the SafetyNet Test app.

If, after the firmware:

  • πŸ“΅ No network: Check the settings APN Or re-flash the modem module separately.
  • πŸ”‹ Battery goes down quickly: Make 2-3 full charge cycles (discharge to 0% β†’ charge%).
  • πŸ”Š Speakers/microphones not working: The firmware may not be compatible with your device revision (check the model code again).

If the phone is unstable (lagging, overheating), try flashing another version. MIUI (Stable instead of Developer or vice versa).

8. Alternative recovery methods

If MiFlash failed, consider alternative ways to:

1. Firmware through TWRP

Suitable for custom firmware installation (such as LineageOS or Pixel Experience).

  • Unlocked Bootloader.
  • Established TWRP Recovery (for each model its own version!).
  • Firmware in.zip format.

Instructions:

  1. Download your phone to TWRP (clip Volume Up + Power).
  2. Back up the section. NVRAM (crucially IMEI!).
  3. Sweep the.zip file through Install.
  4. Clean it up. Dalvik/Cache.

2. Firmware through SP Flash Tool

Relevant for devices on Mediatek processors (for example, Redmi) 9A, POCO C31). It will:

  • Firmware file in Scatter format.
  • Mediatek Preloader drivers.
  • The SP Flash Tool.

3. Service in the service centre

If all attempts of self-recovery failed, contact the authorized service Xiaomi. the cost of repair in case of software failure usually does not exceed 1-3 thousand rubles (2026), but you will receive a guarantee for work.

The service center is the only option if:

  • πŸ”§ The phone is not defined in Fastboot or in the EDL.
  • πŸ“‘ Damaged board (for example, after falling or getting moisture).
  • πŸ”’ Anti-Rollback device blocked due to rollback version.

πŸ’‘

If you're not sure what you're doing, it's better to pay for the service than to permanently ruin the phone. EDL or soldering containers on board require professional equipment.

FAQ: Frequent questions about Xiaomi's recovery

❓ Can I Switch Xiaomi Without Unlocking Bootloader?
No, MiFlash requires an unlocked bootloader. The only exception is the firmware through Recovery (but it doesn't treat serious crashes). If the Bootloader is locked and the phone doesn't turn on, then only the service center remains.
❓ Why MiFlash doesn't see my Xiaomi in Fastboot?
There are several reasons: Drivers are not installed (check in Device Manager for Android Bootloader Interface). USB 3.0. Conflict with other programs (close Mi) PC Suite, ADB Older version of MiFlash (try version 2018.5.4.0) Also check that the phone is in Fastboot mode (should be black screen with a hare).
❓ How to repair IMEI post-fix?
If it's gone after the firmware. IMEI (No network, try: Restore the backup partition NVRAM (If you did it before the firmware. IMEI manually via Engineer Mode: ##36446337## β†’ Connectivity β†’ CDS Information β†’ Radio Information β†’ Phone 1/2 β†’ enter AT-recovery IMEI. Reflash the modem module separately (files) modem.img If nothing helps, contact the service - self-restore. IMEI It may be illegal in some countries.
❓ Can I use Xiaomi on Mac or Linux?
The official MiFlash only works on Windows, but there are alternatives: 🍎 On macOS: Use fastboot manually via Terminal (the commands are the same as in MiFlash, but without a GUI). 🐧 On Linux: install fastboot-tools and run the command: sudo fastboot flash all name firmware.img For both cases, you will need drivers and the correct access rights to the device. USB.
❓ What to do if the phone does not turn on after the firmware?
Possible causes and solutions: πŸ”‹ Battery is dead: Connect to charging for 30 to 60 minutes, then try turning on. πŸ“± Wrong firmware: Re-sweep, making sure the version is suitable for your model and revision. πŸ”§ The loader is damaged: Try to stitch through EDL (Authorized account required). πŸ’₯ Hardware malfunction: If the phone does not respond to charging and is not determined by the computer, the problem is in the board (repair is needed).