Android on the Iphone

Thursday, April 22, 2010

How to install iDroid: Android on your first-generation iPhone===============================

Download links to the required files are displayed in the left hand column on this page.

These instructions describe how to build an Android system for iPhone 2G fromsources. These instructions are currently just notes and are being graduallyworked into a more readable form. Please submit questions and suggestions forclarification to #iphonelinux on irc.osx86.hu.

If you have a prebuilt android.img.gz, ramdisk.img, system.img, userdata.imgand cache.img, you still need to follow the directions in the "Firmware"section and add all the firmware files to

/lib/firmware in android.img.gz (it's a compressed ext2 image)

/etc/firmware in system.img (it's an uncompressed ext2 image)

After this, you can skip down to "Installation".

Linux kernel------------

1. Check out commit e27f17b5318851395a66cbaf1524ea89ff8f0cb9 of theandroid-2.6.32 branch of git://android.git.kernel.org/kernel/common

2. Apply the patches from android/kernel

3. Fix the Makefile for your system (you may need to use Google's repo tocheck out your own copy of the Android toolchain).

4. Use something based on android/kernel/.config as your .config

5. Build

Firmware--------

These can't be redistributed due to copyright laws. The multitouch firmwarewill need to be extracted from your ioreg tree. Install iokittools from Cydiaand perform ioreg -l -w 0 and pipe the result to some file. Read this file andlook for entries under AppleMultitouchSPI for Firmware and A-Speed Firmware.These contain a simple hexadecimal encoding for the bytes of the firmwarefiles. Convert and keep "Firmware" as zephyr_main.bin and "A-Speed Firmware"as zephyr_aspeed.bin.

The firmware for the wi-fi can be found on Marvell's site athttp://www.marvell.com/support.html Under "Choose a platform", select "Linux2.6 - Fedora" and click the Search button under the drop down box. TheSD-8686-* zip archive will contain the files. Rename helper_sd.bin tosd8686_helper.bin and keep that and sd8686.bin.

It's also possible to cut a more recent version of the Marvell firmware fromthe iPhone kernel. Can someone create a firmware cutter utility for thisstuff?

Boot initrd-----------

The Android initrd was created under a Debian installation of iPhone Linux(which is not currently available) using the create-initrd-android.sh script.However, if you read it, you can figure out generally how it's done.

YOU WILL NEED TO COPY ALL THE FIRMWARE *.bins TO /lib/firmware on thisramdisk!

Now wait forever for Android to build. You'll get ramdisk.img and system.imgin out/debug/target/product/generic/. Ignore the other .img files, we won't beusing them.

Android ramdisk.img-------------------

Create a blank 1 MB file and make a ext2 filesystem on it. Mount it as aloopback device. Rename the ramdisk.img from Android to ramdisk.img.gz. Usegunzip on ramdisk.img.gz. Use cpio -i -F ramdisk.img as root with the currentdirectory in the new ext2 filesystem to extract the ramdisk files onto theramdisk.

Apply android/init.rc.patch to init.rc

Make a directory called /cache

Unmount and you have your ramdisk.img

Android system.img------------------

You can just use the system.img Android compiled.

Android userdata.img--------------------

You can start with a perfectly empty userdata.img (as long as its properlyformatted). However, without the Dalvik caches, the boot will hang the firstcouple of times until those can be generated. This is some strange timeoutissue.

After the initial boot, you have to do

INSERT INTO secure (name, value) VALUES ('device_provisioned', 1);

Using sqlite3 in the database

/data/data/com.android.providers.settings/databases/settings.db

If the device is not "provisioned", it will automatically reject all incomingcalls. Very stupid.