[GUIDE][Linux] Flashing Xiaomi .tgz

Search This thread

guglicap

Senior Member
Apr 1, 2017
185
45
OnePlus 6
Hello everyone,
I recently had to flash a stock firmware file from Xiaomi (.tgz) and being primarily a Linux user I was quite disappointed by the fact that the company only provides a flashing tool for Windows.
Either way, I booted into Windows and flashed it. I had a look at the logs later and apparently their flash tool is just a front-end to fastboot, and looking at their firmware archives I noticed there were some .sh files in there, and guess what, they're scripts which do the exact same things their Windows scripts do! So I decided to try to use them to flash the firmware on Linux and, sure enough, after ~10 minutes the device was successfully flashed.

Here's what I did, as always I don't take responsibility for bricked devices, try this at your own risk:

1. unpack the archive
Code:
 tar -xf <archive_name>.tgz

2. cd to the archive directory

3. grant run permissions
Code:
 chmod +x flash_all.sh
(in my case I was interested in flash_all.sh, I think you can follow the exact same procedure with whichever script you want, though I haven't tested it)

4. get your device id
Code:
 fastboot devices
you'll get something like this
Code:
List of devices attached
d82c2d3	fastboot
you're interested in the first column, so in my case d82c2d3

5. run the script
Code:
 ./flash_all -s <device_id>

at this point the flashing process should start and if everything went good your phone should reboot in a few minutes.
You might need to prepend the commands in point 4 and 5 with sudo.

Also, I don't know if every firmware archive has these .sh files, but it would seem logical. By the way, let me know if this is common knowledge and my googling just sucks as I couldn't find anything related to it...
 

typos1

Senior Member
Apr 3, 2007
9,539
1,755
UK
Just tried it on my Mi 10 Pro and it doesnt work says device is locked just like it does if I try and flash using fastboot.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Hello everyone,
    I recently had to flash a stock firmware file from Xiaomi (.tgz) and being primarily a Linux user I was quite disappointed by the fact that the company only provides a flashing tool for Windows.
    Either way, I booted into Windows and flashed it. I had a look at the logs later and apparently their flash tool is just a front-end to fastboot, and looking at their firmware archives I noticed there were some .sh files in there, and guess what, they're scripts which do the exact same things their Windows scripts do! So I decided to try to use them to flash the firmware on Linux and, sure enough, after ~10 minutes the device was successfully flashed.

    Here's what I did, as always I don't take responsibility for bricked devices, try this at your own risk:

    1. unpack the archive
    Code:
     tar -xf <archive_name>.tgz

    2. cd to the archive directory

    3. grant run permissions
    Code:
     chmod +x flash_all.sh
    (in my case I was interested in flash_all.sh, I think you can follow the exact same procedure with whichever script you want, though I haven't tested it)

    4. get your device id
    Code:
     fastboot devices
    you'll get something like this
    Code:
    List of devices attached
    d82c2d3	fastboot
    you're interested in the first column, so in my case d82c2d3

    5. run the script
    Code:
     ./flash_all -s <device_id>

    at this point the flashing process should start and if everything went good your phone should reboot in a few minutes.
    You might need to prepend the commands in point 4 and 5 with sudo.

    Also, I don't know if every firmware archive has these .sh files, but it would seem logical. By the way, let me know if this is common knowledge and my googling just sucks as I couldn't find anything related to it...