How To Unbrick MTK Device In Linux


I used a Micromax Unite 2 (A106), a MediaTek MTK6582 model. It was very popular in India around 2013.
At 2016, the device got old and I wanted to move from the stock Android Kitkat 4.4.2. So I flashed some ROM on it, but for some erroneous reason, the device got bricked. Not just any regular bricked which you can fix from the recovery – the device somehow managed to wipe out /system, /data, /cache and even recovery. It had nothing but the boot-loader. Hence it was stuck to the boot-screen forever (2-3 hrs until I plugged off the battery). It wasn’t even charging.
Moreover, I tried to install SP Flash-tool on Linux and I didn’t knew the process, and so I chose to format the whole device except boot-loader. Seeing nothing on the screen, I even interrupted that process. Even the Recovery mode Key combination did not work. My phone was beyond “just bricked”. I had only two option – Either I take it to the service centre and spend thousands as the warranty already expired in 2015, and they would definitely ask a lot of money as they would be servicing a device they don’t have any warranty for; or I could do a clean flash any ROM and build up from there. But all the tutorials available on the internet is about using Flash-Tool on Windows. I couldn’t afford a new phone and I didn’t have Windows. I had to find a way.
After days of studies, I found few ways to use the Flash-Tool on Linux, none of which worked. Only until I combined the methods and improvised. I found a detailed guide on XDA developers which says how to install the SP Flash-Tool on Linux. I followed that and every time it presented me with a “BROM ERROR:S_COM_PORT_OPEN Fail(1013)” Error. I found another tutorial but it was neither about a MTK device nor it worked with the current Flash-Tool.
So I had to combine them and I come up with a way which worked like magic!

So let’s get started.


  1. Ubuntu 16.04.1 (64bit) or higher (or Any other distro).
  2. Sp Flash-Tool v5.1640 (Linux, 64bit) or higher. (
    Flashable ROM. (Any ROM will do). Kitkat is better as it is more stable than Lollipop.
  3. Tune up some music! Time for Action!


To avoid entering wrong commands, copy-paste from here.

  • 1. Boot up a Live version of *Ubuntu 16.04.1 64bit. Yes, that’s right! We will do nothing to mess up our original system installation. We will do nothing on an installed Ubuntu.
  • 2. Open System Settings> Software Sources & Updates> Ubuntu Softwares.
    Tick all the sources (main, universe, restricted and multiverse).
    Close window.
    Hit Ctrl+ALt+T and enter the following command and press Enter.
sudo apt update
  • 3. Wait until it updates the repository. Once done, enter:
sudo apt install default-jdk android-tools-adb android-tools-fastboot lib32ncurses5 lib32z1 libusb-dev
  • 4. After installation, change the downloaded zip file of the SP Flash-Tool to something simple like and move it to the Home folder.
  • 5. Unzip the Sp Flash-Tool in Home directory. Remember, in Live-mode, your username is ubuntu and password is blank.
unzip ~/
  • 6. Rename the extracted folder something simple similarly. I named it flashtool. You can make it even smaller like one letter.
  • 7. Navigate to the flashtool folder:
cd ~/flashtool
  • 8. Make two scripts executable:
chmod +x flash_tool
chmod +x

If you don’t want to run the scripts as root, read on Step 9. Otherwise, jump to Step 10

  • 9. According to a XDA-Deveoper’s tutorial, now you should add ubuntu (the Live user) in the usergroup dialout to avoid running the script as root, but that is not needed at all if you are cautious.
    I don’t know the consequences if you do that because I did not perform those tasks. So be sure what you are doing. If you still want to know – here is how:
sudo adduser ubuntu dialout
newgrp – dialout
For Arch:
gpasswd -a username uucp
newgrp – uucp

Moving on.

  • 10. We need to add some rules and permissions for the USB. Open a new terminal window without closing the old one.
sudo gedit /etc/udev/rules.d/80-persistent-usb.rules
SUBSYSTEM=="usb", ACTION=="add", SYSFS{idVendor}=="0e8d", SYSFS{idProduct}=="*", MODE="0777"
0e8d is the Vendor ID for MTK devices. And mode 0777 means it should be readable, accessible and writable by anyone (rwxrwxrwx).  
Here is a full list:
  • 11. Save and enter:
sudo service udev restart
sudo gedit /etc/udev/rules.d/20-mm-blacklist-mtk.rules
ATTRS{idVendor}=="0e8d", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="6000", ENV{ID_MM_DEVICE_IGNORE}="1"
  • Save and enter:
sudo service udev restart
  • 12. Back to the old terminal window, without leaving the flashtool directory:
sudo su

(It won’t prompt for a password, since you are using Live usb.)

  • 13. The Flash-Tool will run.
  • 14. Click “Load scatter file” under the Download tab and select the appropriate scatter file found in your Custom/Stock ROM’s directory.
  • 15. It will load the rest of the files itself. The default mode is “Download Only”.
  • 16. After this part, I connected my phone (switch off, take battery off for a minute and then insert again but don’t turn on) and it presented me the same old “BROM ERROR:S_COM_PORT_OPEN Fail(1013)” error. Without being disheartened, I chose the option from the drop down list “Firmware upgrade” and hit Download button. Connect your phone via USB cable and voila!


  • 17. The progress bar will show red bar, and then puprle (very fast), after that green bar (format progress) and then finally you will see a yellow bar progressing called “Downloading *%”. Once done 100%, a tiny window with a green circle will appear with a white tick on it. Your flashing was succesful.
  • 18. Close the green-tick window and disconnect your phone from the computer. Boot it up with the power button. The first boot takes some time like 5-10 minutes depending on the ROM you flashed.
  • 19. Keep faith, breath and your phone will boot into your newly flashed ROM in no time.
  • 20. Cheers!


In my case, I flashed a Lollipop ROM. The terrible 5.0 version. Full of bugs and ridiculous. I had to root it with kingroot, flash Lollipop recovery (From my experience: Other than, Philz Recovery for Lollipop, no other recovery works in lollipop).
But that touch-recovery was supersensitive to touch. I wanted to flash a recovery-flashable Kitkat ROM but ended up the old bootloop delelting the system. So againflashed Lollipop. Flashed Recovery. Flashed Kitkat from recovery. Booted into Kitkat and rooted it with Kingroot. Flashed TWRP for Kitkat with Flashify and then restored the entire system backup (I made a entire system backup by TWRP before my device bricked).
Finally I got back my old phone.


Creative Commons License

How To Unbrick MTK Device In Linux

How to Encrypt and Decrypt Home Directory in Linux Ubuntu after Installation

1. Backup Home Directory:


   “user” is the username of your (main) Home directory. Be sure to change it whenever applicable.   

  • Login to the (main) Home directory which needs to be encrypted
  • Ctrl+ALt+T
sudo apt install ecryptfs-utils cryptsetup
sudo cp -rp /home/user /home/user.backup
  • Create A new User account with admisnistrative rights. System Settings> User Accounts> Unlock> Create New User (+)
    • Account Type: Administrator
    • Full name: TempUser
    • Username: tempuser
  • Create
  • Enable Account
  • Set up a password
  • Automatic Login: On
  • Log out
  • Log in to the temporary account

2. Encrypt (main) Home Folder:

sudo ecryptfs-migrate-home -u user
  • Provide password of temporary account and then the main Home/account password
  • Wait until it shows a dialogue called “Some Important Notes!” and ensures the encryption/migration of Home folder is done
  • Log out and log back in the (main) Home Account
  • Wait until a dialogue pops up which says “Update Information – Record Your Encryption Passphrase”.
  • Click Run this action now.
  • A terminal will pop up and and may show nothing but a blank screen with Passphrase written on it. Simple type your password and hit Enter.
  • A long string of passphrase will be displayed. Copy and save it somewhere safe.
  • Visit the passphrase anytime by running –

3. Encrypt SWAP partition:

sudo ecryptfs-setup-swap
  • Type Shift+Y and hit Enter.
  • Remove Auto-generated backup
sudo rm -rf /home/user.random numbers

4. Decrypt Home Folder:

  • Disable Encrypted SWAP:
    *” addresses the correct partition number according to the system.
sudo swapoff -a
sudo cryptsetup remove /dev/ mapper/cryptswap1
sudo vim /et/crypttab
  • Remove the /dev/sda* line. For example, /dev/sda2
sudo /sbin/mkswap /dev/sda*
sudo swapon /dev/sda*
sudo vim /etc/fstab
  • Replace /dev/mapper/cryptswap1 with /dev/sda*

5. Remove Home Encryption:

  • Log out and log in to the temporary account.
  • Ctrl+Alt+T
sudo rm -rf /home/user
sudo rm -rf /home/user.backup/.ecryptfs
sudo apt remove encryptfs-utils libecryptfs0
sudo mv /home/user.backup /home/user
  • Log out of temporary account and Log in to the main account.
  • Remove the temporary account same way as it was created.


Helper Links:

Creative Commons License

How to Encrypt and Decrypt Home Directory in Linux Ubuntu after Installation