用buildroot qemu 执行 Android 系统

准备 qemu。 编译 arm 的执行环境


(system 模式。是模拟整个硬件了,user 模式是仅仅模拟arm cpu, sys call 转变为对 host linux-x86的调用)

准备build root, build root 自己主动下载须要文件编译须要的 kernel, rootfs
  • $ wget http://buildroot.uclibc.org/downloads/buildroot-2014.05.tar.bz2
  • $ tar xjvf buildroot-2014.05.tar.bz2
  • $ cd buildroot-2014.05/
  • $ make qemu_arm_vexpress_defconfig
  • $ make menuconfig
    Toolchain -> C library -> eglibc
    Toolchain -> Enable C++ support
    System configuration -> Root filesystem overlay directories -> <path to your alien rootfs dir, e.g. /home/payne/qemu/rootfs_my/>
    Target packages -> Show packages that are also provided by busybox
    Target packages -> Debugging, profiling and benchmark -> gdb -> full debugger
    Target packages -> Networking applications -> dhcpcd
    Target packages -> Shell and utilities -> bash
    Filesystem images -> cpio the root filesystem
    Filesystem images -> tar the root filesystem
  • $ export BR2_JLEVEL=4
  • $ make linux-menuconfig
    Device Drivers -> (*) Staging drivers -> (*) Android -> (*) Android Binder IPC Driver
    File systems -> (*) FUSE (Filesystem in Userspace) support
  • $ make


能够指定自己的rootfs, 把 target arm 的可运行文件,放在此文件夹/home/payne/qemu/rootfs_my/, 运行qemu-arm 的时候,就能够在shell 中运行了

执行qemu, 使用的ZImage和rootfs 都是在buildroot中生成的
  • $ ./qemu-2.0.0/bin/system/arm-softmmu/qemu-system-arm -M vexpress-a9 -m 1G -kernel ./buildroot-2014.05/output/images/zImage -drive file=./buildroot-2014.05/output/images/rootfs.ext2,if=sd -append "console=ttyAMA0,115200 root=/dev/mmcblk0" -serial stdio -net nic,model=lan9118 -net user -redir tcp:5900::5900
  • Input "root" when you see the login prompt
  • # dhcpcd

值得注意的是, qemu并不自己主动netwrok, 要执行dhcpcd获得ip(更android 一样。10.0.2.15是自己,10.0.2.2 是host), 在qemu中能訪问外部internet,可是要外部訪问内部须要用port转发-redir tcp:5900::5900,就是把guest os 的5900 和host os 的5900做map, 这样訪问host os 5900就是訪问guest os 的5900
原文地址:https://www.cnblogs.com/slgkaifa/p/6826999.html