Linux kernel --- VirtualBox
来源:互联网 发布:mac系统dmg下载地址 编辑:程序博客网 时间:2024/06/08 19:18
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.
- Linux kernel --- VirtualBox
- Linux Kernel -- Debug VirtualBox
- Tutorial: Debugging Linux Kernel with GDB under VirtualBox
- Debugging the linux kernel using kgdb and VirtualBox
- VirtualBox + kgdb analysis of Linux kernel (v3.4.0-rc3)
- The VirtualBox Linux kernel driver (vboxdrv) is either not loaded
- The VirtualBox kernel modules do not match this version of VirtualBox 解决 (linux update,nvidia失败)
- Recompiling VirtualBox kernel module
- VirtualBox kernel modules lost!!!
- 使用virtualbox + kgdb调试kernel
- Debugging Linux Kernel Modules with VirtualBox and KGDB(自己加调试方法总结)
- Linux下VirtualBox USB以及Kernel driver not installed的解决办法
- VirtualBox安装VBoxLinuxAdditions错误:unable to find the sources of your current linux kernel
- VirtualBox安装VBoxLinuxAdditions错误:unable to find the sources of your current linux kernel
- Linux(ArchLinux) 下Virtualbox启动报错Kernel driver not installed (rc=-1908)
- kali 安装virtualbox tools出错ERROR: UNABLE TO FIND THE SOURCES OF YOUR CURRENT LINUX KERNEL.
- VirtualBox安装VBoxLinuxAdditions错误:unable to find the sources of your current linux kernel
- linux kernel
- Delphi类的静态属性及方法。
- 异步串行通讯和同步串行通讯
- GlusterFS:No such file or directory
- struts的bean标签
- ruby&python 从CGI 到 WSGI 到 Rack, 顺带Sinatra
- Linux kernel --- VirtualBox
- 专家讲解:Md5(base64)加密与解密实战
- web项目Spring框架下虚拟测试端编写
- 多个文件下使用全局变量
- lr_convert_string_encoding
- 用Mac和Linux命令行工具使用Windows Azure
- 二十六、JCreator使用初步
- IIS 使用域账户访问SQL 需要配置
- java封装