If you accidentally try and upgrade your iPhone 3GS through iTunes after having previously jailbroke it, it will get stuck in recovery mode and fail to restore to the official Apple firmware bundles IPSW. You will get a whole bunch of iTunes errors like 1015.
The iPhone needs to be restored with the custom IPSW used to jailbreak the iphone in the first place.
This guide specifically deals with the iPhone 3GS, on a custom firmware of iOS 4.2.1 or 4.3.3 and an updated iPad Baseband 0f 6.15.00
A Custom Restore Image 4.3.3 IPSW if you have lost your own, one is filed here with a prefix of NO_BB so it will preserve your existing baseband.
1) Make sure iTunes is not running.
1) Launch redsn0w > Browse – select the original Apple Restore Image IPSW – iPhone2,1_4.2.1 or iPhone2,1_4.3.3
2) Select your correct model according to the Serial Number – let redsn0w parse the image
3) Select only “Just enter pwned phone in DFU mode right now”
4) Follow the steps in redsn0w to get the iPhone 3GS into DFU mode which is going to send the screen to black
5) Launch iTunes, hold the shift/option key whilst clicking on “Restore”, then navigate and choose the custom restore – either your own or the downloaded one that starts with NO_BB (which preserves the existing baseband).
6) Say a prayer
7) You should now boot up to a familiar screen, happy days!
8 ) Restore data from iTune backup.
1) Launch redsn0w this time selecting the original Apple restore image – iPhone2,1_4.2.1_8C148a_Restore.ipsw, or iPhone2,1_4.3.3_8J2_Restore.ipsw and only select the option to “Install Cydia”.
2) It will need to enter DFU mode again, follow the steps and the screen goes black, and then the jailbreak process begins, unix flying bash code and running pineapples.
3) iPhone reboots – install ultrasn0w from Cydia to re- jailbreak the device.