Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Restoring Stock Firmware with Heimdall

  1. #1
    Junior Member
    Join Date
    Nov 2015
    Posts
    1

    Restoring Stock Firmware with Heimdall

    I am on Mac, but Odin is a Windows application. How can I get my phone back to stock? Well, it turns out that there is an open-source tool called Heimdall which speaks the same download protocol as Odin, but which works on a Mac or Linux box. I couldn't find any guides to using this Heimdall with the firmware found here on SamMobile, so I decided to write my own based on my own experience. Hopefully they work for you.

    # Prerequisites

    This guide uses the command-line. This is more advanced than using a point & click tool, but hopefully Linux or Mac users are more familiar with this sort of thing.

    ## Downloads

    You need to download and unzip the firmware for your device, like G960FXXU8DTC5_G960FOXM8DTC5_BTU.zip. I paid for premium here on SamMobile, since it's a big download and I don't want to mess around.

    You also need the Heimdall tool, which comes from a developer called [ Login above or register to see download links. ].

    ## Getting the PIT file

    First, you need to get your phone into download mode. For my phone, I had to power off, then power on while holding the volume down, bixby, and power buttons. This is the mode that the heimdall tool knows how to talk to. We will initially use this mode to do two things:

    • Test that we can talk to the phone
    • Discover which partitions exist on the phone

    To accomplish these goals, run the following command:

    Code:
    heimdall print-pit --no-reboot
    If this works, it will print out details about the various partitions on the phone. Copy this information into a text editor, so we can refer to it later. If the command does not work, you will have to figure out what's wrong with your USB cable or heimdall setup.

    ## Extracting the images

    The firmware bundle is a zip file that contains tar files that contain compressed images - three layers of packaging we need to unwrap! I used the following steps to get everything out:

    Code:
    # Unpack the main zip:
    unzip G960FXXU8DTC5_G960FOXM8DTC5_BTU.zip
    
    # Unpack each of the tar files:
    for file in *.tar.md5; do
      tar -xvf $file
    done
    
    # Uncompress all of the images:
    unlz4 -m *.lz4
    This produces a folder full of .bin and .img files, as well as some miscellaneous stuff we can ignore:

    Code:
    $ ls *.bin *.img
    boot.img        hidden.img      odm.img         sboot.bin       vendor.img
    cache.img       keystorage.bin  omr.img         system.img
    cm.bin          modem.bin       param.bin       up_param.bin
    dqmdbg.img      modem_debug.bin recovery.img    userdata.img
    ## Matching files to partitions

    The next step is to figure out where all these images go on the phone. The partition dump file from earlier has the clues:

    Code:
    --- Entry #0 ---
    Binary Type: 0 (AP)
    Device Type: 8 (Unknown)
    Identifier: 80
    Attributes: 2 (STL Read-Only)
    Update Attributes: 1 (FOTA)
    Partition Block Size/Offset: 0
    Partition Block Count: 1024
    File Offset (Obsolete): 1
    File Size (Obsolete): 0
    Partition Name: BOOTLOADER
    Flash Filename: sboot.bin
    FOTA Filename:
    This says that the file named "sboot.bin" goes into a partition called "BOOTLOADER". There are many other entries in this file, which should help you match the various files to their correct partitions, like this:

    Code:
    Bootloader (BL_...):
      --CM cm.bin
      --KEYSTORAGE keystorage.bin
      --PARAM param.bin
      --BOOTLOADER sboot.bin
      --UP_PARAM up_param.bin
    
    Modem (BL_...):
      --RADIO modem.bin
      --CP_DEBUG modem_debug.bin
    
    OS (AP_...):
      --BOOT boot.img
      --RECOVERY recovery.img
      --SYSTEM system.img
      --VENDOR vendor.img
      --USERDATA userdata.img
    
    Carrier (CSC_... or HOME_CSC_...):
      --CACHE cache.img
      --HIDDEN hidden.img
      --ODM odm.img
      --OMR omr.img
    I suggest doing this in a text editor of some kind.

    ## Flashing

    Once you have figured out which files go where, assemble your work into a command line like the following:

    Code:
    heimdall flash --CM cm.bin --KEYSTORAGE keystorage.bin --PARAM param.bin --BOOTLOADER sboot.bin --UP_PARAM up_param.bin --RADIO modem.bin --CP_DEBUG modem_debug.bin --BOOT boot.img --RECOVERY recovery.img --SYSTEM system.img --VENDOR vendor.img --USERDATA userdata.img
    Paste this into your terminal & run it. Do not interrupt this step! Be sure you have a full charge on your laptop & phone, and that you don't have to go anywhere for a while. Once you are done, your device should reboot & be ready to go.

    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.

    In my personal goal wasn't to run stock, but to un-bork my LineageOS setup. Since that was the case, 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. These instructions worked for my own purposes, but I don't know if they will work for yours.
    Last edited by swansontec; 22-04-2020 at 21:18.

  2. #2
    Junior Member
    Join Date
    May 2020
    Posts
    1
    thanks so much

  3. #3
    Junior Member
    Join Date
    May 2020
    Posts
    1
    Wow, I actually had to [ Login above or register to see download links. ] a site! this is a first. Keep it up

  4. #4
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Merci beaucoup bonne journée

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Posts
    1
    It's hella annyoing me too

  6. #6
    Junior Member
    Join Date
    Jun 2020
    Posts
    1
    Wow[ Login above or register to see download links. ]this is realy a cool site.

  7. #7
    Junior Member
    Join Date
    Feb 2020
    Posts
    1
    Gt-s6790l

  8. #8
    Junior Member
    Join Date
    Jul 2020
    Posts
    1
    Tank

  9. #9
    Junior Member
    Join Date
    Aug 2020
    Posts
    3
    Svp je demande firmware Galaxy s7 edge

  10. #10
    Administrator
    Join Date
    Jul 2012
    Posts
    8,153
    Quote Originally Posted by Koudouss [ Login above or register to see download links. ]
    Svp je demande firmware Galaxy s7 edge
    Hi there

    Here you go: [ Login above or register to see download links. ]

    Be advised, the language on this forum is English

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •