Background

The Open Source Android sources, also known as AOSP, lack several key files in order to actually work on real phones. Jean-Baptiste Queru, of Google, has made significant progress in writing scripts and adaptations for extracting the missing proprietary files from HTC's supplied images so that an almost completely open source image can still be compiled and run. Unfortunately, these instructions were only aimed at the ADP1 (aka G1 or Google Phone) and ADP2/Google I/O phones. While these phones are, generally, available as commercial phones as well, JBQ has made it clear that the commercial phones are not a priority as far as he's concerned.

In particular, the Google I/O phone is a variant of a commercial phone called "HTC Sapphire", also referred to as "HTC Magic". The Sapphire phone comes in two variants. The Google I/O, as well as most phones branded with a carrier name, are called "32B". HTC branded phones are of a slightly different variant, called "32A". The boot loader for the phone clearly shows which phone it is. All AOSP efforts have, thus far, been directed at the 32B variant, producing images that do not boot on 32A phones.

The purpose of this howto is to allow developers to build software images aimed at the 32A phones.

Core Methodology

The basic steps for compiling an AOSP image for the 32B phones require the following steps:

  1. Check out the AOSP image on the relevant branch
  2. Source build/envsetup.sh to set up certain environment variables.
  3. Run "lunch" to select the variant to be used
  4. First time only - go to vendor/htc/sapphire-open, and run the "unzip-files.sh" script on an OTA zip file downloaded from HTC's web site to extract the proprietary files used in the image.
  5. Run "make" with the correct number of -j to speed things up, depending on the number of CPUs your machine has. Conventional wisdom states #CPUs times 2, but my dual core laptop runs out of memory even with -j2, so YMMV.
  6. When done, the out directory will contain .img files for the boot, system and recovery partitions.

Sapphire 32A Variant

The 32B image can run, almost as is, on a 32A phone, with one major difference - the kernel. I have been unable to find out what, exactly, needs to be different about the kernel in order to make it work, but the supplied HTC 32B kernel simply refuses to run on my 32A phone. At some later point in time, I may find out why, but for the mean while, I simply provided the kernel that HTC compiled for my HTC Magic phone. Of course, when replacing the kernel, one also needs to replace the wlan.ko module that is used for loading the Wifi drivers. The tar file contains both the kernel and its matching wifi driver.

The other thing that needs to be updated is the kernel's load address. The load address for the 32A phone is different than the default one that mkbootimg uses. Fortunately, as of donught, mkbootimg supports a command line parameter that can change the base load address. The system's make files contain a parameter that, if set, passes this command line to mkbootimg. The archive contains a patch file that changes the sapphire-open phone configuration to include the modified base load address.

Installation Instructions

To build AOSP for 32A phones, perform the following additional steps to those listed above:

  1. Download the 32A patch.
  2. After step 4 above, untar the file and replace kernel and wlan.ko with the files in the archive. Also, apply the patch.
    • If you do not want (or cannot) apply the patch, simply edit vendor/htc/sapphire-open/BoardConfig.mk, and after the line saying "BOARD_KERNEL_CMDLINE", add a line saying: "BOARD_KERNEL_BASE := 19200000"
  3. Continue with the rest of the steps as usual

The system.img and boot.img should now work on 32A phones.

Please be sure to read the "warnings" section of this document, especially the part marked in red, before attempting to actually flash the images you produced.

What works for me

Works for me: placing phone calls, receiving phone calls, sending SMSs, connecting via GPRS, Wifi, bluetooth and GPS.

Doesn't work for me: Speaker phone. Don't ask me why.

Please Send me Feedback

Feedback on this, or any, solution is most welcome. Please use the contact form on the site.

A Few Words of Warning

Replacing your boot images can be extremely dangerous. The best way to move forward is to have an ENG S-off boot loader, that allows flashing the device from the boot loader. These boot loaders are circulating around. Just look for "htc magic spl" in your favorite search engine. Of course, replacing the boot loader is also a dangerous operation...

Also, do not be tempted to flash your 32A phone with a radio image designed for the 32B. I tried it once, but your phone supplier may not be as understanding as mine. Flashing a 32B radio image to a 32A phone will brick your phone, even if you are using an engineering boot loader! You have been warned.