Today we are going to cover how to successfully downgrade the iPhone from OS 4 beta (iPhone 4.0) back to iPhone 3.1.3. If you're a small developer who installed the iPhone OS 4 beta then realized you had to troubleshoot problems for an existing app under 3.1, it can sometimes come down to this or having to quickly go shopping for a second iPhone or iPod touch. Luckily, downgrading can be done pretty easily a majority of the time, even though things sometimes go downhill, like DFU loops, errors, etc.. We will cover these scenarios right now and hopefully get a lot of people where they need to be. I'll show you two ways to downgrade, through XCode (Mac only) and through iTunes (Mac and PC).
And as always, if you are even a little scared you may mess up your phone during this process, stop right now. What you do to your phone is always on you. These guides are there for your convenience, but we hold no responsibility for any bricked iDevices of any kind.
If that didn't scare the pants off of you, hit the jump for screenshots, a written walk-through, and a video!
First of all, we need to differentiate between firmware and a baseband as a lot of people seem to get those confused. Firmware is the actual software your phone is running, which in most cases can be downgraded easily. A baseband however can NOT be downgraded as easy. This is part of what makes a phone unlockable (when the baseband is cracked).
Currently, iPhone firmware 3.1.3 and above can not be unlocked as the baseband version changed. So if you are trying to downgrade in order to get your unlock back, don't bother with this process. Your baseband will currently remain at the 4.0 baseband. Even when you downgrade successfully, your baseband will remain the same, ruining your chances at having your unlock back.
What I'm getting at here is, do not downgrade in hopes of getting an unlock back. If you've installed 3.1.3 and higher, there is no unlock released. The only way you can unlock 3.1.3 is to have an older bootrom that was not upgraded (meaning you upgraded to 3.1.3 from a custom firmware ipsw, not the official 3.1.3).
The easiest way to downgrade is going to be to go through XCode on a Mac. If you're just going through XCode, simply choose 3.1.3 from your available firmwares, and voila, your phone will restore. If you are a licensed dev, you should have no problem going this route. No errors, nothing. You will not need the packages listed above (at least you shouldn't). Open XCode and go to Organizer...
Then choose 3.1.3...
If you do get stuck in a DFU loop or get an error, jump down to the iTunes directions and continue from there (typically error 1015 or a DFU loop, which is where you need iRecovery - covered below and in video). I did not include an XCode walkthrough in the video as it's extremely simple and painless if done correctly.
Even though I am covering a PC downgrade, you should NEVER ever install a beta OS through a PC. That is not the way they were meant to be installed. Betas should NEVER be installed through iTunes, always through XCode on a Mac. Especially with 4.0. The file system changed and iTunes will install the old way, creating crashes and all kinds of other nastiness. Even though I am giving instructions for PC downgrade, I have no way to test them, if there are issues, please let me know so I can correct them.
Alright, now on to what you'll need to have beforehand -
Here is what you need to download to your computer (to your desktop is easiest):
After you have downloaded the files above, install libusb and iRecovery (PC, you don't install iRecovery, you run it through command prompt). Then plug in your iPhone. Open iTunes and hold down alt/option and click restore (ctrl click on a PC). Now navigate to where you saved your firmware like below (I have a folder on my desktop called iPhone firmwares).
Wait for your phone to go through the restore process (I would normally of told you to backup before doing any of this, but as 4.0 does not support backups yet, that isn't possible. Hopefully you backed up your data before 4.0 so you can restore from that).
Your phone will not complete the downgrade, it will give you an error like below, that's OK.
Next, open iRecovery. There are 2 versions of iRecovery. One you have to manually enter commands, the other, fast version is a button click. So for Mac users, open the faster iRecovery and click the button. iRecovery will reboot your phone and you "should" be done and able to sync and restore like normal through iTunes (you are done if you have a screen showing "Slide for Emergency", if you still have "Connect to iTunes", skip to the section titled "Still Stuck"). For PCs who need to enter commands into your command prompt, type the commands in this order:
If you are still stuck in DFU, continue, if you have "Slide for emergency" (below), you are done, sync like normal. "Connect to iTunes" (below) is bad, so continue on...
When I decided to downgrade, my phone was stuck in a hopeless loop of DFU fail. I found a way around this with blackra1n.
First, download blackra1n to your computer. Launch it, and click "make it ra1n". Wait about 30 seconds, your screen should be black but not off.
UNPLUG your phone and hard reboot it. When it comes back on, you should now have "Slide for Emergency" and be able to sync like normal. blackra1n will not jailbreak your phone, so if you want a Jailbreak, use Spirit afterwards (see my Spirit Jailbreak for iPhone 3.1.3 walkthrough). But it will get your phone out of DFU mode.
Just a side not: Anytime you restore you may have to repeat this process as a clean restore may still fail (at least until 4.0 official drops and you upgrade to that). Forcing your iPhone out of DFU mode can cause restores to act funky, so just save these steps for further reference. You should now be able to backup and sync like normal though.
Questions, problems? Let us know in the comments or in the TiPb Jailbreak Forum!