最近学习了下QEMU。今天就把官网的内容贴过了给大家分享一下。
QEMU是一个法国的天才程序员Fabrice Bellared 开发的虚拟化软件。类似于VMwar、Virtual Box。但是他是开源的遵循LGPL协议。没有Xilinx硬件开发环境的情况下,也可以配合QEMU来玩虚拟的zynq的东东。
官方给的方法很详细,这里就不翻译了。
(参考链接:http://www.wiki.xilinx.com/QEMUhttp://wiki.qemu.org/Main_Page
http://xilinx.lzu.edu.cn/zynq-qemu)
三个步骤:下载、配置和编译。
然后就可以大家虚拟的系统来玩,具体的参考下面的内容:
Downloading QEMU from XilinxThe Xilinx Zynq QEMU source code is available on the Xilinx Git server and can be downloaded using the following command.
$ git clone git://github.com/Xilinx/qemu.git$ cd qemu
Configuring QEMUQEMU must be configured to build on the Linux host. This can be accomplished using the following command line.
$ ./configure --target-list="aarch64-softmmu,microblazeel-softmmu" --enable-fdt --disable-kvm
Building QEMUThe following command line builds QEMU to run on the host computer.
$ make
If the build is successful, an executable named qemu-system-aarch64 and qemu-system-microblazeel will be created in the aarch64-softmmu and microblazeel-softmmu sub-directory respectively.
Running QEMUXilinx QEMU implements a framework for generating custom machine models based on a device tree (dtb).
QEMU expects a device tree blob to be passed to it on the command line using the -dtb option. A device tree file, *.dts, is compiled to a device tree blob, *.dtb, using the device tree compiler as shown at Zynq Linux.
After compiling a device tree into a device tree blob, the file path is specified on the command line of QEMU. QEMU will then create a custom machine model that matches the passed in dtb. Devices not supported by QEMU will have their compatible properties invalidated if booting Linux.
NOTE: It is still up to the user to select the correct machine model for their architecture, see below.
Standard Arguments RequiredBelow are some of the standard QEMU arguments to boot Xilinx machines. See the QEMU documentation for more information.
Argument
| Standard Options
| Explanation
|
-M
| microblaze-fdt-plnx
arm-generic-fdt-plnx
| Specifies what machine QEMU should use. In this case it's either a MicroBlaze or Zynq generic machine based on the DTB.
|
-m
|
| Specifies the amount of memory. Generally for MicroBlaze use 256
|
-serial
| mon:stdio
| Specifies where to connect the serial to. There are more advanced options available, but this connections the QEMU monitor and first serial device to standard IO.
|
display
| none
| Tells QEMU not to try and create a display.
|
-kernel
|
| Specifies the boot image.
|
-gdb
| tcp:9000
| Opens a connection for GDB debugging
|
-dtb
|
| Specifies a DTB to use to create the machine and pass to the guest
|
-machine
| linux=on
| Tells QEMU to boot Linux
|
Running a Linux Kernel Image In QEMUBelow is an example of booting a Linux image on a Zynq machine. The Linux kernel should start booting and a shell prompt should be displayed. Control A-X will exit QEMU.
$ ./aarch64-softmmu/qemu-system-aarch64 -M arm-generic-fdt-plnx -machine linux=on -serial /dev/null -serial mon:stdio -display none -kernel
/uImage -dtb /devicetree.dtb --initrd /uramdisk.image.gzExample images can be found in the Zynq release tarball available at: http://www.wiki.xilinx.com/Zynq+Releases
Both Zynq ARM Cortex A9 processors are running in Linux under QEMU. The following command shows both processor details.
zynq> cat /proc/cpuinfo
Below is an example of booting a Linux ELF image on a Zynq machine. The Linux kernel should start booting and a shell prompt should be displayed. Control A-X will exit QEMU.
$ ./aarch64-softmmu/qemu-system-aarch64 -M arm-generic-fdt-plnx -machine linux=on -serial /dev/null -serial mon:stdio -display none -kernel /image.elf -dtb /system.dtbComplete Linux ELF images and device trees can be built by PetaLinux.
Both Zynq ARM Cortex A9 processors are running in Linux under QEMU. The following command shows both processor details.
zynq> cat /proc/cpuinfo
Below is an example of booting a Linux ELF image on a MicroBlaze machine. The Linux kernel should start booting and a shell prompt should be displayed. Control A-X will exit QEMU.
$ ./microblazeel-softmmu/qemu-system-microblazeel -M microblaze-fdt-plnx -m 256 -serial mon:stdio -display none -dtb /system.dtb -kernel /image.elfComplete Linux ELF images and device trees can be built by PetaLinux.
1. Networking
The following command line switch examples which are not specific to Xilinx QEMU can also be added to the QEMU command line for networking.
Command line switch
| Purpose
|
-tftp /path-to-your-home-directory
| sets up a TFTP server to the specified directory
|
-redir tcp:10021:10.0.2.15:21
| redirects port 10021 on the host to port 21 (ftp) in the guest
|
-redir tcp:10023:10.0.2.15:23
| redirects port 10023 on the host to port 23 (telnet) in the guest
|
-redir tcp:10080:10.0.2.15:80
| redirects port 10080 on the host to port 80 (http) in the guest
|
-redir tcp:10022:10.0.2.15:22
| redirects port 10022 on the host to port 22 (ssh) in the guest
|
2. Using SSH From Host To Guest
To avoid issues with passwords, an SSH configuration file is recommended on the Linux host which removes the host authentication for the local host. Add the following line to the file .ssh/config of the user home area on the Linux host to avoid password issues.
NoHostAuthenticationForLocalhost=yes
Assuming port 10022 was redirected in the QEMU command line, as illustrated above, the following command can be used to SSH to the guest on the Linux host (user = root, password = root).
bash$ ssh localhost -p 10022 -l root3. Running With USB SupportBefore starting QEMU on the Linux host, information about the USB devices needs to be discovered. The method to discover this can be different across Linux distributions (RedHat vs Ubuntu) and this may be dependent more on the kernel version than the distribution. The following command is used to discover the USB device information for Redhat.
bash$ cat /proc/bus/u***/devices
This command will show all the USB devices connected to your host. It is be displayed as a paragraph for each device. For example if you are looking for mass storage device, look for a line in a paragraph that starts with (S) and has Product=Mass Storage. In the same paragraph look for the line that starts with the letter (P), you should see Vendor=xxxx ProdID=xxxx.
To enable USB host support with QEMU, add "-u*** -u***device host::" to the QEMU command line. The vender ID and product ID in the command line should be replaced by the vendor ID and product ID found discovered for the USB device on the host.
Please notice that QEMU emulates OTG USB Controller when it is configured as a host controller since a typical PC has only A-type USB receptacles.
Z-turn Board 学习笔记(7)--- Blink LED