QEMU学习之路(4)— Xilinx开源项目systemctlm-cosim-demo安装与使用

QEMU学习之路(4)--- Xilinx开源项目systemctlm-cosim-demo安装与使用

一、前言

项目说明:https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/862421112/Co-simulation

操作系统:Ubuntu 20.04.6 LTS

gcc版本:9.4.0

二、SystemC安装

systemctlm-cosim-demo基于SystemC-2.3.2的,所以需要先安装SystemC-2.3.2,安装方式参考:
SystemC学习(1)--- SystemC安装与HelloWorld

三、安装systemctlm-cosim-demo

通过git下载源码库,命令如下:

bash 复制代码
git clone https://github.com/Xilinx/systemctlm-cosim-demo.git

下载好后进入该目录,更新如下子模块:

bash 复制代码
git submodule update --init libsystemctlm-soc
git submodule update --init pcie-model

然后安装需要依赖的库

bash 复制代码
sudo apt-get install linux-libc-dev

然后我们需要设置SYSTEMC路径和做一些其他设置,在systemctlm-cosim-demo目录下创建.config.mk文件 ,内容如下所示:

bash 复制代码
HAVE_VERILOG=n
HAVE_VERILOG_VERILATOR=n
HAVE_VERILOG_VCS=n
SYSTEMC=${SYSTEMC_HOME}

然后就可以执行make 命令开始创建了,我们创建一个cpm4-qdma-demo,命令如下:

bash 复制代码
make pcie/versal/cpm4-qdma-demo

四、安装xilinx-qemu

通过git下载源码库,命令如下:

bash 复制代码
git clone https://github.com/Xilinx/qemu.git

然后切换到如下commit:

bash 复制代码
git checkout 74d70f8008

然后安装如下软件依赖:

bash 复制代码
sudo apt install git cmake make wget gcc g++ python3 pkg-config libglib2.0-dev libpixman-1-dev verilator expect cpio unzip rsync bc libssl-dev

然后使用如下命令进行配置:

bash 复制代码
./configure --target-list="arm-softmmu,aarch64-softmmu,microblazeel-softmmu,riscv32-softmmu,riscv64-softmmu,x86_64-softmmu" --enable-fdt --enable-kvm --disable-xen

然后执行如下命令进行编译:

bash 复制代码
make -j$((`nproc`+1))

指定安装路径安装:

bash 复制代码
make install DESTDIR=/home/william/tools/qemu

安装完成后,既可以在/home/william/tools/qemu/usr/local/bin/目录下看到如下可执行文件:

五、运行xilinx-qemu

创建一个运行目录,下载如下文件:

bash 复制代码
mkdir run; cd run
wget https://cloud-images.ubuntu.com/releases/focal/release-20210125/ubuntu-20.04-server-cloudimg-amd64.img
wget https://cloud-images.ubuntu.com/releases/focal/release-20210125/unpacked/ubuntu-20.04-server-cloudimg-amd64-vmlinuz-generic
wget https://cloud-images.ubuntu.com/releases/focal/release-20210125/unpacked/ubuntu-20.04-server-cloudimg-amd64-initrd-generic

使用如下命令重设img的大小:

bash 复制代码
qemu-img resize ubuntu-20.04-server-cloudimg-amd64.img 30G

然后安装cloud-image-utils

bash 复制代码
sudo apt-get install cloud-image-utils

创建user-data文件,输入如下内容:

bash 复制代码
#cloud-config
password: pass
chpasswd: { expire: False }
ssh_pwauth: True

然后创建一个user-data.img

bash 复制代码
cloud-localds user-data.img user-data

新建run_qemu.sh,内容如下:

bash 复制代码
/home/william/tools/qemu/usr/local/binqemu-system-x86_64                              \
	-M q35,accel=kvm,kernel-irqchip=split -cpu qemu64,rdtscp                          \
    -m 4G -smp 4 -enable-kvm -display none                                            \
    -kernel ubuntu-20.04-server-cloudimg-amd64-vmlinuz-generic               		  \
    -append "root=/dev/sda1 rootwait console=tty1 console=ttyS0 intel_iommu=on"       \
    -initrd ubuntu-20.04-server-cloudimg-amd64-initrd-generic                	      \
    -serial mon:stdio -device intel-iommu,intremap=on,device-iotlb=on                 \
    -drive file=ubuntu-20.04-server-cloudimg-amd64.img                       		  \
    -drive file=user-data.img,format=raw                                              \
    -device ioh3420,id=rootport1,slot=1                                               \
    -device remote-port-pci-adaptor,bus=rootport1,id=rp0                              \
    -machine-path /tmp/machine-x86/                                                   \
    -device virtio-net-pci,netdev=net0 -netdev type=user,id=net0                      \
    -device remote-port-pcie-root-port,id=rprootport,slot=0,rp-adaptor0=rp,rp-chan0=0

然后创建交换目录:

bash 复制代码
mkdir /tmp/machine-x86

执行如下命令启动qemu

bash 复制代码
sh run_qemu.sh

在另一个Terminal 进入systemctlm-cosim-demo目录下,执行

bash 复制代码
./pcie/versal/cpm4-qdma-demo unix:/tmp/machine-x86/qemu-rport-_machine_peripheral_rp0_rp 10000

可以看到如下打印:

在运行qemu的Terminal 下可以看到如下,已经可以登录ubuntu系统了

登录账号是ubuntu,密码是pass

登录成功如下所示

然后输入lspci命令,就可以看到虚拟出来的pcie设备了:

相关推荐
西岸行者11 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
悠哉悠哉愿意11 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
别催小唐敲代码11 天前
嵌入式学习路线
学习
毛小茛11 天前
计算机系统概论——校验码
学习
babe小鑫11 天前
大专经济信息管理专业学习数据分析的必要性
学习·数据挖掘·数据分析
winfreedoms11 天前
ROS2知识大白话
笔记·学习·ros2
在这habit之下11 天前
Linux Virtual Server(LVS)学习总结
linux·学习·lvs
我想我不够好。11 天前
2026.2.25监控学习
学习
im_AMBER11 天前
Leetcode 127 删除有序数组中的重复项 | 删除有序数组中的重复项 II
数据结构·学习·算法·leetcode
CodeJourney_J11 天前
从“Hello World“ 开始 C++
c语言·c++·学习