Reflashing Xiaomi Mi A1: from unlocking the bootloader to installing custom software

Xiaomi Mi A1

Android One

Android

custom-fix

Mi A1

OTA

Fastboot

TWRP

In this article, you will find step-by-step instructions for all scenarios, from unlocking the bootloader to installing LineageOS or returning to stock firmware. We will also analyze typical errors (for example, Error 7 in TWRP or getting stuck on the Xiaomi logo) and give recommendations for choosing software. Importantly, the Mi A1 has a unique feature – its bootloader locks automatically after each flashing, so you will have to unlock it every time.

If you are a beginner, start with the official methods (sections 2–3). Power users can immediately jump to custom firmware installation (sections 4–6). Don’t forget to back up data – the flashing process erases all user files from internal memory!

πŸ“Š Why would you want to reflash the Xiaomi Mi A1?
Install a new version of Android
Fix bugs and lags
Install custom firmware (LineageOS, Pixel Experience)
Return the stock firmware
Other

1. Firmware preparation: Backup and unlock the bootloader

Before any firmware manipulations, you need to save important data and unlock the bootloader. Xiaomi Mi A1 uses a closed bootloader by default, so installing custom software is impossible without unlocking.

Step 1: Backup

Copy it to your PC or cloud:

  • πŸ“ Photos and videos (Folders DCIM, Pictures)
  • πŸ“± Contacts (export via Google Contacts)
  • πŸ”‘ Logins and passwords (use Google Smart Lock or Bitwarden)
  • 🎡 Music and Documents (check Download, Documents folders)

⚠️ Warning: Fastboot or TWRP firmware formats the /data partition, removing all user files, including installed applications and their data (e.g., saves in games).

Step 2: Unlocking the Xiaomi bootloader requires official permission to unlock.

  1. Link your Mi Account to your device: Settings β†’ Xiaomi account.
  2. Activate Developer Options: Go to Settings β†’ About Phone and click on the Build Number 7 times.
  3. Enable USB Debugging and OEM Unlocking in Settings β†’ For Developers.
  4. Connect your phone to your PC, install ADB/Fastboot Tools, and execute the command: fastboot oem unlock

Once confirmed on the phone screen, the bootloader will be unlocked. Note: this will reset the device to factory settings!

Is Mi Account connected to phone | USB | Installed ADB drivers on PC | At least 60% charged | All important data is saved-->

2.Official firmware methods: OTA and Mi Flash Tool

If you don't need custom firmware, start with the official methods. They're safe and don't require unlocking the bootloader (except in downgrad cases).

Method 1: Air Update (OTA) Mi A1 supports updates via Settings β†’ System β†’ System Update. However, since 2020, official updates have stopped. If you are offered an upgrade to Android 9 Pie (the latest official version), follow the instructions on the screen.

  • πŸ”„ All data and settings are stored.
  • πŸ›‘οΈ Minimum risk of "bricking."
  • πŸ“± No PC required.

Method 2: Firmware with the Mi Flash Tool

If OTA is not available or you need to reinstall the stock firmware:

  1. Download the official firmware for the Mi A1 (select the Fastboot version).
  2. Unpack the archive into a folder without Cyrillic characters (e.g., C:\MiA1\).
  3. Install the Mi Flash Tool and connect the phone in Fastboot mode (clip Volume Down + Power).
  4. In the program, select a firmware folder and press Refresh, then Flash.

Choose Clean all or Clean all and lock mode, the second option is recommended if you plan to sell the phone.

What if the Mi Flash Tool can’t see the device?
Make sure that Qualcomm HS-USB QDLoader 9008 drivers are installed. If the phone is defined as QHUSB_BULK, try: 1. Disable driver signatures in Windows (via gpedit.msc). 2. Use another USB- port (preferably 2.0). 3 Reboot your PC and phone in Fastboot mode.

3. Installation of custom TWRP Recovery

TWRP (Team Win Recovery Project) is an alternative recovery that allows you to install custom firmware, make backups and restore the system. For the Mi A1, there is a special version of TWRP 3.6.2, adapted for Android One.

Installation instructions:

  1. Download the latest version of TWRP for Mi A1 (.img file).
  2. Move the file to the platform-tools folder and rename it to twrp.img.
  3. Connect your phone in Fastboot mode and execute the command: fastboot flash recovery twrp.img
  4. Immediately after that, go to the recap, holding Volume up + Nutrition (otherwise, the stock recap will overwrite TWRP).

Features of the TWRP for the Mi A1:

  • πŸ”§ Supports F2FS and ext4 for the /data partition.
  • πŸ“± Has a touchscreen interface (finger control).
  • ⚠️ The /data encryption doesn’t work – you’ll have to format the partition when you install the firmware.

⚠️ Warning: Once installed, the TWRP stock recavator will automatically recover when rebooted. To avoid this, immediately after firmware TWRP follow the command: fastboot flash boot twrp.img This will replace the boot image, but may result in a bootloop ( looped reboot) if you do not plan to install custom software.

4. Custom firmware choice: MIUI vs Android One vs LineageOS

Once you have TWRP installed, you can choose between three types of firmware, each with pros and cons:

Type of firmwareAdvantagesDeficienciesRecommended version
Official MIUIStability, OTG support, optimization for ironClosed source, advertising, no Android 10+MIUI 12.5 (Android 9)
Android One (Stock)Clean Android, Quick Updates (previously)Outdated version (maximum Android 9), no customizationAndroid 9 Pie (OPM7.181205.001)
LineageOSAndroid 11/12, open source, no BloatwareThere may be camera bugs or Wi-Fi, there are no Google Apps by defaultLineageOS 18.1 (Android 11)
Pixel ExperienceInterface like Google Pixel, Android 12Less optimization for Mi A1, possible lagsPixel Experience Plus (Android 12)

How do you choose?

  • πŸ“± If you want the most stable option, stay on the stock Android One or MIUI.
  • πŸ”„ If newer versions of Android are important, go with LineageOS or Pixel Experience.
  • 🎯 If you want customization (themes, gestures) try MIUI with patches or Havoc-OS.

πŸ’‘

Before installing custom firmware, check the reviews on the XDA-Developers forum. Pay attention to camera bugs (the dual module on the Mi A1 often works incorrectly) and the NFC module (if you use contactless payments).

5. Step-by-step installation of custom firmware through TWRP

The custom software installation process consists of 5 steps. Don't miss any! Any mistake at any step can lead to a brick.

Step 1: Preparing files

Download to your phone (in internal memory or SD- card):

  • πŸ“¦ Firmware (e.g. lineage-18.1-20230510-nightly-tissot-signed.zip).
  • πŸ€– Google Apps (open_gapps-arm-11.0-nano-20230510.zip – choose the nano or pico version).
  • πŸ”‘ Magisk (optional, for root rights: Magisk-v25.2.zip).

Step 2: Cleaning the sections

In TWRP, do:

  1. Wipe β†’ Advanced Wipe.
  2. Check the boxes: Dalvik / ART Cache, System, Data, Cache.
  3. Swipe for confirmation.

⚠️ Warning: If you are installing Android 10+-based firmware and you were previously running Android 9, make sure to change the /data partition file system to F2FS (in TWRP: Wipe β†’ Format Data β†’ F2FS).

Step 3: Install firmware and GApps

  1. Return to the main TWRP menu and click Install.
  2. Select the firmware file and swipe for installation.
  3. Repeat the step for GApps (if you need Google services).
  4. If you install Magisk, add it to the queue after the firmware.

Step 4: First download

After installation:

  1. Press Reboot System.
  2. The first download will take 5-15 minutes – do not interrupt the process!
  3. If the phone has been stuck on the logo for more than 20 minutes, go back to TWRP and repeat the steps (the firmware may not be compatible with your bootloader version).

πŸ’‘

If you don't have a network after the firmware (IMEI is gone), go back to TWRP and run the modem.img file from stock firmware. This is a common problem when switching from MIUI to Android One or custom firmware.

Typical errors and their solution

Even with the correct instructions, there can be problems, and here are the most common ways to correct them:

Error 1: Error 7 in TWRP

Reason: The firmware is not compatible with the current version of Android or the device model.

Decision:

  • Check that you downloaded the firmware for Mi A1 (codename - tissot).
  • If you are switching from Android 8 to Android 11, install the middle firmware (such as Android 9) first.
  • Open the updater-script file in the firmware archive and delete the line with the model verification (if you are sure of compatibility).

Error 2: Phone not turned on (black screen)

Reasons:

  • Improperly sewn boot.img.
  • Damaged section of EFS (responsible for IMEI)
  • Failure to format /data.

Decision:

  1. Try booting up to Fastboot (Loudness Down + Power) and running the stock firmware through the Mi Flash Tool.
  2. If it doesn’t work, check the EFS with the Xiaomi EFS Tools tool.

Error 3: No network (IMEI missing)

Cause: Damage to the modem or EFS partition when running firmware.

Decision:

  • Return to TWRP and swipe modem.img from stock firmware.
  • If IMEI is reset on 0, restore it using the QCN- file (backup required).
How to make an IMEI backup before firmware?
Use the Chamelephon application (root required) or the command in ADB: adb shell su dd if=/dev/block/bootdevice/by-name/modemst1 of=/sdcard/modemst1.img dd if=/dev/block/bootdevice/by-name/modemst2 of=/sdcard/modemst2.img dd if=/dev/block/bootdevice/by-name/fsg of=/sdcard/fsg.img Copy the resulting files to the PC. Use similar if-to-of commands to recover.

7. rollback to stock firmware and locking the loader

If custom firmware is unstable or you plan to sell your phone, go back to the stockware.

Step 1: Download the official firmware

Select the version on the Xiaomi or Xiaomi Firmware Updater website. For Mi A1, the following are relevant:

  • Android One (Pure Android) – if you want the original system.
  • MIUI Global Stable – if you need Xiaomi features (themes, dual applications).

Step 2: Fastboot through the Fastboot

Use the Mi Flash Tool (instruction in Section 2). Select Clean all and lock mode to:

  • Return the stock recap.
  • Lock the loader (important for security).
  • Remove all traces of custom software.

Step 3: System inspection

After the firmware:

  1. Restart your phone and wait for the first setup.
  2. Check the IMEI in Settings β†’ About Phone β†’ Status.
  3. Update the system via OTA if updates are available.

⚠️ Warning: If you block the bootloader on custom firmware (not stock), the phone won't turn on. First, go back to the official software!

FAQ: Frequent questions about the firmware Xiaomi Mi A1

Can I flash the Mi A1 without unlocking the bootloader?
No. Installing custom firmware or TWRP requires an unlocked bootloader, except for official updates via OTA or Mi Flash Tool (but only for stockware).
What is the safest way to make a newbie?
Use the Mi Flash Tool with official firmware in Clean all mode. This method is minimally risky and does not require manual intervention in partitions.
Why is the camera not working after LineageOS?
The dual Mi A1 module requires special drivers. Install the Camera2API patch or run alternative software like GCam with a config for tissot.
Can I return the warranty after unlocking the bootloader?
No. Unlocking the bootloader will void Xiaomi’s warranty. However, if you return the stock firmware and lock the bootloader, the phone looks like new (but the service center can check the bootloader status through Fastboot).
How to upgrade TWRP to Mi A1?
Download the new version of.img and run it through Fastboot: fastboot flash recovery twrp_new.img fastboot reboot recovery Do not update the TWRP through the Recovery itself - this can cause a failure!