qemu在Linux系统上的使用

来源:互联网 发布:js超链接跳转 编辑:程序博客网 时间:2024/05/16 05:10
========================================================


基于arm的模拟器:
ARM的ARMulator;
SkyEye;
GNU的ARMulator;
Softgun;
realboard;
QEMU;著名的android emulator就是基于QEMU的;


=======================================================


环境:ubuntu 12.04(x86_64)
     QEMU emulator version 1.0.50


qemu官方网站:www.qemu.org


qemu安装:
sudo apt-get install qemu-system
qemu常用命令
qemu-system-arm 启动仿真arm芯片
qemu-system-arm -M ? 察看支持arm平台有哪些(开发板)
qemu-system-arm -cpu ? 察看支持arm哪些cpu
qemu-img 格​式​化​虚​拟​客​户​端​映​像​、​附​加​存​储​设​备​以​及​网​络​存​储


========================================================
关于qemu模拟器调试arm程序:


1.搭建交叉编译环境
arm-linux-gcc
arm-linux-as
arm-linux-ld
arm-linux-gdb


2.创建测试程序
=======test.S========
.globl _start
_start:
  mov r0, #0
  mov r1, #1
  mov r2, #2
loop:
  b loop
=======EOF=========


编译:arm-linx-as -o test.o test.S
链接:arm-linux-ld -o test test.o


3.调试
 
(1)运行:qemu-system-arm -gdb tcp::2828 -kernel test
(2)运行:arm-linux-gdb test
      (gdb) target remote localhost:2828
      (gdb) c


4.Here are some useful tips in order to use gdb on system code:


Use info reg to display all the CPU registers.
Use x/10i $eip to display the code at the PC position.
Use set architecture i8086 to dump 16 bit code. Then use x/10i $cs*16+$eip to dump the code at the PC position.


更多功能参考qemu官方网站。


===========================================================


在qemu上安装Linux系统
1.qemu官方提供的arm的linux测试版本,下载地址:http://wiki.qemu.org/Testing
2.下载文件 arm-test-0.2.tar.gz
3.gunzip –c arm-test-0.2.tar.gz
  tar xvf arm-test-0.2.tar
4.启动(图形):qemu-system-arm -kernel zImage.integrator -initrd arm_root.img
  启动(非图形):qemu-system-arm -kernel zImage.integrator -initrd arm_root.img -nographic


在qemu上安装自己编译内核的Linux内核系统
1.下载linux最新内核源代码linux-3.5.2
2.配置编译内核
# make make make vexpress_defconfig
# make
生成镜像<home_src>/arch/arm/boot/zImage
3.运行
qemu-system-arm -M vexpress-a9 -kernel zImage  -initrd /home/duli/kernel/arm-test/arm_root.img
===========================================================


关于ubuntu搭建虚拟网卡


虚拟机的桥接


virtualbox 中,由于virtualbox为这些把工作已经给做好了,所以直接使用则可以


qemu中,则需要自己去配置


安装必要工具
$sudo apt-get install uml-utilities bridge-utils


安装上述软件之后,系统中会出现一个名为“uml-net”的用户组,为了使你的虚拟机能够访问网络接口,必须将运行虚拟主机的用户的用户名添加到该组中:
sudo gpasswd -a 你的帐户名 uml-net


设置Virtualbox启动
/etc/network/interfaces 配置文件的配置
$sudo gpasswd -a 你的帐户名 uml-net
sudo gpasswd -a 你的帐户名 vboxusers


 auto lo
 iface lo inet loopback
 
 auto eth0
 iface eth0 inet manual
 
 auto tap0
 iface tap0 inet manual
 up ifconfig $IFACE 0.0.0.0 up
 down ifconfig $IFACE down
 tunctl_user root
  
 auto br0
 iface br0 inet static
 address 192.168.6.240
 network 192.168.6.0
 netmask 255.255.255.0
 broadcast 192.168.6.255
 gateway 192.168.6.1
 ridge_ports eth0
 bridge_stp off
 bridge_fd 0
 bridge_maxwait 0




注:tun0有没有其作用不是清楚;


配置文件注解:
tap0,是定义的网络接口
br0,是建立一个桥叫br0,主机中的所有网络接口,也包括tap0这个虚拟网络接口,都将建立在这个桥之上


ifup br0 没有起来也可以只用tap0去通信
ifup tap0


qemu-system-arm -M vexpress-a9 -m 512 -kernel u-boot -net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,ifname=tap0,script=no 


set serverip 
set ipaddr


tftp 82000000






============================================================


qemu上关于BootLoader的安装


1. 编译u-boot,配置选项选择qemu支持的一种开发板,比如有vexpress-a9开发板的
(1)make ca9x4_ct_vxp_config
(2)make
注:这里配置目标板为 Cortex-A9x4 vexpress. 之所以选这个配置可以从 boards.cfg文件里看到, vexpress是ARM公司使用Cortext-A9的一个开发板,相关的代码在 board/armltd/vexpress/ 目录,配置文件为include/configs/ca9x4_ct_vxp.h。  而且关键的是Qemu里面已经支持这个板卡。


2.  
qemu-system-arm -m 256M -M vexpress-a9 -kernel u-boot -nographic
0 0
原创粉丝点击