Table of Contents
Compile And Run The Android Goldfish Kernel
You are largely following an online tutorial at blog.markloiseau.com on your assigned lab machine.
For long Terminal commands, I recommend copying and pasting from this page to the Terminal.
You can do Parts 1 and 2 at the same time in different Terminals.
Part 1. Download kernel build environment (prebuilt C compiler)
cd /usr/local/android/sdk mkdir -p prebuilt/linux-x86/toolchain cd prebuilt/linux-x86/toolchain git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
Part 2. Download android kernel
cd /usr/local/android/sdk mkdir -p src/kernel cd src/kernel git clone https://android.googlesource.com/kernel/goldfish
Part 3. Set up android kernel source
You may have noticed that after the big download of Part 2, there appears to be nothing in the goldfish
directory. Actually, there's a hidden .git
directory in there. Don't erase it. It contains a local git repository of the kernel source. We need to “checkout” a working copy of the kernel source from the repository before we can work with it. Run these commands. (The '#' lines are just comments.)
cd /usr/local/android/sdk/src/kernel/goldfish # OPTIONAL; shows hidden .git directory ls -a git branch -a git checkout -t origin/android-goldfish-2.6.29 -b goldfish # Shows the working copy of kernel source that was checked out. ls -a
Part 4: Set build environment variables and build kernel
# Make commands in kernel build environment available in the current running shell: export PATH=/usr/local/android/sdk/prebuilt/linux-x86/toolchain/arm-eabi-4.6/bin:$PATH # OPTIONAL; see what the PATH environment variable contains: echo $PATH # Set up architecture-specific variables: export ARCH=arm export SUBARCH=arm export CROSS_COMPILE=arm-eabi- # Create a configuration file (.config) for the kernel we're about to compile: make goldfish_armv7_defconfig # OPTIONAL; see the main Makefile for the kernel build less Makefile # press 'q' to quit the 'less' program # Process the Makefile to build the kernel; the 'time' command will tell us how long the # compile process took. time make # Assuming no errors occurred above, the compiled kernel image will be the zImage # file located in /usr/local/android/sdk/src/kernel/goldfish/arch/arm/boot directory. ls -l arch/arm/boot/zImage
Part 5: Run an arm-based AVD with the arm kernel we just compiled
This part assumes that you have gone through all steps to set up a virtual Android environment, particularly that you created an arm-based AVD along with your Intel Atom-based AVD.
# Assumes you have changed directory (cd) to the # /usr/local/android/sdk/src/kernel/goldfish directory; # Copy the kernel to the /usr/local/android/sdk/src/kernel/goldfish directory for future use: cp arch/arm/boot/zImage zImage-arm-goldfish-2.6.29 # Run your arm-based AVD with the new kernel; # If your arm-based AVD has a different name than "TestAVDarm" substitute that name below: emulator -kernel zImage-arm-goldfish-2.6.29 -avd TestAVDarm
- This should start the AVD with the
zImage-arm-goldfish-2.6.29
kernel. To verify, in the AVD go to “Settings” and select “About phone” and look at “Kernel version”.
- While a AVD is running, you can run
adb shell
in another Terminal. This will open the Android Debug Bridge command prompt on the AVD. You'll see a#
command prompt in which you can run a variety of useful commands. For now, just runcat /proc/version
to see more information about the kernel.