Xilinx actively develops a QEMU tree for both Microblaze and Zynq. The Xilinx QEMU git tree follows mainline development continuously and developers make effort to push all developments upstream. The Xilinx tree is more however more complete that the qemu upstream (git://git.qemu-project.org/qemu.git), and it is recommended that customers use the QEMU tree provided at https://github.com/Xilinx/qemu.

Supported Zynq Hardware

A limited subset of the Xilinx Zynq hardware is supported in QEMU. Each model has only been tested with the respective Linux driver such that not all hardware features may be modelled. The following table lists the hardware that is modelled in QEMU.
Model Source
Hardware Block
QEMU
Cortex A9
QEMU
NEON
QEMU
ARM MPCore
Xilinx
EMAC
Xilinx
Timer Counter
Xilinx
UART
Xilinx
USB
Xilinx
I2C (with swich and EEPROM)
Xilinx
DMA
Xilinx
SPI (with flash)
Xilinx
NAND
Xilinx
NOR
Xilinx
QSPI (with flash)

QEMU Source Code

Downloading QEMU from Xilinx

The Xilinx Zynq QEMU source code is available on the Xiilnx Git server and can be downloaded using the following command.
$ git clone git://github.com/Xilinx/qemu.git
$ cd qemu
 
$ git checkout xilinx-master

Configuring QEMU

QEMU must be configured to build on the Linux host. This can be accomplished using the following command line.
$ ./configure --target-list="arm-softmmu,microblazeel-softmmu" --enable-fdt --disable-kvm

Building QEMU

The following command line builds QEMU to run on the host computer.
bash$ make
If the build is successful, an executable named qemu-system-arm will be created in the arm-softmmu sub-directory.

Running QEMU

Xilinx 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. Device not supported by QEMU will have their compatible properties invalidated if booting Linux.

Running a Linux Kernel In QEMU

The following command line is used to start QEMU with a Linux kernel, dtb, and ramdisk.

$ ./arm-softmmu/qemu-system-arm -M arm-generic-fdt -nographic -smp 2 -machine linux=on -serial mon:stdio -dtb <path>/foo.dtb -kernel <path>/zImage -initrd <path>/ramdisk.img
The Linux kernel should start booting and a shell prompt should be displayed. Control A-X will exit QEMU.
Note: The ramdisk.img must not have a u-boot header.

Both Zynq ARM Cortex A9 processors are running in Linux under QEMU. The following command shows both processor details.
zynq> cat /proc/cpuinfo
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 root
3. Running With USB Support
Before 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/usb/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 "-usb -usbdevice host:<vendor ID>:<product ID>" 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.

Related Links