Installing a custom recovery
Samsung devices come with a unique boot mode called Download Mode which is very similar to Fastboot Mode on some devices with unlocked bootloaders. Heimdall is a cross-platform, open source tool for interfacing with Download Mode on Samsung devices. The preferred method of installing a custom recovery is through this boot mode. Rooting the stock firmware is neither recommended nor necessary.
- Download and install the Heimdall Suite
- Windows: Extract the Heimdall suite and take note of the directory holding
heimdall.exe
. You can verify Heimdall is working by opening a command prompt in this directory and typingheimdall version
. If you receive an error, be sure that you have the Microsoft Visual C++ 2012 Redistributable Package (x86/32bit) installed on your computer. - Linux: Pick the appropriate installation package based on your distribution. The
-frontend
packages are not required for this guide. After installation, heimdall should be available from the terminal; typeheimdall version
to verify installation succeeded. - Mac: Install the dmg package. After installation, heimdall should be available from the terminal; type
heimdall version
to verify installation succeeded. - Building from source: The source code for the Heimdall Suite is available on Github. For more details about how to compile the Heimdall Suite, please refer to the
README
file on Github under the relevant operating system directory. You can also refer to the Install and compile Heimdall instructions on this wiki.
- Windows: Extract the Heimdall suite and take note of the directory holding
- Download recovery — visit TWRP site to check for the latest version of recovery for your device (if your device can be found there). For general info about recoveries click here.
- Power off the {{{device_name}}} and connect the USB adapter to the computer but not to the {{{device_name}}}, yet.
- Boot the {{{device_name}}} into download mode. {{{device_download_mode_steps}}} Accept the disclaimer on the device. Then, insert the USB cable into the device.
- Windows (only) driver installation – Skip this step if you are using Linux or Mac
- A more complete set of the following instructions can be found in the Zadig User Guide.
- Run
zadig.exe
from the Drivers folder of the Heimdall Suite. - Choose Options ยป List All Devices from the menu.
- Select Samsung USB Composite Device or MSM8x60 or Gadget Serial or Device Name from the drop down menu. (If nothing relevant appears, try uninstalling any Samsung related Windows software, like Samsung Windows drivers and/or Kies).
- Click Replace Driver (having selecting “Install Driver” from the drop down list built into the button).
- If you are prompted with a warning that the installer is unable to verify the publisher of the driver, select Install this driver anyway. You may receive two more prompts about security. Select the options that allow you to carry on.
- At this point, familiarize yourself with the Flashing with heimdall notes below so that you are prepared for any strange behaviour if it occurs.
- On the computer, open a terminal (or Command Prompt on Windows) in the directory where the recovery image is located and type:
- Tip: The file may not be named identically to what’s in this command. If the file is wrapped in a zip or tar file, extract the file first, because heimdall isn’t going to do it for you.
- A blue transfer bar will appear on the device showing the recovery being transferred.
- Unplug the USB cable from your device.
- NOTE: Be sure to reboot into recovery immediately after having installed the custom recovery. Otherwise the custom recovery will be overwritten and the device will reboot (appearing as though your custom recovery failed to install).
- Manually reboot the phone into recovery mode by performing the following. {{{device_recovery_boot_steps}}}
- The {{{device_name}}} now has a custom recovery installed. Continue to the next section.
Note: Flashing with heimdall
- In Windows 7 UAC (User Account Control) may need switching off. Once Heimdall is finished it can be re-enabled.
- Protocol initialization can fail if the device is connected via a USB hub – connect the USB cable directly to the PC
- It may be necessary to run the heimdall flash command as root in Linux or Mac OS X:
sudo heimdall flash [...]
. Typical symptoms of this are:- a blue bar doesn’t show up after the process has finished
- Failed to confirm end of file transfer sequence!
- It may be necessary to capitalize the name of the partition on some devices. Try
--KERNEL
instead of--kernel
and/or--recovery
instead of--RECOVERY
. - If on Linux 64bit you get “unable to execute ./heimdall: No such file or directory”, try the 32bit version and make sure to run it with sudo: reference.
- On Mac OS X you may see this message: “ERROR: Claiming interface failed!”. If so, you need to disable the default USB drivers with the following commands:
sudo kextunload -b com.apple.driver.AppleUSBCDC;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMControl;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMData;
If you have installed Samsung Kies, you may further need to unload those USB drivers with the following commands:sudo kextunload -b com.devguru.driver.SamsungComposite;
sudo kextunload -b com.devguru.driver.SamsungACMData
sudo kextunload -b com.devguru.driver.SamsungACMControl
- Using Heimdall version 1.4.0 (the latest version available for download on the Glass Echidna website) you may see this message or one similar to it:
Error: Failed to confirm end of PIT file transfer!
If you experience this error, follow the instructions for compiling Heimdall from source to get the latest version on GitHub with the issue patched.
Helpful Tip
- The stock ROM may overwrite your custom recovery on boot. To prevent this, boot immediately into recovery after leaving Download Mode instead of letting the ROM boot up normally. If your recovery is overwritten, simply redo the steps you followed above and catch it before it boots next time.
- Note for upgrades from gingerbread to jellybean remember the recovery is changed. This means once you install do NOT restore to old-gingerbread-stock ROM from cwm-recovery.
- To upgrade from stock/CM7/CM9/CM10.1.2/CM10.1.3 to CM10.2, you must first boot into recovery and wipe data, cache, and dalvik cache (factory reset). Due to the new partition layout in CM10.2, failing to perform these steps will result in a bootloop. See here for details; more about repartitioning here. If you missed this step before installing, boot to recovery and factory reset, then reinstall CM10.2.
- Some users have reported connection errors if the device is connected to a USB hub. If you experience such errors it is recommended that you try connecting your device to a USB port on the motherboard.
- Antivirus software may prevent Heimdall from connecting properly. Disable your antivirus before proceeding.
- When Heimdall fails to connect, the Download mode may get stuck, making all further attempts fail too. To retry, you may need to restart the Download mode: turn off the phone by holding Power for 5-10 seconds (or by pulling out the battery), then boot into Download mode and run Heimdall again.
- If Heimdall fails to connect (errors related to initializing the protocol, or transferring data):
- if you just installed the driver, try rebooting your computer and trying again.
- if you still have troubles after reboot, in Zadig try installing the libusbK driver rather than the WinUSB driver.
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.