Sunday, February 21, 2016

Problems with Heimdall



One of the stranger technical adventures I have been on lately was updating the modem on my Note 3 with Heimdall. A wonderful cross platform flashing utility for Samsung phones. The idea is simple. You put the phone in download buy holding down the power, volume down, and the center button, and the phone boots into download. Next the you issue heidall detect as root. It should look something like this:



~$ sudo heimdall detect
Device detected



OK, cool so I went on to the next step.



~$ sudo heimdall flash –APNHLOS ~/Downloads/CP_N900TUVUFOL1_MODEM/NON-HLOS.bin --MDM ~/Downloads/CP_N900TUVUFOL1_MODEM/modem.bin



This one is the big one because if it messes up you will be install a stock rom to fix it. I got a protocol error the first time.



Initialising protocol...
ERROR: Protocol initialisation failed!
I thought something else a had control of the usb port. Got on the net and started poking around. The answer showed up here. Cool, so I create /etc/udev/rules.d/79-samsung.rules with vi. In the file is one line ATTRS{idVendor}=="04e8", ENV{ID_MM_DEVICE_IGNORE}="1". Close the file, reboot. I run the flash command again and get this:



Downloading device's PIT file...
PIT file download successful.

ERROR: Partition "MDM" does not exist in the specified PIT.
Ending session...
Rebooting device...
Releasing device interface...
Re-attaching kernel driver...


So
what's next you ask. Well since Heimdall looks at the PIT file, we have to too, to know what's going on.



~$ sudo heimdall print-pit --verbose –no-reboot

.

.

.

--- Entry #0 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 1
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 8192
Partition Block Count: 30720
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: APNHLOS
Flash Filename: NON-HLOS.bin
FOTA Filename:


--- Entry #1 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 2
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 38912
Partition Block Count: 117632
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: MODEM
Flash Filename: modem.bin
FOTA Filename:

AH, Ha, The partition call MODEM. It also appears we have a new G3 modem installed and the older G4 uninstalled the phone is still booting, so, Bonus!



~$ sudo heimdall flash --APNHLOS ~/Downloads/CP_N900TUVUFOL1_MODEM/NON-HLOS.bin --MODEM ~/Downloads/CP_N900TUVUFOL1_MODEM/modem.bin

And this kids, is what the magic looks like when it works…



If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading APNHLOS
100%
APNHLOS upload successful

Uploading MODEM
100%
MODEM upload successful

Ending session...
Rebooting device...
Releasing device interface...
Re-attaching kernel driver...