• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[Tutorial][S4/S3] How to use OTA zip to get back to Stock OS

Search This thread

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
Lately, many people, including myself, have been at a disadvantage of not having an official RUU for JellyBean so that stock environment can be achieved. Although sometimes, OTA's are available which can do the job. Hence this Tutorial. Also this saves the effort to do S-OFF/SuperCID which often brings along more problems.

This Tutorial, in principle, can be applied to both S4 and S3 variants.

All thanks to @xander1993 at the VilleC2 Development Section who created the original thread Here. Though somewhat unclear and related to VilleC2, I thought of making a thorough guide for Ville with some minor changes.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

For T-MOBILE UK Users: (UK people with other operators e.g Three, Vodafone etc can also try the Jellybean Nandroid backup IF their firmware is upgraded to that of Jellybean)

ICS Users: Those stuck on ICS custom ROMs and can't get stock, Use This RUU to get to stock ICS and then update to Jellybean via System Updates Check. Thanks to @ppm48

Jellybean Users:Those stuck on Jellybean custom ROMs wanting to get stock, I have a Stock Jellybean 4.1.1 Nandroid backup for you guys Here Since there isn't any OTA.zip for T-Mobile UK for Jellybean. You can just flash this Nandroid right away without using this tutorial. Again, Thanks to @ppm48 for this. Also, if you have bootloops after restoring this backup, flash a Jellybean Sense boot.img.

Additionally refer to this post by @mkoev , should prove a lot helpful. Then you can follow the tutorial.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

For OPTUS Users with CID OPTUS001: (All thanks to @salac)

Get the modified OTA.zip Here. by @salac

Follow the instructions from step 12.
Step 14. Flashing the firmware.zip worked the second try for me
Step 22. I did flash the boot.img to make sure it will work since I don't think I had the original one.

Good Luck

Optus users please follow @salac 's post above to flash the OTA.zip


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



Pre-requisites:
1. Notepad++
2. 7-Zip (Recommended)
3. ADB+Fastboot (Get it Here)
4. HTC drivers (Standalone OR HTC Sync Manager Drivers)
5. Unlock_code.bin from HTCDev to unlock bootloader.
6. Any OS (Custom/Stock) present on the phone. (I have not tested it for phones without any OS, you may try it at your own risk and post results here) Not Needed anymore.

Common Steps:

In this guide, I will ask you to go to fastboot/adb so you should know how you would do that. (All fastboot/adb commands are to be given via Command Prompt from PC)

To execute Fastboot Commands:

- Go to fastboot folder on your PC
- Go to fastboot via bootloader on your phone
- Connect the Phone to PC and on the Phone it should say Fastboot - USB Mode
- Now in the fastboot folder on your PC, Hold Shift + Right-Click and click Open Command Window Here
- Now you can enter commands given in the guide for fastboot.

To execute ADB Commands:

- Same procedure except that you don't need to go to fasboot on your phone. You can execute adb commands while in Android OS/desktop.

To boot into Bootloader:

- While the phone is turned off, Press Volume Down + Power Button simultaneously.

OR

- If you are in Android OS, use the following adb command to boot into bootloader:
Code:
adb reboot bootloader

OR

- If you want to reboot into bootloader from fastboot:
Code:
fastboot reboot-bootloader

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Caution for SuperCID users: Please click the CROSS button on your Browser Tab, as flashing this is not intended for you. Either don't flash the OTA.zip, which will brick your phone if you do, OR change your CID to original one. e.g. H3G__001, BM___001, ORANG001


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Procedure:


- ** - ** - ** - Make Nandroid Backups before you do anything, remember you are doing this at your own risk - ** - ** - ** -


1. Download a OTA.zip – Most likely from Here. (You can rename the OTA file which usually has a long name to simply OTA.zip for ease)

2. Extract firmware.zip from OTA.zip. Then extract boot.img from firmware.zip. For now, copy Boot.img to ADB+Fastboot Folder..

3. Now to match the CID of your phone. You can get the CID of your phone via CID Getter from Play Store. Once opened, at the top will be your CID in Red color.

Alternatively, You can also get CID of your phone via Fastboot. Command for that is:
Code:
fastboot getvar cid
and it should display your CID.

4. Inside firmware.zip, look for android-info.txt. Supported CIDs should be mentioned inside this file. If it matches with that of your phone, Proceed otherwise stop and don't put yourself into more problems. (CID Match Exception: This 4th step may not be applicable to you if & only if you are to skip steps 11 to 16, if this is the case, you may flash OTA.zip skipping steps 11 to 16; Read step 10 for more info and then come back here)

5. We need to remove some code lines from inside the OTA.zip. For this, Open the OTA.zip with 7-zip (Right-click ---> 7-zip ---> Open Archive).

6. Head over to META-INF\com\google\android and find a file named updater-script. Drag it out of the archive to the folder/desktop where you can edit it. You should make an extra copy of this file.

7. Once you drag it out, delete the original updater-script inside the archive. It will recompress OTA.zip.

8. Edit with Notepad++ the extracted updater-script file. Find these lines (in the beginning of the file) and delete them altogether:
Code:
[COLOR="Purple"]assert(check_cid(getprop("ro.cid"), "00000000" , "11111111" ,
       "22222222" , "33333333" , "44444444" , "55555555" , "66666666" ,
       "77777777" , "88888888" , "99999999" ,
       "BM___001") == "t");[/COLOR]
ifelse( is_ship_bootloader(getprop("ro.bootloader")) == "t" ,
       assert(check_mid("full", "PJ4011000") == "t");,
       assert(check_mid("simple", "PJ4011000") == "t");
       );
You should delete these lines up to exact semi-colon ; at the end. (the purple lines with different CIDs can be different from those mentioned here, so no need to panic, just delete them)


9. Once edited, Copy this edited updater-script into the OTA.zip archive at the same location from which it was removed. It will recompress OTA.zip. You may now transfer OTA.zip to your SD-Card on your phone.

10. If you previously updated to JellyBean via OTA (Or if you have the exact or newer firmware on your phone than that present inside OTA.zip), skip steps 11 to 16. For example, if you have HBOOT Version 2.15.0000/2.13.0000 or above, it means you have already upgraded to Jellybean firmware so no need for Steps 11 to 16.

In case, if you are to proceed to step 11, that is if you are to flash firmware.zip, make sure to match CID as mentioned in step 4 to avoid any bricks. This is especially useful for those who have ICS and want to get stock JB or those on JB but want complete stock HBOOT, recovery etc.


11. Place firmware.zip extracted from OTA.zip inside ADB + Fastboot Folder.

12. Lock the bootloader, if unlocked. For this, go to fastboot on your phone and give the command:
Code:
fastboot oem lock
The phone reboots after this.


13. While in Android OS/Desktop, fire up Command window on PC to give the following ADB command to boot into OEM Update Mode.
Code:
adb reboot oem-78

OR (if you can't access OS to execute adb)

From Fastboot:

Code:
fastboot oem rebootRUU

You should be seeing HTC logo.


14. While in OEM Update Mode, give the following fastboot command to flash firmware:
Code:
fastboot flash zip firmware.zip
If it fails with error and doesn't show any
Green Progressbar, keep trying the above command. Usually works after a few tries.

********** DO NOT REBOOT MANUALLY UNTIL IT FINISHES FLASHING FIRMWARE OR YOU'LL BRICK YOUR PHONE *************

15. Once firmware is updated, reboot into bootloader. Go into fastboot.

16. Place Unlock_code.bin inside ADB + Fastboot Folder. Use the following fastboot command to unlock your bootloader again. (This will wipe your phone except for SD, so you must make a backup before doing this)

Code:
[COLOR="Blue"]fastboot flash unlocktoken Unlock_code.bin[/COLOR]

17. Download a recovery. Preferred Recovery is TWRP 2.3.3.0 and I have not tested this guide with any other version. Put the recovery in the ADB + Fastboot folder.

18. Now go into bootloader again. This time to flash the recovery anew.

Code:
fastboot flash recovery recovery.img

19. Now go to the recovery via bootloader. Wipe data/factory reset, cache, dalvik.

20. Restore the Nandroid backup you had made earlier.

21. Now Flash the OTA.zip which is on your SD-Card. It should flash fine.

22. Go to fastboot via bootloader. We are now going to flash kernel with the following command, boot.img you had earlier copied to ADB+Fastboot folder.

Code:
fastboot flash boot boot.img

23. Reboot to the OS and you should see complete stock JB OS.


--------------------------------------------------------------------------------------------------------------------------------------------------------

Please Rate the thread and Hit the Thanks button if this tutorial helped you!
 
Last edited:

mortek

Member
Oct 2, 2012
26
2
I am trying to use your method to get back to stock instead of the RUU method since I am on Mac.

The problem I am running into is that the best OS X alternative to 7zip is an app called BetterZip with wich the recompressed OTA.zip is of different size compared to the original (633MB vs. 647.3MB).

Do you think this is likely to cause problems when flashing the modified OTA.zip?
 
Last edited:

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
I am trying to use your method to get back to stock instead of the RUU method since I am on Mac.

The problem I am running into is that the best OS X alternative to 7zip is an app called BetterZip with wich the recompressed OTA.zip is of different size compared to the original (633MB vs. 647.3MB).

Do you think this is likely to cause problems when flashing the modified OTA.zip?

Well, When I edited OTA.zip, it was the same size before/after. But maybe OS X uses different compression values.

I think you should go ahead with it and try it.
 
  • Like
Reactions: Atrax2010 and mkoev

mortek

Member
Oct 2, 2012
26
2
I am stuck.

Since my phone is bricked and it can't boot into the ROM I cannot issue the ADB command from step 13 while in fastboot :/
 

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
I am stuck.

Since my phone is bricked and it can't boot into the ROM I cannot issue the ADB command from step 13 while in fastboot :/

last time you flashed was a Viper rom I think. So What firmware did you flash? if it was that of JB firmware then it's ok to skip the Firmware Flashing steps.

Edit: I have updated step 13. If you can't use ADB, use the fastboot command.
 
Last edited:
  • Like
Reactions: Atrax2010 and mkoev

mortek

Member
Oct 2, 2012
26
2
last time you flashed was a Viper rom I think. So What firmware did you flash? if it was that of JB firmware then it's ok to skip the Firmware Flashing steps.

Edit: I have updated step 13. If you can't use ADB, use the fastboot command.
The OTA.zip was flashed successfully but in the recovery's log there is a line which reads "E:unknown command [firmware]".

The last ROM i flashed was indeed ViperRom but I didn't flash any firmware manually. Should I have done so? I didn't see such an instruction in the respective thread.

Edit:
I just saw your edit. I'll try the fastboot command and report back asap. Thanks.
 
Last edited:

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
The OTA.zip was flashed successfully but in the recovery's log there is a line which reads "E:unknown command [firmware]".

The last ROM i flashed was indeed ViperRom but I didn't flash any firmware manually. Should I have done so? I didn't see such an instruction in the respective thread.

Edit:
I just saw your edit. I'll try the fastboot command and report back asap. Thanks.

Actually, I had read your post where you mentioned that you used AOSP firmware. Maybe that is a bit different than the stock firmware. If it poses problems, you might need to flash the stock one, present inside OTA.zip.

Also flash the stock kernel if you find that the ROM is behaving oddly.
 
  • Like
Reactions: Atrax2010 and mkoev

mortek

Member
Oct 2, 2012
26
2
Actually, I had read your post where you mentioned that you used AOSP firmware. Maybe that is a bit different than the stock firmware. If it poses problems, you might need to flash the stock one, present inside OTA.zip.

Also flash the stock kernel if you find that the ROM is behaving oddly.
The fastboot command worked fine so I flashed the stock firmware and the stock kernel, flashed the OTA.zip, rebooted and I am again stuck in a bootloop :/

Might be the OS X recompression. I will try again with different options.

Most likely the solution should be to get stock recovery, perform a "clear storage" command and then resume flashing. Problem is I am not aware of an alternative to the RUU method for that.
 

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
The fastboot command worked fine so I flashed the stock firmware and the stock kernel, flashed the OTA.zip, rebooted and I am again stuck in a bootloop :/

Might be the OS X recompression. I will try again with different options.

Most likely the solution should be to get stock recovery, perform a "clear storage" command and then resume flashing. Problem is I am not aware of an alternative to the RUU method for that.

Hmmm that's strange.

I had read somewhere that formatting SD card with Stock Recovery corrects some problems while using SD.

Stock Recovery is present inside firmware.zip by the name of recovery.img. might want to flash it and clear storage. Stock recovery can be flashed using the same method as custom recovery. Refer to Steps 17,18 to flash it.
 

mortek

Member
Oct 2, 2012
26
2
Hmmm that's strange.

I had read somewhere that formatting SD card with Stock Recovery corrects some problems while using SD.

Stock Recovery is present inside firmware.zip by the name of recovery.img. might want to flash it and clear storage. Stock recovery can be flashed using the same method as custom recovery. Refer to Steps 17,18 to flash it.
I flashed the stock recovery but I am still having bootloops with the stock ROM :(

Although, I flashed Viper rom and after several reboots it finally booted!

The truth is that I am not sure the sdcard won't get corrupt the next time my phone reboots, but its better than having a bricked phone.

I'll keep on digging on the sdcard corruption by reboot issue.

Thanks again.
 
  • Like
Reactions: khan.orak

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
I flashed the stock recovery but I am still having bootloops with the stock ROM :(

Although, I flashed Viper rom and after several reboots it finally booted!

The truth is that I am not sure the sdcard won't get corrupt the next time my phone reboots, but its better than having a bricked phone.

I'll keep on digging on the sdcard corruption by reboot issue.

Thanks again.

After this, the last thing on my mind is the HBOOT. You can flash original HBOOT 2.15 anew with the help of this post http://forum.xda-developers.com/showpost.php?p=39216236&postcount=274

But if the bootloops persist even after trying all of this, maybe the car charger has done something to the battery or some other hardware part.

Best of luck!
 
  • Like
Reactions: Atrax2010 and mkoev

mortek

Member
Oct 2, 2012
26
2
After this, the last thing on my mind is the HBOOT. You can flash original HBOOT 2.15 anew with the help of this post http://forum.xda-developers.com/showpost.php?p=39216236&postcount=274

But if the bootloops persist even after trying all of this, maybe the car charger has done something to the battery or some other hardware part.

Best of luck!
I rebooted the phone in order to flash an OTA for the Viper ROM and I went into the familiar bootloop again.

So I tried flashing the original HBOOT 2.15 using the method you pointed out and I got this reply:

sending 'zip' (400 KB)...
OKAY [ 0.226s]
writing 'zip'...
(bootloader) zip header checking...
(bootloader) zip info parsing...
FAILED (remote: 99 unknown fail)
finished. total time: 1.735s

I then tried clearing storage with stock recovery but once again I am stuck with that bootloop. :s
 

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
I rebooted the phone in order to flash an OTA for the Viper ROM and I went into the familiar bootloop again.

So I tried flashing the original HBOOT 2.15 using the method you pointed out and I got this reply:

...........

I then tried clearing storage with stock recovery but once again I am stuck with that bootloop. :s

I suspect hardware failure.

Sent from my HTC One S using Tapatalk 4 Beta
 
  • Like
Reactions: Atrax2010

booenson

Member
Feb 8, 2013
24
0
Trying to get back to stock so I can send my phone in for repairs, followed all your steps, and I'm coming from TrickDroid 10. Previously, I had the Rogers/Fido 4.1.1 OTA which brought my hboot to 2.15. I downloaded this OTA , followed all your steps exactly but when I tried flashing the OTA.zip I get the following error:

E:Error in /sdcard/OTA.zip
(Status 6)
Error flashing zip '/sdcard/OTA.zip'
Updating partition details...

Then in bold, red letter it says "Failed" near the menus.
 

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
Trying to get back to stock so I can send my phone in for repairs, followed all your steps, and I'm coming from TrickDroid 10. Previously, I had the Rogers/Fido 4.1.1 OTA which brought my hboot to 2.15. I downloaded this OTA , followed all your steps exactly but when I tried flashing the OTA.zip I get the following error:

E:Error in /sdcard/OTA.zip
(Status 6)
Error flashing zip '/sdcard/OTA.zip'
Updating partition details...

Then in bold, red letter it says "Failed" near the menus.

What recovery did you use? And did you edit updater script using notepad++?

Edit: Yup, after searching, Error Status 6 appears when you edit the UPDATER-SCRIPT using wordpad/windows editor which messes all that is inside it. Use Notepad++
 
Last edited:

booenson

Member
Feb 8, 2013
24
0
What recovery did you use? And did you edit updater script using notepad++?

TWRP 2.4.1.0. No, I used notepad, but after googling and reading the differences between notepad++ and notepad, I will have to re edit with notepad++. Will try again tomorrow when I have more time, I still need to use this phone for work and can't have it bricked lol
 

booenson

Member
Feb 8, 2013
24
0
Tried this again, flash went through and then flashed the boot.img included with the OTA zip, and my phones stuck at the "htc one" loading screen

Edit: relocked, flashed the stock recovery, thought it was still stuck at the loading screen so I unlocked it then went to install TWRP again to restore my nandroid, and it decided to finally boot. I guess I just needed to give it more time, currently back on 4.1.1, time to send this thing in under warranty so I can get my 3G/HSPA+ fixed. Thanks!
 
Last edited:

khan.orak

Senior Member
Jun 26, 2012
760
284
Peshawar
Just wondering, am I able to use an ota from another carrier to update my firmware and hboot as long as it fits my Cid? I believe my Cid is the global 001

Sent from my One S using xda app-developers app

I think yes. You can check if you CID is supported. It is inside the OTA.zip\firmware.zip, a file named android-info.txt and the supported CIDs will be there.

Edit: You should first check your CID. Download CID GETTER from Play Store. Shows CID in red on top.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    Lately, many people, including myself, have been at a disadvantage of not having an official RUU for JellyBean so that stock environment can be achieved. Although sometimes, OTA's are available which can do the job. Hence this Tutorial. Also this saves the effort to do S-OFF/SuperCID which often brings along more problems.

    This Tutorial, in principle, can be applied to both S4 and S3 variants.

    All thanks to @xander1993 at the VilleC2 Development Section who created the original thread Here. Though somewhat unclear and related to VilleC2, I thought of making a thorough guide for Ville with some minor changes.

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    For T-MOBILE UK Users: (UK people with other operators e.g Three, Vodafone etc can also try the Jellybean Nandroid backup IF their firmware is upgraded to that of Jellybean)

    ICS Users: Those stuck on ICS custom ROMs and can't get stock, Use This RUU to get to stock ICS and then update to Jellybean via System Updates Check. Thanks to @ppm48

    Jellybean Users:Those stuck on Jellybean custom ROMs wanting to get stock, I have a Stock Jellybean 4.1.1 Nandroid backup for you guys Here Since there isn't any OTA.zip for T-Mobile UK for Jellybean. You can just flash this Nandroid right away without using this tutorial. Again, Thanks to @ppm48 for this. Also, if you have bootloops after restoring this backup, flash a Jellybean Sense boot.img.

    Additionally refer to this post by @mkoev , should prove a lot helpful. Then you can follow the tutorial.

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    For OPTUS Users with CID OPTUS001: (All thanks to @salac)

    Get the modified OTA.zip Here. by @salac

    Follow the instructions from step 12.
    Step 14. Flashing the firmware.zip worked the second try for me
    Step 22. I did flash the boot.img to make sure it will work since I don't think I had the original one.

    Good Luck

    Optus users please follow @salac 's post above to flash the OTA.zip


    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    Pre-requisites:
    1. Notepad++
    2. 7-Zip (Recommended)
    3. ADB+Fastboot (Get it Here)
    4. HTC drivers (Standalone OR HTC Sync Manager Drivers)
    5. Unlock_code.bin from HTCDev to unlock bootloader.
    6. Any OS (Custom/Stock) present on the phone. (I have not tested it for phones without any OS, you may try it at your own risk and post results here) Not Needed anymore.

    Common Steps:

    In this guide, I will ask you to go to fastboot/adb so you should know how you would do that. (All fastboot/adb commands are to be given via Command Prompt from PC)

    To execute Fastboot Commands:

    - Go to fastboot folder on your PC
    - Go to fastboot via bootloader on your phone
    - Connect the Phone to PC and on the Phone it should say Fastboot - USB Mode
    - Now in the fastboot folder on your PC, Hold Shift + Right-Click and click Open Command Window Here
    - Now you can enter commands given in the guide for fastboot.

    To execute ADB Commands:

    - Same procedure except that you don't need to go to fasboot on your phone. You can execute adb commands while in Android OS/desktop.

    To boot into Bootloader:

    - While the phone is turned off, Press Volume Down + Power Button simultaneously.

    OR

    - If you are in Android OS, use the following adb command to boot into bootloader:
    Code:
    adb reboot bootloader

    OR

    - If you want to reboot into bootloader from fastboot:
    Code:
    fastboot reboot-bootloader

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    Caution for SuperCID users: Please click the CROSS button on your Browser Tab, as flashing this is not intended for you. Either don't flash the OTA.zip, which will brick your phone if you do, OR change your CID to original one. e.g. H3G__001, BM___001, ORANG001


    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Procedure:


    - ** - ** - ** - Make Nandroid Backups before you do anything, remember you are doing this at your own risk - ** - ** - ** -


    1. Download a OTA.zip – Most likely from Here. (You can rename the OTA file which usually has a long name to simply OTA.zip for ease)

    2. Extract firmware.zip from OTA.zip. Then extract boot.img from firmware.zip. For now, copy Boot.img to ADB+Fastboot Folder..

    3. Now to match the CID of your phone. You can get the CID of your phone via CID Getter from Play Store. Once opened, at the top will be your CID in Red color.

    Alternatively, You can also get CID of your phone via Fastboot. Command for that is:
    Code:
    fastboot getvar cid
    and it should display your CID.

    4. Inside firmware.zip, look for android-info.txt. Supported CIDs should be mentioned inside this file. If it matches with that of your phone, Proceed otherwise stop and don't put yourself into more problems. (CID Match Exception: This 4th step may not be applicable to you if & only if you are to skip steps 11 to 16, if this is the case, you may flash OTA.zip skipping steps 11 to 16; Read step 10 for more info and then come back here)

    5. We need to remove some code lines from inside the OTA.zip. For this, Open the OTA.zip with 7-zip (Right-click ---> 7-zip ---> Open Archive).

    6. Head over to META-INF\com\google\android and find a file named updater-script. Drag it out of the archive to the folder/desktop where you can edit it. You should make an extra copy of this file.

    7. Once you drag it out, delete the original updater-script inside the archive. It will recompress OTA.zip.

    8. Edit with Notepad++ the extracted updater-script file. Find these lines (in the beginning of the file) and delete them altogether:
    Code:
    [COLOR="Purple"]assert(check_cid(getprop("ro.cid"), "00000000" , "11111111" ,
           "22222222" , "33333333" , "44444444" , "55555555" , "66666666" ,
           "77777777" , "88888888" , "99999999" ,
           "BM___001") == "t");[/COLOR]
    ifelse( is_ship_bootloader(getprop("ro.bootloader")) == "t" ,
           assert(check_mid("full", "PJ4011000") == "t");,
           assert(check_mid("simple", "PJ4011000") == "t");
           );
    You should delete these lines up to exact semi-colon ; at the end. (the purple lines with different CIDs can be different from those mentioned here, so no need to panic, just delete them)


    9. Once edited, Copy this edited updater-script into the OTA.zip archive at the same location from which it was removed. It will recompress OTA.zip. You may now transfer OTA.zip to your SD-Card on your phone.

    10. If you previously updated to JellyBean via OTA (Or if you have the exact or newer firmware on your phone than that present inside OTA.zip), skip steps 11 to 16. For example, if you have HBOOT Version 2.15.0000/2.13.0000 or above, it means you have already upgraded to Jellybean firmware so no need for Steps 11 to 16.

    In case, if you are to proceed to step 11, that is if you are to flash firmware.zip, make sure to match CID as mentioned in step 4 to avoid any bricks. This is especially useful for those who have ICS and want to get stock JB or those on JB but want complete stock HBOOT, recovery etc.


    11. Place firmware.zip extracted from OTA.zip inside ADB + Fastboot Folder.

    12. Lock the bootloader, if unlocked. For this, go to fastboot on your phone and give the command:
    Code:
    fastboot oem lock
    The phone reboots after this.


    13. While in Android OS/Desktop, fire up Command window on PC to give the following ADB command to boot into OEM Update Mode.
    Code:
    adb reboot oem-78

    OR (if you can't access OS to execute adb)

    From Fastboot:

    Code:
    fastboot oem rebootRUU

    You should be seeing HTC logo.


    14. While in OEM Update Mode, give the following fastboot command to flash firmware:
    Code:
    fastboot flash zip firmware.zip
    If it fails with error and doesn't show any
    Green Progressbar, keep trying the above command. Usually works after a few tries.

    ********** DO NOT REBOOT MANUALLY UNTIL IT FINISHES FLASHING FIRMWARE OR YOU'LL BRICK YOUR PHONE *************

    15. Once firmware is updated, reboot into bootloader. Go into fastboot.

    16. Place Unlock_code.bin inside ADB + Fastboot Folder. Use the following fastboot command to unlock your bootloader again. (This will wipe your phone except for SD, so you must make a backup before doing this)

    Code:
    [COLOR="Blue"]fastboot flash unlocktoken Unlock_code.bin[/COLOR]

    17. Download a recovery. Preferred Recovery is TWRP 2.3.3.0 and I have not tested this guide with any other version. Put the recovery in the ADB + Fastboot folder.

    18. Now go into bootloader again. This time to flash the recovery anew.

    Code:
    fastboot flash recovery recovery.img

    19. Now go to the recovery via bootloader. Wipe data/factory reset, cache, dalvik.

    20. Restore the Nandroid backup you had made earlier.

    21. Now Flash the OTA.zip which is on your SD-Card. It should flash fine.

    22. Go to fastboot via bootloader. We are now going to flash kernel with the following command, boot.img you had earlier copied to ADB+Fastboot folder.

    Code:
    fastboot flash boot boot.img

    23. Reboot to the OS and you should see complete stock JB OS.


    --------------------------------------------------------------------------------------------------------------------------------------------------------

    Please Rate the thread and Hit the Thanks button if this tutorial helped you!
    3
    The fastboot command worked fine so I flashed the stock firmware and the stock kernel, flashed the OTA.zip, rebooted and I am again stuck in a bootloop :/

    Might be the OS X recompression. I will try again with different options.

    Most likely the solution should be to get stock recovery, perform a "clear storage" command and then resume flashing. Problem is I am not aware of an alternative to the RUU method for that.

    Hmmm that's strange.

    I had read somewhere that formatting SD card with Stock Recovery corrects some problems while using SD.

    Stock Recovery is present inside firmware.zip by the name of recovery.img. might want to flash it and clear storage. Stock recovery can be flashed using the same method as custom recovery. Refer to Steps 17,18 to flash it.
    2
    I am trying to use your method to get back to stock instead of the RUU method since I am on Mac.

    The problem I am running into is that the best OS X alternative to 7zip is an app called BetterZip with wich the recompressed OTA.zip is of different size compared to the original (633MB vs. 647.3MB).

    Do you think this is likely to cause problems when flashing the modified OTA.zip?

    Well, When I edited OTA.zip, it was the same size before/after. But maybe OS X uses different compression values.

    I think you should go ahead with it and try it.
    2
    I am trying to use your method to get back to stock instead of the RUU method since I am on Mac.
    .......................

    Do you think this is likely to cause problems when flashing the modified OTA.zip?

    Can you use Winzip/Winrar? Might want to check with those two..
    2
    I am stuck.

    Since my phone is bricked and it can't boot into the ROM I cannot issue the ADB command from step 13 while in fastboot :/

    last time you flashed was a Viper rom I think. So What firmware did you flash? if it was that of JB firmware then it's ok to skip the Firmware Flashing steps.

    Edit: I have updated step 13. If you can't use ADB, use the fastboot command.