How to root your HTC Desire and install Android 2.3 (Gingerbread)

Step-by-step guide

There are various reasons to do this, including:

  • Needing root to run certain apps. This includes taking backups, removing unwanted pre-installed apps, and installing a fix for the tiny (140 MB) internal storage on the HTC Desire.
  • Wanting an upgrade to Android 2.3 or higher. This is not available officially.

Isn’t this explained elsewhere online? Yes, but many guides are out-of-date or include unhelpful advice. I wasn’t able to find everything I needed in one place.

This post is 80% there: http://androidforums.com/desire-all-things-root/439627-guide-revolutionary-s-off-rooting.html

This will wipe your phone including apps and data.

Preparation

As well as an HTC Desire you need a Windows PC connected to the Internet and a micro-USB cable for your phone.

The custom ROM process is a bit quicker if you have a USB reader for your micro SD card.

Drivers

On your PC:

  • Download and install HTC Sync. Then uninstall the HTC Sync software itself, leaving the HTC drivers in place.
  • Download and install the HTC fastboot drivers mentioned on the Revolutionary documentation.

Is it necessary to install the Android SDK for this process – using adb shell? I don’t think so. Described on this post.

On your phone:

  • Enable USB debugging.
  • Enable installing non-Market apps.

Root and custom recovery

This is a two step process: we use Revolutionary to gain S-OFF on the phone, then flashing a root zip file which gains you root. Revolutionary does not get you root by itself.

HBOOT version / erase size of 20,000 or 40,000. As we’re using Revolutionary and ClockWorkMod (CWM) does this apply? I think not.

From boot screen:

Check if PVT version is PVT4. If so check erase size.

Install Terminal Emulator from Market, then

cat /proc/mtd

Check if 20000 or 40000. If 20000 or not PVT4, we’ll use ClockWorkMod.

Check HBOOT version, this must be lower than 1.06.

On your PC:

  • Turn off your anti-virus software temporarily.
  • Download Revolutionary from http://revolutionary.io and the custom root zip file mentioned on their documentation page.
  • Connect the phone. Put the custom root zip file on the SD card.
  • Start Revolutionary. It will guide you through the process.
  • You need to get a beta key for Revolutionary – the program gives the details about your phone to generate one on the Revolutionary site.
  • The phone will restart a few times and Revolutionary will update you on progress. It’s automatic, but keep an eye on it.
  • As a final step Revolutionary asks if you want to install a custom recovery – CWM. Say ‘yes’ to this.

You now have S-OFF on the phone.

On the phone:

  • Switch off the phone, and boot into HBOOT by holding ‘volume down’ and pressing the power button.
  • The boot screen should say -REVOLUTIONARY- at the top and mention S-OFF in the next line.
  • Choose Recovery from the menu.
  • Select ‘Install zip from sdcard’ then ‘Choose zip from sdcard’.
  • Choose your root zip file, should be named Superuser-3.0.7-efgh-signed.zip.
  • Power off the phone from the CWM menu.

You now have an HTC desire with root and a custom recovery.

Custom ROM

We will use CWM to partition the SD card then install a custom ROM.

There are some dire warnings online about not partitioning an SD card with CWM, these apply to old versions of CWM and can be ignored with the current version.

This process will wipe the SD card. Copy the contents of it onto your computer first if you want to keep them.

Partition the SD card

Goal is to provide two partitions on your phone:

  • An ext4-formatted partition of 1 or 2 GB on your SD card that the phone will use as internal storage.
  • The rest of the card as a fat32-formatted partition the phone will use as regular SD card storage.

The only complication here is the ext4 partition must come second on the card, the fat32 partition must come first. CWM will handle this for us.

On the phone:

  • Boot into HBOOT by powering off and holding ‘volume down’ and the power button.
  • Go into Recovery → Advanced → Partition SD card.
  • Set the sd-ext partition to be 1 GB.
  • You don’t need a swap partition but setting one of 32 MB will not hurt anything.
  • The partitioning and formatting will take a while. Leave it be.
  • When this is done power off the phone

Installing a custom ROM

Take out the SD card and connect to your Windows PC.

Download your custom ROM of choice. There are many available for the Desire so it depends on what features you want.

I am using the SuperNova ROM which is very good. It provides Gingerbread and HTC Sense and a fairly ‘stock’ experience. Importantly, The ROM has a stable Data2SD installed that provides ample internal storage using your SD card.

Download the latest SuperNova and put it on your SD card. SuperNova instructions are here.

Quick version:

  • Shut down your phone and reboot to HBOOT.

Select Recovery, then:

  • Wipe data/factory reset
  • Install zip from sdcard → choose zip from sdcard → pick the SuperNova file.

Question: is it required to wipe cache and/or dalvik cache? Think it doesn’t hurt at the first install of SuperNova but should never be done when upgrading.

SuperNova is a big file so this process takes a while. It provides updates as it goes. Once it’s finished power off.

At first boot:

  • Allow the phone to boot, then answer all the questions asked except skip the Google account setup. Check About → Software shows the build as SuperNova.
  • Don’t restore data or apps yet. Reboot the phone.
  • At this point Data2SD runs during boot. When the phone has finished booting up, check the internal storage – it should be 900+ MB.

New Radio

Not the Bikini Kill song. The radio is software on the phone that allows you to make phone calls and use mobile Internet.

There seem to be incompatibilities between different Android releases, different custom ROMs, and different radio versions.

Radios are available from Mo Firouz’s site.

Best approach is to leave your radio alone and check if everything works with your new ROM.

  • If it does not, install the most recent radio release. SuperNova recommend you use this – version 5.17.05.23.
  • If this does not work then downgrade to version 5.09.05.30 recommended by Mo Firouz. This worked for me on Gingerbread when my current radio and the newest radio didn’t work.

Flashing the radio

This is complex. The radio as you download it cannot be loaded directly using CWM as they are only distributed in an old and incompatible format. Ignore the steps on the download page above.

You can flash the radio using fastboot. This is a hassle – there must be a better way, surely?

Guide to ADB and Fastboot for Windows.

On the PC:

  • First install the Android SDK. This will take a while as the downloads are large files.
  • Download and install the HTC fastboot drivers mentioned in the Revolutionary documentation.
  • Download your radio file and extract the radio.img file from it.
  • Reboot to HBOOT then select Fastboot from the menu.
  • Connect the phone using USB. Your phone screen should update to say ‘FASTBOOT USB’.
  • At this point you can issue commands using the ADB shell on your Windows computer.
  • Open a shell in Windows using cmd.exe. Navigate to the folder containing your radio.img file.
  • Note: online guides mention setting the system PATH variable. Don’t worry about this, you can just run the fastboot program directly.
  • Find fastboot.exe – it will be somewhere in the Android SDK folder. On my 64-bit Windows 7 machine, it’s:
c:\Program Files (x86)\Android\android-sdk\platform-tools\fastboot.exe
  • Flash the radio using this fastboot command:
c:\Program Files (x86)\Android\android-sdk\platform-tools\fastboot.exe flash radio radio.img
  • Finally reboot the phone:
c:\Program Files (x86)\Android\android-sdk\platform-tools\fastboot.exe reboot

Photo credit

HTC Desire‘ by Flickr user Matthias Penke, license CC BY-NC-ND.

Tracking usage of QR codes by smartphone users

Recently I added QR codes to the Senate House Library catalogue hoping to improve user experience for smartphone users. In true “dogfooding” style I have made a lot of use of it myself, but I need to see more data. One thing was missing was any analytics tracking for smartphone users recording these codes and following them into the mobile catalogue.

Tracking QR code use

I realised I could do this by adding parameters to the QR code URLs that would be picked up by Google Analytics: Analytics Help – How do I tag my links?

I tweaked the Javascript generating my markup to insert the required parameters utm_source, utm_medium, and utm_campaign:

  • Campaign Source (utm_source): webpac
  • Campaign Medium (utm_medium): qr
  • Campaign Name (utm_campaign): mobile

Values used can be whatever you want, I’ve tried to keep them short but meaningful. You can then track visitors under Traffic Sources – Sources – Campaigns in Google Analytics.

Adding complexity

Being able to track use of this service is very helpful, but providing more information in the QR code increases the complexity of the code and makes it more “dense” and “busy”. Though I’ve had no problems with this on my phone this could cause problems for older smartphones with lower-resolution cameras. My quick solution is just to bump up the size a bit as this makes the QR code easier for the smartphone to read.

For comparison including a longer URL takes you from this:

With Borges / Alberto Manguel.

http://m.ulrls.lon.ac.uk/record=b2941947~S24

To this:

With Borges / Alberto Manguel.

http://m.ulrls.lon.ac.uk/record=b2941947~S24?utm_source=webpac&utm_medium=qr&utm_campaign=mobile

As these QR codes are meant for a mobile phone camera to direct a Web browser to a page, I thought the URL itself need not be “cool”, bookmarkable, or even very human readable. One option is to shorten the URL as it is generated and encode that. Here is the result of shortening with our own shortening service. (Your library does have its own URL shortening service, right?)

With Borges / Alberto Manguel.

http://senatehou.se/b2941947

That is much nicer! Better than the original link to the mobile catalogue, even.

How to do it

Actually achieving this result in the Millennium ‘classic catalog’ / WebPAC is more difficult. To do the extra step of shortening the URL you will probably need to use the API from your shortening service to first shorten the URL, then you can generate your QR code image. On the WebPAC you’re going to need to do this in Javascript.

In the WebPAC I knew I will run into problems with insecure scripts because our shortener doesn’t have an SSL certificate yet, so this will be just an example. I was able to do it using jQuery and this jQuery plugin jquery-urlshortener.js by James Robert combined with bit.ly as a shortener.

First add jQuery and jquery-urlshortener.js to your INSERTTAG_INHEAD wwwoption. I put a local copy of jQuery on our server for testing:

<script language="JavaScript" type="text/javascript" src="/screens/qrcode.js"></script><script type='text/javascript' src='/screens/jquery.js'></script><script type='text/javascript' src='/screens/jquery.urlshortener.js'></script>

Add your bit.ly API key and username to jquery-urlshortener.js.

Update the qrcode.js to request a short URL from bit.ly using jQuery and use that to generate a QR code using the Google Chart API:

function linkto_catalog_qr() {
    var qrairpacstub = "http://m.ulrls.lon.ac.uk/record=";
    var qrrecordlink = document.getElementById("recordnum").getAttribute("href");
    var str = qrrecordlink.indexOf("=");
    var qrrecordid = qrrecordlink.substr(str + 1);
    var longurl = '' + qrairpacstub + qrrecordid + '?utm_source=webpac%26utm_medium=qr%26utm_campaign=mobile';
    $.shortenUrl(longurl, function (short_url) {
        document.getElementById('qrcode').innerHTML = '<img src="http://chart.apis.google.com/chart?cht=qr&chs=130x130&chl=' + short_url + '" alt="QR code for this record" title="QR code for this record" /><br><a href="http://www.senatehouselibrary.ac.uk/library/helpandsupport/qrcodes.shtml">What's this?</a>';
    });
}

This works as a proof of concept and is enabled on our test / staging port, for example:

With Borges / Alberto Manguel.

I am not so keen on sending thousands of requests to bit.ly every day and would prefer to use our own shortening service so I’m not making this live just yet.

QR codes in the library catalogue

Really quick introduction

QR codes are a type of 2-dimensional barcode that can be used to encode various information. A QR code looks like this:

QR codes have various applications along the lines of mobile tagging: embedding information on something in a way that can be understood by a smartphone. My colleague Adrian blogged about them a few days ago.

You will likely appreciate the explanation that the above is a link to Hackney, that rose-red empire : a confidential report / by Iain Sinclair in our mobile catalogue.

Why we wanted to do this

The reason is to embed some information about the item on the bibliographic record screen that is useful to a smartphone.

We’ve noted many readers making use of smartphones to record shelfmarks of items of interest versus pen and paper. It’s noticeable that more readers are coming to the enquiries desk to show us a record on a smartphone with a query about it. We’re not sure how readers are making the leap from the catalogue terminal to the smartphone though. Aaron Tay makes this observation:

These days, it’s very common for users to show me library catalogue records (call numbers, titles) on their hand phones when I’m at the desk. This seems to be quickly replacing scribbled notes on paper. I’m never worked out the courage to ask them though, how they got the information onto the handphones

Our assumption is a URL would be a useful thing to encode and as it’s for use on a smartphone, a link to our mobile catalogue might be the most appropriate thing. Have the right QR code app installed and you can snap away on the catalogue and end up with a list of items to go and find them (wayfinding in our building is another blog post).

I haven’t actually made this live yet: it will be live tomorrow!

How to do this in the Innovative ‘classic catalog’ / WebPAC

Here’s how. On your WebPAC server put this Javascript in /screens/qrcode.js:

function linkto_catalog_qr() {
        var qrairpacstub = "http://m.ulrls.lon.ac.uk/record=";
        var qrrecordlink = document.getElementById("recordnum").getAttribute("href");
        var str = qrrecordlink.indexOf("=");
        var qrrecordid = qrrecordlink.substr(str+1);
        document.write('<img src="http://chart.apis.google.com/chart?cht=qr&chs=120x120&chl='+qrairpacstub+qrrecordid+'" alt="QR code for this record" title="QR code for this record" />');
        document.write('<br/><a href="http://www.senatehouselibrary.ac.uk/library/helpandsupport/qrcodes.shtml">What's this?</a>');
}

Above, “recordnum” is the ID of a link inserted into the bib_display.html using the WebPAC <!–{recordlink}–> tag. This produces a link like this in the page markup:

<a id="recordnum" href="/record=b3112148~S1"></a>

In your INSERTTAG_INHEAD wwwoption, insert this:

INSERTTAG_INHEAD=<script language="JavaScript" type="text/javascript" src="/screens/qrcode.js"></script>

On your bib_display.html, put this JS where you want the QR code:

<script type="text/javascript">
<!--
linkto_catalog_qr();
-->
</script>

An alternative approach is to put the JavaScript to generate the markup into the WebBridge bib panel. Rather than using WebBridge to create a link, you embed the little chunk of JavaScript that generates the QR code for you. This idea is from Natalie Pollecutt at the Wellcome Library who posted about it on the IUG mailing list.

Wellcome Library haven’t made this live, but you can see it on their test / “staging” port, for example: From ‘cuckoos’ to ‘zombies’ : the changing portrayal of lobotomy in American popular fiction from 1960-2010 / by Amy Chandler.

Result

Hackney, that rose-red empire : a confidential report / by Iain Sinclair.