Dual Android

Introduction

The below tutorial outlines how to run two instances of virtualized Androids on Google Galaxy Nexus phone, using the pre-built binaries as well as the sources.

Demonstration details

  • The following demo is for Google Galaxy Nexus phone, having OMAP 4460 processors.
  • We will run two instances of virtualized Android kernels, paralelly, over the Codezero hypervisor.
  • Android#0 will boot from the flash memory of the phone, while Android#1 will boot via NFS, exported by Android#0.
  • Both Android kernels as well as filesystems are based on android_4.0.3-r1/ICS AOSP release by Google.
  • Android#0 will boot on Core0 and Android#1 will boot on core1.

Hardware requirements

  • Google Galaxy Nexus handset/mobile phone.
  • Micro-USB to USB converter.

Downloading the pre-built binaries

Download binaries from here. It contains the following files

  • system.img – Android#0 filesystem’s system binary image
  • userdata.img – Android#0 filesystem’s userdata binary image
  • ramdisk.img – Android#0 filesystem’s system ramdisk image
  • root.tar – Tarball containing ramdisk of Android#1
  • system.tar – Tarball containing system partition of Android#1′s filesystem
  • Image – ELF file containing Codezero, Android#0 and Android#1 kernels and ramdisk.img
  • nfs.tar – NFS scripts
  • vanilla-kernel-boot.img – Vanilla kernel boot image
  • androidVNC-modified-signed.apk – VNC client application
  • su.zip – Super User application
  • recovery-clockwork-touch-5.8.0.2-maguro.img – Recovery image

Setting up the demo

Install AOSP tools and configure fastboot device access by following the Installing AOSP host tools and Configuring USB Access sections of the Initializing the Host Environment page.

Connect the phone to the host machine using Micro-USB to USB converter. Press Volume UP, Volume Down and Power keys of the phone simultaneously, making the phone go into the fastboot mode.

Flash Android#0′s binaries

$ fastboot erase cache
$ fastboot flash recovery recovery-clockwork-touch-5.8.0.2-maguro.img
$ fastboot flash system system.img
$ fastboot flash userdata userdata.img
$ fastboot flash boot vanilla-kernel-boot.img
$fastboot reboot

Once the phone boots, flash SU application

$ adb push su.zip /sdcard/su.zip

Reboot the phone in recovery mode using volume and power keys. In recovery mode, install su.zip. Reboot the phone.

Once the phone has booted, flash Android#1′s filesystem

$ adb push system.tar /sdcard/system.tar
$ adb push root.tar /sdcard/root.tar
$ adb push nfs.tar /sdcard/nfs.tar
$ adb install androidVNC-modified-signed.apk

Install Android#1′s filesystem on phone

$ adb shell; This will take you to phone's console and all the commands \
              mentioned below are issued in phone's shell.
$ su
$ cd /data/
$ /busybox cp /sdcard/nfs.tar .
$ cd nfsdir
$ /busybox tar -xvf /sdcard/root.tar
$ mv root/* .
$ cd system
$ /busybox tar -xvf /sdcard/system.tar
$ mv system/* .
$ reboot bootloader

Once the phone has booted in bootloader mode, flash Codezero and virtual android kernels

$ mkbootimg --kernel Image --ramdisk ramdisk.img -o paravirt-boot.img
$ fastboot flash boot paravirt-boot.img
$ fastboot reboot

Successful setup will lead to booting of Android#0 on the phone’s screen.

Switching GUI between Android#0 and Android#1

Initially Android#0 appears on the phone screen. To switch to Android#1

Click on the AndroidVNC application icon.
Enter the following settings- IP: 10.0.2.16, Port: 5901 and BPP: 24.
Press connect.

This should connect you to the VNC server running on Android#1.

Building from sources

Check the section on Building from Source for Galaxy Nexus page for instructions on building Codezero and Android kernels from the sources.

Known Issues

  • First few boots may be extra slow, due to Android initializing the filesystem for the first time.
  • Android#1 may be a bit slower than Android#0.
  • Touch screen/Keyboard inputs to Android#1 may not work initially. To enable key inputs, send “CTRL+ATL+SHIFT+F10″ input to Android#1 from the VNC client’s Send Keys option.

Replacing Android#1 with Linux

To boot Linux based distribution instead of Android#1 follow exactly the same procedure as mentioned above, but instead of using root.tar and system.tar use buildroot based linux distro from here.

Install Linux filesystem/distro on phone

$ adb push linux-rootfs.tar.gz /sdcard/linux-rootfs.tar.gz
$ adb shell; This will take you to phone's console and all the commands \
              mentioned below are issued in phone's shell.
$ su
$ cd /data/
$ cd nfsdir
$ /busybox tar -xvf /sdcard/linux-vx-rootfs.tar.gz
$ /busybox chown 1000:1000 rootfs/* -R
$ mv rootfs/* .
$ reboot bootloader

Also, to connect to the VNC server of Linux from Android#0 VNC client use the following settings

IP-Address: 10.0.2.16, Port: 5900, Colours/Bits per Pixel: 24(4bit)

Other than this, all the procedure is same as mentioned in Setting up the demo section above.

Once you are connected to the VNC server of Linux, if Linux screen shows black area in background i.e whole screen is not used by Linux, fix the screen geometry in /data/nfsdir/etc/init.d/S32vnc; here pass the correct geometry to Xtightvnc based on your display resolution. Fix this and reboot.

Comments are closed.