Petalinux编译环境搭建-ZYNQ-7020
最近捣鼓了Petalinux,使用ZYNQ-7020开发板(AC820),本文简单记录了一下环境搭建步骤,后续还有内容会陆续发布。本文使用的版本是Ubuntu 18.04和Vivado、Vitis(2019_R2)。
准备环境
从官网中找的版本对应表格,比较旧了,但是涵盖了本文章里面2019_R2
的版本,其他版本的对应关系可以在网上索引一下。
Release names and Branches | Required Vivado/Vitis versions |
---|---|
2014_R2 | Vivado 2014.2 |
2015_R2 | Vivado 2015.2 |
2016_R1 | Vivado 2015.4.2 |
2016_R2 | Vivado 2016.2 |
2017_R1 | Vivado 2016.4 |
2018_R1 | Vivado 2017.4 |
2018_R2 | Vivado 2018.2 |
2019_R1 | Vivado 2018.3 |
2019_R2 | Vivado 2019.1 |
2021_R1 | Vivado 2021.1 |
参考资料:
使用Petalinux定制自己的linux系统-CSDN博客
ZYNQ:使用PetaLinux打包 BOOT.BIN、image.ub - schips - 博客园
PetaLinux Tools Documentation: Reference Guide • 查看器 • AMD 技术信息门户网站
主要可以参考petalinux-tools-reference-guide
中的内容,AD的资料还是很齐全的。
安装依赖
sudo apt-get install tofrodos iproute2 gawk gcc g++ git make net-tools libncurses5-dev zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libglib2.0-dev screen pax gzip automake libncursesw5-dev
配置默认Python
如果系统已经默认安装,并指定,则本步骤可以跳过。如果安装多个版本Python,未配置默认,也需要指定。
cyqsd@cyqsd-virtual-machine:~/Workspace$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
安装PetaLinux
从AMD的官网下载:PetaLinux Tools - Installer Downloads,这里选的版本是2019.2。
cyqsd@cyqsd-virtual-machine:/opt/tools/petalinux$ ./petalinux-v2019.2-final-installer.run
INFO: Checking installation environment requirements...
WARNING: This is not a supported OS
INFO: Checking free disk space
INFO: Checking installed tools
environment: line 302: ((: 10#34+ > 10#24: syntax error: operand expected (error token is "> 10#24")
environment: line 306: ((: 10#34+ < 10#24: syntax error: operand expected (error token is "< 10#24")
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
INFO: Checking installer checksum...
INFO: Extracting PetaLinux installer...
LICENSE AGREEMENTS
PetaLinux SDK contains software from a number of sources. Please review
the following licenses and indicate your acceptance of each to continue.
You do not have to accept the licenses, however if you do not then you may
not use PetaLinux SDK.
Use PgUp/PgDn to navigate the license viewer, and press 'q' to close
Press Enter to display the license agreements
Do you accept Xilinx End User License Agreement? [y/N] > y
Do you accept Webtalk Terms and Conditions? [y/N] > y
Do you accept Third Party End User License Agreement? [y/N] > y
INFO: Installing PetaLinux...
*********************************************
WARNING: You haven't specified the installation location.
*********************************************
*********************************************
WARNING: By default, it will be installed in your working directory: /opt/tools/petalinux
*********************************************
Please input "y" to proceed the installation, "n" to exit otherwise:y
*********************************************
WARNING: PetaLinux installation directory: /opt/tools/petalinux/. is not empty!
*********************************************
Please input "y" to continue to install PetaLinux in that directory?[n]y
INFO: Checking PetaLinux installer integrity...
INFO: Installing PetaLinux SDK to "/opt/tools/petalinux/."
INFO: Installing aarch64 Yocto SDK to "/opt/tools/petalinux/./components/yocto/source/aarch64"...
INFO: Installing arm Yocto SDK to "/opt/tools/petalinux/./components/yocto/source/arm"...
INFO: Installing microblaze_full Yocto SDK to "/opt/tools/petalinux/./components/yocto/source/microblaze_full"...
INFO: Installing microblaze_lite Yocto SDK to "/opt/tools/petalinux/./components/yocto/source/microblaze_lite"...
INFO: PetaLinux SDK has been installed to /opt/tools/petalinux/.
协议按Enter
进入阅读,q
退出,并y
同意。
设置环境
source /opt/tools/petalinux/settings.sh
# bash is PetaLinux recommended shell. Please set your default shell to bash.
sudo dpkg-reconfigure dash
提示WARNING: No tftp server found - please refer to "PetaLinux SDK Installation Guide" for its impact and solution
,可以自行看需不需要tftp。
初始化项目
# petalinux-create -t project --template zynq -n 工程名字
petalinux-create -t project --template zynq -n ad9361_linux_2021
# petalinux-config --get-hw-description 或者 -p hdf、xsa文件所在目录路径
petalinux-config --get-hw-description
cyqsd@ubuntu:~/Workspace/ZYNQ$ petalinux-create -t project --template zynq -n ad9361_linux_2021
INFO: Create project: ad9361_linux_2021
INFO: New project successfully created in /home/cyqsd/Workspace/ZYNQ/ad9361_linux_2021
cyqsd@ubuntu:~/Workspace/ZYNQ$ cd /home/cyqsd/Workspace/ZYNQ/ad9361_linux_2021
cyqsd@ubuntu:~/Workspace/ZYNQ/ad9361_linux_2021$ petalinux-config --get-hw-description
[INFO] Sourcing buildtools
INFO: Getting hardware description...
INFO: Renaming system_top.xsa to system.xsa
[INFO] Generating Kconfig for project
...
更换文件系统类型,可以换成内存卡。
# 使用如下命令配置内核
petalinux-config -c kernel
在如下目录中找到system-user.dtsi
文件,
/home/cyqsd/Workspace/ZYNQ/AC820_Linux_2021/project-spec/meta-user/recipes-bsp/device-tree/files
可以添加自定义的设备树文件。
然后就使用:
petalinux-build
编译所有内容。
最后提示成功,则可以进行后面的打包步骤。
生成boot.bin
# 不含system.bit的打包
# petalinux-package --boot --fsbl zynq_fsbl.elf --u-boot u-boot.elf --force
cyqsd@ubuntu:~/Workspace/ZYNQ/AC820_Linux_2021/images/linux$ petalinux-package --boot --fsbl zynq_fsbl.elf --u-boot u-boot.elf --force
[INFO] Sourcing buildtools
INFO: Getting system flash information...
INFO: File in BOOT BIN: "/home/cyqsd/Workspace/ZYNQ/AC820_Linux_2021/images/linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/cyqsd/Workspace/ZYNQ/AC820_Linux_2021/images/linux/u-boot.elf"
INFO: File in BOOT BIN: "/home/cyqsd/Workspace/ZYNQ/AC820_Linux_2021/images/linux/system.dtb"
INFO: Generating Zynq binary package BOOT.BIN...
****** Xilinx Bootgen v2021.1
**** Build date : May 28 2021-21:36:22
** Copyright 1986-2021 Xilinx, Inc. All Rights Reserved.
[INFO] : Bootimage generated successfully
INFO: Binary is ready.
# 参数说明
Usage:
petalinux-package --boot|--bsp|--prebuilt|--sysroot [options]
Required:
--boot|--bsp|--prebuilt|--sysroot
Various package mode.
boot: packages a boot.bin for Zynq
bsp: packages a bsp
prebuilt: package images to prebuilt
sysroot: Install sdk
Options:
-h|--help Display help messages
Please specify a package mode option for the detailed options
Show package boot options:
$ petalinux-package --boot --help
Show package bsp options:
$ petalinux-package --bsp --help
Show package prebuilt options:
$ petalinux-package --prebuilt --help
Show package sysroot options:
$ petalinux-package --sysroot --help
Show package wic options:
$ petalinux-package --wic --help
从内存卡启动,配置两个分区,FAT分区1,EXT4分区1。按正常部署方式操作即可。
Dropbear SSH配置
需要从SSH连接设备,默认的dropbear是安装了的,可以参考:嵌入式Linux下Dropbear SSH配置优化。
# 通过top或者ps找到dropbear的进程ID,并kill掉
root@petalinux:/sys/firmware/devicetree/base/axi# ps -l|grep dropbear
S 0 542 1 1964 88 0:0 12:45 00:00:00 /usr/sbin/dropbear -r /et
S 0 544 542 2052 1544 0:0 12:45 00:00:00 /usr/sbin/dropbear -r /etv g
S 0 565 516 2360 712 253:0 12:47 00:00:00 grep dropbear
#
/usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22
默认用户名:root
默认密码:analog
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。