Xiaomi firmware through ADB and Fastboot: a step-by-step guide

The procedure for updating or restoring the operating system on Xiaomi smartphones is often required when software failures occur, the device is “bricked” or you want to install a custom Android build. Using the ADB command line interface (Android Debug Bridge) and Fastboot mode is the most reliable method of interaction with the system partition of the device when standard methods through the Recovery menu are unavailable or blocked.

Unlike the Airborne Update (OTA), which is limited by user rights, firmware through a computer allows you to bypass many software restrictions and restore the health of even a severely damaged system. However, it is worth noting that working with low-level tools requires care and accurate follow-up of instructions, since an error in one command can lead to complete failure of the gadget. It is critical before starting any manipulations to make a full backup of important data, since the firmware process often involves completely removing all information from the internal drive.

In this guide, we will take a look at how you prepare your computer and smartphone, install the necessary drivers, and the algorithm for flashing your device. We will look at the nuances of working with the ADB utility, commands to put your phone in bootloader mode, and methods for forcibly overwriting system partitions. Even if you are new to the Android modding world, a detailed description of each step will help you succeed.

Workplace preparation and necessary tools

The first step is to organize the right software environment: you need a computer running Windows, macOS or Linux. To work with ADB and Fastboot, you need to download the official SDK Platform Tools from the Android developer site. This is a set of basic tools that contains the executable files adb.exe and fastboot.exe necessary for communication between the PC and the smartphone.

In addition to system utilities, you will need firmware itself. For Xiaomi devices, there are two main types of firmware: Recovery (extension.zip) and Fastboot (extension.tgz). For the method described in this article, we will need Fastboot firmware, since it contains the full image of the system, including a bootloader, radio module and system partition. You should only download files from trusted sources, for example, from the official MIUI Download website or authoritative forums.

Just as important is the physical interface of the connection. Use the original. USB-The cable that came with the smartphone, or the high-quality analogue with data support. Cheap "charging only" cables will not allow the computer to see the device in debugging mode. USB The computer's motherboard is serviceable and provides a stable

power, as the communication break at the critical moment of data recording is fatal.

☑️ Firmware readiness

Done: 0 / 4

Check for free space on your computer's system drive. Unpacked firmware files can take anywhere from 3 to 5 gigabytes. It is also recommended to disable antivirus software during the procedure, as it can falsely identify the firmware scripts as a threat and block their execution, which will lead to a process error.

Installation of drivers and activation of debugging

Without the right drivers, your computer won’t be able to recognize your smartphone in special modes. Xiaomi devices most often require Qualcomm HS-USB QDLoader 9008 drivers (for EDL mode) and standard Android Bootloader Interface drivers. In Windows 10 and Windows 11, drivers are often installed automatically when you first connect, but for stable operation it’s better to install them manually through Device Manager.

On the smartphone side, you need to activate the hidden menu for developers. To do this, go to Settings → About the phone and find the MIUI version. Click on it 7-10 times in a row until the notification “You became a developer” appears. Then a new item “For developers” will appear in the “Additional” (or “Extended settings”) menu.

Inside the developer menu, find and activate the USB Debugging Switch. When you connect your phone to your computer in this mode, you'll see a request for debugging permission on your smartphone screen. Make sure you tick "Always Allow from this computer" and click "OK." Without this confirmation, the ADB commands won't be executed.

⚠️ Note: If you plan to unlock the Unlock Bootloader, one debugging by one USB You will need to link your Mi Account to your phone settings and get official permission through the Mi Unlock Tool, which can take 3 to 7 days to wait.

To check for communication, open the Command Prompt (CMD) or PowerShell in the Platform Tools folder and type in the adb device command. If a device with a serial number and device status appears on the list, the connection is established correctly. If the status is unauthorized, check the phone screen for permission request.

Translation of the smartphone to Fastboot mode

Fastboot mode (or bootloader mode) is a state of the device in which it is ready to receive low-level commands to write memory partitions. This mode does not load the Android operating system, which allows you to replace system files without conflicts. You can transfer Xiaomi to this mode software through ADB or hardware using buttons.

The easiest software method is to use the USB debugging already installed: connect your phone to your PC, open the console in the folder with ADB and type in the command:

adb reboot bootloader

The smartphone will immediately restart and you will see an image with a hare fixing an android, or an inscription. FASTBOOT If the phone doesn't respond to commands, it's orange. ADB (For example, the system is getting stuck, use the hardware method. Turn the device off completely, then press the Volume Down button, and hold it back and plug it in. USB-computer-wire.

After switching to Fastboot mode, check the visibility of the device with the command:

fastboot devices

The device serial number should be displayed in response. If the list is empty, check the drivers in Windows Device Manager (section "Controllers" USB» or "Portable devices"). The device may be displayed as "Android" or «QHSUSB_BULK» (If it has gone into deep recovery mode).

What to do if the phone is gone to mode EDL (If the phone is identified as Qualcomm when connected HS-USB QDLoader 9008 And the screen is black, so the device is in emergency recovery mode. 15-20 If that doesn't work, you'll need a dedicated contact-closing cable or an authorized Mi Account to run through the Mi Flash Tool.--> The process of writing the firmware depends on the format in which you downloaded the archive. If you use a standard Fastboot firmware (.tgz), it must be pre-unpacked. Inside the folder, you'll find a scriptwriter that automates the process, or you can execute commands manually for full control. For Windows users, the unpacked firmware folder usually contains a file. flash_all.bat. Run it while the phone is in Fastboot mode and connected to the PC. The script will clear the memory itself and flood all the necessary images. ADB/Fastboot It's considered more expert and reliable because it allows you to see the logs of each operation. Let's look at the key commands for manual firmware of the main partitions. Run them sequentially in the terminal.
🚀 Clear partitions: Before writing new data, it is recommended to erase old ones. 💾 Recording of the bootloader: fastboot flash boot boot.img — This is a critical stage without which the phone will not start. 📦 Installation of the system: fastboot flash system system.img — It takes the most time, as the bulk of the data is recorded. 🔄 Reboot: After all operations are complete, enter fastboot reboot for the first run. During the execution of commands, the status of the operation will be displayed in the terminal. OKAY, faults — FAILED. Do not interrupt the process or disconnect the cable until you see a message about the completion of the last command. 5 before 15 minutes depending on speed USB-port-size. Even with strict adherence to the instructions, technical difficulties can arise. Below is a table with the most common errors that occur when you run Xiaomi through the firmware. ADB, Terminal error Possible reason Waiting for device Method Not installed drivers or bad cable Reinstall drivers, replace drivers USB-cable, change port FAILED: device is locked bootloader is blocked by the manufacturer Unlock through Mi Unlock Tool with account binding FAILED: remote: command not allowed Downgrade attempt of Android version Use firmware of the same or newer version, or special error methods: device unauthorized Not confirmed permission on the phone screen Confirm debugging on the smartphone screen, check the cable Separately, it is worth mentioning an error associated with the incompatibility of regions. Firmware global version (Global) on the Chinese device (CN) or vice versa without changing the region can lead to a cyclic reboot (bootloop). In such cases, you need a complete cleanup (fastboot erase userdata command) and use the appropriate version of the firmware. If during the firmware process there is a power failure or cable break, the phone can stop responding to Fastboot commands. In this case, try to switch the device to EDL (Emergency Down Mode) and use the Mi Flash Tool utility with an authorized service center account, or contact the service for longer than the first time of the programmap for the new configuration of the device, after the first configuration of the device, it will start of the new memory and reboot 5 minutes. A logo may be displayed on the screen. MI Don't panic if the phone hangs on the logo for a while, which is normal behavior. After you boot, you're greeted by the language selection screen, and since we've been doing a full flashing, all the data will be deleted. You have to reconfigure Wi-Fi, log into your Google account and Mi Account. If you unlock the bootloader, the first time you turn on the security system can warn you that the software is not original — it is standard behavior for modified devices. 📊 What purpose are you flashing your phone?Recovery after a failureInstallation of global firmwareGet Root-rightsWish to get fresh Android Just for the sake of the experiment It is recommended immediately after the first download to check the version of the software in the settings to make sure that the firmware has stood up correctly. It is also worth checking the main modules: camera, speakers, sensor and communication modules. If everything is functioning normally, the procedure can be considered successful. ⚠️ Note: After the bootloader is firmware and unlocked, some banking applications and services (Google Pay, Mir Pay) may stop working due to a security breach. Frequently asked questions (FAQ) Can I use Xiaomi to help you? ADB No, fastboot flash commands require an unlocked bootloader to write system partitions. Without unlocking, you can only clean partitions or restart the device, but not write new system images. EDL, But it requires an authorized account, so will my photos and contacts disappear after the firmware is up? Yes, using the Fastboot method with the team flash_all or manual partition cleaning, all user data will be permanently deleted. Be sure to back up important files to your computer or the cloud before starting the procedure. MI Try rebooting to Recovery Mode (clutching the power and volume button up) and doing Wipe Data/Factory If it doesn't help, it's possible the firmware is damaged or not suitable for your model, and the procedure needs to be repeated with another firmware file. ADB? Using informal assemblies always carries risks, they can contain errors, unstable work or have security vulnerabilities. ROMYou only need to know the source and how to back off in case of trouble.