Download - ZynqMPのQEMU
![Page 1: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/1.jpg)
ZynqMPのQEMU
@Vengineer
ZynqMP勉強会資料 (2016/2/20)
![Page 2: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/2.jpg)
自己紹介
Twitter ID :@Vengineer 2009年〜
Blog :@Vengineerの戯言 2007年〜
http://blogs.yahoo.co.jp/verification_engineer
:昭和の時代(1987年)〜 C++を書いているプログラマ
AT&T C++ Translator => Zortech C++ … GCC/Intel/LLVM
:「SystemVerilog設計スタートアップ(2008年)」の中の人のひとり
http://www.cqpub.co.jp/hanbai/books/36/36191.htm
![Page 3: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/3.jpg)
ZynqMP : QEMU
1)、Xilinx Github : https://github.com/xilinx
2)、Xilinx Wiki : http://www.wiki.xilinx.com/
3)、QEMU User Guide, UG1169 (v1.0) November 18, 2015
4)、QEMU Github : https://github.com/qemu/qemu
![Page 4: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/4.jpg)
ZynqのQEMU
自分のブログに、2012年3月9日から4月11日の間に、
Zynqのqemu(その0) 〜 Zynqのqemu(その11) でアップしていた。
ZynqMPに関しては、
「QEMU for ZynqMP」として、2015年7月31日に書いてた。
http://blogs.yahoo.co.jp/verification_engineer/69990003.html
![Page 5: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/5.jpg)
QEMU for Xilinx ZynqMP by Edgar E. Lglesias
QEMU for Xilinx ZynqMP by Edgar E. Iglesias
https://www.youtube.com/watch?v=L5zG5Aukfek
http://events.linuxfoundation.org/sites/events/files/slides/zynqmp-qemu.pdf
この人、TLMu : https://edgarigl.github.io/tlmu/ も作っています。
TLMuは、hdLab (http://www.hdlab.co.jp/web/a050consulting/b009armcpumodel/) や プロファウンド・デザイン・テクノロジー (http://www.profound-dt.co.jp/tlmu.php) で利用されています。
LinkedIn : http://au.linkedin.com/in/edgariglesias
![Page 6: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/6.jpg)
ソースコード(Xilinx)からビルド
参考文献2)、QEMU+-+ZynqMP 、QEMU
$ git clone git://github.com/Xilinx/qemu.git
$ cd qemu
$ ./configure --target-list="aarch64-softmmu,microblazeel-softmmu"
--enable-fdt --disable-kvm
$ make
![Page 7: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/7.jpg)
ソースコード(本家)からビルド
参考文献3)、P.31−32
./configure --target-list="aarch64-softmmu,microblazeel-softmmu,arm-softmmu" \
--enable-fdt \
--extra-cflags=”-DXILINX_SPIPS_ERR_DEBUG=2 -DM25P80_ERR_DEBUG=2 \
-DNAND_ERR_DEBUG=1 -DARASAN_NFC_ERR_DEBUG=1 \
-DSDHC_DEBUG -DFDT_GENERIC_UTIL_ERR_DEBUG=2 \
-DCADENCE_GEM_ERR_DEBUG -DCONFIG_FDT “ \
--enable-debug --force-internal-fdt --disable-werror --enable-sdl
![Page 8: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/8.jpg)
A53でStandalone program
参考文献3)、P.10
Standalone Hello World ExampleThis example runs a “Hello-world” ELF file on an A53 processor. Substitute thehello_world.elf with the location your target software, as follows:
qemu-system-aarch64 -nographic -M arm-generic-fdt -dtb qemu-arm.dtb \-device loader,file=./hello_world.elf,cpu=0 \-device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4
![Page 9: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/9.jpg)
A53でStandalone program
参考文献3)、P.13
プログラムが動作するCPUは、”-cpu=<value>” オプションで指定できる。
0 A53-0、 1 A53-1、 2 A53-2、 3 A53-34 R5-0、 5 R5-1
A53だけでなく、R5も指定できる!
ただし、dtb(dts)ファイル内で /cpuノード 内の番号を変えると上記の割当を変更できる。
![Page 10: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/10.jpg)
Multiple Architecture QEMU
参考文献3)、P.134
・This version of QEMU supports running the ARM (Cortex-A53s and Cortex-R5s) and Microblaze™ power management unit (PMU).
・ The multi-architecture version of QEMU needs different device tree binaries (DTB)s, than what is necessary for single-architecture (Single-Architecture).
![Page 11: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/11.jpg)
Serial
参考文献3)、P.17
-serial=<arg>
<arg> /dev/null Disconnect this particular serial.<arg> mon:stdio Connect this serial and monitor to the terminal.<arg> stdio Connect this serial to terminal.<arg> telnet::<port>,server, nowait
Create a localhost telnet server on <port> for the serialconnection. It can be accessed by: telnet localhost <port>.
<arg> chardev: dev Connects serial to a backend; for example, to a socket, pipe, or terminal.
![Page 12: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/12.jpg)
no graphic
参考文献3)、P.17
-nographic
By default, QEMU attempts to create a display for user I/O. This option instructs the QEMUthat there is no need for a display and I/O is serial.QEMU attaches the invoking terminal to the serial port in this case (in the default use cases,this is UART0).
In this mode, the QEMU monitor (a command line interface for sending control commandsto QEMU) is multiplexed on stdio. To switch between the serial port and the monitor, usethe following command: CTRL-a c
![Page 13: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/13.jpg)
ソースコードを追ってみる
![Page 14: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/14.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、
![Page 15: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/15.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、ありませーん。
![Page 16: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/16.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、ありませーん。
hw/arm/xilinx_zynq.cになっていました。
![Page 17: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/17.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、ありませーん。
hw/arm/xilinx_zynq.cになっていました。
どうして?
![Page 18: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/18.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、ありませーん。
hw/arm/xilinx_zynq.cになっていました。
どうして? => DTB(Device Tree Blob)を使うようになったので、
![Page 19: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/19.jpg)
ブログ、Zynqのqemu(その2)
http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから
Zynqのhw/xilinx.cを探したら、ありませーん。
hw/arm/xilinx_zynq.cになっていました。
どうして? => DTB(Device Tree Blob)を使うようになったので、
で、ZynqMPは、 hw/arm/xlnx_zynqmp.c で、xlnx_ep108.c が評価ボード。
![Page 20: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/20.jpg)
xilinx_init関数
http://blogs.yahoo.co.jp/verification_engineer/66230769.htmlから
xilinx_init関数内でZynq内部の次のような機能に対応するコードがありました。
DRAM、On-chip memory (256KB)、Flash memory、QSPI Flash (32MB)、
Nand Controller、 SMC、 SLCR (System Level Control Register)、 A9-MPCore (Dual Core)、 割り
込み、 GPIO、LQSPI、 CAN、I2C、SPIS、UART、Timer、 Watch Dog Timer、
SD Card Drive、NIC、DMAC、 PL330 (L2-Cache)、Devcfg
![Page 21: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/21.jpg)
xlnx_zynqmp_init関数
参考文献1)、qemu/blob/master/hw/arm/xlnx-zynqmp.c
一方、ZynqMPのxlnx_zynqmp_init関数では、
CPU(Cortex-A53)、GIC(割り込み)、GEM(GbE)、UART
の設定のみ。
残りはQEMU起動時に指定したDTBファイルにて設定する。
![Page 22: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/22.jpg)
本家のQEMUでは!
https://github.com/qemu/qemu/blob/master/hw/arm/xlnx-zynqmp.c
CPU(Cortex-A53)、GIC(割り込み)、GEM(GbE)、UART
に加えて、
SATA、SDHCI、SPI
が追加されている。
![Page 23: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/23.jpg)
DTB : zynqmp-qemu-arm.dts
参考文献2)、QEMU+-+ZynqMP
ZCU102 - QEMU Released with PetaLinux 2015.4
zynqmp-qemu-arm.dts
![Page 24: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/24.jpg)
-M arm-generic-fdt
参考文献3)、P.16参考文献1)、qemu/blob/master/hw/arm/arm_generic_fdt.c
-M arm-generic-fdt ( -hw-dtb | -dtb ) <file> : -hw-dtbが優先される
-dtb vs -hw-dtbFor Linux Kernel boots, QEMU supports a flow where different DTBs are used for machinegeneration and Linux Kernel boot. In this flow, both -dtb and -hw-dtb are specified onthe command line.The -hw-dtb is used for machine generation and -dtb is passed to the Linux Kernel (usinga memory buffer). For standalone, flows these two arguments are fully interchangeable;specify only one or the other.
参考文献2)、QEMU+-+Zynq-7000Zynqの場合は、-M arm-generic-fdt-plnx
![Page 25: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/25.jpg)
PetaLinux 2015.4
参考文献2)、QEMU+-+ZynqMP
$ ./aarch64-softmmu/qemu-system-aarch64 -M arm-generic-fdt -serial mon:stdio \
-serial /dev/null -display none \
-device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4 \ # Un-reset the A53
-device loader,file=./pre-built/linux/images/bl31.elf,cpu=0 \ # ARM Trusted Firmware
-device loader,file=./pre-built/linux/images/Image,addr=0x00080000 \ # Linux kernel
-device loader,file=./images/linux/system.dtb,addr=0x04080000 # \ # Linux Device Tree
-device loader,file=./build/linux/misc/linux-boot/linux-boot.elf \ # A light boot loader
-hw-dtb ./pre-built/linux/images/zynqmp-qemu-arm.dtb # HW Device Tree
![Page 26: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/26.jpg)
QEMU : MPSoC+Power+Management
参考文献2)、MPSoC+Power+Management
Cortex-A53用QEMU
$qemu-system-aarch64 -M arm-generic-fdt -hw-dtb <path_to_ARM_DTB> -gdb tcp::6667 -nographic -machine-path qemu-tmp -tftp <path_to_PETALINUX_IMAGES>
Microblaze用QEMU
$qemu-system-microblazeel -M microblaze-fdt -hw-dtb <path_to_pmu_dtb> -kernel <path_to_pmu_rom_elf> -nographic -machine-path qemu-tmp
2つのQMUを接続して動作するポイントは、-machine-path qemu-tmpZynqMP QEMUのオリジナル機能
![Page 27: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/27.jpg)
QEMU : Suspend
参考文献2)、MPSoC+Power+Management
Peta Linux
Appselfsuspend
PMU Firmware
QEMUAArch64
QEMUMicroblade
Cortex-A53
![Page 28: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/28.jpg)
QEMU : Hotplug
参考文献2)、MPSoC+Power+Management
ATF bl31PMU
Firmware
QEMUAArch64
QEMUMicroblade
Peta Linux
Power Off$echo 0 > /sys/devices/system/cpu/cpu1/online
Power On$echo 1 > /sys/devices/system/cpu/cpu1/online
![Page 29: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/29.jpg)
ZynqMP QEMUを使って出来そうなこと
![Page 30: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/30.jpg)
HDL SimulatorとCo-Simulation
Linux
App
HDL Sim
RTL
QEMU Co-Sim
x86-Linux
![Page 31: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/31.jpg)
実FPGAとCo-Simulation
QEMU
Linux
App
FPGA
x86-Linux
![Page 32: ZynqMPのQEMU](https://reader031.vdocuments.pub/reader031/viewer/2022030310/58f9aa85760da3da068b79c9/html5/thumbnails/32.jpg)
おしまい