赞
踩
虚拟机软件版本:VMware14.1.1
Linux系统版本:ubuntu-16.04.6
petalinux版本:petalinux-v2019.2
vivado版本:Vivado 2019.2
一、petalinux工具设置
1、进入到petalinux工具的安装目录,执行如下命令:
source settings.sh
执行完该命令后,提示信息如下所示:
PetaLinux environment set to '/home/petalinx'
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
WARNING: No tftp server found - please refer to "PetaLinux SDK Installation Guide" for its impact and solution
zj@zj-virtual-machine:~/petalinx$
2、有效性测试
在命令行输入如下命令:
pet
然后按Tab键,看命令是否补齐为petlinux- 如果能补齐说明工具已经生效。
二、构建Linux工程文件
1、构建全新的工程文件
1.1、创建新工程
在命令行中输入如下命令:
petalinux-create -t project --template zynq -n test_project
执行完该命令后,提示信息如下:
INFO: Create project: test_project
INFO: New project successfully created in /home/zynq/test_project
根据提示,新工程已经创建成功。
命令说明,输入命令petalinux-create help 可以查看该命令的所有参数信息,下面对我们使用的参数进行简要说明:
参数-t 是类型 后面可选参数为 1 project 2 apps 3 modules
参数–template 是CPU系列 后面可选参数为 1 versal 2 zynqMP 3 zynq 4 microblaze
参数-n 是要创建的工程的名称 可自己命令,此处命名为:test_project
1.2、配置工程文件
1.2.1、进入创建的新工程目录,执行如下命令:
cd test_project
1.2.2、 准备配置工程所需HDF文件
将Vivado生成的项目HDF文件,放入ubuntu的某个文件夹下,供项目配置使用,比如我们就将改文件放到虚拟机ubuntu系统和Windows系统的共享目录下,目录路径如下:
/mnt/hgfs/share/
文件名可重命名为system.hdf
1.2.3 配置工程
执行如下命令进行配置:
petalinux-config --get-hw-description=/mnt/hgfs/share/
执行完该命令后,会进入如下的配置界面:
在此,我们可以配置一些系统参数,主要的配置包括:启动方式,启动存储器分区表,启动文件名称等等,此工程我们暂不对其修改(默认是从SD卡中启动),不进行任何配置,选择退出,进入如下界面:
默认为,保存新配置,在此也不做修改,直接回车,保存新配置即可。
接下来,配置工具会根据我们的Vivodao工程所生成的HDF文件进行Linux工程的配置工作,这个过程会花费较长的时间。
配置完成后,提示信息如下所示:
INFO: Getting hardware description... INFO: Rename system_wrapper.hdf to system.hdf [INFO] generating Kconfig for project [INFO] menuconfig project configuration written to /home/zynq/test_project/project-spec/configs/config *** End of the configuration. *** Execute 'make' to start the build or try 'make help'. [INFO] sourcing bitbake [INFO] generating plnxtool conf [INFO] generating meta-plnx-generated layer [INFO] generating user layers [INFO] generating workspace directory [INFO] generating machine configuration [INFO] generating bbappends for project . This may take time ! [INFO] generating u-boot configuration files [INFO] generating kernel configuration files [INFO] generating kconfig for Rootfs [INFO] silentconfig rootfs [INFO] generating petalinux-user-image.bb zj@zj-virtual-machine:~/zynq/test_project$
三、编译Linux工程
执行如下命令:
petalinux-build
执行完该命令后,输出信息如下:
[INFO] building project [INFO] sourcing bitbake [INFO] generating user layers [INFO] generating workspace directory INFO: bitbake petalinux-user-image Loading cache: 100% |############################################| Time: 0:00:01 Loaded 3978 entries from dependency cache. Parsing recipes: 100% |##########################################| Time: 0:00:05 Parsing of 2893 .bb files complete (2885 cached, 8 parsed). 3980 targets, 169 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |#######################################| Time: 0:00:05 Checking sstate mirror object availability: 100% |###############| Time: 0:00:28 Sstate summary: Wanted 887 Found 711 Missed 352 Current 0 (80% match, 0% complete) NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks WARNING: external-hdf-1.0-r0 do_check: Only XSA format is supported in Vivado tool starting from 2019.2 release NOTE: Tasks Summary: Attempted 3218 tasks of which 2362 didn't need to be rerun and all succeeded. Summary: There was 1 WARNING message shown. INFO: Copying Images from deploy to images INFO: Creating /home/zynq/test_project/images/Linux directory NOTE: Failed to copy built images to tftp dir: /tftpboot [INFO] successfully built project zj@zj-virtual-machine:~/zynq/test_project$
输出信息最后内容为successfully built project,说明工程文件编译成功。
此时,我们发现在工程目录下,会生成一个images文件夹,改目录下生产一个linux文件夹,一层层进入,发现在images/linux/目录下生成了多个文件,如下图:
这些文件中,我们会用到的有:
image.ub 该文件为Linux系统镜像文件,需要将该文件拷到SD卡中。
zynq_fsbl.elf 该文件为系统初始化引导文件,后面会将该文件打包到UOOT.BIN文件中。
system.bit 该文件为FPGA的位流文件,后面会将该文件打包到UOOT.BIN文件中。
u-boot.elf 该文件为 u-boot文件,后面会将该文件打包到UOOT.BIN文件中。
四、生成启动BOOT.BIN文件
执行命令如下:
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot
执行完该命令后,输入如下提示信息:
INFO: File in BOOT BIN: "/home/zynq/test_project/images/Linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/zynq/test_project/images/Linux/system.bit"
INFO: File in BOOT BIN: "/home/zynq/test_project/images/Linux/u-boot.elf"
INFO: Generating Zynq binary package BOOT.BIN...
****** Xilinx Bootgen v2019.2
**** Build date : Oct 23 2019-22:59:42
** Copyright 1986-2019 Xilinx, Inc. All Rights Reserved.
INFO: Binary is ready.
WARNING: Unable to access the TFTPBOOT folder /tftpboot!!!
WARNING: Skip file copy to TFTPBOOT folder!!!
zj@zj-virtual-machine:~/zynq/test_project$
成功生成的BOOT.BIN文件位于工程目录images/linux/BOOT.BIN。
五、启动测试
1、SD卡准备
准备一张SD卡,格式化为fat32 格式。
2、文件拷贝
将生成的BOOT.BIN文件和image.ub文件拷入SD卡中。
3、启动测试
3.1 将开发板设置为SD卡启动。
3.2 插入SD卡。
3.3 接好串口工具,打开串口软件,给开发板上电。
linux系统启动后,会输出大量的提示信息,在其就不一一列出了。
启动启动成功后,会出现
test_project login:
并停在此处,此时,需输入登录名:root,接着提示请输入登录密码,同样输入:root;即可登录成功,进入系统。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。