VirtualBox非官方中文论坛

 

 

搜索
VirtualBox非官方中文论坛 广场 VirtualBox文档 Android移植到VirtualBox及详细流程
查看: 2855|回复: 0
go

[Fedora] Android移植到VirtualBox及详细流程

Rank: 8Rank: 8

UID
帖子
106 
VirtualBoxChina币
301 分 
活跃积分
0 点 
技术积分
0 ° 
注册时间
2009-5-17 
最后登录
2010-12-9 
VirtualBoxChina 发表于 2010-3-3 22:16 |显示全部帖子

您是本帖的第2855个浏览者


Opendroid原创,转载清注明!
请想要深入学习和研究Android的朋友加入Opendroid QQ群81410571,我们目前已成功移植android到s3c2440以及virtualbox等。正在筹划进一步的深入学习计划!
  VirtualBox是Sun推出的一款跨平台开源虚拟机软件,Android目前已经支持x86原生编译,我们的目的是让Android可以在VirtualBox上运行。鉴于x86虚拟机平台调试的方便性,不失为一学习研究的好平台。
  本文写作时,android已经被国内外人士移植到x86之上。Eeepc 701和vmware是最早跑起来的一些x86平台。同时VirtualBox也已经有人移植成功。
  本文亦参考了这些经验。特别是如下两文:
http://groups.google.com/group/android-porting/msg/6cf95445f9709987
http://groups.google.com/group/android-porting/msg/2dedc5fe7ad58ed3

  详细的移植步骤,我们按3步来:
1.Android根文件系统
这个与eeepc701上的完全一样, 需要下载源码并自行编译.
请参考http://blog.csdn.net/opendroid/archive/2009/02/24/3933897.aspx
如果提示out/.../data目录不存在, 创建之后重编, 直到生成installer.img.

2.支持VirtualBox的linux kernel
我们这里主要添加的是网卡和fb支持.
首先拷贝./vendor/asus/eee_701/kernel.config到kernel/.config
然后make menuconfig修改如下选项:
network device support ->
   Ethernet (10 or 100Mbit)  --->
      
  •    EISA, VLB, PCI and on board controllers
             <*>     AMD PCnet32 PCI support  

      Graphics support  --->
       <*>  Support for frame buffer devices  --->
          
  •    VESA VGA graphics support  <- Unfortunately, Vesa VGA

      Console display driver support  --->
           <*> Framebuffer Console support
          
  • Select compiled-in fonts
             
  •    VGA 8x8 font
             
  •    VGA 8x16 font
    同时,还需要去掉pmem支持,只有需要大块连续内存的设备上需要它
    * Disable pmem allocator if your kernel is 2.6.27 base.
  • Misc devices  --->
      [ ]   Android pmem allocator (NEW)
    最后make bzImage生成到arch/x86/boot/bzImage

    3.镜像生成
    这是一个比较复杂的过程
    1)创建分区配置文件, 可以参考vendor/asus/eee_701/disk_layout.conf
    $vim d.conf
    内容为:
    device {
        scheme mbr

        # bytes in a disk sector (== 1 LBA), must be a power of 2!
        sector_size 512

        # What LBA should the partitions start at?
        start_lba 2048

        # Autodetect disk size if == 0
        num_lba 0

        partitions {
            sysloader {
                active y
                type linux
            }

            recovery {
                active y
                type linux
            }

            boot {
                active y
                type linux
            }

            cache {
                type linux
            }

            system {
                type linux
            }

            third_party {
                type linux
            }

            data {
                type linux
            }
        }
    }

    2)拷贝host机器的mbr文件
    $cp grub/grub.bin installed.img

    3)创建 boot.img:
      里面需要有三个文件:
      ramdisk cmdline kernel
      你需要export out/host/linux-x86/bin/到PATH以便方便的访问如下用到的一些工具。
      
      接下来一步步创建出来:
      $mkdir bootimg
      $cp -raf root rootimg
      rootimg里面的init.rc,需要改掉所有的mount ext3为ext2,因为genext2fs只能生成ext2镜像.
      $mkbootfs rootimg | gzip -9 > bootimg/ramdisk

      $echo "console=tty0 console=ttyS1,115200n8 console=tty0
    androidboot.hardware=eee_701 vga=788" > bootimg/cmdline

      $cp android/kernel/arch/x86/boot/bzImage bootimg/kernel
      
      生成boot.img:
      $genext2fs -b 8192 -m 0 -d bootimg boot.img

    4)创建dummy img
      $mkdir dummy
      $genext2fs -b 8192 -m 0 -N 8 -d dummy dummy.img

    5)创建data.img
      $genext2fs -b 81920 -d data -N 512 -m 0 data.img

    6)创建磁盘镜像文件installed.img
      $editdisklbl -l d.conf -i installed.img  boot=boot.img cache=dummy.img system=system.img third_party=dummy.img data=data.img
      至此,installed.img镜像生成后,你可以直接在kvm/qemu,也可以经过一些处理,在vmware和virtualbox上使用。

    7)在virtualbox上,我们需要将installed.img转换成installed.vdi
      $VBoxManage convertfromraw -format VDI ./installed.img ./installed.vdi

    4.运行
    1)配置virtualbox
      任选一linux based的机型即可。硬盘选ide primary master, 镜像选择你才做好的install.vdi..网络选择NAT方式,虽然受限制,但是可以直接支持访问外网。
    2)启动
      启动之后,在sun的图片界面,一定要按F12以进入启动选择界面,之后按1)即可。否则会卡在grub,需要重新生成vdi文件并重新加载!!切记!!  
    3)切换到命令行
      按alt+right可以切换到命令行,方便调试。

    Opendroid团队


    QQ群:81410571



    文章来源:http://paullu.blog.51cto.com/828864/168465


  • plugin_name


    VirtualBox非官方中文论坛 - 论坛版权

    VirtualBox非官方中文论坛 百度GG

    GMT+8, 2012-2-6 08:17 , Processed in 0.025221 second(s), 19 queries , Gzip On.

    Powered by Discuz! X1.5

    © 2001-2010 Comsenz Inc.