Skip to content

Instantly share code, notes, and snippets.

@micw
Last active February 22, 2026 17:41
Show Gist options
  • Select an option

  • Save micw/d99d973736c901a58d5622d85f5b3720 to your computer and use it in GitHub Desktop.

Select an option

Save micw/d99d973736c901a58d5622d85f5b3720 to your computer and use it in GitHub Desktop.
LinageOS on Samsgung Galaxy S5e WiFi from scratch from Linux with heimdall

LinageOS on Samsgung Galaxy S5e WiFi/LTE from scratch from Linux with heimdall

Compile a patched version of heimdall

cd /tmp
git clone https://github.com/Benjamin-Dobell/Heimdall.git
cd Heimdall
git fetch origin pull/478/head:pr478
git checkout pr478
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=1 ..
make
  • The patched version of heimdall can be found in bin

Enable OEM unlock

  • Boot the device
  • In device info / software info tap 7 times on "Build number" - this will enable developer options
  • In developer options enable "OEM unlock" This option might not be available unless the device is connected to a wifi or mobile internet connection

Unlock the bootloader

  • power off the device
  • while pressing and holding Vol+ and Vol-, plug an USB cable (you might need to grow another hand to do so ^^)
  • A blue warning screen will appear with 3 options
    • Vol+: Continue
    • Vol+ long press: Device unlock mode
    • Vol-: Cancel
  • Use "Vol+ long press" to unlock the bootloader
  • On the next screen, confirm with "Vol+". This will unlock the boot loader and factory reset the device

Verify/Re-Enable OEM unlock

  • After unlocking the bootloader, boot the device
  • Go through the android setup, connect the device to a wifi
  • Repeat the steps above to enable "OEM unlock"
  • In my case, "OEM unlock" was still enabled and grayed out. But be sure to have it checked.

Flash a modified version of vbmeta.img

  • power off the device
  • while pressing and holding Vol+ and Vol-, plug an USB cable
  • A blue warning screen will appear with the same 3 options as before
  • press "Vol+" to enter "download" mode
  • In the top left corner are some relevant information. Be sure that it correlates with the following, otherwise bad things will happen
    • FRP LOCK: Off
    • OEM Lock: OFF (U)
  • Download vbmeta.img
  • Using heimdal compiled in the initial step, now run ./bin/heimdall flash --VBMETA /tmp/vbmeta.img --verbose
  • After successfully flashing the image, the device reboots with a lot of warnings. It fails to boot into android and recommends a factory data reset
    • Follow the instructions to do the factory data reset
    • Android will now boot

Verify/Re-Enable OEM unlock

  • After unlocking the bootloader, boot the device
  • Go through the android setup, connect the device to a wifi
  • Repeat the steps above to enable "OEM unlock"
  • In my case, "OEM onlock" was still enabled and grayed out. But be sure to have it checked.

Flash and boot recovery.img

  • Power off the device, hold Vol+ and Vol-, plug an USB cable to your computer
  • On the blue screen press "Vol+" to enter "download" mode
  • Download recovery.img
  • Using heimdal compiled in the initial step, now run ./bin/heimdall flash --RECOVERY /tmp/recovery.img --verbose --no-reboot
  • The "no-reboot" option is very important. Do not let android boot at this stage!
  • Now good timing is required
    • Press and hold Power and Vol- until the device reboots
    • As soon as the screen turns black, press and hold Power and Vol+
  • If all went right, Lineage OS recovery is started. It is regognizable by thepink/purple colors and the Lineage OS logo on the top
  • Repeat the whole procesdure in this chapter if anything fails

Flash Lineage OS and optionally Google Apps and/or Magisk (for root)

  • The device must be in Lineage OS recovery and be connected via USB
  • ADB must be installed on your computer
  • Download Lineage OS from https://download.lineageos.org/devices/gts4lvwifi/builds
    • On the device go to "Apply update", confirm with Power Key
    • Then go to "Apply from ADB", confirm with Power Key
    • Flash with adb sideload /tmp/lineage-21.0-20240320-nightly-gts4lvwifi-signed.zip
  • Optionally download a matching version of Google Apps from https://wiki.lineageos.org/gapps/. You neeed the ARM64 version
    • On the device go to "Apply update", confirm with Power Key
    • Then go to "Apply from ADB", confirm with Power Key
    • Flash with adb sideload /tmp/MindTheGapps-14.0.0-arm64-20240225_232108.zip
    • On the device confirm that the package shall be installed despite that the signature verification has failed.
  • Optionally latest Magisk zip from https://github.com/topjohnwu/Magisk
    • On the device go to "Apply update", confirm with Power Key
    • Then go to "Apply from ADB", confirm with Power Key
    • Flash with adb sideload /tmp/Magisk-v28.1.apk
    • On the device confirm that the package shall be installed despite that the signature verification has failed.
  • Now you must do another factory data reset. Otherwise boot will fail until you do so.
  • After that you can boot into Lineage OS.
  • If you have flashed Magisk, start the app and follow the instructions (install App, patch boot image) to finish the setup
@micw
Copy link
Author

micw commented Dec 3, 2024

Thanks for your guide. As heimdall is only used in cli mode, there is no need to build the qt5 front end. Pass -DDISABLE_FRONTEND=1 to cmake to disable. cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=1 ..

Good point, thank you. I will flash another one in the next 2 weeks, so I try it and update my tutorial accordingly.

Edit: Confirmed to work as expected. I have modified the command above.

@speicie
Copy link

speicie commented Jun 3, 2025

Hi and thank you for the guide.

I unfortunately run into this mistake:

 
 /tmp/Heimdall$ cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=1 ..
 CMake Warning:
   Ignoring extra path from command line:
 
    ".."
 
 
 CMake Error: The source directory "/tmp" does not appear to contain CMakeLists.txt.
 Specify --help for usage, or press the help button on the CMake GUI.
 

Does someone know, why that is?

@speicie
Copy link

speicie commented Jun 3, 2025

Got it, you have to run the whole code path as root.

@micw
Copy link
Author

micw commented Jun 4, 2025

No need to run as root

/tmp/Heimdall$ cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=1 ..

You checked out to /tmp/Heimdall but forgot to change into the build directory (mkdir build; cd build).

@stoneubi
Copy link

Hi there, maybe someone can help me. I have Linux Mint Version 22.3 installed and also installed right now git and cmake.

I get the following error message during the cmake prompt:

root@HP-EliteBook-850-G6:/tmp# git clone https://github.com/Benjamin-Dobell/Heimdall.git
Klone nach 'Heimdall' …
remote: Enumerating objects: 2024, done.
remote: Counting objects: 100% (617/617), done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 2024 (delta 545), reused 514 (delta 514), pack-reused 1407 (from 1)
Empfange Objekte: 100% (2024/2024), 8.69 MiB | 4.02 MiB/s, fertig.
Löse Unterschiede auf: 100% (1362/1362), fertig.
root@HP-EliteBook-850-G6:/tmp# cd Heimdall
root@HP-EliteBook-850-G6:/tmp/Heimdall# git fetch origin pull/478/head:pr478
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
Entpacke Objekte: 100% (5/5), 9.46 KiB | 1.35 MiB/s, fertig.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Von https://github.com/Benjamin-Dobell/Heimdall

  • [neue Referenz] refs/pull/478/head -> pr478
    root@HP-EliteBook-850-G6:/tmp/Heimdall# git checkout pr478
    Zu Zweig »pr478« gewechselt
    root@HP-EliteBook-850-G6:/tmp/Heimdall# mkdir build
    root@HP-EliteBook-850-G6:/tmp/Heimdall# cd build
    root@HP-EliteBook-850-G6:/tmp/Heimdall/build# cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=1 ..
    CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at libpit/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

CMake Deprecation Warning at heimdall/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find libusb (missing: LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/Findlibusb.cmake:30 (find_package_handle_standard_args)
heimdall/CMakeLists.txt:9 (find_package)

-- Configuring incomplete, errors occurred!
root@HP-EliteBook-850-G6:/tmp/Heimdall/build#

How can I fix this.

Thank you,
stoneubi

@stoneubi
Copy link

Hi there, I solved it. I had missing dependencies. Trying to install these dependencies brought me to troubles with libgl1-mesa-glx and qt5-default. Both are not available any more.

I had to install the following to solve this:
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mesa/libgl1-mesa-glx_23.0.4-0ubuntu1~22.04.1_amd64.deb
sudo apt install ./libgl1-mesa-glx_23.0.4-0ubuntu1~22.04.1_amd64.deb

and
sudo apt install qtbase5-dev qt5-qmake

Now heimdall was build. I will get my samsung within this week so I will try if above process was successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment