2011年5月20日金曜日

android-x86

Introduction

This page has (hopefully) the latest information about how to build Android for x86 platforms like Eee PC. The built images runs well on a real hardware as well as virtual machines (qemu or virtual box).

Now it is very easy to compile Android for x86 platform from our git repositories. You need not to apply any patch. Just follow the below instructions.

Getting Android-x86 source code

First, follow this page to configure your build environment. Then

 $ mkdir android-x86
$ cd android
-
x86
$ repo init
-u git://git.android-x86.org/platform/manifest.git

$ repo sync

This will point the projects created or modified by android-x86 to our git server. All the other projects still point to android.git.kernel.org.

If you hope to keep syncing your tree with Android-x86 repository, just do repo sync. No need to do repo init again. However, sometimes you may see conflicts during repo sync. See the below section for how to solve this situation.

Building the image

To generate an installation and live cd developed by us, run

 $ make -jX iso_img TARGET_PRODUCT=eeepc

Replace X by the number of processors you have. For example, if you have a quad core CPU, set X=4.

To generate an live USB image, run

 $ make -jX usb_img TARGET_PRODUCT=eeepc

Then you will get an iso file out/target/product/eeepc/eeepc.iso, or usb image file out/target/product/eeepc/eeepc_usb.img.

If you have squashfs-tools 4.0 (older version will not work) installed in your host, the generated Android core filesystem will be compressed by squashfs. So the iso file is very small (only about 18xMB). If you hope to disable it, add USE_SQUASHFS=0 to make.

You can easily test the iso file by a virtual box or qemu. On the booting screen, select the VESA or debug mode to boot.

Of course you can burn the iso to a CD disk and test it on a real hardware. On booting it will automatically detect your hardware and load necessary modules. If you have problem with the default frame buffer driver, you may try the VESA mode (select second item on boot screen).

To test the usb image, just dump it to a USB disk

 $ dd if=out/target/product/eeepc/eeepc_usb.img of=/dev/sdX

where /dev/sdX is the device name of your USB disk.

The old style Android disk installer could also be made,

 $ make -jX installer_img TARGET_PRODUCT=eeepc

But it doesn't work anymore. We have no plan to fix it.

Advanced

This section describes some useful information for advanced users. You may need good linux expertise to complete it.

Install to USB disk

Now you can get a live USB disk by making usb_img target, or use the new disk installer to install Android-x86 to a USB disk. However, if you want to install by hand, this section is for you.

Here are the three steps:

  1. Install grub to your USB disk
    • find a linux machine with the latest grub installed
    • partition your USB drive with fdisk or gpartd and mark the partition as bootable
    • format that partition to ext3 (recommended) or vfat.
    • mount your usb drive to /mnt
    • cd /mnt
    • grub-install --root-directory=. --no-floppy /dev/<your usb device node name>
    • cd /boot/grub
    • create your menu.lst based on the next section
  2. Add this section to menu.lst

    title Run Android
            kernel
    /android/kernel root=/dev/ram0 androidboot.hardware=eeepc  acpi_sleep=s3_bios,s3_mode SRC=/android
            initrd /
    android/initrd.
    img

    title
    Run Android (VESA mode)

            kernel
    /android/kernel root=/dev/ram0 androidboot.hardware=eeepc  acpi_sleep=s3_bios,s3_mode vga=788 SRC=/android
            initrd /
    android/initrd.
    img

    title
    Run Android (Debug mode)

            kernel
    /android/kernel root=/dev/ram0 androidboot.hardware=eeepc  acpi_sleep=s3_bios,s3_mode vga=788 SRC=
    /android DEBUG=1
            initrd /
    android/initrd.
    img
  3. Create /android directory in the USB disk, and copy the four files kernel initrd.img ramdisk.img system.sfs (or system.img if you set USE_SQUASHFS=0) to it.

Then you can boot from the USB disk and enjoy Android. Note all data are saved to the ramdisk, so all will lose after power off. If you hope to save data to disk, see the next section.

Install to hard disk

Install to a hard disk is just the same as install to a USB disk. Even you do not need to create a new partition. Just copy android files into an existing partition, install grub to the hard disk (if not done yet), and modify the menu.lst.

People still ask, what if my hard disk is empty? How to install grub and copy files into it? There are several ways to do it. I provide two here:

  • Boot from any rescue cd like systemrescuecd, and follow the instructions in the previous section.
  • Install your favorite linux distribution, then copy android files and modify the grub menu.

Save data to USB/hard disk

We support two ways to save data to your disk.

  • Create a subdirectory named data in your /android directory. The user data will be directly saved to that directory. This method only works for ext3 partition.

  • Create a separate partition and save data to it. You have to add DATA=<device_name> to the boot option. For example, suppose your data partition is /dev/sda2, then add DATA=sda2 to the boot option.

How to solve conflicts

There are several reason to have conflicts during repo sync, say

  • You modify your tree locally.
  • The upstream changed. Since we usually keep syncing with original Android repository, sometimes we have to rebase with it. That changes the history and may cause conflicts.

In this section we assume you have conflicts due to the upstream changed. That is, you don't have local modifications. If you do, you have to solve conflicts yourself. If you follow the procedures in this section, you may lose your local modifications.

Here is an example of a conflict in the manifest:

$ repo sync
remote
: Counting objects: 71, done.

remote
: Compressing objects: 100% (41/41), done.
remote
: Total 65 (delta 25), reused 28 (delta 9)
Unpacking objects: 100% (65/65), done.
From git://git.tarot.com.tw/android-x86/platform/manifest
   d53e6c1
..2de7a11  android-1.5r2 -> origin/android-1.5r2
 
* [new branch]      android-1.5r3 -> origin/android-1.5r3
 
* [new branch]      android-sdk-1.5_r3 -> origin/android-sdk-1.5_r3
   d53e6c1
..c544020  cupcake    -> origin/
cupcake
 
* [new branch]      cupcake-release -> origin/cupcake-
release
   f4d79b1
..6f7e0dd  donut      -> origin/
donut
 
+ 7308d31...4a4f936 lan        -> origin/lan  (forced update)

 
+ b480a6d...d82496e local      -> origin/local  (forced update)
 
+ 11c9d96...84345fb master     -> origin/master  (forced update)
 
+ 5bcbf93...66e92cc mirror     -> origin/mirror  (forced update)
 
+ 9f3092f...665f9e8 ssh        -> origin/ssh  (forced update)
 
+ c6037be...d70927f ssh-mirror -> origin/ssh-mirror  (forced update)
 
+ 00a823f...3ddaf66 test       -> origin/test  (forced update)
 
* [new tag]         android-1.5r3 -> android-1.5r3
 
* [new tag]         android-sdk-1.5_r3 -> android-sdk-1.5_r3
Fetching projects: 100% (128/128), done.
 
project
.repo/manifests/

First, rewinding head to replay your work on top of it...
Applying: merge donut, change or add the projects to x86 port
error
: patch failed: default.xml:3

error
: default.xml: patch does not apply
Using index info to reconstruct a base tree...

Falling back to patching base and 3-way merge...
Auto-merging default.xml
CONFLICT
(content): Merge conflict in default.
xml
Failed to merge in the changes.

Patch failed at 0001 merge donut, change or add the projects to x86 port

When you have resolved this problem run "git rebase --continue".

If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

repo sync stopped on conflicts. Since we don't have local modifications, just ignore it by git rebase --skip:

$ cd .repo/manifests
$ git rebase
--
skip
HEAD
is now at 4a4f936 add branch for local
lan
Applying: add platform/frameworks/policies/base
to x86
error
: patch failed: default.xml:18

error
: default.xml: patch does not apply
Using index info to reconstruct a base tree...

Falling back to patching base and 3-way merge...
Auto-merging default.xml
No changes -- Patch already applied.

Applying: add branch for local lan
error
: patch failed: default.xml:1

error
: default.xml: patch does not apply
Using index info to reconstruct a base tree...

Falling back to patching base and 3-way merge...
Auto-merging default.
xml
No changes -- Patch already applied
.

If it complains about another conflict, do git rebase --skip again, until the rebase procedure completes. Usually it is enough, but if you hope to be absolute clean, you can ignore this branch and checkout a new one:

$ git checkout -b master origin/master

Replace origin with x86 if the conflict is in an x86 project.

0 件のコメント:

コメントを投稿