Installing LineageOS 15.1 with microG on a Samsung Galaxy S5 (klte, SM-G900F)

This is a brief report on how to flash LineageOS 15.1 with microG on a Samsung Galaxy S5 (klte, SM-G900F). I use Heimdall on Linux (Ubuntu 16.04.3 LTE) in order to first install the TWRP Recovery tool and then the desired LineageOS 15.1. Note that the procedure works for the version of the Galaxy S5 that is called SM-G900F by Samsung and klte by the Cyanogen and Lineage communities.

Preparation

Before we can boot the Galaxy S5 into recovery mode, we need to activate the developer options menu. Go to Settings -> About Device and tap seven times on the item Build Number. Then go to Settings -> Developer Options and allow USB Debugging (adb).

If you wish to backup the factory software that is installed on the Galaxy S5, you should insert a formatted micro SD card with about 4.5GB free space, or you need that amount of free space in your internal flash memory.

Required Tools

On Linux, we need the Android Debug Bridge (adb) which can be installed on Ubuntu 16.04.3 LTS by

sudo apt-get install libusb-dev adb

We also need the Heimdall tool in order to flash a recovery image to the Galaxy S5. Unfortunately, Ubuntu 16.04.3 LTS provides only version 1.4.1, but for the Galaxy S5, Heimdall 1.4.2 is required. We therefore download Heimdall-v1.4.2.tar from the Gihub Release Page. In order to compile it, we need the following prerequisites on Ubuntu 16.04.3 LTS:

sudo apt-get install build-essential cmake zlib1g-dev qt5-default libusb-1.0-0-dev libgl1-mesa-glx libgl1-mesa-dev

We find a place at which to unpack the sources and then build Heimdall as follows.

tar -xf Heimdall-v1.4.2.tar
cd Heimdall-v1.4.2
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
sudo cp bin/heimdall /usr/local/bin

(Remember that the last step, simply copying the binary to /usr/local/bin is frowned upon because this way the apt package management tool does not know the executable is there nor where it comes from. In any case,

heimdall version

now displays v1.4.2. If it does not, perhaps your PATH ought to be configured so that /usr/local/bin takes precendence over /usr/bin, or you perhaps have the Ubuntu version of Heimdall installed which can be removed with

sudo apt-get remove heimdall-flash heimdall-flash-frontend

Downloads

We download Lineage 15.1 with microG from this repository (for me the build lineage-15.1-20180813-microG-klte.zip works well) and the matching Super User tools addonsu-15.1-arm-signed.zip from their extras page. Our recovery tool in order to deploy the new OS is TWRP. The version twrp-3.2.2-0-klte.img.tar from this repository worked for me.

Installing a Recovery Tool and Flashing the OS

Power off the S5. Then start it in download mode by pressing [home]+[power]+[volume down] and then confirm by pressing [power up]. Connect the Galaxy S5 with your PC via the USB cable and type

sudo heimdall print-pit --no-reboot

You ought to see a blue progress bar on the Galaxy S5 and the partition information printed to your Linux console. This confirms that Heimdall and your Galaxy S5 work together as expected. Disconnect the USB cable and power down the phone. Unpack the twrp-3.2.2-0-klte.img.tar by

tar -xf twrp-3.2.2-0-klte.img.tar

in order to obtain the recovery.img. Start the Galaxy S5 in download mode once more by pressing [home]+[power]+[volume down] and then [volume up]. Now we flash the recovery image by

sudo heimdall flash --RECOVERY recovery.img --no-reboot

You should see a blue progress bar on the phone and a success message in the Linux console. Now you can power down the phone and then boot it in recovery mode by pressing [home]+[power]+[volume up]. As soon as the blue text appears, you can release the buttons. The phone boots into the TWRP recovery tool.

In TWRP, swipe in order to confirm that the phone will be modified (note that a hardware counter in the phone will irreversibly be increased once you flash a new OS, and Symsung will most likely refuse to help you with any software issues as a consequence).

First, you may wish to backup the factory software that is installed on the phone. Therefore, select Backup in TWRP and tick all partitions. Choose the micro SD card as the target for the backup and confirm. With

adb shell

you can traverse the file tree on the Galaxy S5 in order to localize the backup that TWRP has written. In my case, it is located at /external_sd/TWRP/BACKUPS/(seriia-no)/(date-time-devicecode)/ and contains 26 files, among them boot.emmc.win, boot.emmc.win.sha2 and so on, which contain images of the partitions of the factory software. Note that with other versions of Android, the /external_sd might be called differently. You can use

adb pull (path-on-phone) .

in order to copy the files to your PC. You may wish to google a bit in order to find a more convenient way to copy entire directories with adb.

Once you are sure the backup has safely arrived on the PC, you can tap on the back icon (bottom left) in TWRP, go back to the main menu, select Wipe and Adcanced Wipe and wipe the cache, dalvik cache, system, data and internal storage partitions (but not the micro SD card). We copy the zip files with the new OS to the Galaxy S5 by

sudo adb push lineage-15.1-20180813-microG-klte.zip /external_sd/
sudo adb push addonsu-15.1-arm-signed.zip           /external_sd/

go back to the TWRP main menu and use TWRP to install these two zip files. Then select Reboot in TWRP, and your new Lineage 15.1 with micro G is live.

2 thoughts on “Installing LineageOS 15.1 with microG on a Samsung Galaxy S5 (klte, SM-G900F)

  1. This guide is a life saver, thank you so much!
    For new users might it be a good idea to indicate that “md” is an alias for “mkdir”.
    In my case I had to sideload the zip file with the OS instead of letting TWRP install it. I actually used this guide to install Lineage OS 16 on a Samsung Galaxy S5 mini (SM-G800F/kminilte) using an unoffical build.
    Thanks again!

    Like

Leave a comment