Building and Running QEMU from Source Code
This page will take you through the steps you need to follow to build and run QEMU from Source Code.
Building QEMU Source Code On a Linux Host:
Downloading QEMU from AMD
The AMD Xilinx QEMU source code is available on Github and can be downloaded using the following command.
git clone https://github.com/Xilinx/qemu.git
cd qemuThe command above will by default clone the master branch of QEMU. This generally is ahead of the version of QEMU released with PetaLinux. This means it has improvements and new features compared to the released version but is also is less thoroughly tested and could have unknown bugs.
If you want to build the source that was used for the released version of QEMU, please checkout the appropriate tag instead of the master branch.
This can be done by first finding a list of tags:
git tag -lAnd then checking out the release you want to use (for example 2020.1):
git checkout tags/xilinx-v2020.1QEMU Linux Dependencies
If the configure or build steps fail, it is possible some build dependencies are missing. On Ubuntu use the below command to install most of the dependencies needed for building QEMU (please note you may find additional dependencies based on your setup).
sudo apt install libglib2.0-dev libgcrypt20-dev zlib1g-dev autoconf automake libtool bison flex libpixman-1-devConfiguring QEMU
QEMU must be configured to build on the Linux host. This can be accomplished using the following command line.
mkdir build
cd build
../configure --target-list="aarch64-softmmu,microblazeel-softmmu,riscv32-softmmu" --enable-fdt --disable-kvm --disable-xen --enable-gcryptThe command shown above configures QEMU to build aarch64-softmmu, microblazeel-softmmu and riscv32-softmmu targets. Use "./configure –help" to know all supported targets and optional features in QEMU. If no "--target-list" provided, QEMU will build all targets.
Configuration and build steps will create a lot of files. To keep things easy, we will create a new folder called /build and execute the following two steps in that folder.
Building QEMU
The following command line builds QEMU to run on the host computer.
make -j4
# -j options specifies the number of jobs (commands) to run simultaneously. You may increase this to 16, 32 or more for faster build.If the build is successful, an executable named qemu-system-aarch64, qemu-system-microblazeel and qemu-system riscv32 will be created in the aarch64-softmmu, microblazeel-softmmu and riscv32-softmmu sub-directory respectively.
To validate the build run below commands:
./aarch64-softmmu/qemu-system-aarch64 --helpBuilding device tree binaries:
Device trees are used by the QEMU provided by AMD to internally generate a machine model.
Install device tree compiler
If device-tree-compiler is not installed, please install it using below command:
apt-get install device-tree-compilerClone AMD QEMU device trees
git clone git://github.com/Xilinx/qemu-devicetrees.git
cd qemu-devicetreesBuild device trees
You must have dtc on your PATH or specify DTC=<path to device-tree-compiler executable> with the make command below:
make
# make DTC=<path to device-tree-compiler executable>This will give you a folder called LATEST which contains sub-directories for the different QEMU operating modes. Under these sub-directories are the board-specific device trees.
Running QEMU
QEMU can run in two ways:
For running Linux on QEMU, please check PetaLinux boot section and look for the commands it prints when executing boot to Linux prompt step.
An example of these commands on a VCK190 machine may look like:
MicroBlaze QEMU machine
qemu-system-microblazeel \
-M microblaze-fdt \
-serial mon:stdio \
-display none \
-device loader,addr=0xf0000000,data0xba020004,data-len=4 \
-device loader,addr=0xf0000004,data=0xb800fffc,data-len=4 \
-device loader,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/pmc_cdo.bin,addr=0xf2000000 \
-device loader,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/BOOT_bh.bin,addr=0xf201e000,force-raw \
-device loader,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/plm.elf \
-hw-dtb /scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/versal-qemu-multiarch-pmc.dtb \
-machine-path /tmp/qemu-shm \
-device loader,addr=0xF1110624,data=0x0,data-len=4 \
-device loader,addr=0xF1110620,data=0x1,data-len=4AArch64 QEMU machine
qemu-system-aarch64 \
-M arm-generic-fdt \
-serial null \
-serial null \
-serial mon:stdio \
-display none \
-boot mode=5 \
-drive if=sd,index=1,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/qemu_boot.img,format=raw \
-device loader,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/rootfs.cpio.gz.u-boot,addr=0x04000000,force-raw \
-device loader,file=/scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/Image,addr=0x00080000,force-raw \
-gdb tcp::9000 \
-net nic,netdev=eth0 \
-netdev user,id=eth0,tftp=/tftpboot \
-net nic \
-hw-dtb /scratch/petalinux-images/xilinx-vck190-2020.2/pre-built/linux/images/versal-qemu-multiarch-ps.dtb \
-machine-path /tmp/qemu-shm \
-m 8GHowever, these commands will vary from machine to machine.
It is recommended you clear the -machine-path directory between boots. PetaLinux and Yocto tools do this for you. See this section for more information.
Running bare metal applications will be talked about in the next section.
© 2025 Advanced Micro Devices, Inc. Privacy Policy