Installing an operating system Android One or custom builds on Xiaomi devices is a popular solution for users who want to get rid of a heavy interface MIUI. The built-in shell from a Chinese manufacturer often contains an excessive amount of pre-installed software, advertising and services that cannot be removed using standard methods. Switching to AOSP (Android Open Source Project) returns the device to performance and significantly extends battery life.

However, the process of replacing the system is associated with certain risks that require technical literacy and care. Incorrect actions can lead to complete inoperability of the device, known as bootloop or “brick”. This article describes in detail all stages of preparation and execution of the procedure in order to minimize the likelihood of errors and get a stable working gadget with a clean interface.

First, you need to understand the difference between the official global firmware and custom builds. Official versions retain all the camera and unlock functions, but leave the MIUIelements. Custom firmware, such as LineageOS or Pixel Experience, provide a completely clean user experience, but may have limitations in the operation of specific equipment, for example, an NFC module or a wide-angle camera.

Preparing the device and collecting the necessary tools

The first step is to create a complete backup of all important data, since during the process of unlocking the bootloader the device will be completely wiped. The user will need a computer running Windows, an original high-quality USB cable and a stable Internet connection. It is also critically important to check the battery charge level, which should be at least 60-70% to prevent a power outage at a critical moment.

To work with system partitions, you need to install specialized drivers and utilities on your computer. The main tool will be ADB i Fastboot, which are part of the Android SDK Platform Tools. Without these components, communication between a personal computer and a smartphone in bootloader mode will be impossible, which will make the firmware procedure impossible.

⚠️ Attention: Make sure that your smartphone model supports bootloader unlocking. Some devices released for certain regions or telecom operators may have a permanent lock that cannot be bypassed using software methods.

Download the desired firmware image and recovery file TWRP, specially adapted for your device model. The use of files from other models is strictly prohibited, as this will lead to driver incompatibility and hardware failure. All downloaded files should be placed in the root folder of the platform platform-tools for ease of access via the command line.

☑️ Preparation for firmware

Done: 0 / 5

Unlocking the bootloader through the official service

The Company Xiaomi has implemented a strict security policy that requires the bootloader to be unlocked before installing third-party software. To do this, you need to create an account Mi Account and link it to the device in the settings menu. In the section Settings → About phone → MIUI version you need to click on the build number several times to activate the menu for developers.

After activating the hidden menu, go to Settings → Advanced settings → For developers and enable the option Factory unlocking (OEM unlocking). The system will request confirmation through the linked account and warn about loss of warranty and deletion of data. Only after successful binding can you proceed to using the utility Mi Unlock Tool on your computer.

Procedure stage User action Expected result
Account linking Login to Mi Account in phone settings Linking status is displayed in the developer menu
Waiting timer Waiting from 7 to 16 days The server allows sending an unlock request
Running the utility Entering Fastboot mode and connecting to a PC Mi Unlock Tool sees the device and account

It is important to note that after linking an account, a waiting timer is often triggered, which can last from one to two weeks. Trying to bypass this limitation by resetting your settings or relinking your account will reset the timer, so you must be patient. After the waiting period has expired, launch Mi Unlock Tool, switch the phone to mode Fastboot (holding the power and volume buttons down) and press the unlock button.

Why is there a wait timer?

The timer was introduced by Xiaomi to protect users from device theft. If the phone is stolen, the attacker will not be able to quickly reflash it and sell it, since the owner will have time to block the device remotely through the Find My Device service.

Installing custom TWRP recovery

After successful unlocking, the standard recovery menu is replaced with a modified one, most often this TWRP (Team Win Recovery Project). This tool allows you to install ZIP archives with firmware that are not signed with the manufacturer's digital keys. To install, you need to put your smartphone into Fastboot mode and connect it to the computer, then open the command line in the tools folder.

Enter the command to check the device connection:

fastboot devices

If the serial number is displayed in response, the connection is established correctly. Next, the command to flash the recovery image is executed:

fastboot flash recovery twrp_image_name.img

Where twrp_image_name.img is the exact name of the downloaded recovery file. Immediately after executing the command, you must manually put the device into recovery mode by holding down the power and volume buttons up to prevent the standard system from overwriting the modified partition.

💡

If after a reboot the standard MIUI menu loaded instead of TWRP, then the system automatically rolled back the changes. Repeat the procedure and immediately after entering the fastboot boot twrp_image_name.img command, go into recovery manually.

Inside the menu TWRP first of all, it is recommended to make a full backup of the current system (Nandroid Backup), even if it is deleted. This will create an exact copy of all partitions on the internal memory or SD card, which will allow you to return to the original state in case of critical errors when installing a new OS. Also in this menu, you can format the Data section to remove encryption.

⚠️ Attention: When you launch TWRP for the first time on an encrypted device, you may be required to enter a pattern key or PIN code from the old system. If the input does not help, run the command Format Data through the cleaning menu by entering the word "yes".

The process of installing firmware and cleaning partitions

Installing a new operating system requires preliminary cleaning of old data to prevent file conflicts and operational errors. Android. In the recovery menu, go to the Wipe section and select Advanced Wipe. It is necessary to mark the sections Dalvik / ART Cache, System, Data and Cache, but under no circumstances touch the section Internal Storageif the firmware file is stored on it.

After cleaning, return to the main menu and select the item Install. Find the previously copied ZIP archive with the firmware and confirm the installation by swiping to the right. The process will take from a few minutes to ten, depending on the speed of the device's flash memory. At this time, a log of executed scripts will be displayed on the screen, which is useful to save in case of errors.

  • 📂 Make sure that the firmware file is in the internal memory and not on an external SD card if the recovery does not support working with external media.
  • ⚙️ After installing the main system, installing packages is often required GApps (Google Apps), if they are not built into the firmware by the developer.
  • 🔄 Do not reboot the system immediately if the instructions for the firmware require initial setup or installation of additional patches.

If you are installing the firmware without built-in Google services, the next step is to install the package OpenGApps or NikGApps. Select the processor architecture (usually arm64) and the Android version corresponding to the installed firmware. Installation is carried out in the same way through the menu Install without re-cleaning the partitions.

📊 What type of firmware do you prefer?
Official global MIUI
Custom with Google services
AOSP without Google services
LineageOS for privacy

Initial system setup and optimization

After completing all installation procedures, select the option Reboot System. The first launch of a clean system can take up to 5-10 minutes, as applications are optimized and new caches are created. Don't panic if the screen remains black for a long time or the Android logo is displayed - this is normal behavior for a new installation.

During the initial setup Android you will be asked to connect to a Wi-Fi network and sign in to your Google account. With clean firmware, this process is much faster and more intuitive than with manufacturers’ shells. It is recommended to immediately check the operation of the main modules: camera, sound, microphone and fingerprint sensor.

To ensure maximum performance, you should go to the developer settings and adjust the animation scale. Setting a value 0.5x for the “Window Animation”, “Transition Animation” and “Animator Duration” scales will visually speed up the interface. It is also useful to disable unused system applications through settings or using ADB commands.

💡

A clean system consumes significantly less RAM when idle, which allows more applications to remain active in the background without unloading.

Possible problems and solutions

Despite careful preparation, users may encounter various errors. One of the most common problems is the bootloop, where the device repeatedly reboots before reaching the desktop. This is often due to incompatibility between the recovery and firmware versions or remnants of old data in the Data section.

If the device is frozen at the logo, try entering Recovery mode and performing a Factory Reset again. In more complex cases, it may be necessary to flash the stock version via EDL (Emergency Download Mode) using an authorized Mi account and special software. This will return the phone to its factory state, but will require contacting a service center if the account is not authorized.

⚠️ Attention: Menu interfaces and item names may vary slightly depending on the TWRP version and the specific smartphone model. Always check the topic threads on the 4PDA or XDA Developers forums for your model.

Problems with the camera often arise due to differences in drivers between MIUI and custom firmware. In this case, it is recommended to install the application port Google Camera (GCam), which often works better than the standard application in pure Android conditions. For stable operation of communications and GPS, it may be necessary to flash the modem or radio module, if this is provided for in the instructions for a specific assembly.

Is it safe to unlock the bootloader on a new phone?

Unlocking the bootloader is officially permitted by the manufacturer, but it will void the device warranty in most regions. In addition, this reduces the level of data security, since an attacker with physical access can more easily access the information.

Is it possible to return the original MIUI firmware back?

Yes, it is possible. To do this, you need to unlock the bootloader again (if it was locked during flashing) and use the official Mi Flash Tool to install the stock Fastboot ROM image. All data will be deleted.

Why does the banking application not work after flashing the firmware?

Banking applications and Google Pay do not work on devices with an unlocked bootloader due to SafetyNet or Play Integrity API protection. To bypass this limitation, you need to install Magisk modules and hide root access, which is a complex procedure.

Do you need Root access to install pure Android?

No, obtaining superuser rights (Root) is not a prerequisite for installing custom firmware. Moreover, many modern firmware recommend installing the system without root access to ensure the stability and security of banking applications.