Tag Archives: emulator-mips

Compiling the Android emulator kernel – the easy way

I have recently posted a series on how to build your Android kernel emulator for arm, x86 and mips. You can do this manually to have full control or you can use a script Google provides in external/qemu/distrib/build-kernel.sh.

First you need to download the goldfish kernel and check out the 2.6.29 branch:

$ git clone https://android.googlesource.com/kernel/goldfish.git
$ cd goldfish
$ git checkout -b 2.6.29 origin/android-goldfish-2.6.29

The Android source tree has a script to compile the kernel in external/qemu/distrib/build-kernel.sh. You need to be in the root of the kernel directory and set the architecture you want to build for.

For arm:

$ ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh --arch=arm

For x86:

$ ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh --arch=x86

For mips:

$ ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh --arch=mips

This will build the kernel in the kernel directory. You can access the zImage/bzImage and vmlinux images as usual from the kernel directory or from the /tmp/kernel-qemu directory. You can start the emulator using one of these images.

For more details you can check the posts on how to build the emulator for arm, x86 or mips.

How to compile the kernel for the mips emulator

If using the Android precompiled kernel for mips is not enough for you, you can compile your own kernel from source.

First you need to download the Android source tree to get the mips emulator.

Next you need to download the emulator kernel source code (the 2.6.29 branch of the goldfish kernel):

$ git clone https://android.googlesource.com/kernel/goldfish.git
$ cd goldfish
$ git checkout -b 2.6.29 origin/android-goldfish-2.6.29

There are instructions on how to build the kernel for the arm emulator on Google’s site. This is what you have to do for mips:

$ export CROSS_COMPILE=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6/bin/mipsel-linux-android-
$ export ARCH=mips
$ export SUBARCH=mips
$ make goldfish_defconfig
$ make

When you’re done building the kernel, you can start the emulator with the newly compiled mips image. When building the kernel for mips you do not get a bzImage or zImage, so we’ll have to use vmlinux.

$ cd ${ANDROID_BUILD_TOP}
$ emulator -kernel ~/workspace/android/goldfish/vmlinux -wipe-data &

To check that you really have your own compiled kernel version, connect with adb to the emulator and check /proc/version:

adb shell cat /proc/version
Linux version 2.6.29-gf1ef1c8 (yaap@yaap-desk) (gcc version 4.6 20120106 (prerelease) (GCC) ) #3 Sun Sep 30 19:14:25 EEST 2012

You can see your username and hostname in the description for the running Linux Kernel.

The new cookie in the Android jar: the mips emulator

You might have noticed a new addition to the targets available for Android in Jelly Bean: the mips emulator.

In order to build it you need the Android source tree (master branch). For instructions on how to get the source code see How to build a custom Android emulator image.

You need to set the environment for the mips emulator and compile:

$ source build/envsetup.sh
$ lunch full_mips-eng
$ make -j4

After the build finishes you can run the mips emulator:

$ emulator -avd my_avd

You can connect to the running emulator using adb to check you are really running the mips emulator:

$ adb shell
# ls /proc/cpuinfo
/proc/cpuinfo
# cat /proc/cpuinfo
system type : MIPS-Goldfish
Hardware : goldfish
Revison : 1
processor : 0
cpu model : MIPS 24Kc V0.0 FPU V0.0
BogoMIPS : 1150.15
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

You can also check the developer.mips.com/android site for information on Android for mips.