Home מדריכים
מדריכים
Running Android AOSP on HTC Magic 32A Phones
מאמרים
נכתב ע"י Shachar Shemesh   
שבת, 14 נובמבר 2009 14:49

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.

 
HTC Android Reboot Command Options
מאמרים
נכתב ע"י Shachar Shemesh   
רביעי, 16 ספטמבר 2009 14:27

Due to a need that came up for us, and since it turned out, at least on IRC, that other people are also looking for an answer, I am documenting the various reboot options available in Android, and in particular, on HTC (and in particular, on the HTC Magic). As far as I can tell, at least some of what iswwritten here will apply to broader audience than just the HTC Magic users, but this is the platform I have tested this on.

How to Reboot the HTC Magic from a Shell Command Line

The basic command to reboot the device is called "reboot". Merely writing reboot will perform a restart of the device. The command will call "sync" before rebooting the device, but will not unmount the file systems. This is up to you. If a full system is running on the device, this might prove to be slightly difficult, and many people just reboot and hope for the best.

Keep in mind that the core OS is stored on the system partition, which is typically mounted read only. This means that the worse data corruption that you could possibly inflict by this is fixable by doing a factory wipe of the device.

Power Off and Avoiding the Sync - All Android Devices

The reboot command can accept two switches. The first is the "-n" switch, which means to not perform a sync before rebooting the device. Use at your own risk. The second switch is "-p", which means to power off the device rather than reboot it. As far as I could tell, if -p is given, the last argument is effectively ignored. Since it is not ignored by the Linux kernel, however, this may not be globally true for all devices.

Reboot Argument - Type of Reboot

If reboot is run with no argument (with or without the options discussed above), it will simply shut down the Linux kernel, restart the device, and reload the operating system as if the device was just turned on. It is, however, possible to provide an additional argument to reboot, which causes the device to do something else. For the HTC Magic, these are the available arguments:

Argument

Meaning

Boot Key Sequence

 
bootloader
 After restart, the device loads the bootloader in fastboot mode
 Power + Back
recovery After restart, the device loads the recovery partition
 Power + Home
 eraseflash During restart the device performs a factory wipe
 oem-XX XX are two hexadecimal digits. Special OEM code. Precise meaning unknown

Source for the Information

The reboot command line is taken from the reboot command source for the open source version, at system/core/toolbox/reboot.c. The "-n" and "-p" options are handled there.

The argument for reboot is transferred, as is, into the kernel. The meanings provided here are taken from the HTC Magic kernel sources (available from the HTC web site) at arch/arm/mach-msm/pm.c.

עדכון אחרון ( שלישי, 22 ספטמבר 2009 06:57 )
 
Getting KDE to Recognize Volume Up/Down Keys
מאמרים
נכתב ע"י Shachar Shemesh   
חמישי, 12 מרץ 2009 10:06

I tried to find an answer to this one on the net, and got only things that got me in the right direction, but not a complete answer. For the sake of documentation, here is how to get KDE to recognize your volume keys (or, for that matter, any other special key). The fact that it doesn't happen automatically is probably a bug in the keyboard layout code. I might file it there. This method works with no special processes running. It works whether kmix is running or not. It causes KDE to display visual feedback to the fact that the volume is changing.

עדכון אחרון ( חמישי, 12 מרץ 2009 10:29 )
קרא עוד...
 


זכויות יוצרים © 2010 . כל הזכויות שמורות.
ג'ומלה! הינה תוכנה חופשית המשוחררת תחת רשיון GNU/GPL.