Sunday, 22 July 2012

Upgrading Android Phone With Linux

I've had a Samsung Galaxy S II with Android 2.3.3 from Virgin Mobility in Canada since last year at this time. Part of the reason I went Android is I wanted to get away from having to have a Windows VM just to manage my phone. When I got the Galaxy I asked how upgrades worked, and I was told it was a stand-alone upgrade.

Time goes by and I rather enjoy not having my phone's behaviour change every time I plug it in to my computer. For that matter, I enjoy not having to plug it into a computer all the time. Lately, however, some of the things that I didn't like about my phone bugged me enough that I thought I should do something about them. And before doing that, I thought, well I better upgrade Android first.

So it turns out I needed a PC or a Mac to upgrade using the Samsung Kies software. No stand-alone upgrade like they told me. Crap. Well, I thought, I'm a Linux user so suck it up and Google for the solution. Many Androids do indeed have a stand-alone upgrade on the phone, and people report it works quite well, although it's best to be connected to WiFi first. I suspect, therefore, that either it's something that Virgin/Bell did to their version of Android, or it's an artefact of the old version of Android.

In other words, these instructions are only for if you can't find the stand-alone upgrade on your phone. Look under Settings-> About Phone.

Without the stand-alone upgrade, here's what I did:
  1. I went to samfirmware.com to find the version of software for my exact model of phone, a GT-I9100M and download it. The version I got was 4.0.3 (Ice Cream Sandwich)
  2. I uncompressed it
  3. Heimdall is the Linux program to flash the Samsung's firmware. I downloaded heimdall 1.3.1, both frontend and the base, from the heimdall github site. At the time I wrote this, heimdall 1.3.2 was the most recent, but apparently it had an issue and the Internet recommended using 1.3.1
  4. I installed each of the .deb files by double-clicking on them
  5. I ran "sudo heimdall-frontend" in a terminal. I had to run it with sudo or I would get a "libusb error: -3" [Update: On another system I got "heimdall-frontend: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory" when I installed the 32-bit Heimdall on a 64-bit Linux Mint.]
  6. Somewhere around here you may want to back up your phone. I didn't, but I was quite confident that most of what I have on the phone is also in the cloud somewhere. I copied all my photos to my computer before starting the upgrade
  7. The phone has to be in "download mode" before connecting to it with heimdall. To put it in download mode, turn off the phone, disconnect the USB cable, and hold down Volume-Down, Power, and Home all at the same time for a few seconds. The phone shows a display that it's in download mode within a couple of seconds. To quit without downloading anything, just hold down the power button for five seconds or so (http://forum.xda-developers.com/wiki/Samsung_Galaxy_S_II_Series#Download_Mode)
  8. I prepared the firmware to flash according to the Heimdall instructions: https://github.com/Benjamin-Dobell/Heimdall/tree/master/Linux, under the heading "Performing a Custom Flash with Heimdall Frontend". Note that the instructions say to get the PIT file from the phone first
It took a couple of minutes to download all the files. For the larger files the feedback would pause every once in a while. I was patient and waited and it continued after a brief pause.

Once it's done the phone rebooted and set about doing a bunch of post-install updating. It took maybe ten minutes tops and the phone was ready to go. My memos were still there.  I lost all my playlists. As far as I can tell, that's all I lost (but then I don't have a lot of stuff on my phone that isn't in the cloud).

Finally, an annoying irony: One of the first things I noticed when I started to use the new version is that it does indeed support a stand-alone upgrade, so now all I need to do is connect to WiFi and upgrade.