Goldfish on Android Emulator

1.Introduction 

This document explains how to download, build and run Goldfish on TI’s ARM Cortex A8 based AM37x Beagleboard-XM. 

2.Getting Source Code:
  • Host Setup 
2.1.1 Java JDK setup


Ubuntu now comes only with OpenJDK which does not work for building the goldfish Android. Please follow the following steps to setup the Sun JDK:


Download the Sun Java JDK from the following link: http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html


You need to download the Linux x64 bin installer. (Not the rpm installer)

Install the JDK into your home using the following commands: 

$ cp android-sdk_r20.0.3-linux.tgz to home dir.
$ tar -zxvf android-sdk_r20.0.3-linux.tgz
$ cd android-sdk_r20.0.3-linux
$ chmod a+x jdk-6u33-linux-x64.bin
$ ./jdk-6u33-linux-x64.bin

If prompted, accept the licence agreement by entering “yes” at the prompt. JDK will be installed to ~/android-sdk_r20.0.3-linux

Add the JDK to your PATH as follows:
$export PATH=”$HOME/android-sdk_r20.0.3-linux/bin:$PATH”
2.1.2 Installing Repo

To install, initialize, and configure repo, follow these steps


Make sure you have a bin/ directory in your home directory, and that it is included in your path

$ mkdir ~/bin
$ PATH=~/bin:$PATH


Download the repo script and ensure it is executable

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

Initializing repo Client, After installing repo, set up your client to access the android source repository

2.2 Get the Files

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

  • Compilation Procedure
3.1 Toolchain Setup

Download cross-tool chain arm-2012.03-56-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 from code sorcery web site.. $ tar -jxvf 2012.03-56-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
$ export PATH=arm-2012.03/bin:$PATH

  • Build Kernel
Change directory to kernel

$ cd goldfish
$ make ARCH=arm CROSS_COMPILE=arm-none-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-none-eabi- goldfish_armv7_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-none-eabi- zImage
This will generate zImage (kernel image) in kernel/arch/arm/boot folder Build Android filesystem


  • Managing Virtual Devices
An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.


The easiest way to create an AVD is to use the graphical AVD Manager, which you launch from Eclipse by clicking Window > AVD Manager. You can also start the AVD Manager from the command line by calling the android tool with the avd options, from the <sdk>/tools/ directory.

Android Emulator
We will run the Android Emulator, which comes within the Android SDK

Download Android SDK

Install Android SDK

We untar the sdk and add tools directory into the PATH variable:

$ tar xvzf android-sdk_r20.0.3-linux.tgz
$ export PATH=$PATH:~/android-sdk-linux_86/tools

We are not going to create an android virtual device, but instead we will use an environment variable to indicate where our images are:

$ emulator -help # Shows some help.
$ export ANDROID_PRODUCT_OUT=/path/to/goldfish/arch/arm/boot/zImage # Env variable showing where our images are.

Run the emulator program:

$ emulator -verbose

if we want more debug information:

$ emulator -show-kernel -verbose

5.2 CONNECTING TO THE EMULATOR USING ADB (ANDROID DEBUG BRIDGE) TOOL

adb tool comes within Android SDK.

In a console we execute:

$ adb devices
It will show available devices in your system:
List of devices attached
emulator-5554 device

We can now connect to the device:

$ adb shell

  • Loading modules in android using ADB bridge
    1. Compile the module hello.c to be inserted using proper cross-tool chain to get .ko file.
    2. Now push hello.ko on to the data dir of emulatorusing cmd push hello.ko /data
    3. runadb shell from your terminal to have goldfish terminal.
    4. ismode /data/hello.ko
    5. Acknowledge if module is loaded or not using dmesg
    6. If module insertion is successfull go rmmode again check the dmesg prints…

Follow the below links for more tutorials

Leave a Comment