qemu不但可以用于软件仿真(如前文提到ubuntu虚拟环境,在此环境下,完全可以构建arm的虚拟软件运行环境,但是其
本身的硬件 cat /pro/cpuinfo可以看到,还是外部真实的硬件环境,–8核心),还可以用于硬件仿真,例如我想构建一个虚拟
的zynq7000处理器的板子,初步的评估下其计算性能,或者在回板之前做一下基本的测试。
当然qemu的硬件仿真是需要相应的厂家支持的,qemu也支持了一些arm(官方)的板子,
xilinx官方也是支持qemu的
其wiki如下
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842060/QEMU
介绍的比较详细
以zynq7000为例,其可以进行的仿真如下
Supported Zynq Devices
Below is a list of Zynq devices that Xilinx’s QEMU supports:
2 Cortex-A9s
DDR (Max 2GB)
OCM (256MB)
PFlash
Zynq SLCR (Mostly dummy implementation)
A9 MPCore
GIC
USB
UART
TTC
SDHCI
PL330 (DMA)
SMC (PL353) NAND
Ethernet
Xilinx DevCFG Interface
SPI
QSPI
N25Q128
I2C
N25Q128
AT24C08
测试如下
test
安装参照wiki,这里需要说明,
The 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.
请注意一下branch的选择
#我安装到了如下目录
zw@zw-pc:~/swap/zynq_data/qemu/install$ ls
bin data libexec share var
#data目录是后面创建的里面拷贝了一些 petalinux编译的文件
zw@zw-pc:~/swap/zynq_data/qemu/install/data$ ls
qemu_image.elf rootfs.ext3 rootfs.ext4 system.dtb system.dts zImage
zw@zw-pc:~/swap/zynq_data/qemu/install/data$
#启动测试
zw@zw-pc:~/swap/zynq_data/qemu/install/bin$ ./qemu-system-aarch64 -M arm-generic-fdt-7series -machine linux=on -serial mon:stdio -serial /dev/null -display none -kernel ../data/zImage -dtb ../data/system.dtb -sd ../data/rootfs.ext3
#启动log
WARNING: Image format was not specified for '../data/rootfs.ext3' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.14.0-xilinx (oe-user@oe-host) (gcc version 7.2.0 (GCC)) #1 SMP PREEMPT Wed Jul 10 11:26:37 CST 2019
[ 0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] OF: fdt: Machine model: xlnx,zynq-7000
[ 0.000000] bootconsole [earlycon0] enabled
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] cma: Reserved 16 MiB at 0x3f000000
[ 0.000000] percpu: Embedded 16 pages/cpu @ef7ce000 s35084 r8192 d22260 u65536
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 260608
[ 0.000000] Kernel command line: console=ttyPS0,115200 earlyprintk root=/dev/mmcblk0 rw
[ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[ 0.000000] Memory: 1012844K/1048576K available (6144K kernel code, 254K rwdata, 1656K rodata, 1024K init, 156K bss, 19348K reserved, 16384K cma-reserved, 245760K highmem)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0xc0008000 - 0xc0700000 (7136 kB)
[ 0.000000] .init : 0xc0900000 - 0xc0a00000 (1024 kB)
[ 0.000000] .data : 0xc0a00000 - 0xc0a3f9a0 ( 255 kB)
[ 0.000000] .bss : 0xc0a3f9a0 - 0xc0a66bc4 ( 157 kB)
[ 0.000000] Preemptible hierarchical RCU implementation.
[ 0.000000] RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[ 0.000000] Tasks RCU enabled.
[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] efuse mapped to f0801000
[ 0.000000] slcr mapped to f0803000
[ 0.000000] L2C: platform modifies aux control register: 0x00000000 -> 0x30400000
[ 0.000000] L2C: DT/platform modifies aux control register: 0x00000000 -> 0x30400000
[ 0.000000] L2C-310 errata 588369 769419 enabled
[ 0.000000] L2C-310 full line of zeros enabled for Cortex-A9
[ 0.000000] L2C-310 cache controller enabled, 8 ways, 64 kB
[ 0.000000] L2C-310: CACHE_ID 0x00000000, AUX_CTRL 0x00000000
[ 0.000000] zynq_clock_init: clkc starts at f0803100
[ 0.000000] Zynq clock init
[ 0.000000] global-timer: non support for this cpu version.
[ 0.000000] Failed to initialize '/amba/timer@f8f00200': -38
[ 0.000000] clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 826992825 ns
[ 0.000226] sched_clock: 16 bits at 35kHz, resolution 28357ns, wraps every 929205421ns
[ 0.003686] timer #0 at f080b000, irq=16
[ 0.011796] Console: colour dummy device 80x30
[ 0.013016] Calibrating delay loop... 2413.36 BogoMIPS (lpj=12066816)
[ 0.764377] pid_max: default: 32768 minimum: 301
[ 0.766504] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.766986] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.781476] CPU: Testing write buffer coherency: ok
[ 0.793925] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.925845] Setting up static identity map for 0x100000 - 0x100060
[ 0.929758] Hierarchical SRCU implementation.
[ 1.084477] smp: Bringing up secondary CPUs ...
[ 1.681232] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 1.685259] smp: Brought up 1 node, 2 CPUs
[ 1.685997] SMP: Total of 2 processors activated (4833.28 BogoMIPS).
[ 1.686507] CPU: All CPU(s) started in SVC mode.
[ 1.750056] devtmpfs: initialized
[ 1.763526] random: get_random_u32 called from bucket_table_alloc+0x1c4/0x204 with crng_init=0
[ 1.768715] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
[ 1.801809] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 1.808529] futex hash table entries: 512 (order: 3, 32768 bytes)
[ 1.818455] pinctrl core: initialized pinctrl subsystem
[ 1.841736] NET: Registered protocol family 16
[ 0.007401] random: fast init done
[ 0.009953] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.017978] cpuidle: using governor menu
[ 0.052376] hw-breakpoint: debug architecture 0x4 unsupported.
[ 0.054786] zynq-ocm f800c000.ocmc: can't request region for resource [mem 0x0000000c-0x0003ffff]
[ 0.056516] zynq-ocm: probe of f800c000.ocmc failed with error -16
[ 0.059238] zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
[ 0.063917] e0000000.serial: ttyPS0 at MMIO 0xe0000000 (irq = 26, base_baud = 859788) is a xuartps
[ 0.066328] console [ttyPS0] enabled
[ 0.066328] console [ttyPS0] enabled
[ 0.066980] bootconsole [earlycon0] disabled
[ 0.066980] bootconsole [earlycon0] disabled
[ 0.138498] vgaarb: loaded
[ 0.141504] SCSI subsystem initialized
[ 0.143262] usbcore: registered new interface driver usbfs
[ 0.143942] usbcore: registered new interface driver hub
[ 0.146126] usbcore: registered new device driver usb
[ 0.147544] media: Linux media interface: v0.10
[ 0.148083] Linux video capture interface: v2.00
[ 0.152251] pps_core: LinuxPPS API ver. 1 registered
[ 0.152620] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti
[ 0.153329] PTP clock support registered
[ 0.153924] EDAC MC: Ver: 3.0.0
[ 0.158036] FPGA manager framework
[ 0.159482] fpga-region fpga-full: FPGA Region probed
[ 0.160957] Advanced Linux Sound Architecture Driver Initialized.
[ 0.173576] clocksource: Switched to clocksource ttc_clocksource
[ 0.221755] NET: Registered protocol family 2
[ 0.229327] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.230064] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[ 0.230745] TCP: Hash tables configured (established 8192 bind 8192)
[ 0.232843] UDP hash table entries: 512 (order: 2, 16384 bytes)
[ 0.233382] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
[ 0.235537] NET: Registered protocol family 1
[ 0.256975] RPC: Registered named UNIX socket transport module.
[ 0.257344] RPC: Registered udp transport module.
[ 0.257656] RPC: Registered tcp transport module.
[ 0.257996] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.264575] hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
[ 0.269651] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available
[ 0.276911] workingset: timestamp_bits=30 max_order=18 bucket_order=0
[ 0.284057] jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
[ 0.294039] bounce: pool size: 64 pages
[ 0.294521] io scheduler noop registered
[ 0.294833] io scheduler deadline registered
[ 0.295315] io scheduler cfq registered (default)
[ 0.295683] io scheduler mq-deadline registered
[ 0.295910] io scheduler kyber registered
[ 0.305835] dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
[ 0.306346] dma-pl330 f8003000.dmac: DBUFF-256x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
[ 0.310911] Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
[ 0.370831] brd: module loaded
[ 0.404151] loop: module loaded
[ 0.419067] m25p80 spi0.0: found n25q512a13, expected n25q512a
[ 0.423151] m25p80 spi0.0: n25q512a13 (65536 Kbytes)
[ 0.424370] 4 ofpart partitions found on MTD device spi0.0
[ 0.424824] Creating 4 MTD partitions on "spi0.0":
[ 0.425589] 0x000000000000-0x000000500000 : "boot"
[ 0.432055] 0x000000500000-0x000000520000 : "bootenv"
[ 0.437556] 0x000000520000-0x000000580000 : "pad"
[ 0.441725] 0x000000580000-0x000004000000 : "spare"
[ 0.448899] libphy: Fixed MDIO Bus: probed
[ 0.454259] CAN device driver interface
[ 0.468835] libphy: MACB_mii_bus: probed
[ 0.764745] macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 28 (00:0a:35:00:22:01)
[ 0.768602] Marvell 88E1149R e000b000.ethernet-ffffffff:04: attached PHY driver [Marvell 88E1149R] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:04, irq=POLL)
[ 0.776287] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[ 0.777790] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 0.792564] ehci_hcd: USB 2.0 ' Enhanced' Host Controller (EHCI) Driver
[ 0.794407] ehci-pci: EHCI PCI platform driver
[ 0.798434] usbcore: registered new interface driver usb-storage
[ 0.822311] i2c /dev entries driver
[ 0.830024] IR NEC protocol handler initialized
[ 0.830989] IR RC5(x/sz) protocol handler initialized
[ 0.831839] IR RC6 protocol handler initialized
[ 0.833796] IR JVC protocol handler initialized
[ 0.834760] IR Sony protocol handler initialized
[ 0.835554] IR SANYO protocol handler initialized
[ 0.836150] IR Sharp protocol handler initialized
[ 0.836859] IR MCE Keyboard/mouse protocol handler initialized
[ 0.837709] IR XMP protocol handler initialized
[ 0.853760] cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer at f0945000 with timeout 10s
[ 0.856851] EDAC MC: ECC not enabled
[ 0.858666] Xilinx Zynq CpuIdle Driver started
[ 0.863827] sdhci: Secure Digital Host Controller Interface driver
[ 0.864394] sdhci: Copyright(c) Pierre Ossman
[ 0.864848] sdhci-pltfm: SDHCI platform and OF driver helper
[ 1.064882] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA 64-bit
[ 1.077813] mmc0: new SD card at address 4567
[ 1.083909] mmcblk0: mmc0:4567 QEMU! 163 MiB
[ 1.149897] mmc1: SDHCI controller on e0101000.sdhci [e0101000.sdhci] using ADMA 64-bit
[ 1.164757] ledtrig-cpu: registered to indicate activity on CPUs
[ 1.166458] usbcore: registered new interface driver usbhid
[ 1.166799] usbhid: USB HID core driver
[ 1.180835] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[ 1.190534] NET: Registered protocol family 10
[ 1.200856] Segment Routing with IPv6
[ 1.201792] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 1.206045] NET: Registered protocol family 17
[ 1.206556] can: controller area network core (rev 20170425 abi 9)
[ 1.207945] NET: Registered protocol family 29
[ 1.208484] can: raw protocol (rev 20170425)
[ 1.208881] can: broadcast manager protocol (rev 20170425 t)
[ 1.209392] can: netlink gateway (rev 20170425) max_hops=1
[ 1.210668] zynq_pm_remap_ocm: OCM pool is not available
[ 1.210951] zynq_pm_suspend_init: Unable to map OCM.
[ 1.211518] Registering SWP/SWPB emulation handler
[ 1.237409] hctosys: unable to open rtc device (rtc0)
[ 1.237834] of_cfs_init
[ 1.239819] of_cfs_init: OK
[ 1.241407] ALSA device list:
[ 1.241747] No soundcards found.
[ 1.260804] EXT4-fs (mmcblk0): mounting ext3 file system using the ext4 subsystem
[ 1.262647] EXT4-fs (mmcblk0): bad geometry: block count 167148 exceeds size of device (166912 blocks)
[ 1.267808] EXT4-fs (mmcblk0): bad geometry: block count 167148 exceeds size of device (166912 blocks)
[ 1.276230] EXT2-fs (mmcblk0): warning: mounting ext3 filesystem as ext2
[ 1.276769] EXT2-fs (mmcblk0): warning: mounting unchecked fs, running e2fsck is recommended
[ 1.281618] VFS: Mounted root (ext2 filesystem) on device 179:0.
[ 1.288537] devtmpfs: mounted
[ 1.325941] Freeing unused kernel memory: 1024K
INIT: version 2.88 booting
Starting udev
[ 4.542422] udevd[766]: starting version 3.2.2
[ 4.800504] udevd[767]: starting eudev-3.2.2
hwclock: can't open '/dev/misc/rtc': No such file or directory
Wed Jul 10 09:22:44 UTC 2019
hwclock: can't open '/dev/misc/rtc': No such file or directory
Starting internet superserver: inetd.
INIT: Entering runlevel: 5
Configuring network interfaces... [ 38.395559] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
udhcpc (v1.24.1) started
Sending discover...
[ 39.535872] macb e000b000.ethernet eth0: unable to generate target frequency: 25000000 Hz
[ 39.545060] macb e000b000.ethernet eth0: link up (100/Full)
[ 39.549824] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Sending discover...
Sending select for 10.0.2.15...
Lease of 10.0.2.15 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 10.0.2.3
done.
Starting system message bus: dbus.
Starting Dropbear SSH server: dropbear.
hwclock: can't open '/dev/misc/rtc': No such file or directory
Starting syslogd/klogd: done
Hello PetaLinux World
sill set dns
Starting tcf-agent: OK
PetaLinux 2018.2 petalinux /dev/ttyPS0
petalinux login: root
Password:
[ 61.138016] EXT2-fs (mmcblk0): error: ext2_lookup: deleted inode referenced: 37849
[ 61.141872] EXT2-fs (mmcblk0): error: ext2_lookup: deleted inode referenced: 37849
root@petalinux:~# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 0 (v7l)
BogoMIPS : 2413.36
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc09
CPU revision : 0
processor : 1
model name : ARMv7 Processor rev 0 (v7l)
BogoMIPS : 2419.91
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc09
CPU revision : 0
Hardware : Xilinx Zynq Platform
Revision : 0000
Serial : 0000000000000000
root@petalinux:~#
root@petalinux:~# QEMU: Terminated
zw@zw-pc:~/swap/zynq_data/qemu/install/bin$