Skip to content

Instantly share code, notes, and snippets.

@duyfken
Forked from j-jith/miui-fastboot-howto.rst
Last active January 29, 2025 20:23
Show Gist options
  • Save duyfken/574f570f40f813604849bd40d9e1a048 to your computer and use it in GitHub Desktop.
Save duyfken/574f570f40f813604849bd40d9e1a048 to your computer and use it in GitHub Desktop.
How to flash MIUI Fastboot ROM from Linux

How to flash MIUI Fastboot ROM from Linux

  • Download the fastboot ROM suitable for your device from the XM Firmware Updater and extract the downloaded archive
  • Download and extract the official Android SDK Platform Tools or install them using your package manager of choice.
    • If you are using the official platform tools, make sure adb and fastboot (components of platform-tools) are in your path
$ export PATH=path/to/android/sdk/platform-tools:$PATH
  • Connect your device to your computer using a USB cable and enable USB Debugging in your device's settings. Check if your device is detected.
$ adb devices
  • If device is listed, reboot to bootloader
$ adb reboot bootloader
  • Check if your device is detected by fastboot
$ fastboot devices

You may need to use sudo before fastboot if you get a permission denied error

Whichever script you decide to use, make sure that the interpreter is mentioned at the top of the script like

#!/bin/sh

If the above line is missing, add it to the top of the script

  • Make the script executable (I've chosen flash_all.sh)
$ cd path/to/extracted/ROM/archive
$ chmod a+x ./flash_all.sh
  • Run the script
$ ./flash_all.sh
  • You may need to run sudo ./flash_all.sh if you had to use sudo with fastboot
  • Sit back and relax. The script needs no user interaction. After flashing the ROM, the script will reboot your device.
  • Reboot will take quite a bit of time. Don't panic.
@Hyakki09
Copy link

But can I use flash_all_lock.sh if I want to lock bootloader or is this not possible?

Yes, flash_all_lock.sh is used to flash the factory ROM and lock the bootloader. Most people will only use this for warranty returns or as-new re-sale, as if you do that you would have to go through the whole unlock procedure again, including the 15-60 day unlock waiting time.

See Q5 of https://www.mi.com/global/support/faq/details/KA-07238

I see, thanks sir. As you said, my purpose for locking os for warranty claims purposes.

@tokenwizard
Copy link

The link to download the factory images above seems to be dead now? Do we have an updated source that is safe?

@duyfken
Copy link
Author

duyfken commented Jan 29, 2025

The link to download the factory images above seems to be dead now? Do we have an updated source that is safe?

The URL has been updated to https://xmfirmwareupdater.com/

@tokenwizard
Copy link

Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment