This article describe about how to roadmap android kernel on VirtualBox
Software environment: Ubuntu 10.0.4LS
1. Download android source code
http://source.android.com/source/downloading.html
$source build/envsetup.sh
$lunch (select vbox_x86-eng target)
$make -j4 android_disk_vdi
Notice: If you have problem with a LUNCHER in your virtualbox and see in the logs in the logcat saying something liek this:"Clamp target Gc heap from 16.880MB to 16.000MB", It means that heap is just too small.
To fix it add ADDITIONAL_BUILD_PROPERTIES+=dalvik.vm.heapsize=32m at the end of file build/target/board/vbox_x86/BoardConfig.mk
2. Download goldfish kernel
git clone http://android.googlesource.com/kernel/goldfish.git
git checkout remotes/origin/android-goldfish-2.6.29
Please refer to androidsrc/external/qemu/docs/ANDROID-KERNEL.TXT to compile kernel
There is a patch for it, 0001-vbox-fix-pic-compilation-error.patch
---
Makefile | 3 ++-
arch/x86/boot/Makefile | 1 +
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 1ab3ebf..987951b 100644
--- a/Makefile
+++ b/Makefile
@@ -346,7 +346,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
- -Werror-implicit-function-declaration
+ -Werror-implicit-function-declaration \
+ -fno-pic
KBUILD_AFLAGS := -D__ASSEMBLY__
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index cd48c72..44b8b68 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -64,6 +64,7 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
-march=i386 -mregparm=3 \
-include $(srctree)/$(src)/code16gcc.h \
-fno-strict-aliasing -fomit-frame-pointer \
+ -fno-pic \
$(call cc-option, -ffreestanding) \
$(call cc-option, -fno-toplevel-reorder,\
$(call cc-option, -fno-unit-at-a-time)) \
--
1.7.0.4
$cd androidsrc
$cd goldfish
$git am 0001-vbox-fix-pic-compilation-error.patch
$ $ANDROID/external/qemu/distrib/build-kernel.sh --arch=x86 --out=$ANDROID/prebuilt/android-x86/kernel --config=vbox
The kernel file will be copied to $ANDROID/prebuilt/android-x86/kernel,
$cd ..
generate vbox vdi again with the new kernel
$ make -j4 android_disk_vdi
3. install virtualbox-4.1_4.1.18-78361~Ubuntu~lucid_amd64.deb
download and install it.
Configure Vbox
4. Connect Vbox
There is adb command at androidsrc/out/host/linux-x86/bin/adb
$adb connect localhost
$adb shell #will go into vbox command console
$adb push ./somefile /data //push some file to vbox
$adb pull /data/somefle . // get some file from vbox
$adb logcat //log will out to current console
5. Create a character driver
put is at driver/chard
create a Kconfig for it
menuconfig CHARDRIVER
bool "enable character driver"
default n
help
This enable my character driver.
character special file /dev/char_deb.
If unsure, say N.
if CHARDRIVER
comment "character Device Drivers"
# Architecture Independent
config CHARD_TEST
tristate "enable chard"
default y
depends on CHARDRIVER
help
Compile this into kernerl or as a module.
Add these 2 lines to arch/x86/configs/vbox_defconfig
CONFIG_CHARDRIVER=y
CONFIG_CHARD_TEST=m
add obj-$(CONFIG_CHARD_TEST) += chard/ to driver/Makefile
Use build-kernel.sh to compile kernel again.
5. Write a test app for character driver
Please refer to One Character driver code
Compile a vbox version,
copy it to androidsrc/external/chardtest,
Create Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= test.c
LOCAL_MODULE := test
#LOCAL_STATIC_LIBRARIES := libcutils libc
include $(BUILD_EXECUTABLE)
$cd androidsrc
$source build/envsetup.sh
$lunch (select vbox_x86-eng target)
$mm external/chardtest
push it to vbox
6. Download busybox for Vbox
Default, there is no mknod command in vbox, need busybox.
Busybox is only a set of programs. Even though it is a fairly comprehensive set of programs needed to run a Linux system, these programs per se can not "run a modem".
http://busybox.net/downloads/binaries/latest/busybox-i686
push it to vbox
./busybox-i686 mknod /dev/char_dev c 100 0
7. Test driver
# echo 0000 > /dev/char_dev
use test app to read it.