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.

Leave a comment