[Droid Incredible Android Development] xraystyle:
The other day my phone's touchscreen developed a dead spot. Verizon was kind enough to send me a "Like-New" replacement and requested that I return the old phone. The only problem with that was I had hacked the hell out of it and didn't want them to see what I did and charge me.

I had rooted the phone, installed Clockwork Recovery, set S-OFF with Unrevoked Forever, updated to the latest radio and installed all kinds of different ROMs before finally settling on CM6. Now I had to find a way to install either stock 2.1 or stock 2.2 with the correct radio for either one, flash back the stock recovery, and finally set the phone back to S-ON. If you find yourself in a similar situation, you'll probably want to read this instead of spending 6 hours pulling your hair out, like I did. Here's what I finally came up with:

STEP 1: Get ADB Running.

Make sure you have ADB up and running. If you're rooted with a custom ROM and you don't have ADB running you have more problems than I can help you with. If you use a Mac, see Step 1A below to make things a little easier when using ADB.

Step 1A: (Mac Users Only) Make Your Life Easier.

Let's add the android SDK tools folder to your .bash_profile. What does this do, you ask? It makes it so that you can run any ADB commands without having to be in your SDK Tools directory. How do we do this?

Open a terminal window. Type

nano ~/.bash_profile

This will open a text editor in the terminal and create a new text file in your home directory called .bash_profile, which will be invisible in the Finder.

Enter the following:

PATH=$PATH:/Applications/Utilities/android-sdk-mac_86/tools
export PATH

!!IMPORTANT!! I have my "android-sdk-mac_86/tools" folder inside my "Utilities" folder, which is inside the "Applications" folder. If you have your android sdk folder somewhere else you will have to change the above text to reflect the proper path to your folder.

Hit ctrl-x. Not cmd-x, ctrl-x.

The editor will ask you if you want to save changes. Press "Y".

It will ask you what you want the file name to be. Just press enter, as we've already named it .bash_profile.

Quit and re-open terminal.

You can now use any command in the SDK tools folder from any directory.

STEP 2: Install Fastboot.

Make sure you have the HTC Fastboot tool installed. If you don't, you can get it here: http://developer.htc.com/adp.html

Download it for your particular operating system.

Another tip for Mac users: Once you download and unzip it, rename it from "fastboot-mac" to just "fastboot", then place it in your SDK Tools directory. ;)

STEP 3: Downgrade To 2.1 With Old Radio.

We now need to downgrade our radio and get back to stock 2.1. The best way I found to do this was explained in this thread: http://xdaforums.com/showthread.php?t=757927

Download the zip and follow the instructions.

Hat tip to Berzerker7 for the write-up, and aiccucs for putting together the zip file in that thread.

The next step will be a little bit of backtracking, but it's mostly painless, and it still seems to be the easiest way to do this.

STEP 4: Set NAND To S-ON.

We now need to set the NAND to S-ON. Problem is, in step 3 we flashed the stock recovery back onto the phone. Not a huge issue.

First, go to unrevoked.com and download unrevoked3. Run it. This will re-root the phone and install Clockwork recovery. Once this is done, go here: http://unrevoked.com/rootwiki/doku.php/public/forever and download the unrevoked-forever S-ON Tool.

Copy this file to your SD card and rename it "update.zip"

You can do that with adb like this:

adb push /path/to/unrevoked-forever-son.zip /sdcard/update.zip

Reboot into recovery and use Clockwork to apply the patch, which will set the NAND back to S-ON.

STEP 5: Get The Phone To Accept Stock Recovery With S-ON

This was the biggest problem that I ran into. The phone would regurgitate every zip I found which contained a stock recovery when the phone was set S-ON. I finally found a way around that.

First, download this PB31IMG.zip file: http://d01.megashares.com/index.php?d01=CHoQD3B

This IMG file was posted by Diego Mejia, on a youtube video he uploaded. Thanks to Diego, his work was very helpful in this process.

Here's the catch: in order to apply this PB31IMG.zip, we need to downgrade HBOOT or we'll get an error, due to the fact that we had set S-ON in the previous step.

Here is a link to a post on androidforums.com with an attached zip file called "revert.zip": http://androidforums.com/incredible-all-things-root/123816-how-revert-back-earlier-version-hboot.html

Credit is due to adrynalyne for coming up with this process and posting the files, I just tweaked his instructions a bit to make them work for me.

Once the "revert.zip" file has been downloaded, follow adrynalyne's instructions on what to do with the files. Reposted below:

If the "fastboot" command works you should see an "H" followed by a string of random numbers and letters. So far, so good.

STEP 6: Reapply Stock 2.1 With Stock Recovery.

Once you've run the "fastboot" command successfully, go ahead and pull the battery. Leave the phone off. Go back to the PB31IMG.zip you downloaded in step 5, and copy it to the root of your SD card. Put the SD card back in the phone and boot it into recovery. If you've done all this correctly, the phone should recognize the PB31IMG.zip as valid and ask if you want to apply it. Do so. This will reflash the stock 2.1 ROM with the stock recovery while the phone is set S-ON. You can now send your phone back to Verizon.

STEP 7: Profit.

--B