MIPSのAndroid 4.0のemulatorをビルドしてみた

MIPSAndroid 4.0のソースコードが公開されたので、emulatorをビルドして動かしてみました。

準備

http://developer.mips.com/android/getting-started-with-android/
に書いてありますが、すでにAndroid 4.0をビルドしたことがあれば飛ばしても大丈夫です。

ソースコードの取得

http://developer.mips.com/android/android-source-code/

 $ mkdir android-mips
 $ cd android-mips/
 $ repo init --repo-url=git://github.com/MIPS/repo.git --repo-branch=stable -u git://github.com/MIPS/manifests.git -b mips-ics-mr1 -m mips-ics-4.0.3_r1m2.xml
 $ time repo sync -j4

一時間くらいかかりました。

real	54m38.700s
user	7m57.080s
sys	1m34.040s

ビルドの環境設定

http://developer.mips.com/android/android-porting-guide/
を見ながら

$ cat env.sh 
export ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-sun
#kexport ANDROID_JAVA_HOME=/usr/lib/jvm/jdk1.6.0_25
export JAVA_HOME=$ANDROID_JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH

export TARGET_ARCH=mips
export TARGET_PRODUCT=generic
export TARGET_ARCH_VARIANT=mips32r2-fp
source build/envsetup.sh
setpaths
settitle

ビルド

 $ . env.sh 
 $ time make -j8 2>&1 |tee make.log

dalvik/vm/Android.mk:53: *** MIPS JIT is untested, please recompile with WITH_JIT=false.  Stop.

おや? WITH_JIT=falseをつけろということなので

 $ time make -j8 WITH_JIT=false 2>&1 |tee make.log
real	33m36.706s
user	253m25.990s
sys	13m7.410s

起動

環境設定してあるので簡単に起動できます。

$ emulator

これでもいいですが、以下のようにすると便利です。

$ emulator -shell -show-kernel

とにかくcpuinfoを見てみると

# cat /proc/cpuinfo
system type		: MIPS-Goldfish
Hardware		: goldfish
Revison		: 1
processor		: 0
cpu model		: MIPS 24Kc V0.0  FPU V0.0
BogoMIPS		: 1042.02
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 16
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 1, address/irw mask: [0x0ff8]
ASEs implemented	:
shadow register sets	: 1
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

# 

確かにMIPSで動いています。
その他のログは以下にまとめました。
http://kobablog.wordpress.com/2011/05/26/boot-logs-of-various-android-devices/