[G2 and Desire Z Android Development] marc91988:
** I AM NOT LIABLE IF YOU BRICK YOUR PHONE OR ANY DAMAGE CAUSED BY YOUR STUPIDITY**

This guide will follow the steps needed to remove permanent root and bring your device back to 100% stock

Here are the following files we will need to download please grab the files needed below and place them on the root of your sdcard

1-a) Stock PRE-OTA Rom rooted:

Stock PRE-OTA Rom

or

1-b) Download the attached HexEditor on the thread

2.) Stock Factory Bootloader / Recovery / ROM / Kernel:

Stock Factory Bootloader / Recovery / ROM / Kernel

(rename this to PC10IMG.ZIP)

3.) T-Mobile OTA Update - Build # 1.22.531.8:

T-Mobile OTA Update

(rename this to update.zip)

Procedure:

Step 1.) Flash Stock Rooted PRE-OTA Rom via ClockWorkMod

Open up RomManger via the Android Launcher and select "Install ROM from SD Card" and select the "stock_root.zip" on the root of the sdcard and select the option to "Wipe Data and Cache" and hit ok. Once rom is flashed it will reboot automatically and bring you back to the os.

**IMPORTANT**

If the flash has failed you must reboot back into the OS and use HexEditor which i have attached to the thread. DO NOT PROCEED UNTIL YOU HAVE DONE THIS!!

Open up an ADB Shell and run the following command:

dd if=/dev/block/mmcblk0p17 of=/sdcard/misc.img

this will then export the misc.img file we need to edit to the root of the sdcard.

Mount your sdcard and save the misc.img file to your PC and Open the file with HexEditor.

You should now see the version number on the right hand side of the application and it should read "1.22.531.8" YOU MUST CHANGE THIS TO "1.19.531.1" you can now save the file as miscnew.img and place it on the root of your sdcard and then unmount the sdcard from windows.

Now go back to your ADB Shell and run the following command

dd if=/sdcard/miscnew.img of=/dev/block/mmcblk0p17

you can now make sure you have copied the PC10IMG.zip file to the root of your SDCARD and power off your phone and proceed to step 2.

*All Credit goes to Apache14 for this method which is in this thread:

http://xdaforums.com/showthread.php?t=831398

Step 2.) Restore factory BOOTLOADER, RECOVERY, KERNEL, ROM (THIS RE-ENABLES S-ON)

Place the factory firmware you downloaded in step 2 above on the root of your sdcard and rename it to PC10IMG.zip one you have done this power off the device and power back on by holding volume down and power. Once in the bootloader it will then scan your sdcard and find the file needed, be patient this can take quite a few minutes. After it finishes scanning you will then have to hit the Volume up key on the side of the phone to restore the software. This will take approximately 5-10 minutes. The phone will reboot in the middle of the update to restore S-ON once rebooted it will then scan sdcard again and resume flashing. Once completed you will have to hit Power to reboot and boot back into the factory restored android os.

Step 3.) -OPTIONAL- Apply OTA Update from T-Mobile

Boot back into android and mount your sdcard once again. You will now delete the PC10IMG.zip file we copied previously. Once you have deleted the file copy the file we downloaded in step 3 above to the root of the sdcard and rename it to “update.zip”. You can now power down your device and power back on holding volume down and power. Once in the bootloader wait 5-10 for it to finish scanning your sdcard and hit volume down and power to select RECOVERY. Once in recovery mode you must now hold volume up and power on your G2. You will now hit volume down and power to select "apply sdcard:update.zip" It will then scan your sdcard verify the update.zip file we placed on the root of the sdcard and proceed to install. You will then have to hit power once more to reboot when indicated on the device. This will now take approximately another 5 minutes and the phone will reboot 2 times automatically do not touch until you are booted automatically back into android.

You are now 100% Back to stock with S-ON, Factory ROM, and Factory Recovery.