13

The first recommended step in the installation of CyanogenMod on Samsung Galaxy S is flashing a custom recovery like ClockworkMod or the one from Replicant with a command like:

heimdall flash --kernel path/to/recovery.img

Now I feel that the instructions might be misleading:

I have done the first step wanting just to have a custom recovery mode, without proceeding to replacing the main OS on the device.

It seems I have done that wrong, because the device now always boots into the recovery mode.

What would be the correct heimdall command to just install a custom recovery system without touching the main system?

5
  • 1
  • It worked for me. But AFAIK it depends on the version of the stock ROM you have: Some custom recoveries are able to boot it, others not. I guess there is no general way.
    – Flow
    Commented Apr 22, 2013 at 7:51
  • @Flow So, the recovery mode and the normal mode are supposed to use the same image when booting? I was thinking that perhaps there are two different images for the different boot modes, and I replaced the wrong one by mistake, and that's the source of my problem: booting always into the recovery system (no matter whether other keys are pressed when powering up) after I executed the flashing command from the post, although I would really like to boot the old main system. Commented Apr 22, 2013 at 8:18
  • No, if the custom kernel/recovery boots always into recovery then it's usually a sign that it is unable to find/boot the normal system.
    – Flow
    Commented Apr 22, 2013 at 8:24
  • He just needed to rerun print-pit cmd, then flash his boot.img into the partition where he'd flashed recovery.img, no? In my experience, they are almost always right next to each other.
    – Nate T
    Commented May 30, 2021 at 21:02

5 Answers 5

16

It depends on your PIT partition file.

Before you do anything using heimdall, print the partition table of your phone.

sudo heimdall print-pit

The output of the file is the location assigned to each partition. For example on my Galaxy S3, I have something like this:

--- Entry #20 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 19
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 491520
Partition Block Count: 32768
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: Kernel2
Flash Filename: recovery.img
FOTA Filename:

Now this tells me 3 main things:

  • Name the flash file: recovery.img
  • Location of the identifier 19
  • And finally the name of the recovery partition Kernel2

What does this means?

This means if I want to flash a recovery image I should use either the identifier 19, or the name Kernel2.

sudo heimdall flash --19 any-type-of-recovery.img

or

sudo heimdall flash --Kernel2 any-type-of-recovery.img

Bottom Line: Look at the pit file to figure out where to flash your recovery.

Cheers, Mel

1
  • Just a note for others, if the recovery.img flash is successful but you let your device reboot as normal straight after, the boot image will likely remove the custom recovery image. Either use adb or use the recovery mode key combination as soon as heimdall is successful.
    – myol
    Commented Jan 6, 2022 at 7:00
4

One effective way with Heimdall is to just run

sudo heimdall flash --RECOVERY twrp.img

Worked for me on an S3 AT&T

Then when phone reboots, go into recovery via

adb reboot recovery

1
  • 2
    I also used --no-reboot flag. Otherwise the system booted and later on an official recovery seemed to be reinstalled so I couldn't enter TWRP. And thank You by the way.
    – kcpr
    Commented May 16, 2022 at 11:08
1

I do not know the partition mapping of the SGS, so my only suggestion would be to use the GUI (heimdall-frontend) and select the recovery partition only. As of restoration of the original system, my suggestion is to reflash the original ROM without touching /data. But backup it first using an advanced custom recovery like this one if possible: http://forum.xda-developers.com/showthread.php?t=2201860 (the key feature is custom backup/restore)

1
  • But what if I destroy the original OS when flashing the custom recovery? In my case, I flashed a custom recovery, but the OS doesn't boot after that... swhat could go wrong? That is something I didn't expect: I just wantee to flash a custom recovery, but do not install a new main OS. Now I'm forced to do that. Commented Aug 2, 2013 at 17:45
1

You never touched neither the SYSTEM, nor the RECOVERY partition. You flashed the CWM image to the KERNEL partition.

The kernel partition (also named boot) is where the core program that manages your phone's CPU resources, memory, and system devices is stored. It starts before the system.

Recoveries (TWRP, CWM, etc.) should be flashed to the RECOVERY partition.

heimdall --RECOVERY /path/to/the/recovery/file

Just flash the default kernel and you'll be fine.

heimdall --KERNEL or BOOT or what your phone uses /path/to/the/boot/file

(lemel already described how to determine how exactly are the partitions named on your phone)

And of course, there is always a way to get back the default images. You can get them off sites like stockrom.net or samfw.com

0
heimdall flash --Recovery /Path/recovery.img --Kernel /Path/recovery.img

Replicant OS Recovery install

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .