If you’re an owner of a Samsung phone, and want to root it, or install some custom ROM goodness, you may have come across an application called Odin. This is a simple tool for flashing custom code to a Samsung phone. The drawback for Linux users is that it only works on Windows. However, Linux users are not shut out of the wonderful world of running a rooted android phone, or a custom ROM. An outfit called Glass Echidna have developed a commandline tool called Heimdall (I think, so named because Heimdall was Odin’s servant in the Marvel Comics universe), which does all that Odin can do, but in an open source and cross platform way. Heimdall is available for Linux, as well as Windows and OSX.
Installation is simple. Most distributions have a package that can be installed from the main repos, or from mainstream alternative repos. If you can’t find a package for your distro, then there are debian packages on the Glass Echidna site. There is no need to install special drivers, as is required for Odin. Heimdall relies on libusb-1.0. Glass Echidna have also created a frontend for the command line tools, which can usually found as a package right next to the Heimdall package.
I won’t go through the usage of the frontend for heimdall, as it is pretty self explanatory. There are generally two main things you are doing when you are using Heimdall/Odin to flash something to your Samsung device. The first is flashing a new kernel, flashing a custom recovery (for example CWM Recovery), or flashing a whole new firmware. So we’ll use those as examples.
flashing a kernel
This is pretty simple. The first thing you need to do is download a kernel image. This will often come in a compressed format. You want to extract this (there may be a couple of levels of compression) and find a file called zImage. Then you need to put your device into download mode. This is usually done with a button combination – for my GS3, and previously my GS2, it’s volume-down+home+power. You may have to use Google to work out what combo works for your device. Connect your device to your computer via USB. Make sure you are in the directory where the zImage file is, and issue the following command:
heimdall flash --kernel zImage
Simple as that.
flashing a custom recovery
Samsung devices come with a recovery menu, which is used for performing low level tasks on the phone. However, there are custom recovery menus out there (eg. CWM Recovery), which provide a much greater functionality, including making full backups of your phone’s current state (nandroid backup), installing custom firmware, fixing permissions, and wiping various caches. Again, you’ll need to download a custom recovery from somewhere – cf-root is a popular one. Again, you will need to uncompress it, and find two files – one called recovery.img and one called cache.img. Put your phone in download mode, connect to your computer, and run the following command:
heimdall flash --recovery recovery.img --cache cache.img
flashing a complete ROM
For this example I’m doing to show you how to flash a stock ROM. Having flashed a number of custom ROMs using CWM, you may want to go back to stock for whatever reason. This is generally done using Heimdall/Odin. To do it in Heimdall, you’ll need to download a stock ROM image for your phone – you can google where to find these, however xda-developers.com will usually have a thread with links to all the stock ROMs for any particular Samsung device. Once you have the ROM file, you’ll need to uncompress it to get all the bits you need to flash it using Heimdall. Put your phone into download mode, connect to the computer, and run this command:
heimdall flash --factoryfs factoryfs.img --cache cache.img \ --hidden hidden.img --modem modem.bin \ --kernel zImage --param param.lfs \ --primary-boot boot.bin --secondary-boot Sbl.bin
For non-stock ROMS, they may not contain all those bits. Just flash what’s in the ROM package – the files are usually well labelled as to what they are.