Skip to content

Instantly share code, notes, and snippets.

@edouard-lopez
Last active March 25, 2024 03:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save edouard-lopez/e4780ff1c6152e5dd851 to your computer and use it in GitHub Desktop.
Save edouard-lopez/e4780ff1c6152e5dd851 to your computer and use it in GitHub Desktop.
Restore Galaxy S 2 i9100 (after breaking with cynogenmod update CM-13.x)

Requirements

sudo apt-get install heimdall{,-frontend} 
sudo apt-get install android-tools-adb
sudo apt-get install build-essential cmake zlib1g-dev qt5-default libusb-1.0-0-dev libgl1-mesa-glx libgl1-mesa-dev
For those of you who want to upgrade your **Galaxy S2 GT-i9100** to **CM13** (CyanogenMod) or any Android 6.0.1 Marshmallow ROM, you will **need to repartition** your system partition so you can install it correctly.
Marshmallow ROMs require **minimum of 1GB for system partition while the Galaxy S2 defaults to 500MB**. To do this, it’s pretty simple to do, you just need to install repartitioning zip file using latest TWRP recovery.
## How to
1. **Back up everything** on your phone beforehand as there is a chance you may **lose some of your data** during repartitioning!
1. Make sure you have a **custom recovery** such as `CWM` or `TWRP` recovery.
2. Boot into your recovery made and **flash the [ISO Rec TWRP recovery](http://downloadandroidrom.com/file/GalaxyS2/recovery/IsoRec_TWRP_3.0.0-0_i9100.zip).
1. Reboot into recovery.
3. Then, **flash the [repartitioning zip file](http://downloadandroidrom.com/file/GalaxyS2/recovery/lanchon-repit-20160406-system=1.0-data=same-sdcard=max-preload=min+wipe-i9100.zip)**.
1. You **only need to repartition** once!
1. Once that’s done, reboot back into recovery.
4. Once rebooted in recovery, you can now do a **standard installation of the ROM**, see our universal failproof guide on how to install Marshmallow ROMs (or see the video tutorial above)
### Downloads
1. [Download ISO Rec TWRP Recovery for GT-i9100](http://downloadandroidrom.com/file/GalaxyS2/recovery/IsoRec_TWRP_3.0.0-0_i9100.zip) ;
2. [Download Repartitioning ZIP file](http://downloadandroidrom.com/file/GalaxyS2/recovery/lanchon-repit-20160406-system=1.0-data=same-sdcard=max-preload=min+wipe-i9100.zip) ;
3. [Download CM13 ROM for GT-i9100](http://downloadandroidrom.com/file/GalaxyS2/roms/CM13/cm-13.0-20160404-NIGHTLY-i9100.zip) (or use a recent one) ;
4. [Download Marshmallow Gapps](http://highonandroid.com/download-android-6-0-marshmallow-gapps/)
Credits – XDA thread [Want to update to CM13? Read this first!](http://forum.xda-developers.com/galaxy-s2/development-derivatives/guide-want-to-update-to-cm13-read-t3313978)

Flash Stock Official Firmware

Following command flash phone with :

  • official stock ROM ;
  • TWRP recovery
  • change /system partition to 4Gb.

Boot phone in download mode, then:

cd android-gs2-base/I9100XWLSS_I9100XXMS2_I9100FRELS1_HOME
sudo heimdall flash \
	--FACTORYFS factoryfs.img \
	--CACHE cache.img \
	--HIDDEN hidden.img \
	--MODEM modem.bin \
	--PARAM param.lfs \
	--BOOT boot.bin \
	--SBL1 Sbl.bin \
	--no-reboot \
	--KERNEL zImage \
	--RECOVERY ../recovery/twrp-3.0.2-0-i9100.img \
	--pit ../PIT/I9100_4GB.pit  \
	--repartition

Flash with custom kernel

I went looking for other one that had a Kernel image and a recovery. Finally:

  1. found this one I9100 CWM+Kernel For Android 4.1.2/ ;

  2. extract the parent archive ;

  3. extract the inner archive file Rooted-kernel-image-Siyah-s2-v6.0b5 Kernel+Recovery.tar ;

  4. then use the zImage file :

     sudo heimdall flash \
     	--FACTORYFS factoryfs.img \
     	--CACHE cache.img \
     	--HIDDEN hidden.img \
     	--MODEM modem.bin \
     	--PARAM param.lfs \
     	--BOOT boot.bin \
     	--SBL1 Sbl.bin \
     	--no-reboot \
     	--KERNEL ../zImage  # Siyah ROM+recovery kernel
    

Install Recovery

CWM-recovery

Start in recovery mode

adb kill-server
adb start-server
adb sideload ./recovery-clockwork-touch-5.8.1.5-galaxys2.zip

TWRP3 recovery

I'm following instruction from TWRP for Samsung Galaxy S2 i9100:

wget -c https://dl.twrp.me/i9100/twrp-3.0.2-0-i9100.img
wget -c https://dl.twrp.me/i9100/twrp-3.0.2-0-i9100.img.md5
# check the MD5 sum

Then we backup our PIT to be able to use it when changing recovery to TWRP:

sudo heimdall download-pit --output my-working.pit --no-reboot

Now, we reboot in recovery mode and run :

adb root
adb push twrp-3.0.2-0-i9100.img /dev/block/mmcblk0p6

Using heimdall command-line (untested), reboot in download mode:

sudo heimdall flash \
	--RECOVERY recovery/twrp-3.0.2-0-i9100.img \
	--PIT PIT/I9100_4GB.pit

How to

How-to download mode

Press simultanously Volume Down+Home+Power buttons.

How-to recovery mode

Press simultanously Volume Up+Home+Power buttons.

Issues

You're in stock recovery, not CWM recovery. CWM recovery doesn't verify signatures. You either failed to install the recovery properly, or you need to hit "install packages" or similar from the stock recovery in order to get into CWM.

Resources

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