WARNING!!

upgrading the firmware of an unlocked iPhone can permanently destroy your unlock if not done correctly. That phone was in perfect working order when you received it. i cannot he held responsible for any mistakes made in following these instructions nor for any other failures. in other words, no guaranty expressed or implied. Even if everything goes correctly, all data will be destroyed on the phone. it will be like a new phone running 5.0.1. Backup anything you want to keep before you start.

Understanding that. . .

Start downloading one of these files:
iPhone 4 iPhone3,1_5.0.1_9A405_Custom_Restore-SAM-activate.ipsw
iPhone 3gs iPhone2,1_5.0.1_9A405_Custom_Restore-SAM-activate.ipsw

Goto: http://blog.iphone-dev.org/

Download Redsn0w 0.9.10b3 for your computer.

Remove SIM
Run Redsn0w
Select Extras
Select Pwned DFU
follow instructions to enter DFU mode

when redsn0w is done, Start iTunes, and it will detect an iPhone in recovery mode (but the screen will be black)
allow it to check with apple's servers, however, you must hold down shift (or option on a mac) when clicking restore in iTunes.

this will allow you select the modified ipsw i created for you. this will restore your phone to a fresh unactivated but unlocked state.

Now we must activate the phone. . .

I have bundled into the package such software. It will install automatically when the phone starts up for the first time. This will cause the phone to seem to run VERY slowly and possibly even completely unresponsive. Please be patient. After the phone finishes the install (about 10 minutes from the completion of the Restore), restart the phone. if the phone is not responsive. . . hold the top (sleep) and the bottom (home) buttons for 10 seconds.

When the phone comes back up, you will be guided through the setup process, and with internet, it should actually activate properly (a neat hack). Now you should be able to insert your sim and use your phone. Restore data from itunes. and enjoy.