基于QEMU系统模拟器Xilinx/QEMU的运行与调试

电子说

1.2w人已加入

描述

Xilinx基于QEMU系统模拟器Xilinx/QEMU可用于模拟运行Zynq Linux的运行与调试。其使用可以是:

(1)利用GitHub上的Xilinx/QEMU源代码进行编译得到QEMU软件模拟器

(2)利用Xilinx提供的PetaLinux工具包,PetaLinux工具包已经包括了QEMU emulator.

一、下载Xilinx/QEMU源码并编译

1. 建立GitHub账户并连接

(a)注册github.com账户

(b)安装git,在REHL-6下使用

yum install git

(c)使用ssh-keygen生成迷匙

ssh-keygen -t rsa -C”email@address.com” -f ~。/ssh/Huatong-github

参数意义如下:

-t 指定密匙算法类型,默认即为rsa

-C 设置注释文字

-f 指定密匙文件存储文件名,上例会生成/home/hhdong/.ssh/huatong-github和/home/hhdong/.ssh/huatong-github.pub两个密匙文件

(d)将SSH公匙添加到github

在浏览器输入https://github.com/settings/ssh点击添加Add ssh key,然后将huatong-github.pub这个文件内容拷贝添加。

(e)新建/home/hhdong/.ssh/config文件,其内容如下:

Host huatong-github

User git

Hostname github.com

PreferredAuthentications publickey

IdentityFile ~/.ssh/huatong-github

注意:其中的用户名为git,而不是github.com网站上的用户名。

(f)连接github.com网站

使用 ssh -T git@github.com或者 ssh -vT git@github.com

其最后会显示:You‘ve successfully authenticated, but GitHub does not provide shell access.这就表示连接成功了。

如果出现连接错误,可以尝试如下解决方法:

(1)是不是正确的拷贝公钥到github.com,注意不要拷贝错误,包含了不必要的字符,空格,回车等

(2)修改.ssh目录属性和其下的文件读写属性。

chmod 700 ~/.ssh

chmod 600 ~/.ssh/*

2. 下载Xilinx/QEMU源代码并编译

(a) git clone git://github.com/Xilinx/qemu.git

然后将其更新到master trunk.

(b) cd qemu

git checkout Xilinx-master

(c)配置QEMU

。/configure --target-list=”arm-softmmu” --enable-fdt --disable-kvm

(d)编译make

我在编译过程中,出现

ERROR: DTC(libfdt) not present

可以根据提示下载sub model解决,git submodule update --init dtc

另外一个问题是在编译过程中提示:

/home/hhdong/qemu/qemu-img.c:73 : undefined reference to ‘g_sequence_lookup’

collect2: ld return 1 exit status

出现错误的原因是g_sequence_lookup是在glibc 2.28上才加入的,而使用的Host REHL-Server-6上的glibc版本为2.12. 由于g_sequence_lookup是用于检查一些情况下,重复的写入了信息。则workaround可以是:

- if (!g_sequence_lookup(seq, (gpointer)fmt_name, compare_data, NULL)) {

g_sequence_insert_sorted(seq, (gpointer)fmt_name, compare_data, NULL);

- }

即不调用g_sequence_lookup进行判断。

3. 运行QEMU,并加载Xilinux预编译好的zImage和system.dtb

/arm-softmmu/qemu-system-arm -M arm-generic-fdt -nographic -smp 2 -machine linux=on -serial mon:stdio -dtb /home/hhdong/Xilinx-ZC706-2014.2/images/linux/system.dtb -kernel /home/hhdong/Xilinx-ZC706-2014.2/pre-built/linux/images/zImage

其会提示:

qemu: fatal: Trying to execute code outside RAM or ROM at 0xfffffff0

然后就是register dump,如下:

R00=00000000 R01=00000000 R02=00000000 R03=00000000

R04=00000000 R05=00000000 R06=00000000 R07=00000000

R08=00000000 R09=00000000 R10=00000000 R11=00000000

R12=00000000 R13=00000000 R14=00000000 R15=fffffff0

PSR=400001d3 -Z-- A svc32 CPU#:1

s00=00000000 s01=00000000 d00=0000000000000000

到目前为止,还没有查出出错的原因。猜想可能是Xilinx/QEMU与预编译的system.dtb之间配合的问题吧。

二、使用PetaLinux工具包提供的QEMU

使用Xilinx提供的PetaLinux工具包包含的QEMU就非常简单了。

从Xilinx网站下载petalinux-v2014.2-final-installer.run和Xilinx-ZC706-v2014.2-final.bsp。查看文档ug976-petalinux-installation.pdf即可。

使用PetaLinux提供的qemu加载上述的预编译zImage和system.dtb则不会出错。如下:

/opt/pkg/petalinux-v2014.2-final/tools/linux-i386/petalinux/bin/qemu-system-arm -M arm-generic-fdt -nographic -smp 2 -machine linux=on -serial mon:stdio -dtb /home/hhdong/Xilinx-ZC706-2014.2/images/linux/system.dtb -kernel /home/hhdong/Xilinx-ZC706-2014.2/pre-built/linux/images/zImage

则能够正常运行。

此时,可以尝试不同的qemu参数了。例如将--serial file:/temp/serial.txt加入到命令中,如

/opt/pkg/petalinux-v2014.2-final/tools/linux-i386/petalinux/bin/qemu-system-arm -M arm-generic-fdt -nographic -smp 2 -machine linux=on -dtb /home/hhdong/Xilinx-ZC706-2014.2/images/linux/system.dtb -kernel /home/hhdong/Xilinx-ZC706-2014.2/pre-built/linux/images/zImage --serial file:/temp/serial.txt

则输出的信息就不会出现在console中断,而是写入到文件/tmp/serial.txt中了。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分