zynqmpのqemu

32
ZynqMPQEMU @Vengineer ZynqMP勉強会資料 (2016/2/20)

Upload: mr-vengineer

Post on 10-Jan-2017

1.289 views

Category:

Devices & Hardware


0 download

TRANSCRIPT

ZynqMPのQEMU

@Vengineer

ZynqMP勉強会資料 (2016/2/20)

自己紹介

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

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

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

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

ソースコード(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

ソースコード(本家)からビルド

参考文献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

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

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ノード 内の番号を変えると上記の割当を変更できる。

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).

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.

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

ソースコードを追ってみる

ブログ、Zynqのqemu(その2)

http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから

Zynqのhw/xilinx.cを探したら、

ブログ、Zynqのqemu(その2)

http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから

Zynqのhw/xilinx.cを探したら、ありませーん。

ブログ、Zynqのqemu(その2)

http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから

Zynqのhw/xilinx.cを探したら、ありませーん。

hw/arm/xilinx_zynq.cになっていました。

ブログ、Zynqのqemu(その2)

http://blogs.yahoo.co.jp/verification_engineer/66226875.htmlから

Zynqのhw/xilinx.cを探したら、ありませーん。

hw/arm/xilinx_zynq.cになっていました。

どうして?

ブログ、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)を使うようになったので、

ブログ、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 が評価ボード。

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

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ファイルにて設定する。

本家のQEMUでは!

https://github.com/qemu/qemu/blob/master/hw/arm/xlnx-zynqmp.c

CPU(Cortex-A53)、GIC(割り込み)、GEM(GbE)、UART 

に加えて、

SATA、SDHCI、SPI

が追加されている。

DTB : zynqmp-qemu-arm.dts

参考文献2)、QEMU+-+ZynqMP

ZCU102 - QEMU Released with PetaLinux 2015.4

zynqmp-qemu-arm.dts

-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

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

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のオリジナル機能

QEMU : Suspend

参考文献2)、MPSoC+Power+Management

Peta Linux

Appselfsuspend

PMU Firmware

QEMUAArch64

QEMUMicroblade

Cortex-A53

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

ZynqMP QEMUを使って出来そうなこと

HDL SimulatorとCo-Simulation

Linux

App

HDL Sim

RTL

QEMU Co-Sim

x86-Linux

実FPGAとCo-Simulation

QEMU

Linux

App

FPGA

x86-Linux

おしまい