Odin and Heimdall: Free Your Samsung Android

This article is about one particular step of the procedure for “flashing” a new android-compatible operating system onto a Samsung device to create a Freedom-Respecting Smart Phone or Tablet.

(For the rest of the procedure, see for example the instructions to install e-OS or install LineageOS .)

Main article: Degoogling a Samsung Galaxy Tab A7 (2020)

Tools for Flashing Samsung: Odin and Heimdall

Samsung Android devices are tightly locked down. My impression is they perhaps allow re-flashing only to fulfil some legal concession. It does not seem to be an option that they want us to use. Nevertheless, it is possible. At least on some models. (I read that some models sold in the USA are completely locked; maybe there is no legal concession to allow changing the software there.)

Samsung do not seem to make available the tools needed to “flash” the software. The instructions I find all reference either “Odin” or “Heimdall”.

Odin is apparently a Samsung internal tool that has been leaked, many years ago, as a Windows-only executable with no source code. This, widely referenced as the way to go, is useless for non-customers of Microsoft-Windows. In 2022 a leaked Odin v4 for Linux was reported, also executable only. Without source code, nobody (outside Samsung) can reasonably make improvements or adaptations. (Also, many instructions including LineageOS's say to download the Odin executable from some unattested third-party web site, not even giving a checksum to verify. This is dangerous.)

Heimdall is a cross-platform open source tool developed independently. Heimdall can replace Odin, but many instructions either do not mention it at all, or point to an out-of-date version such as v1.4.2 that lacks important updates and bug fixes.

Both Odin and Heimdall work with Samsung's “download” mode, and are needed to get an alternative (freedom) operating system onto the device.

Heimdall, Open Source Samsung Flashing Tool (Odin Alternative)

An open-source flashing tool for Samsung devices, called Heimdall, was developed by Benjamin Dobell (https://glassechidna.com.au/heimdall/) around 2010 to 2017. That version is most commonly referenced.

Some bug fixes and updates have been made by other people since then, but not merged back to that version. Some of these can be found inside Microsoft's GitHub, but the best version is not there: it rightly lives on a Freedom software forge called Source Hut.

Heimdall up to v1.4.2, the latest “original” version (from Benjamin Dobell or “glassechidna”) at the time of this writing, did not work for me. See Troubleshooting: Heimdall Fails at Initialising Protocol.

Henrik Grimler now maintains a version of Heimdall at https://git.sr.ht/~grimler/Heimdall .

I recommend using Grimler's version. It has fixes and updates needed for more recent devices.

It is available as source code. You could ask around for someone to provide a build, or build it yourself following the included instructions.

Building Heimdall

Referring to Appendix B at the bottom of the instructions page for Linux, on Ubuntu 22.04, on which I already had most of the dependencies installed, I built Heimdall like this:

$ sudo apt install libusb-1.0-0-dev  # you may need more: see below
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND=ON ..
$ make
$ # The executable is then found at `./bin/heimdall`
$ ./bin/heimdall version
v2.0.2

Required dependency packages are listed in the doc linked above, and also machine-readably in the source tree in the files .builds/{alpine.yml,archlinux.yml,ubuntu.yml}.

I used 'DISABLE_FRONTEND' because I was not interested in building a GUI, and could omit installing 'qtbase5-dev' and its several sub-dependencies.

Using Heimdall in place of Odin

To flash a recovery image, Odin wants to be given a “tar” file (a similar concept to a zip file) with the image file inside it. For example, we have to create recovery.tar which contains recovery.img. By contrast, Heimdall takes the image file directly, e.g. recovery.img.

Where instructions for Odin say to select the “AP” (Android Partition) button and choose the recovery.tar file, the Heimdall translation is to run heimdall flash --RECOVERY recovery.img . For flashing a different kind of image such as “vbmeta”, we write heimdall flash --VBMETA vbmeta.img. We can give more than one pair of command-line arguments to flash more than one image.

Referring to this XDA post, the command needed for this device is:

$ heimdall flash --VBMETA vbmeta.img --RECOVERY recovery.img

Or, if we prefer not to reboot immediately (equivalent of disabling Odin's “Auto-Reboot” option), add the '—no-reboot' flag:

$ heimdall flash --VBMETA vbmeta.img --RECOVERY recovery.img --no-reboot

#fossGadgets #android #degoogled #lineageOS #eOS


Follow/Feedback/Contact: RSS feed · Fedi follow this blog: @julian​@wrily.foad.me.uk · use the Cactus Comments box above · matrix me · Fedi follow me · email me · julian.foad.me.uk Donate: via Liberapay All posts © Julian Foad and licensed CC-BY-ND except quotes, translations, or where stated otherwise