#+title: ON MERLIN'S BEARD #+OPTIONS: ^:{} #+AUTHOR: Crystal for my sloth #+OPTIONS: num:nil #+EXPORT_FILE_NAME: ../../../../blog/misc/merlin.html #+HTML_HEAD: #+HTML_HEAD: #+OPTIONS: html-style:nil #+OPTIONS: toc:nil #+HTML_HEAD: #+HTML_LINK_HOME: https://crystal.tilde.institute/ Let's say, hypothetically, you have a *Xiaomi Redmi Note 9* (codenamed *Merlin*), and we would assume that it's broken in a way that it shows the *Xiaomi logo* only then reboots/shuts-down, your first solution would be "Oh let's take it to a repairshop, they would fix it" but why do so when you could fix it at home, alone, with the help of this little guide. * Axioms : We will assume the following things : - You have a Redmi Note 9...or any Redmi, but some steps WILL vary ever so slightly. - The phone at least gives a sign of life, the Xiaomi logo is well enough. - You have a PC, preferably running the second best OS known to mankind, *Linux !!!*. If you are not running Linux, a good start is *Ubuntu* (we will assume the usage of a *Debian*-based distro here, if you use anything other than them, you are probably smart enough to figure this shit yourself) - You have a good USB-C cable. - You have a working brain. * Step Uno : Downloading the required files and the medkits : ** android-tools : #+BEGIN_SRC sh sudo apt update sudo apt install android-tools-adb android-tools-fastboot #+END_SRC ** mtkclient and it's dependencies : *** Dependencies : #+BEGIN_SRC sh sudo apt install python3 git libusb-1.0-0 python3-pip #+END_SRC *** Grab the files : #+BEGIN_SRC shell git clone https://github.com/bkerler/mtkclient cd mtkclient pip3 install . #+END_SRC *** Install rules : #+BEGIN_SRC shell sudo usermod -a -G plugdev $USER sudo usermod -a -G dialout $USER sudo cp mtkclient/Setup/Linux/*.rules /etc/udev/rules.d sudo udevadm control -R #+END_SRC and do *NOT* forget to reboot, otherwise you will face errors. ** Fastboot image : Personally, I prefer to use a custom ROM for these XIMI phones, but since this is a fool-proof guide, we will use the latest *Global* fastboot image, note that the difference between *Global* , *EEA (European Economic Area)* , *Turkish* , *Russian* and *Taiwan* ROMS are little though the Global version is most of the time behind the other ones in terms of updates , but the biggest one comes with the *Chinese* one, it's more polished, runs faster, but is filled with Chinese-only apps, and does not have Google services (which is a huge W for me). But at the end of the day, it's up to you! We will be using this one https://xiaomifirmwareupdater.com/miui/merlin/stable/V13.0.2.0.SJOMIXM/ which is the Global version of miui. Make sure to scroll all the way *Down* and download the one with *Type: Fastboot*, it will be larger in size, but it's the one we need. Use any mirror that you want, and wait patiently for it to download. Once it finishes, extract it to a folder, it's a big archive so it will take time. ** Meanwhile, mtkclient : While waiting for your download to finish, go to your mtkclient folder and run this command: #+BEGIN_SRC shell python mtk_gui #+END_SRC this should bring up the GUI client, if it doesn't, replace *python* with *python3*. Once it's running, make sure your phone is powered-off, and plug the USB-C cable into your PC *While holding both the Up and Down volume buttons* until you see a change in the GUI app. If you notice a red error message on the console which will be running in the background, relaunch using *sudo*. Now explore the app but do *NOT* touch anything with the word *Write* or *Erase*, also the ones with *Read* are useless for you, what is important is looking for the *Unlock bootloader* button, click on it, and wait until it's okay, then remove your phone from the cable. aaaand we shoould be done for this part. ** The Fun Part : Once the fastboot image is downloaded and extracted, go to the folder and look for this file *flash_all_except_storage.sh* this will be the one you would need. *DO NOT EVER EVER EVER, UNDER ANY CASE, TOUCH A FILE THAT HAS THE WORD LOCK IN IT.* Once you located this file, open a terminal there, and give it exec permissions. Or in other words : #+BEGIN_SRC shell chmod +x ./flash_all_except_storage.sh #+END_SRC and now take your phone *again* and now Power it on while holding the *Vol DOWN* button, keep that position until you see a *fastboot* screen, or a Russian robot rewiring the organs of it's victim. Once you see it, plug the phone to the pc, and run #+BEGIN_SRC shell sudo fastboot devices #+END_SRC sudo might not be needed for you, but i dont know why, it never worked for me without sudo (probably the rules step) Once you see your device in there, it means it recognized it, go again to the folder with *flash_all_except_storage* and run it #+BEGIN_SRC shell sudo ./flash_all_except_storage.sh #+END_SRC ** Waiting : This step takes a lot of time, so be sure to let your pc in a place where you don't risk accidentally moving your phone and disconnecting it. DO NOT CLOSE THE TERMINAL, once it's finished, it should reboot automatically and voila !! good as knew, and you might even keep your local files if you provide your password * Edge cases : - If the initial setup (after the reboot) doesn't work, try the flash_all.sh file instead.