This thread is a fantastic summary of how to modify your phone with Linux, thank you.
I have updated some parts in a post below.
Originally Posted by
vocx
I decided to reformat and rewrite some parts of the guide from the beginning of this thread.
Since this thread may come up in future searches on Heimdall on Linux, I want to point out a problem that is encountered with many Samsung phones as of 2016.
As seen in other threads on the internet (2, 3, 4), some people report the error
Code:
ERROR: Failed to receive handshake response. Result: -7
ERROR: Protocol initialisation failed!
and are unable to transfer any custom recovery (TWRP, CWM), or complete images (CyanogenMod) to their devices. Not even printing the PIT (partition index table) information works.
To solve this issue the threads commonly propose two solutions
- Installing the latest Heimdall, and
- Making sure the phone is not recognized as a modem by "udev"
For the first solution they recommend installing developer tools such as
Code:
sudo apt-get install build-essential cmake zlib1g-dev qt5-default libusb-1.0-0-dev libgl1-mesa-glx libgl1-mesa-dev
and compiling Heimdall in your own system. The program "heimdall" has existed since 2012 at least, but it seems the source code has not changed much since 2014, when v1.4.1 was released. You could follow the Github page for further development.
Compiling should be a matter of downloading the project folder and then
Code:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
For the second solution, they suggest editing a file
Code:
sudo nano /etc/udev/rules.d/79-samsung.rules
and adding the following lines
Code:
SUSBSYSTEM=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}="685d", MODE="0666", GROUP="plugdev"
SUSBSYSTEM=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}="685d", ENV{ID_MM_DEVICE_IGNORE}="1"
The first line identifies a connected USB device by the vendor ID "04e8" (corresponding to Samsung), product ID "685d" (corresponding to Galaxy SII, and other similar phones), sets the mode to "0666", meaning read and write access for the owner, group and others, and sets the group to "plugdev". This may help with reading and writing to the device.
The second line again identifies the vendor and product, and sets a property to "1", to avoid recognizing the device as a modem. This may be helpful if the kernel messages given by "dmesg" show something like this
Code:
[25117.873244] cdc_acm 2-1.3:1.0: This device cannot do calls on its own. It is not a modem.
Otherwise only the first line may be necessary.
After saving that file you should restart the "udev" service, or just restart the computer, for the changes to take place
Code:
sudo service udev restart
The specific vendor and product number can be seen in the output 04e8:6860 of the "lsusb" command, and in the kernel messages obtained from "dmesg"
Code:
Bus 002 Device 022: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)
Code:
[29199.511138] usb 2-1: new high-speed USB device number 22 using xhci_hcd
[29199.640254] usb 2-1: New USB device found, idVendor=04e8, idProduct=6860
[29199.640257] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[29199.640259] usb 2-1: Product: SAMSUNG_Android
[29199.640260] usb 2-1: Manufacturer: SAMSUNG
[29199.640262] usb 2-1: SerialNumber: eea0c257
Despite performing these steps, it seems this is not a solution for everybody. For many people Heimdall simply won't connect to the phone when it's in download mode.
This seems to be a problem mostly with phones based on the Qualcomm Snapdragon (S4 series) MSM8960 system on chip, as seen from the kernel messages. This affects many S and A models, and possibly other phones.
Code:
[25117.780287] usb 2-1.3: new high-speed USB device number 15 using ehci-pci
[25117.872818] usb 2-1.3: New USB device found, idVendor=04e8, idProduct=685d
[25117.872823] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[25117.872827] usb 2-1.3: Product: MSM8960
[25117.872829] usb 2-1.3: Manufacturer: Sasmsung
[25117.873244] cdc_acm 2-1.3:1.0: This device cannot do calls on its own. It is not a modem.
[25117.873313] cdc_acm 2-1.3:1.0: ttyACM0: USB ACM device
In my case, I couldn't make it work in Linux, so I had to borrow a Windows 10 computer to flash the custom recovery image using the Windows-only Odin program, as is described in instructions found elsewhere.
Remember that programs in Linux use underlying system libraries that are different from those in Windows. In particular, this may not be a problem with Heimdall, but with the underlying "libusb" library, on which Heimdall depends.