[TUTORIAL]How to setup SP_Flash_Tool_Linux (MTK/MediaTek Soc)

Search This thread

Fstop

Senior Member
Apr 18, 2015
122
12
1June2018
Created the Black List file & added the 2 lines suggested.
Changed from Download Only to Uprgrade Firmware
Option: With the Battery in -
Phone Power Off Connect USB After Hitting Download Button
But then the Battery comes on within a minute and I get the "Status Change Error" battery icon comes on changing this Devices Status.
 
Last edited:

Fstop

Senior Member
Apr 18, 2015
122
12
@ady, Didn't get that far on Ubuntu, do you have this configuration file /80-persistent-usb.rules?
Ran Live Ubuntu 16.04.1 & when I got to gedit /etc/udev/rules.d/ there is no /80-persistent-usb.rules. yes I did sudo apt installed libusb-dev? Error: "The file or directory doesn't exist".
June24: update, used vi instead of gedit which opens a blank: /etc/udev/rules.d/80-persistent-usb.rules because 80-persistent-usb.rules doesn't exist. Copy and pasted line:
Code:
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0e8d", ATTR{idProduct}=="*"
- into body of this empty file not yet created.
Code:
 :wq command
- will save the line & create this file: /etc/udev/rules.d/80-persistent-usb.rules
Same thing with this file: /etc/udev/rules.d/20-mm-blacklist-mtk.rules - this did not solve the changing status problem - that keeps SP_Flash Tool from working.

Created a persistent USB Ubuntu14.04.5-64 followed the excellent tutorial again. Tried different options: 1) with 2)without & 3) Auto detect battery. I tried the button + & - while connecting the usb cable to PC.

Finally today I was able to engage Doogee Mix with
SP_Flash Tool used: + volume button while connecting USB cable and holding it till the Red Line Started-
in combination with No. 3. Auto detect battery - option, and the Upgrade Option.

Made sure device power was Off
Started Download
Then connected the USB Cable to PC while holding the + Volume carefully.
Took me a month+ to restore Doogee Mix 6+64GB that has no LTE for USA users.
Thanks @ Miss Montage for telling me what wasn't wrong in my output and all the tutorials she mentioned plus all the ones I got bits and pieces of info to get the device unbricked.
 
Last edited:
  • Like
Reactions: Miss Montage

kenshinta

Senior Member
Dec 13, 2004
378
62
Redmi Note 10S
This works only on Linux 64-bit
snip

In order to avoid running the flash_tool as root user, you need to add a standard user to the usergroup "dialout" (thanks to @egalus for this bit!)
Code:
sudo adduser username dialout
For Arch Linux:
Code:
gpasswd -a username uucp

and activate the membership immediately
Code:
newgrp - dialout
(Arch Linux):
Code:
newgrp - uucp

snip

Are there extra steps for ubuntu 18.04? Done everything right except for non-root running.
 

militiaOfDeath

Senior Member
Dec 14, 2012
88
10
Has anyone made this work from terminal in Ubuntu 18.04? If I try ./flash_tool or ./flash_tool.sh I only get the message "flash_tool: cannot connect to X server", no matter if running as root or not. If I double click icon in file explorer it starts as expected, but then I always get an error about not being able to open the port when trying e.g. a read back.

Update; A reboot fixed the issue, so far works like expected.
 
Last edited:
  • Like
Reactions: Miss Montage

zvolsky

New member
Feb 6, 2017
2
1
Java and kernel versions

I have had serious problems with Download and especially with Format in ./flash_tool on my Debian Testing machine.
I received many errors and googling them leads to no results or to the misleading results.
The solution was:
- use Java 8 instead of the newer one (download/extract from Oracle, export PATH=...../java8/bin:$PATH, check the version: java -version)
If errors will not disapear with J8, then try older kernel.
My problems were on current 4.17 version, so do something like:
apt install linux-image-4.9.0-7-amd64 linux-headers-4.9.0-7-amd64 ; update-grub
and maybe boot with Shift. I don't know how to do it exactly, I have used the 2-nd machine with 4.9.0-5.

PS: MT6589 is supported in Flash Tool 5.1724 and older.
 
  • Like
Reactions: Miss Montage

MK404

New member
Feb 26, 2017
1
0
how to fix ?

[email protected]:~$ sudo gedit /etc/udev/rules.d/20-mm-blacklist-mtk.rules
[sudo] password for mskopi:

** (gedit:6189): WARNING **: 13:43:32.358: Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported

** (gedit:6189): WARNING **: 13:43:32.359: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported

** (gedit:6189): WARNING **: 13:55:43.540: Set document metadata failed: Setting attribute metadata::gedit-position not supported
 

mayur badam

Member
Mar 27, 2017
17
1
How to install this on Ubuntu 32 bit. This tutorial doesn't work for 32bit. Are there any sites for tutorial on installing on 32-bit Ubuntu 18.04
 

Bomassy

New member
Feb 17, 2015
2
0
Hello,
I get always the Error 2004.
./flash_toolQObject::moveToThread: Cannot move objects with a parent
support_dl_cert_to_storage: 0
Connecting to BROM...
Scanning USB port...
Search usb, timeout set as 3600000 ms
[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1

[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0

[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/tty/ttyACM0

vid is 0e8d

device vid = 0e8d

pid is 0003

device pid = 0003

com portName is: /dev/ttyACM0

Total wait time = -1542300868.000000
USB port is obtained. path name(/dev/ttyACM0), port name(/dev/ttyACM0)
USB port detected: /dev/ttyACM0
BROM connected
Downloading & Connecting to DA...
connect DA end stage: 2, enable DRAM in 1st DA: 0
COM port is open. Trying to sync with the target...
Failed to Connect DA: S_BROM_DOWNLOAD_DA_FAIL(2004)
Disconnect!
BROM Exception! ( ERROR : S_BROM_DOWNLOAD_DA_FAIL (2004)

[H/W] Fail to download DA to baseband chip's internal SRAM!
[HINT]:
1. There's an cable communication problem between FlashTool and BootROM.
2. Target might be shutdown unexpectedly or target lost power supply.
[ACTION]
1. Try again.
2. Proceed H/W checking in download cable and target side com port.
3. Monitor if power-drop occured in target side.)((ConnectDA,../../../flashtool/Conn/Connection.cpp,146))


Can anyone help me please?
 

gerstavros

Senior Member
May 30, 2012
768
117
Athens
Hello,
I get always the Error 2004.
./flash_toolQObject::moveToThread: Cannot move objects with a parent
support_dl_cert_to_storage: 0
Connecting to BROM...
Scanning USB port...
Search usb, timeout set as 3600000 ms
[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1

[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0

[email protected]/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/tty/ttyACM0

vid is 0e8d

device vid = 0e8d

pid is 0003

device pid = 0003

com portName is: /dev/ttyACM0

Total wait time = -1542300868.000000
USB port is obtained. path name(/dev/ttyACM0), port name(/dev/ttyACM0)
USB port detected: /dev/ttyACM0
BROM connected
Downloading & Connecting to DA...
connect DA end stage: 2, enable DRAM in 1st DA: 0
COM port is open. Trying to sync with the target...
Failed to Connect DA: S_BROM_DOWNLOAD_DA_FAIL(2004)
Disconnect!
BROM Exception! ( ERROR : S_BROM_DOWNLOAD_DA_FAIL (2004)

[H/W] Fail to download DA to baseband chip's internal SRAM!
[HINT]:
1. There's an cable communication problem between FlashTool and BootROM.
2. Target might be shutdown unexpectedly or target lost power supply.
[ACTION]
1. Try again.
2. Proceed H/W checking in download cable and target side com port.
3. Monitor if power-drop occured in target side.)((ConnectDA,../../../flashtool/Conn/Connection.cpp,146))


Can anyone help me please?
This is normally a problem of nand flash. But, did you run as root?
 

lil chickenz

Member
Nov 29, 2017
49
6
I'm not sure what's wrong but here's the end of my log:

Code:
11/20/2018 21:03:41.940 FlashTool[22708][22416][D]: BromBootArg::cb_download_da_init(): Download DA now...(..\..\flashtool\Arg\BootRomArg.cpp,201)
11/20/2018 21:03:41.985 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The sent_bytes is 32768(..\..\flashtool\Arg\BootRomArg.cpp,222)
11/20/2018 21:03:41.985 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The total_bytes is 97000(..\..\flashtool\Arg\BootRomArg.cpp,223)
11/20/2018 21:03:42.006 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The sent_bytes is 65536(..\..\flashtool\Arg\BootRomArg.cpp,222)
11/20/2018 21:03:42.006 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The total_bytes is 97000(..\..\flashtool\Arg\BootRomArg.cpp,223)
11/20/2018 21:03:42.027 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): 100% of DA has been sent.(..\..\flashtool\Arg\BootRomArg.cpp,218)
11/20/2018 21:03:42.034 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The sent_bytes is 97000(..\..\flashtool\Arg\BootRomArg.cpp,222)
11/20/2018 21:03:42.034 FlashTool[22708][22416][D]: BromBootArg::cb_download_da(): The total_bytes is 97000(..\..\flashtool\Arg\BootRomArg.cpp,223)
11/20/2018 21:03:42.119 FlashTool[22708][22416][D]: APCore::Connection::ConnectDA(): Failed to Connect DA: S_BROM_DOWNLOAD_DA_FAIL(..\..\flashtool\Conn\Connection.cpp,130)
11/20/2018 21:03:42.144 FlashTool[22708][22416][D]: APCore::Connection::Disconnect(): Disconnect!(..\..\flashtool\Conn\Connection.cpp,140)
11/20/2018 21:03:52.256 FlashTool[22708][22416][D]: APCore::DAHandle::~DAHandle(): dtor of DAHandle(..\..\flashtool\Resource\Handle\DAHandle.cpp,25)
11/20/2018 21:03:52.266 FlashTool[22708][22416][D]: APCore::DLHandle::~DLHandle(): dtor of DLHandle(..\..\flashtool\Resource\Handle\DLHandle.cpp,23)
11/20/2018 21:03:52.266 FlashTool[22708][22416][D]: APCore::RBHandle::~RBHandle(): dtor of RBHandle(..\..\flashtool\Resource\Handle\RBHandle.cpp,19)
11/20/2018 21:03:52.267 FlashTool[22708][22416][D]: APCore::RBHandle::~RBHandle(): RB_ClearAll(0)(..\..\flashtool\Resource\Handle\RBHandle.cpp,21)
11/20/2018 21:03:52.267 FlashTool[22708][22416][D]: APCore::RBHandle::~RBHandle(): RB_Destroy(0)(..\..\flashtool\Resource\Handle\RBHandle.cpp,23)
11/20/2018 21:03:52.267 FlashTool[22708][22416][D]: APCore::ScretHandle::~ScretHandle(): dtor of ScretHandle(..\..\flashtool\Resource\Handle\ScretHandle.cpp,23)
11/20/2018 21:03:52.268 FlashTool[22708][22416][D]: APCore::AuthHandle::~AuthHandle(): dtor of auth handle.(..\..\flashtool\Resource\Handle\AuthHandle.cpp,22)
11/20/2018 21:03:52.268 FlashTool[22708][22416][D]: main(): Uncaught BaseException in main():  BROM ERROR : S_BROM_DOWNLOAD_DA_FAIL (0x7D4)

[H/W] Fail to download DA to baseband chip's internal SRAM! 
[HINT]:
1. There's an cable communication problem between FlashTool and BootROM.

2. Target might be shutdown unexpectedly or target lost power supply.

[ACTION]

1. Try again.

2. Proceed H/W checking in download cable and target side com port.

3. Monitor if power-drop occured in target side.
(APCore::Connection::ConnectDA,..\..\flashtool\Conn\Connection.cpp,131)(..\..\flashtool\main.cpp,101)

Logger deinited.

Something I've noticed is that the failure seems to happen just as the phone boots up shortly after the tool starts
 

Goksu

New member
libpng

I have been trying to port a solution to the libpng12 error here but have not been able to due to having less than 10 posts. basically do a search for the deb to add to the source file as libpng12 support has been dropped since 16.10 in ubuntu in favor of libpng16.
 

Micchael3345

New member
Feb 28, 2015
1
0
Santiago, Chile
Hi, thanks for you help to install this, i have only one problem and it's that the red bar appears and get stuck there, at the right down corner i can read this "/dev/ttyACM0". i don't know what's happening :S.
 

Ateo1961

New member
Dec 20, 2013
1
0

Ekki12

Member
Jul 30, 2019
20
2
When i try to run ./flash_tool i get "Floating point exception" message (kde neon)

Any suggestion??
 

Top Liked Posts

  • There are no posts matching your filters.
  • 61
    This works only on Linux 64-bit
    DISCLAIMER: It is always risky to flash your mobile device. I do not and will not take any responsibility for bootloops and bricks.
    Please check carefully that the ROM or recovery.img you want to flash is suitable for your specific device and for the sp_flash_tool. The firmware directory should neither contain meta-inf nor system folder, but something_with_a_scatter.txt and a system.img
    Backup your phone before flashing!
    Your phone's battery should be at least half charged (50 percent) before you start this.

    I successfully ran these steps on my UMI Hammer with Linux Ubuntu 14.04 and 16.04. I do not have other devices or Linux derivates and do not plan to buy/install any.

    CREDITS and a zillion thanks to Sergio Rivero for his excellent tutorial on mibqyyo.com!!!!
    Also many thanks to N2K1 for giving me some more background information!

    So here we go:

    Step 1:
    If you haven't done so before, install the Linux generic usb-drivers package:
    Code:
    sudo apt-get update
    sudo apt install libusb-dev
    Download SP Flash Tool Linux (latest version): http://mtk2000.ucoz.ru/load/soft/soft_mtk/sp_flash_tool/5-1-0-14 (Password to extract currently is mtk2000v3)
    or here https://androidmtk.com/smart-phone-flash-tool
    In case you haven't done before, install unrar:
    Code:
    sudo apt install unrar
    Extract the downloaded file -> graphic file manager (e.g. Nautilus): double-click and extract. Terminal:
    Code:
    unrar x path_to_file
    (from now on: please adapt paths to your own settings)
    Move the new folder „sp_flash_tool“ to a directory of your choice.
    Code:
    mv /home/username/Downloads/sp_flash_tool /home/username/...
    You might also need to install libqtwebkit4 (it just happened to me on Linux Ubuntu 16.04):
    Code:
    sudo apt install libqtwebkit4

    [Only For Ubuntu 16.10 and newer]
    Run
    Code:
    dpkg -x libpng12-0_1.2.54-1ubuntu1.1_amd64.deb /tmp/libpng2
    cp /tmp/libpng2/lib/x86_64-linux-gnu/libpng12.so.0.54.0 lib
    cd lib
    ln -s libpng12.so.0.54.0 libpng12.so.0
    These libraries are still required for the flash tool but have been removed from new Ubuntu versions.
    Thanks @hanalinqu, @z3r0c00l_2k https://forum.xda-developers.com/showpost.php?p=73484473&postcount=216 and @opticyclic https://forum.xda-developers.com/showpost.php?p=81543495&postcount=285 for this information!

    Step 2:

    Change into the newly created directory:
    Code:
    cd /sp_flash_tool
    We make one file executable by typing:
    Code:
    chmod +x flash_tool

    In order to avoid running the flash_tool as root user, you need to add a standard user to the usergroup "dialout" (thanks to @egalus for this bit!)
    Code:
    sudo adduser username dialout
    For Arch Linux:
    Code:
    gpasswd -a username uucp

    and activate the membership immediately
    Code:
    newgrp - dialout
    (Arch Linux):
    Code:
    newgrp - uucp

    Step 3:

    Now you can open the tool:

    Code:
    ./flash_tool
    or double-click on the flash_tool icon.
    You can try at this stage if the flash tool connects to your phone:
    In the user interface, choose tab „Download“. Hit "scatter-loading", navigate to a directory with a valid firmware for your device and choose the scatter-file.
    For testing purposes uncheck "name" and check one of the smaller files in the list below (for example "logo")
    Switch off your device. Hit the "Download" button in SP_Flash_Tool and connect your phone to the computer. Some devices require you to take off the battery for about 10 seconds, with others you need to press Vol+ or Vol- while plugging the cable into the phone. Please look up device-specific threads and try out different options.

    If nothing happens at all, open a second terminal, run
    Code:
    dmesg | grep usb
    and look out for a MediaTek entry. If there is none → did you install libusb-dev (Step 1?)
    If the answer is yes, you might need to create a persistent udev rule for the MTK Preloader:
    Code:
    sudo gedit /etc/udev/rules.d/80-persistent-usb.rules
    Add the following line to the file:
    Code:
    SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0e8d", ATTR{idProduct}=="*"
    Save the file and exit.
    Reload the usb-rules:
    Code:
    sudo service udev restart
    Disconnect the usb data cable from the computer and the smartphone. Close the flash tool. Switch on your phone (fastboot mode will do). Repeat the first paragraph of Step 3.

    If the tool connects, within a few seconds a red progress bar will appear. Unfortunately, in my case an error message came along with it:
    S_BROM_CMD_JUMP_DA_FAIL (2035)
    There is a connection, but also one more obstacle to overcome...

    Step 4:
    Now we come to the interesting part, which cost me 2 weeks of (futile) research and frustration. Finally I found Sergio Riveros tutorial on mibqyyo. Thanks to him again and again and again for this priceless piece of information :)
    The “modemmanager” package integrated by default within Linux Ubuntu 14.04 and later is not compatible with the MTK Flash Tool for Linux
    To put it in different words: The modem manager controls port /dev/ttyACM0 and disables the Flash Tool. So we blacklist it for the two MTK vendor IDs the flash tool uses:
    Code:
    sudo gedit /etc/udev/rules.d/20-mm-blacklist-mtk.rules
    You insert these two lines:
    Code:
    ATTRS{idVendor}=="0e8d", ENV{ID_MM_DEVICE_IGNORE}="1"
    ATTRS{idVendor}=="6000", ENV{ID_MM_DEVICE_IGNORE}="1"
    Save the file, exit and restart udev:
    Code:
    sudo service udev restart

    Switch your phone on (fastboot mode will suffice) and off again.

    Step 5:
    Code:
    ./flash_tool
    or double-click on the flash_tool icon.
    Now everything should run smoothly. In case you encounter
    Code:
    BROM ERROR : S_SECURITY_SF_CODE_FORMAT_FORBIDDEN (6012) , MSP ERROE CODE : 0x00
    change the download agent to MTK_AllInOne_DA.bin (screenshot #4)
    There are plenty of tutorials on the web for the further steps.
    Happy flashing! When a green circle with a white checkmark appears, you are done. You can close the flash tool and disconnect your phone. For a clean start with a new ROM boot into recovery and wipe data/factory reset.
    5
    edent; BROM Exception! ( BROM ERROR : S_COM_PORT_OPEN_FAIL (1013) [COM said:
    Failed to open COM port.[/CODE]

    dear edent,

    I had the same as you (error1013)

    I just started flash_tool in root mode (sudo ./flash_tool.sh)
    and it worked...

    arnold
    3
    Please change your tutorial and remove the security risk of executing flash_tool as root.
    As far as I understand the flashing procedure it is just using a serial connection to upload the rom to the mobile device thus it only needs one special right not every user might have:
    The user needs write permission to the MTK usb-device.
    At least for ubuntu it suffices to add the user to the dialout group as groupmembers get access to every modem.
    Maybe logging out and back in again after adding the user to the group is needed.

    I tested this by flashing my Jiayu S3 (which used /dev/ttyACM0) using ubuntu 15.04 and a user who is a member of the dialout group - no problem at all, thus no need for root except for adding the user to the group dialout.

    Never execute anything you download from places like needrom as root user - at least not on a system you need or have data on that you need!
    2
    Well, that's what life's supposed to be - give and take :) You are especially welcome!
    2
    Great post!

    Just wanted to say you saved me HOURS OR DAYS OR WEEKS of time on the modemmanager thing. I have Arch Linux, successfully ported over this tutorial, but I had no idea the modemmanager package was causing the issue. SP Flash Tool was the last frontier for using my Android devices on Linux. Thanks so much!