Search

Ubuntu - Error while flashing latest Samsung phones with Heimdall

Contents[Hide]

dropcap-ubuntu-android

Last week I wanted to flash latest LineageOS 15.1 on a Samsung Galaxy A5 2016 (A500-FU).

So I installed Heimdall from official Ubuntu Xenial repository to do the job. But I encountered errors while trying to flash the recovery. After some googling, I realised that Heimdall in Ubuntu repository is too old and doesn't handle PIT extraction on latest Samsung smartphones.

From Heimdall official site https://glassechidna.com.au/heimdall/ it appears that it has been updated to handle latest Samsung devices.

But deb files available for download on official Ubuntu repositories are quite outdated. So it is compulsory to compile it from official GitLab sources.

This article explains how to compile latest GitLab version of Heimdall under Ubuntu Xenial 16.04 LTS or Bionic 18.04 LTS.

Once compiled, you should be able to flash any recovery or ROM on latest Samsung Android smartphones.

1. Heimdall Error

With latest Heimdall version available on official Ubuntu repositories (1.4.1), you'll get following error if you try to flash anything to a new Samsung phone.

Terminal
# heimdall flash --RECOVERY './recovery.img'
Heimdall v1.4.1

Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

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...
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...
ERROR: Failed to send request to end PIT file transfer!
ERROR: Failed to download PIT file!
Ending session...
ERROR: Failed to send end session packet!
Releasing device interface...

Error comes from the PIT extraction stage.

This error has been corrected, but only on latest source version.

2. Heimdall compilation from sources

It quite simple to compile Heimdall from official GitLab sources under Ubuntu.

Steps are :

  1. to uninstall official version if already installed
  2. to install compilation environment packages
  3. to retrieve and compile heimdall from sources

Terminal
# sudo apt purge heimdall-flash
# sudo apt install build-essential cmake zlib1g-dev qt5-default libusb-1.0-0-dev libgl1-mesa-glx libgl1-mesa-dev
# cd ~
# wget https://gitlab.com/BenjaminDobell/Heimdall/-/archive/master/Heimdall-master.tar.gz
# tar -xvf Heimdall-master.tar.gz
# cd Heimdall-master/
# mkdir build
# cd build
# cmake -DCMAKE_BUILD_TYPE=Release ..
# make
# sudo mv ./bin/heimdall* /usr/local/bin

You should now get latest Heimdall version under /usr/local/bin

If you start a new terminal, you can check that version has changed.

Terminal
# heimdall version
v1.4.2

3. Flash using Latest Heimdall version

You should now be ready to flash any new firmware on your latest Samsung device.

If you've just comiled Heimdall, make sure to :

  • unplug and replug your smartphone USB cable
  • have your smartphone in download mode

Terminal
# heimdall flash --RECOVERY '/home/nicolas/Downloads/recovery.img'
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

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...
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 RECOVERY
100%
RECOVERY upload successful

Ending session...
Rebooting device...
Releasing device interface...

PIT extraction has succeeded and flash was succesfull !

 

Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus