How to compile the kernel for the arm emulator

If you want to compile the kernel for the arm emulator, you first need to read Google’s instructions on how to compile the kernel. Except from following these instructions you will have to fix one issue to run the arm emulator with the new kernel.

Google’s instructions

First you need to download the Android emulator kernel sources. The stable branch is 2.6.39 so this is what we are going to use.

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

Google’s site gives detailed instructions on how to compile the kernel for arm:

$ export CROSS_COMPILE=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-
$ export ARCH=arm
$ export SUBARCH=arm
$ make goldfish_defconfig
$ make

${ANDROID_BUILD_TOP} should point to the top of your Google Android tree. It should be set automatically if you have the Google environment set. In order to do that you need to run source build/envsetup.sh and lunch full-eng.

You just need to start the arm emulator with the newly compiled kernel:

$ cd ${ANDROID_BUILD_TOP}
$ emulator -kernel ~/workspace/android/goldfish/arch/arm/boot/zImage -wipe-data &

First (and only) problem: arm emulator does not boot

After the steps mentioned above, the emulator will not boot. Seems that the goldfish_defconfig is not working. The solution is to use goldfish_armv7_defconfig instead:

$ make goldfish_armv7_defconfig

Leave a comment