[HOWTO] (Needs expert review) Flash Galaxy s9+ to Stock Android 10 using heimdall-gui

This HOWTO shows how I did this on a Ubuntu 20.04 host.

(There are other topics that explain about using Odin on a Windows machine - I can’t do that, so doing this instead. There are other topics and links about using heimdall, but none give all the details. Please reader, if you know more about this topic, do help me out.)


Check whole thread for feedback. I’d prefer that some experienced users who can get themselves out of trouble test this before saying this guide is ready. Usual disclaimers apply - if something goes wrong your phone may become unusable, I’m not responsible for that

  1. Identify my phone model. In my case SM-G965F

  2. Getting the Stock Image.
    I went to https://samfrew.com/all/ and searched for my device type, then got image for my region:
    NZ android Q version
    Downloaded (allow about 8 hours for slow download) sfirmware and samfw are faster
    Optional: Get TWRP image here

  3. Received zip file NZC-G965FXXUFFUC6-20210428121900.zip (about 4.8GiB), save into its own empty directory

  4. unzip this file, results in 5 files

  • BL_G965FXXUFFUC6_CL21315605_QB39020729_REV01_user_low_ship.tar.md5

  • AP_G965FXXUFFUC6_CL21315605_QB39020729_REV01_user_low_ship_meta_OS10.tar.md5

  • CP_G965FXXUFFUC6_CP18513641_CL21315605_QB39020729_REV01_user_low_ship.tar.md5

  • HOME_CSC_OMC_OXM_G965FOXMFFUC6_CL21315605_QB39020729_REV01_user_low_ship.tar.md5

  • CSC_OMC_OXM_G965FOXMFFUC6_CL21315605_QB39020729_REV01_user_low_ship.tar.md5

    Reading the sidebar here I learned that CSC and HOME_CSC tar files are alternative versions of the same data “Use CSC_*** if you want to do a clean flash or HOME_CSC_*** if you want to keep your apps and data.” So you may not want to unpack the file starting with HOME_

$ the_text_of --the command -lines

  1. Each of these can be unpacked with tar e.g. tar xf BL_G965FXXUFFUC6_CL21315605_QB39020729_REV01_user_low_ship.tar.md5 Note that the shell won’t autocomplete the filename because of the .md5 at the end, but tar works fine.
    Or use this commandline to remove the md5 extension

for f in *.md5 ; do mv $f "${f%.md5}" ; done

  1. Some of the resulting files are compressed, and have the extension .lz4, so they need to be unpacked with the command lz4 -m -d --rm *.lz4 (multiple files, decompress, remove source)

  2. Now I have a bunch of files (grouped by origin tar file)
    filename, partition name to be used in a later step


  • boot.img BOOT
  • dqmdbg.img DQMDBG
  • recovery.img RECOVERY
  • system.img SYSTEM
  • userdata.img USERDATA
  • vendor.img VENDOR


  • cm.bin CM
  • param.bin PARAM
  • sboot.bin BOOTLOADER
  • up_param.bin UP_PARAM
  • keystorage.bin KEYSTORAGE


  • modem.bin RADIO
  • modem_debug.bin CP_DEBUG


  • cache.img CACHE
  • hidden.img HIDDEN
  • odm.img ODM
  • omr.img OMR
  • STAR2LTE_EUR_OPEN.pit (list of partitions)

HOME_CSC_OMC_OXM_G965F: (note duplication of files from CSC)

  • cache.img CACHE
  • hidden.img HIDDEN
  • odm.img ODM
  1. Install heimdall-gui (and heimdall)

$ sudo apt install heimdall-flash heimdall-frontend then run heimdall-frontend` (HG for short)

  1. Reboot the phone into download mode. Power off, then press and hold Volume down + Bixby (single button below volume down) + Power button until download confirmation screent appears. Press Volume Up button to confirm. Connect phone to PC with USB cable.
    Preferably connect to a USB2 port. (I found that when connected via USB3, I got USB bulk transfer errors; switching to USB2 let it work)

  2. Confirming compatible PIT file. In HG, select the Utilities tab, click Detect device, hopefully your device is detected. Then Download PIT. Enter a destination filename, e.g. “my-device.pit”, then click Download.
    Then use Print PIT. Select Local File, navigate to “my-device.pit”, click Print. A bunch of stuff shows up in the Output window. Click in there, select all and copy. Open a text editor, paste the text, and save as e.g. “my-device-pit.txt”.
    Repeat the print, but this time load the pit file that came from the firmware archive, in my case “STAR2LTE_EUR_OPEN.pit”. Get the result into e.g. “downloaded-pit.txt”.
    Now, compare the two text files, I think they should be identical diff my-device-pit.txt downloaded-pit.txt showed no differences. ?What to do if they are different?

  3. Selecting what to flash.
    At this stage advice is to flash ALL the img and bin files you got at step 6 - I’m not sure this is truly necessary or safe - what is modified by the /e/ os install?
    Go to the Flash tab on HG. Similar instructions with images here
    First the PIT option. Browse for the pit file that came as part of the download and load it.
    For each of the .bin and .img files you have, Click the Add button, then use the dropdown box under Partition Details to find the partition name that it should be loaded into. As you select different partition names a hint shows up next to File, just under Partition ID. (add annotated screenshot here) See point (7) for my list.
    If you got a TWRP image, you can use that instead of the stock recovery.img. In my case

  4. Reflash the phone. Click the Start button.

    It will install all the listed partitions, one by one.

  5. Either the device will reboot by itself, or you can manually reboot.
    At this point my phone went into a boot loop! But all was not lost…

  6. Reboot into recovery (I assume you installed TWRP for the recovery
    (Press Volume Up + Bixby + Power). If bootloop is happening, you may have to try multiple times, but you should be able to get there.

  7. At last, install /e/ by following the standard instructions here, hopefully /e/ will boot.

  8. If you have an /e/ account@e.email, then pretty soon after entering your credentials at the startup prompts, your stuff from ecloud (mail, contacts, notes, photos) will be synced to your phone.

Other relevant topics:


Do I need to flash ALL the files, or can I leave some out. Particularly concerned about bootloaders, if something goes wrong, could this brick the phone?

Could I replace the standard recovery with TWRP, or just not flash recovery partition if TWRP is already there?

Thanks to user @aibd for link to this guide Restoring-Stock-Firmware-with-Heimdall about how to use commandline heimdall. It covers much of the same ground as the guide above.

It answers a couple of my questions:
Yes, install ALL the images:

You don’t want to install only half of a section. For example, if you install only some of the files in the BL_ package but not others, you could ruin your booloader and brick your device. That’s why it’s important to specify all the partitions you want in a single command, and never interrupt it.

Yes, you can replace stock recovery with TWRP:

I swapped the stock --RECOVERY partition with a recent version of TWRP, and then used that to install LineageOS. So, I never actually did reboot into the stock firmware

I found another interesting page The Complete Guide to Flashing Factory Images on Android Using Fastboot
While not directly applicable (because it talks about fastboot), it does have good explanations of what all the different partitions are for, and gives some examples of how you might only need to flash one partition. E.g.

You may just be re-flashing the stock firmware to recover from a soft brick. If this is the case, the system image is often the only image you need to flash in order to fix everything, because it contains the entirety of Android.

For newers like me I will download JOdin for Linux, to make it more easy to understand instead of the terminal.

JOdin is not easy to install for a basic user