2008年12月31日 星期三

X86上執行Android[轉貼]

Lim,GeunSik剛剛在android-porting討論組中詳細闡述了這個方法。我先把方法放過來,不過還沒來得及驗證,他用的是ASUS Eee,估計效果和N810上的差不多的。一下所有步驟都是基于Fedora的,ubuntu用戶自行參考。

開發環境:
- Linux PC: Fedora 9 ( 2.6.25.6-55.fc9 i686)
. CPU: Intel(R) Core(TM)2 Duo CPU T5750 @ 2.00GHz ( Samsung
SENS R60 Laptop )
. RAM: Samsung DDR Ram
- Target: Eee PC (ASUS) and Samsung nettop NC01
- Reference: http://www.kandroid.org/board/board.php?board=androidsource&command=body&no=19

1. Linux發行版訊息

首先是驗證系統訊息

Fedora9$> uname -a
Linux fedora-invain9 2.6.25.6-55.fc9.i686 #1 SMP Tue Jun 10 16:27:49
EDT 2008 i686 i686 i386 GNU/Linux

Fedora9$> gcc –version and Fedora9$> gcc34 –version
Fedora9$> gcc –version
gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

Fedora9$> gcc34 –version
gcc34 (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE


2. repo init 和 Sync 操作
- 首先下載Android for x86的完整源代碼。Eee pc 的 dev tree 在 “git://android.git.kernel.org/platform/vendor/asus/eee_701.git”.

Fedora9$> cd ~
Fedora9$> mkdir bin_x86 && cd bin_x86
Fedora9$> mkdir mydroid && cd mydroid
Fedora9$> repo init -u git://android.git.kernel.org/platform/manifest.git
-b cupcake
Fedora9$> repo sync
Fedora9$> vi ./.repo/local_manifest.xml





Fedora9$> repo sync
… A new repo command ( 1.8) is available.
… You should upgrade soon:

cp /home/invain/bin_x86/mydroid/.repo/repo/repo /home/invain/bin/
repo

Initializing project platform/vendor/asus/eee_701 …
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 33 (delta 2), reused 33 (delta 2)
Unpacking objects: 100% (33/33), done.
From git://android.git.kernel.org/platform/vendor/asus/eee_701
* [new branch] cupcake -> korg/cupcake
* [new branch] master -> korg/master

3. 構建 x86 android

Fedora9$> export PATH=$PATH:/usr/sbin:/sbin (to use /sbin/tune2fs
command of e2fsprogs pack )
Fedora9$> TARGET_ARCH=x86 TARGET_PRODUCT=eee_701 DISABLE_DEXPREOPT=true CC=gcc34 CXX=g++34 make -j2 installer_img

build/core/product_config.mk:207: WARNING: adding test OTA key
============================================
TARGET_PRODUCT=eee_701
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=
============================================
build/core/main.mk:178: implicitly installing apns-conf_sdk.xml
…………… Below Omission ……………….


* 在構建中可能遇到一些問題,解決辦法是

- 用低版本gcc 替換 gcc-4.3 version. Ubuntu 8.04LT用的是GCC 4.2, Ubuntu 8.10是GCC 4.3,所以推荐用8.04來做build

- 如果你正在使用 GCC 4.3, 請照下面修改源代碼中的相關頭文件:

Fedora9$> vi external/srec/tools/thirdparty/OpenFst/fst/lib/../../fst/
lib/vector-fst.h
Fedora9$> vi external/srec/tools/thirdparty/OpenFst/fst/lib/symbol-
table.cpp
Fedora9$> vi frameworks/base/tools/aidl/aidl.cpp –> #include
, #include

等等。

- Lim,GeunSik使用的是gcc 3.4

#> yum install compat-gcc*
#> rpm -qa grep compat-gcc
compat-gcc-34-3.4.6-9.i386
compat-gcc-34-c++-3.4.6-9.i386
compat-gcc-34-g77-3.4.6-9.i386

Fedora9$> vi

Fedora9$> ls -lh out/target/product/eee_701/

total 770624
drwxrwxr-x 9 invain invain 4096 2008-12-24 16:05 .
drwxrwxr-x 3 invain invain 4096 2008-12-24 15:34 ..
-rw-rw-r– 1 invain invain 2606080 2008-12-24 15:50 boot.img
-rw-rw-r– 1 invain invain 57 2008-12-24 16:03 clean_steps.mk
drwxrwxr-x 4 invain invain 4096 2008-12-24 15:54 data
drwxrwxr-x 2 invain invain 4096 2008-12-24 15:50 grub
drwxrwxr-x 4 invain invain 4096 2008-12-24 16:05 installer
-rw-rw-r– 1 invain invain 406862848 2008-12-24 16:06 installer.img
-rw-rw-r– 1 invain invain 1951340 2008-12-23 19:18 kernel
drwxrwxr-x 12 invain invain 4096 2008-12-24 16:05 obj
-rw-rw-r– 1 invain invain 607384 2008-12-24 15:50 ramdisk.img
drwxrwxr-x 9 invain invain 4096 2008-12-24 15:50 root
drwxrwxr-x 4 invain invain 4096 2008-12-24 15:50 symbols
drwxrwxr-x 12 invain invain 4096 2008-12-24 15:53 system
-rw-rw-r– 1 invain invain 372056064 2008-12-24 16:05 system.img
-rw-rw-r– 1 invain invain 5156864 2008-12-24 16:04 userdata.img

Fedora9$> file out/target/product/eee_701/installer.img
./out/target/product/eee_701/installer.img: x86 boot sector; GRand
Unified Bootloader, stage1 version 0×3; partition 1: ID=0×83, active,
starthead 0, startsector 2048, 8878 sectors; partition 2: ID=0×83,
starthead 0, startsector 10926, 783728 sectors

Fedora9$> file out/target/product/eee_701/installer.img
File: `./out/target/product/eee_701/installer.img’
Size: 406862848 Blocks: 793552 IO Block: 4096 일반 파일
Device: fd00h/64768d Inode: 5349917 Links: 1
Access: (0664/-rw-rw-r–) Uid: ( 778/ invain) Gid: ( 778/
invain)
Access: 2008-12-24 16:08:21.000000000 +0900
Modify: 2008-12-24 16:06:05.000000000 +0900
Change: 2008-12-24 16:06:05.000000000 +0900

Fedora9$> file out/target/product/eee_701/system.img
./out/target/product/eee_701/system.img: Linux rev 0.0 ext2 filesystem
data

Fedora9$> file out/target/product/eee_701/userdata.img
./out/target/product/eee_701/userdata.img: Linux rev 0.0 ext2
filesystem data

Fedora9$> pushd out/target/product/eee_701/

Fedora9$> sudo mount -o loop boot.img /mnt

Fedora9#> popd
total 2519
-rw-rw-r– 1 invain invain 77 2008-12-24 15:50 cmdline
-rw-rw-r– 1 invain invain 1951340 2008-12-24 15:50 kernel
-rw-rw-r– 1 invain invain 607384 2008-12-24 15:50 ramdisk

Fedora9$> cat /mnt/test/cmndline
console=tty0 console=ttyS1,115200n8 console=tty0
androidboot.hardware=eee_701

Fedora9$> cp /mnt/test/ramdisk /tmp/ramdisk.gz
Fedora9$> pushd /tmp
Fedora9$> gunzip ramdisk.gz
Fedora9$> cpio -iv < ramdisk

Fedora9$> popd
init.goldfish.rc
init
data
init.eee_701.rc
proc
sbin
sbin/adbd
system
init.rc
default.prop
lib
lib/modules
lib/modules/atl2.ko
lib/modules/drm.ko
lib/modules/fbcon.ko
lib/modules/cfbimgblt.ko
lib/modules/i915.ko
lib/modules/cfbcopyarea.ko
lib/modules/bitblit.ko
lib/modules/softcursor.ko
lib/modules/font.ko
lib/modules/cfbfillrect.ko
dev
sys
2958 blocks

Fedora9$> file /tmp/init
/tmp/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
statically linked, not stripped


4. 制作USB Pen Disk安裝包

- 在BIOS中把第一啟動設備設置成USB,然後

Fedora9$> dd if=out/target/product/eee_701/installer.img of=/dev/your_usb_disk(例如/dev/sda1)

好了,接下來可以用你的android USB Pen Disk來嘗試啟動了。Enjoy it。

最後友情提示一句,我還沒有試這種方法,不過反正也不會破壞什麼,有興趣的朋友可以試一下。

資料來源:
http://www.forwind.cn/2008/12/24/android-on-x8/
Howto build Android full source for X86 Architecture like EeePC(ASUS)

3 則留言:

fallrain 提到...

根據我的經驗
在eeepc上試過後可以用
但是我遇到的情況是
由usb開機後
其中的installer.img
會將eeepc中原本的系統刪掉
將Android裝到裏面
因此以後不需要再以隨身碟開機
但是原本的系統會不見
這是個人的經驗

cinatit 提到...

/dev/sdb1 (sda1 有可能是 S-ATA HDD)

The realistic 提到...
作者已經移除這則留言。

一個小故事讓我們明白資金流通的意義

“又是炎熱小鎮慵懶的一天。太陽高掛,街道無人,每個人都債台高築,靠信用度日。這時,從外地來了一位有錢的旅客,他進了一家旅館,拿出一張1000 元鈔票放在櫃檯,說想先看看房間,挑一間合適的過夜,就在此人上樓的時候---- 店主抓了這張1000 元鈔,跑到隔壁屠戶那裡支付了他欠的肉錢...