User Tools

Site Tools


doc:appunti:android:sp_flash_tool

SP Flash Tool on GNU/Linux

SP flash tool is an application which mainly helps you to flash stock ROMs, custom ROMs, custom recovery, etc. on Android devices based on the MTK chipsets. It can also fix some extreme cases of bricked devices, occured during firmware updates, etc. SmartPhone FlashTool is working with MediaTek Android smartphones (MTK based).

You can download the executable from the spflashtools.com. :!: WARNING: The site is not officially managed by MediaTek, many other sites exist offering the same download (e.g. spflashtool.com), but none seems to be the official one.

The software is proprietary and closed source, it is distributed for two platforms: MS-Windows and GNU/Linux.

The USB Abstract Control Model

An MTK Android smartphone, when powered-off, exposes and USB device once connected to the USB port of a GNU/Linux host:

usb 2-2.2: new full-speed USB device number 5 using ehci-pci
usb 2-2.2: New USB device found, idVendor=0e8d, idProduct=0003, bcdDevice= 1.00
usb 2-2.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
cdc_acm 2-2.2:1.0: ttyACM0: USB ACM device
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver option
usbserial: USB Serial support registered for GSM modem (1-port)

The normal workflow with SP Flash Tool is to initiate the required operation (Download or Readback) with the USB cable disconnected. Then you will connect the USB port and SP Flash Tool will detect the device, performing the operation.

The Scatter File

To perform upload (flashing) and readback (backup) of partitions using SP Flash Tool, you need a scatter file specifically written for your device. See this paragrah for more info: Android paritions - The scatter file.

MTK Droid Tools

The most common way to create a scatter file was to use MTK Droid Tools, a proprietary, MS-Windows only, software. It seems that that software does not longer work with Android 5.0 Lollipop and later. The latest MTK Droid Tools is version 2.5.3, which is from 2014.

It seems that the program runs over the ADB (Android Debug Bridge), so it requires that the phone is started and running the operating system, and that it has the USB debugging enabled. Using the ADB bridge, it should do not require the MTK VCOM drivers, but it requires the ADB Windows Drivers. It seems also that MTK Droid Tool requires root access on the phone to achieve all its functions.

MTK Droid Tools does indeed runs in GNU/Linux using the Wine compatibility software, but it cannot access the USB port as it requires, so it is useless. Some people reported to be able to use the program under a full GNU/Linux virtualization environment (like VirtualBox).

The Miracle Box

It seems that the preferred tool to read/write firmware on moderm smartphones is the Miracle Box. It is a combination of hardware and software, but it seems that there is also a software-only solution, at least accordingly to this post: Miracle Box / Thunder setup latest versions and drivers. Look at this post to get an idea on how to backup a firmware using the Miracle Box: How to use Miracle Box to backup Mediatek (MTK) firmware.

Find the scatter file on the net

Another approach to obtain the scatter file for your Android device, is to search the internet for a stock ROM or a custom ROM for your exact model. These ROMs are generally shared as archives containing the various images files and the scatter file, usable to flash the images back to the phone (using SP Flash Tool). However, you should be very careful before using a scatter file to flash your device; you should check at least that the output of cat /proc/partitions to verify that starting address and size does match. Read this page: Inspecting partitions on the command line.

Download

Download is the operation of flashing the memory of the device with the content of a file that you have on the PC. You must provide the scatter file and the program looks in the same directory for all the image files it refers.

Download only You must choose this option if you flash selective partitions e.g. recovery only.
Firmware Upgrade This will try to preserve your apps, data and media while flashing the firmware.
Format All + Download You must provide all partitions to restore and all checkboxes must be checked. If you try to unselect a single partition, you won't be able to do format before flashing.

Problem: Trying to sync with the target...

You may experience a problem on GNU/Linux: attempting a Download or Readback operation, you see the a red bar on the bottom of the screen, but the operation does not actually start. The blue progress bar does not start at all, or it hangs after a few seconds. On the console where you started the program you can read the following messages:

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...

If you wait enough time, an error is displayed in a dialog box:

ERROR : S_FT_DA_NO_RESPONSE (4001)
DA didn't send response data to FlashTool!

Check if you have the modemmanager package installed; in that case it may be interfering with the /dev/ttyACM0 device, preventing SP Flash Tool to operate correctly. The interfering process is spawned by D-Bus, so the quickest fix is to remove the package alltogether. On a Debian distribution you can just execute:

dpkg --purge modemmanager

The ModemManager is generally required when you want to use dialup modems (internet keys, mobile phones, etc.) connected via the USB port.

Alternatively you can just stop or even disable (preventing future start) the service:

systemctl stop ModemManager.service
systemctl disable ModemManager.service
systemctl status ModemManager.service

Problem: PMT changed for the ROM

PMT changed for the ROM; it must be downloaded.
Please select "Format All + Download" scene and try again

The problem can arise if you try to download (flash) a partition using a scatter file which differs from the one used during readback.

Web References

doc/appunti/android/sp_flash_tool.txt · Last modified: 2023/08/27 11:56 by niccolo