Skip to content

Instantly share code, notes, and snippets.

@kevinpapst
Last active February 19, 2023 23:24
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save kevinpapst/2962b66d9528e966ec5b068d2081f6c5 to your computer and use it in GitHub Desktop.
Save kevinpapst/2962b66d9528e966ec5b068d2081f6c5 to your computer and use it in GitHub Desktop.
Flash a new Android ROM on Mac with ADB and Heimdall

Installing an Android ROM with your Mac via Heimdall and bash

Because every time I want to flash a new ROM, I forgot how I did it the last time.

This is how I re-flashed my unbranded Samsung Galaxy S4 (german black edition) with a stock ROM (because Cyanogenmod crashed my phone all the time). The correct Stock ROM for my Galaxy S4 is: I9505XXUHOJ2_I9505OXAHOJ2_I9505XXUHOJ2

Software you need

  • adb
  • heimdall (brew cask install heimdall-suite)

Preparing the ROM

  • Find any ROM that you want to flash and unzip it
  • If there is a xxx.tar.md5 remove the .md5 and untar the file as well, until there is a list of around 12 files in a folder (see list of required files in heimdall command below)
  • Now switch to your console and change into that directory

Flashing the ROM

Enter Download mode with Power + Volumne Down or:

adb reboot bootloader

Wait until the system is in Download mode and then execute:

heimdall flash --APNHLOS NON-HLOS.bin \
 --ABOOT aboot.mbn \
 --BOOT boot.img \
 --HIDDEN hidden.img.ext4 \
 --MDM modem.bin \
 --RECOVERY recovery.img \
 --RPM rpm.mbn \
 --SBL2 sbl2.mbn \
 --SBL3 sbl3.mbn \
 --SYSTEM system.img.ext4 \
 --TZ tz.mbn \
 --CACHE cache.img.ext4

Have fun with your new ROM!

Known problems

Stuck at Samsung logo

Boot into recovery mode Volume Up + Power + Home and execute

  • Wipe data / factory reset
  • Wipe cache partition
  • Reboot

Cannot get into recovery mode

Flash it again from within Download mode

heimdall flash --RECOVERY recovery.img

Heimdall "Claiming Interface Failed

If you have the Samsung Kies software installed, this might load some intrusive kernel modules. This is how to find and get rid of them:

kextstat | grep -v apple
sudo kextunload -b com.devguru.driver.SamsungComposite
sudo kextunload -b com.devguru.driver.SamsungACMData
sudo kextunload -b com.devguru.driver.SamsungACMControl
@ehsanghaffar
Copy link

thanks a lot

Is it possible to access the IMEI and repair it with Heimdall?

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