在上文中介绍了如何安装petalinux 2018.2。其验证的方法是:
source /home/liwenz/petalinux/settings.sh
如果不报错,并且echo $PETALINUX 能显示你的安装路径就是好了。其中/home/liwenz/petalinux 是我的安装目录。
本文在此基础上创建一个工程,并用sd卡启动测试。
1:搭建硬件环境
ug1144 里提到zynq 7000 的硬件建立条件是:
1. One Triple Timer Counter (TTC) (required)
2. External memory controller with at least 32 MB of memory (required)
3. UART for serial console (required)
4. Non-volatile memory (optional), for example, QSPI Flash and SD/MMC
5. Ethernet (optional, essential for network access)
参考helloworld 实验建立工程,设计原理图。
需要添加补充的如下:添加设置DDR, QSPI,SD卡,串口用于显示(helloworld 实验里一样),网口,定时器。
下图是定时器的设置示意图:
余下操作和helloworld 基本一样。右键单击 Block 文件,选择 Generate the Output Products,然后右键单击 Block 文件,选择 Create a HDL wrapper,根据 Block 文件内容产生一个 HDL 的顶层文件,并选择让 vivado 自动完成。
经Vivado综合,实现,比特流后,在Vivado中导出硬件,输出PetaLinux所需要的硬件描述文件 。
输出的文件就在“/(工程文件夹)/(工程名).sdk”这个文件夹下,这个文件夹下的system_wrapper.hdf待用。
2:建立petalinux 工程,配置,编译
2.1 配置petalinux 环境
source /home/liwenz/petalinux/settings.sh
我开始操作的时候,忘记前面的source, 请不要忘记。
2.2 建立工程
petalinux-create
liwenz@ubuntu:~/pro$ petalinux-create --type project --template zynq --name he
INFO: Create project: he
INFO: New project successfully created in /home/liwenz/pro/he
liwenz@ubuntu:~/pro$
2.3 复制第1章得到的hdf文件到工程目录下
cp /mnt/hgfs/xilinx/*.hdf /home/liwenz/pro/he
列表工程目录显示如下:
liwenz@ubuntu:~/pro$ ls -l he
total 372
-rw-r--r-- 1 liwenz liwenz 248 Sep 18 14:13 config.project
drwxr-xr-x 5 liwenz liwenz 4096 Sep 18 14:13 project-spec
-rwxrwxr-x 1 liwenz liwenz 369297 Sep 18 14:15 system_wrapper.hdf
liwenz@ubuntu:~/pro$
2.4 工程配置
工程配置就用 petalinux-config, 命令如下
petalinux-config --get-hw-description=<path-to-directory-containing-hardwaredescription-file>
包含硬件配置hdf文件的目录名
ug1144 和其他文档都这么说,可我操作总显示工程目录名不存在。
后来我就cd 工程目录(he)
然后在工程目录里配置 petalinux-config --get-hw-description=.
这样操作就没问题,这里工程目录名就是当前目录,用 一点'.'表示。
运行正常后,提示参数设置菜单栏:
Linux Components Selection --->
Auto Config Settings --->
-*- Subsystem AUTO Hardware Settings --->
DTG Settings --->
Kernel Bootargs --->
ARM Trusted Firmware Compilation Configuration --->
PMU FIRMWARE Configuration --->
u-boot Configuration --->
Image Packaging Configuration --->
Firmware Version Configuration --->
Yocto Settings --->
确保选择
Subsystem AUTO Hardware Settings ---> |
进入子菜单对话:</