Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE] How to Flash Custom Binaries Without Ever Incrementing the Flash Counter!!

OP creepyncrawly

20th October 2011, 01:43 AM   |  #1  
OP Recognized Contributor
Thanks Meter: 3,083
 
2,504 posts
Join Date:Joined: Sep 2010
Donate to Me
This approach to customizing your phone involves the following steps:

1. Read the flash counter.
2. Root your phone:
- by using DooMLoRD's Easy Rooting Toolkit. (ZergRush Exploit)
- by using SuperOneClick Root. (ZergRush Exploit)
- by flashing Entropy512's Return/Unbrick to stock, Kernel + Rooted System Package using Odin or Heimdall.
3. Install a customized kernel containing ClockworkMod Recovery:
- by using Mobile Odin Lite or Mobile Odin Pro on your phone.
- by using adb on your computer.
- by using Android Terminal Emulator on your phone.
4. Flash the custom ROM package of your choice:
- by using ClockworkMod Recovery and a CWM flashable zip package.
- by using Mobile Odin.


PLEASE NOTE: While the following guide was written before AT&T officially released ICS, the principles contained in this guide are still applicable to our phone regardless of firmware version. However if your phone is currently running stock ICS UCLE5, using this method will install Gingerbread, taking your phone back to an earlier version. To root the phone while retaining ICS, please see the [Heimdall][Odin][Stock][Root]UCLE5 Stock ICS with Root thread.


JANUARY 2013 ROOTING UPDATE: In mid December of 2012, Samsung released an over-the-air update for the SGH-I777UCLK3, taking the operating system to version 4.0.4. Around the same time, XDA developer Chainfire released an application called ExynosAbuse APK which can be used to root the SGH-I777 with SuperSU, without the need to use a PC. ExynosAbuse APK is the best, and probably the only practical method for rooting UCLK3 without flashing some other distribution. In addition, it seems that this application is a good way to root any phone running 4.x operating systems, and possibly phones running 2.x operating systems as well. Be aware, there are possible risks involved with using this application. Please thoroughly read and understand Chainfire's thread linked above before using his application.


Discussion

The Samsung Galaxy S II contains an internal flash counter which is incremented each time a non-stock binary (kernel/rom) is flashed from a computer using Odin or Heimdall. (Using the new Mobile Odin on your phone does not increment the flash counter.) The purpose of the flash counter is believed to be to allow Samsung and or AT&T technicians to detect if the phone has a voided warranty through flashing non-stock firmware. The first time the flash counter is activated, the phone also displays a warning screen on boot up with a yellow warning triangle containing an exclamation point. The warning screen also contains the i9100 logo. (Evidently, Samsung did not change the warning screen from the International version of the Galaxy S II for the AT&T version.) Some rooting methods require that a non-stock kernel be flashed before rooting can be accomplished. So rooting and flashing custom software can both cause the dreaded yellow triangle, and increment the flash counter.

It is possible to remove the warning screen by two methods. One is by using a Jig to place the phone into download mode. The other is by flashing a stock kernel using either Odin or Heimdall. However, there is only one way to reset the flash counter, and that is with a micro usb Jig. This was true for the International version of the Galaxy S II as confirmed by Chainfire on the i9100 forums. This has also been confirmed for the AT&T Galaxy S II by dayv. Please see his post here, and then go to this post and read it and the following five posts for a complete description with screen shots.

pinoymutt adds:
Quote:

On the newer versions of the i9100 ROMs apparently Samsung has updated the bootloaders to render the "jig trick" to reset the counter useless. This has also been observed in the latest ATT leak that DG posted in the General Forum (UCKJ2), where new bootloaders are included that render the jig reset obsolete.

Additionally, there have been rumors that there is a secondary counter hidden in the code of the Galaxy S II which increments each time the primary flash counter is reset to zero. This rumor was either started or strengthened over in the i9100 forums by Chainfire. He never did find any code, and later said he was not fully convinced there ever was any code. But the rumor has already had some discussion in these At&T forums, so it's worth mentioning. My opinion is that a secondary counter doesn't exist, but if it does, this would be an additional reason for this guide.

Some people may be reluctant to root their phone and/or flash custom software onto it, not wishing to take a chance on voiding their warranty. However, there is a way to completely avoid this problem. The solution is to never increment the flash counter in the first place, and never activate the yellow warning triangle. Using this guide to root and modify an AT&T Galaxy S II phone right out of the box, along with the ability to flash back to completely stock firmware followed by a wipe data/factory reset from stock 3e recovery, (see this Guide), will result in a phone that can be returned for warranty purposes to either AT&T or Samsung without fear of the warranty being denied.

Disclaimer: I didn't think all this stuff up. The following information is mainly gleaned from all the great developers and knowledgable users on this forum. A special thanks to Entropy512 for creating the stock + root package that makes this all possible.

Here is some additional information for noobs about the tools and techniques used in this guide.




1.) How to read the flash counter on an AT&T Samsung Galaxy S II
  • Boot into download mode by this method:
    • With the phone powered off, plug in the usb cable while holding the vol up + vol down buttons (but not the power button).
    • When the warning screen appears, press Volume up to continue into download mode.
  • At the top of the screen you will see:
    ODIN MODE
    PRODUCT NAME: SGH-I777
    CUSTOM BINARY DOWNLOAD: NO --or-- YES (x counts)
    CURRENT BINARY: SAMSUNG OFFICIAL --or-- CUSTOM
  • Once you have verified the information, remove the usb cable, and hold down the power button until the phone begins to reboot. (Do not do this if you are actually flashing the phone. Interrupting a flash can cause bad things to happen.)
  • You will not see the above information if you enter download mode by another method, ie. by using adb or the power menu, etc.
  • Now you can check on your flash counter at any stage of the foregoing guide.


Quote:

To root UCKK6, use method 2c or 2d to flash UCKH7 stock plus root. Immediately after rooting, if you want UCKK6, open Settings and check for updates, download and install the OTA update, and it will retain root. Some have reported this works, and some say not. Alternatively, use Odin3 v1.85 to flash Entropy512's UCKK6 Stock plus Root package from his thread here.

2a.) How to root by using DooMLoRD's Easy Rooting Toolkit. (ZergRush Exploit) (Windows)
  • This rooting method does not work on the UCKK6.
  • This is the preferred method of rooting for users with the Windows operating system on their computer, and a phone running UCKH7.
  • Download the "DooMLoRD's Easy Rooting Toolkit v4.0" package from this thread and extract it to a directory on your hard drive using WinZip or a similar program.
  • You need to have the USB drivers for SGH-I777 installed on your computer. (It will be "Samsung USB Driver for Mobile Phones" in Control Panel\Uninstall Programs.) Download and install the latest drivers from this thread. (x86 and x64)
  • Both USB Debugging (Menu\Settings\Applications\Development) and Unknown Sources (Menu\Settings\Applications) should be enabled on your phone.
  • Increase the screen timeout on your phone to 10 minutes. (Menu\Settings\Display\Screen Timeout) Remember to set it back to a shorter interval after you are done rooting.
  • Connect the USB cable to the phone and the computer. Go to the directory where you extracted the package and execute "runme.bat".
  • The toolkit will open a command prompt window where you will see the progress of the rooting process. It takes between 5 and 10 minutes for the process to complete.
  • Success. You're rooted.

2b.) How to root by using SuperOneClick Root. (ZergRush Exploit) (Windows, Linux and Mac OS)
  • This rooting method does not work on the UCKK6.
  • Download "SuperOneClick v2.3.1 - Automatic Driver Installation" from DepositFiles (or look for links here) and extract it to a directory on your hard drive using WinZip or a similar program.
  • Please go the the SuperOneClick thread and read about the tool and how to use it. For Windows XP you need to have .NET Framework v2.0 or above installed. For Mac OS and certain flavors of Linux, you need to install Mono.
  • I have not tested this tool. It is included here because it claims to work for Mac OS and Linux, and provides a way to use the ZergRush Exploit on those operating systems. Since I am only familiar with Windows, I will be unable to support this rooting method. For problems, try posting questions in the SuperOneClick thread linked above.
  • If you try SuperOneClick on Linux or Mac, please post your (success or failure) results. Thanks.

2c.) How to root by flashing Entropy512's Return/Unbrick to Stock, Kernel + Rooted System Package with Modem using Odin3 One-Click Downloader (Windows)
  • Download the "Odin3 One-Click Downloader Stock I-777 UCKH7 with Root no BL" package from Hotfile | Dev-Host 268.64 MB.
  • Extract the contents of the zip file to a directory on your hard disk drive. This is a One-Click version of Entropy512's Return/Unbrick to Stock, Kernel + Rooted System Package plus stock modem from the development forum. (Contains stock zImage, factoryfs.img with root, and modem.bin.)
  • Start the Odin3 One-Click Downloader program by double clicking on "I777UCKH7 OCD With Root.exe".
  • Now Enter Download Mode:
    • With the phone powered off, plug in the usb cable while holding the vol up + vol down buttons (but not the power button).
    • When the warning screen appears, press Volume up to continue into download mode.
  • In Odin, the small edit box in the upper left corner will turn yellow, and say something like [0:COM8]. The number could be different.
  • Click Start. Watch the progress bar advance in green while the message box in the lower area describes the steps. When the flash is finished, the top left larger edit box will turn green and say PASS! and your phone will automatically reboot.
  • Unplug the usb cable from you phone after it boots up. Success. You're Rooted.

2d.) How to root by flashing Entropy512's Return/Unbrick to Stock, Kernel + Rooted System Package from the command line using Heimdall (Linux and Mac OS)
  • Tested on Linux, should work on Mac OS
  • Download and install the latest version of Heimdall Command Line for your operating system from here. (Latest version 1.3.1 at this writing.)
  • Download Entropy512's Return/Unbrick to Stock, Kernel + Rooted System Package from here, or if you have difficulty with the links in his thread, there are alternative links for all his files in the Download Repository toward the bottom. Extract the PDA.tar file from this package to a directory on your hard disk drive, then extract the two component files from the tar - zImage and factoryfs.img.
  • Place zImage and factoryfs.img both in the directory where you have the Heimdall command line executable, and enter the following at the command prompt:
    Code:
    heimdall flash --kernel zImage --factoryfs factoryfs.img
  • Reboot the phone. Success. You're Rooted.


Quote:

You must use a Gingerbread kernel when using this method. If you use an ICS kernel while your phone is running Gingerbread, it will not boot!!!

3a.) How to Install a customized kernel containing ClockworkMod Recovery onto your Rooted phone from your phone, using Mobile Odin Lite or Mobile Odin Pro
  • This is the preferred method to install a customized kernel onto your phone. In addition, Mobile Odin is a very useful tool that will allow you to install custom software directly on your phone without using a computer.
  • Mobile Odin Lite (free) can be downloaded and installed directly on your phone, or it can be downloaded to your computer and installed with adb. Alternatively, you can purchase Mobile Odin Pro for under $5.00 and install it directly from the market. It's easier, and you'll support the developer!
  • To use Mobile Odin Lite, download the file attached to the OP of this thread. You may need to be a registerd member of xda forums to download this file. Download directly on your phone, or to your computer and move or copy it to your phones sdcard. Using any file manager such as MyFiles or Root Explorer, select the file and install it. You can also install it from your computer using the following adb command:
    Code:
    adb install MobileODINLite-v2.30.apk
  • Download the file containing the kernel you want to flash, and extract from it the zImage, which contains the actual kernel. There are several kernels available which can be found in the AT&T SGS II Android Development forum. You must use a Gingerbread kernel! Usually choose between the following two Gingerbread kernels: Entropy512's Daily Driver or Siyah 2.6.
  • Transfer the zImage to the root of your phone's internal or external sdcard, using a usb cable or another method such as dropbox.
  • On your phone, open the Mobile Odin program. If you installed Mobile Odin Lite, when it prompts you to install the add-in, click cancel. If you installed Mobile Odin Pro, you will have already downloaded and installed the add-in to activate all the features in the program. With Mobile Odin Lite, you will still be able to install the kernel.
  • In Mobile Odin, click on Kernel or Install Kernel, find and select the zImage on your internal or external SD card, and then click on Flash Firmware.
  • Mobile Odin will flash the kernel and then reboot the phone. You have now installed a custom kernel containing clockworkMod Recovery without changing the flash counter.
  • If you want to confirm installation of the new kernel, reboot into recovery to verify that you now have ClockworkMod Recovery. (The stock kernel has 3e recovery.) Or install CPU Spy from the Market (before you root) and compare the Kernel Info it displays with the same info from the stock kernel.
  • To reboot into recovery on the SGH-I777: With the phone powered off, hold down the vol up + vol down + power buttons continuously until the initial boot screen appears a second time.
  • The 5.0.2.3 and later versions of ClockworkMod Recovery have a different button configuration. Home = select, Back = back, Power = back from submenu or toggle logo/main menu. The 5.0.2.7 version of ClockworkMod Recovery retains this button configuration but changes it to Power = select.
  • If you installed Mobile Odin Lite, and you don't want to keep it, you can uninstall it now. If you want to keep it and activate all its features, download the add-on MobileODIN_FlashKernel_I777-v1.0.apk from here and install it on your phone with adb using the instructions above.

3b.) How to Install a customized kernel containing ClockworkMod Recovery onto your Rooted phone from a pc, using Android Debug Bridge (Windows, Linux and Mac OS)
  • Download and install the Android Software Developer Kit (SDK) from here. You may need to run SDK Manager with administrator privledges.
  • You need to have the USB drivers for SGH-I777 installed on your computer. (It will be "Samsung USB Driver for Mobile Phones" in Control Panel\Uninstall Programs.) Download and install the latest drivers from this thread. (x86 and x64)
  • Download the file containing the kernel you want to flash, and extract from it the zImage, which contains the actual kernel. There are several kernels available which can be found in the AT&T SGS II Android Development forum. You must use a Gingerbread kernel! Usually choose between the following two Gingerbread kernels: Entropy512's Daily Driver or Siyah 2.6.
  • Move or copy the zImage into the platform-tools directory (on older installations it is the tools directory) where adb.exe resides. This will be something like (on Windows) c:\android-sdk-windows\platform-tools.
  • On your phone, first enable USB Debugging (Menu\Settings\Applications\Development\USB Debugging) and then plug in your USB cable, connecting your phone to your computer.
  • Open a command prompt. Change directory to the tools directory, then enter the following at the command line:
    Code:
    adb push zImage /sdcard/zImage
    adb shell
    $ su
    # dd if=/sdcard/zImage of=/dev/block/mmcblk0p5
    # exit
    $ exit
  • The dd command requires superuser permission on the phone represented by a # prompt. After you type su and hit enter, look for a superuser window on your phone and give the permission. If the permission request doesn't pop up, open superuser on your phone to force the phone to prompt for superuser permission. After approval, the adb session will be listed as Unknown in superuser.
  • After you've finished, the code in the Command prompt window will look something like this (your command prompt and some numbers will be different):
    Code:
    C:\android-sdk-windows\platform-tools>adb push zImage /sdcard/zImage
    4279 KB/s <4776784 bytes in 1.090s>
    C:\android-sdk-windows\platform-tools>adb shell
    $ su
    su
    # dd if=/sdcard/zImage of=/dev/block/mmcblk0p5
    dd if=/sdcard/zImage of=/dev/block/mmcblk0p5
    10153+1 records in
    10153+1 records out
    5198492 bytes transferred in 2.558 secs <2032248 bytes/sec>
    # exit
    exit
    $ exit
    exit
  • Reboot the phone. You have now installed a custom kernel containing clockworkMod Recovery without changing the flash counter.
  • If you want to confirm installation of the new kernel, reboot into recovery to verify that you now have ClockworkMod Recovery. (The stock kernel has 3e recovery.) Or install CPU Spy from the Market (before you root) and compare the Kernel Info it displays with the same info from the stock kernel.
  • To reboot into recovery on the SGH-I777: With the phone powered off, hold down the vol up + vol down + power buttons continuously until the initial boot screen appears a second time.
  • The 5.0.2.3 and later versions of ClockworkMod Recovery have a different button configuration. Home = select, Back = back, Power = back from submenu or toggle logo/main menu. The 5.0.2.7 version of ClockworkMod Recovery retains this button configuration but changes it to Power = select.

3c.) How to Install a customized kernel containing ClockworkMod Recovery onto your Rooted phone from your phone, using Android Terminal Emulator
  • Download and Install Android Terminal Emulator onto your phone from the Market.
  • Download (onto your PC) the file containing the kernel you want to flash, and extract from it the zImage, which contains the actual kernel. There are several kernels available which can be found in the AT&T SGS II Android Development forum. You must use a Gingerbread kernel! Usually choose between the following two Gingerbread kernels: Entropy512's Daily Driver or Siyah 2.6.
  • Transfer the zImage to the root of your phone's sdcard, using a usb cable or another method such as dropbox.
  • On the phone, open a terminal session with Android Terminal Emulator.
  • A few points to be aware of:
    Android is a version of linux so you are using linux commands. Linux commands are case sensitive, so you must for instance type "zImage" and not "zimage", if that is the way the file is spelled on the sd card.
    Since this will be the first time you have used superuser.apk with the terminal, you may need to approve it on you phone. After that, superuser permission will be remembered.
    When you first open a terminal session, you will be at the root of the phone, or essentially "/". The $ prompt means shell access, the # prompt means root file access.
    You need a # prompt to complete this Step.
    If your keyboard goes away, use the menu button options to get it back.
  • In the terminal session, type su and then enter. You will get a superuser request. Once you approve it, you will get the # prompt.
  • Then type the following:
    Code:
    dd if=/sdcard/zImage of=/dev/block/mmcblk0p5
  • Press enter, wait till the zImage is copied over to the named block. (takes about 2 or 3 seconds)
  • To close the root session, type "exit" and enter. Use the back button to close Android Terminal Emulator.
  • Reboot the phone. You have now installed a custom kernel containing clockworkMod Recovery without changing the flash counter.
  • If you want to confirm installation of the new kernel, reboot into recovery to verify that you now have ClockworkMod Recovery. (The stock kernel has 3e recovery.) Or install CPU Spy from the Market (before you root) and compare the Kernel Info it displays with the same info from the stock kernel.
  • To reboot into recovery on the SGH-I777: With the phone powered off, hold down the vol up + vol down + power buttons continuously until the initial boot screen appears a second time.
  • The 5.0.2.3 and later versions of ClockworkMod Recovery have a different button configuration. Home = select, Back = back, Power = back from submenu or toggle logo/main menu. The 5.0.2.7 version of ClockworkMod Recovery retains this button configuration but changes it to Power = select.


4.) Flash the ROM package of your choice using ClockworkMod Recovery and a CWM flashable zip package or Mobile Odin with any package
Your phone is now set up to flash custom software using ClockworkMod zipped install files in ClockworkMod Recovery. If you used and retained Mobile Odin, you can also flash custom software with it. Anything you flash on the phone using ClockworkMod Recovery, Mobile Odin, adb or terminal, will not affect the flash counter or invoke the warning triangle. Therefore, you can flash ROM's Kernels and Modems to your hearts content. Just avoid ever flashing anything containing a non-stock kernel with Odin or Heimdall from your computer. I would also caution against flashing any package with bootloaders. There is no valid reason to flash bootloaders on the SGH-I777 at this time, but some developers may include bootloaders in their CWM flashable zip files, or Odin flashable tar files.
Last edited by creepyncrawly; 11th January 2013 at 10:09 PM.
The Following 171 Users Say Thank You to creepyncrawly For This Useful Post: [ View ]
20th October 2011, 02:02 AM   |  #2  
pinoymutt's Avatar
Senior Member
SoCal
Thanks Meter: 414
 
1,236 posts
Join Date:Joined: Nov 2008
More
Nice write-up. The info has been floating around on various threads and posts, but you did a great job putting all together into one nice step-by-step for folks looking to learn.

Hopefully it'll also cut down on the million of duplicate threads asking the same question!

---------- Post added at 05:02 PM ---------- Previous post was at 04:58 PM ----------

Quote:
Originally Posted by creepyncrawly

Discussion

It has been reported to be possible to remove the warning screen and reset the flash counter by two methods. One is by using a Jig to place the phone into download mode. The other is by flashing a stock kernel using either Odin or Heimdall. However, while it is confirmed that the jig will both remove the triangle and reset the counter, and that flashing a stock kernel with Odin or Heimdall will remove the warning triangle, it is not certain that flashing a stock kernel with Odin or Heimdall will actually reset the flash counter. The developer Chainfire on the i9100 forums says that on the International version of the Galaxy S II, it will not. This is yet to be confirmed or denied on the AT&T version of the phone, as far as I know.

On the newer versions of the i9100 ROMs apparently Samsung has updated the bootloaders to render the "jig trick" to reset the counter useless.

This has also been observed in the latest ATT leak that DG posted in the General Forum (UCKJ2), where new bootloaders are included that render the jig reset obsolete.
The Following 5 Users Say Thank You to pinoymutt For This Useful Post: [ View ]
20th October 2011, 02:07 AM   |  #3  
ceo.mtcl's Avatar
Senior Member
Flag St. Paul, MN
Thanks Meter: 412
 
2,141 posts
Join Date:Joined: Aug 2008
More
Great guide, lots of information in here! Thanks for preparing it.

Sent from my SAMSUNG-SGH-I777 using xda premium
20th October 2011, 03:03 AM   |  #4  
dayv's Avatar
Senior Member
Thanks Meter: 135
 
637 posts
Join Date:Joined: Sep 2010
More
I think this guide is sticky worthy.

Sent from my SAMSUNG-SGH-I777 using XDA App
The Following User Says Thank You to dayv For This Useful Post: [ View ]
20th October 2011, 03:28 AM   |  #5  
dandrumheller's Avatar
Senior Member
Southern Maine / Seacoast NH
Thanks Meter: 714
 
2,463 posts
Join Date:Joined: Jul 2010
More
Awesome guide, thank you for putting this all together in one place. Very helpful for a guy coming to Samsung from HTC.

+1 for sticky worthy!


Sent from my SAMSUNG-SGH-I777 using Tapatalk
The Following User Says Thank You to dandrumheller For This Useful Post: [ View ]
20th October 2011, 03:51 AM   |  #6  
Senior Member
Thanks Meter: 50
 
517 posts
Join Date:Joined: Oct 2011
THANKS! Helped me when I got stuck!

Sent from my SAMSUNG-SGH-I777 using xda premium
The Following User Says Thank You to xAnimal5 For This Useful Post: [ View ]
20th October 2011, 06:25 AM   |  #7  
DoctorQMM's Avatar
Senior Member
Thanks Meter: 634
 
1,078 posts
Join Date:Joined: Feb 2011
This is exactly what I needed.... yesterday (as you know)... my Search and Question buttons almost caught fire from over-use looking for all the pieces of the puzzle. I did the Entropy512 "Kernel + Rooted System Package via Odin3 v1.85.... extracted the zImage from Codeworkx's CWM Kernel, and pushed it to phone via adb push. I got hung up on the "permission" to write to the block, but finally got it solved. Creepyncrawly: you might want to add a bullet step to your OP#1 to open SuperUser app on phone just prior to the adb shell "su" command. When I did this, phone prompted for superuser permission... after acceptance, it is stored as "Unknown" in the superuser app list. Once this occurred, then I got the "#" prompt and could dd write to block to flash CWM.

Absolutely stellar post as it puts it all in one place. This will definitely help others who might stumble in adb as I did. Thanks again to all the forum members who posted helpful advice and links.
The Following User Says Thank You to DoctorQMM For This Useful Post: [ View ]
20th October 2011, 06:58 AM   |  #8  
Twisted Z's Avatar
Member
Flag Seattle Area
Thanks Meter: 4
 
42 posts
Join Date:Joined: Sep 2011
More
DAMN! My JIG just got here!

Thanks for the nice write up!
20th October 2011, 07:55 AM   |  #9  
Alucardis666's Avatar
Senior Member
Miramar
Thanks Meter: 229
 
1,951 posts
Join Date:Joined: Jul 2009
More
Great write up OP. however like the above poster my JIG just got here too and I just used it, and it was quick and painless.
20th October 2011, 12:46 PM   |  #10  
Senior Member
Thanks Meter: 50
 
517 posts
Join Date:Joined: Oct 2011
Quote:
Originally Posted by Alucardis666

Great write up OP. however like the above poster my JIG just got here too and I just used it, and it was quick and painless.

Jigs don't work in 2.3.5 so these methods will be extremely helpful for others

Sent from my SAMSUNG-SGH-I777 using xda premium

The Following User Says Thank You to xAnimal5 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes