Unlocked iPhone 3G with 3.1.3

Jenn had been carrying around both her Samsung M300 and iPod Touch, far too often the phone wasn’t charged. Merging the two devices into an iPhone seemed like a sensible move.  She’s somewhat frugal like myself and doesn’t want to carry the cost of a data plan, so an unlocked phone seemed like the best path forward.

My first step was to locate a reasonably priced used iPhone.  With the new iPhone 4 out, you can just go pay full ticket and get an unlocked version if you want.  Yet, with the new model out – there are plenty of 3G and 3Gs devices on the used market.  I watched both usedottawa.com and ottawa.kijiji.com looking for a deal.  A good price was looking like $230 or so for the 3G, and $300 for the 3Gs (the 8Gb versions).

It only took a couple of days watching to come across a 3G going for a good price and I snapped it up.  There was one small snag when the previous owner decided to wipe the phone before I picked it up, they failed to plug it into power during the wipe and the battery gave out. This meant that the phone was non-functional when I got it, but as a bonus I ended up with a lower price.

Recovering from a bad wipe (or any other snafu with an iPhone) can usually be accomplished – you need to get into recovery mode, or if that doesn’t work device firmware update (DFU) mode. In my case DFU mode was what I needed. To get into DFU mode:

  1. Plug the phone into your PC
  2. Power it off
  3. Hold the Home button
  4. Hold the power/wake/sleep button
  5. After 10 seconds, release the power/wake/sleep button – keep holding Home
  6. Once iTunes detects the phone in recovery mode, release Home

The next step was to jailbreak the iPhone, this is necessary to install the unlock. Since I was using Windows to do this work (I didn’t want to mess with Jenn’s Mac) many of the how to guides didn’t apply.  I found one on iClarified.com that did work for me. There is some confusion as to if you need a SIM card to allow you to jailbreak with redsn0w or not – I did not need one installed at all in order to complete the jailbreak.  I simply followed the entire guide (including step 2) as I didn’t care about reflashing the 3.1.3 firmware (again).  It was easy – but pretty scary.  Read the guide completely and carefully.

After you’ve run redsn0w, you’ll probably want to reboot your windows box.  I found that without a reboot iTunes was not happy about the phone.

Now that you’ve got a jailbroken phone, you can install ultrasn0w to unlock it. The version of Cydia that was installed already had the correct repository enabled, so it was just a matter of installing it via Cydia.  I did find that Cydia was very slow, you need to be patient the refresh does take forever (15mins?).

Reboot the phone, install SIM card. Tada – I’m rocking an unlocked iPhone 3G. So very tempting to install this as the boot logo.

For what it’s worth, I did actually run through the entire wipe / jailbreak cycle twice. The first time something bad happened to Cydia causing it to completely fail for me. Re-doing the jailbreak worked fine the second time. One other useful resource I came across was jailbreakmatrix.com which helped me understand what options I had for jailbreaking and unlocking.

As you can see from the picture on this post, Jenn’s using PetroCanada Mobile as her provider. I didn’t have to do any magic to disable data usage, as the pay-as-you-go plan she uses has no data support.  There is something in the Cydia market that will let you control data usage if you need to do that. The iPhone works well as a phone, and sending an receiving text messages – data is provided exclusively over WiFi and for Jenn’s needs, that’s just fine.

Goo Gone

I like to buy movies, but I’m cheap. This means I usually pick up previously viewed movies, often in multiples to take advantage of the sale prices. This is one thing that digital media has changed the equation for, the used copy is exactly as good as the new copy with maybe the exception of the packaging.

I does drive me a little nuts that the video store will liberally put stickers right on the case (vs. on shrink wrap around the case as you would get with a new purchase). Do I really want to advertise that my movie collection is primarily built out of previously viewed titles? It turns out there is a simple solution to removing those really sticky, gooey stickers.

Goo Gone.  This is wonderful stuff. A small bottle will last a very long time. To remove a sticker, peel off what you can easily. Then use a paper towel to give the sticker a soak in goo gone (a few seconds). Then gently with a finger nail scrape off more of the sticker. Usually the ‘stick’ is gone and you just need to remove the paper blocking the goo gone from getting to the rest of the stickyness. The entire process should take a few minutes.

A water rinse and you’ll have it looking as good as new.  For movies, I usually remove the movie and the artwork to avoid getting it messed up while I’m cleaning the case.

When Android Fails

I really have myself to blame.  Android is the right smart phone platform for me: provided you have a rooted phone, you can get inside the device and tinker and there are community created ROMs which let you change the base system.  It is effectively an embedded Linux platform with a java like application stack.  I tend to follow the CyanogenMod crowd.

On my ADP1, I’ve got the developer friendly “fastboot”.  Using this you can install what is called a “recovery image” – a secondary boot mode which lets you get in and do maintenance etc.  Recently I found myself in a state where I had lost my recovery image.  The forum has some good basic advice if this happens to you.

As I found myself needing to reinstall.  The recommended recovery image is Amon_RA.  I used the fastboot flash method, from my Ubuntu desktop using the fastboot binary.  Once I had the binary, it really was as easy as booting into fastboot mode (hold camera button while phone is booting) and runnning the fastboot program.

fastboot flash recovery recovery_of_choice.img

Now what got me to this state of no recovery image, was most likely a finger fumble while I was trying to recover the phone from a bad state.  (Did I mention I was to blame here?)  Now I suspect there is some sort of latent bug in the Dalvik cache management that leads to this bad state, but I don’t yet have enough data to make a strong statement here.

What happens is at one point, apps stop opening properly for me.  Specifically things like the web browser.  The 1st time this happened, I ended up wiping the phone and starting again from scratch. While this is a recommended step if you’re going to play in the ROM scene, it is annoying to lose all of your state.  To my dismay it happened again.

The symptom is a boot loop when you reboot.  Using some of the tools from the Android SDK, you can watch things as they happen on boot.  I use ddms for this.  In the most recent failure, the loop looked like this in the log:

07-04 16:17:28.114: DEBUG/AndroidRuntime(249): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-04 16:17:28.114: DEBUG/AndroidRuntime(249): CheckJNI is OFF
07-04 16:17:28.284: DEBUG/AndroidRuntime(249): --- registering native functions ---
07-04 16:17:28.544: ERROR/AndroidRuntime(249): JavaVM unable to find main() in 'com.android.internal.os.ZygoteInit'
07-04 16:17:28.544: DEBUG/AndroidRuntime(249): Shutting down VM
07-04 16:17:28.544: WARN/dalvikvm(249): threadid=3: thread exiting with uncaught exception (group=0x4001e178)
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM waiting for non-daemon threads to exit
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM shutting VM down
07-04 16:17:28.574: DEBUG/dalvikvm(249): VM cleaning u
p

Not good.  Something can’t be found that is fairly critical, so the Dalvik system is continually bailing out on its start-up, then trying again.

The fix was quite easy (if we ignore the step where during the investigation, I mess up my recovery image).  The adb tool found in the Android SDK is much more powerful than I initially understood it to be.  We can use it to stop the Android sytem.

> adb shell stop

This effectively stops the boot loop from spinning around and around.  Now issuing:

> adb shell

Gets you into the device, and we can go and fix the filesystem.  I located and cleared the Dalvik caches (deleted the contents of the directories).
cache/dalvik-cache
sd-ext/dalvik-cache
data/dalvik-cache

You may only need to clear the 3rd one, but that is the list I cleared out to get back into a working state.  Much easier than a full wipe and reconfigure.