1 概述
PetaLinux 工具提供在 Xilinx 处理系统上定制、构建和调配嵌入式 Linux 解决方案所需的所有组件。该解决方案旨在提升设计生产力,可与 Xilinx 硬件设计工具配合使用,以简化针对 Versal、Zynq™ UltraScale+™ MPSoC、Zynq™ 7000 SoC、和 MicroBlaze™ 的 Linux 系统开发。
PetaLinux 工具可帮助简化基于 Linux 产品的开发;您可以使用下列工具来完成从系统启动到执行的所有操作:
- 命令行接口
- 应用、器件驱动程序、库生成器以及开发模板
- 可引导的系统映像生成器
- 调试代理程序
- GCC 工具
- 集成的 QEMU 全系统仿真器
- 自动化工具
- 支持系统调试器
嵌入式软件与生态系统:
使用这些工具,开发人员可以定制引导载入程序、Linux 内核或 Linux 应用。他们可以通过网络或 JTAG 在随附的全系统仿真器 (QEMU) 或物理硬件上添加新的内核、器件驱动程序、应用和库,以及启动并测试软件协议栈。
2 安装
本次安装软件版本是petalinux-v2020.1-final-installer.run
2.1 软硬件需求
2.1.1 硬件需求
硬件最小需求:
- 8GB 内存
- 2 GHZ CPU时钟
- 100GB 系统硬盘
支持操作系统:
- Red Hat Enterprise Workstation/Server 7.4,7.5,7.6,7.7(64-bit)
- Centos Workstation/Server 7.4,7.5,7.6,7.7(64-bit)
- Ubuntu Linux Workstation/Server 16.04.5,16.04.6,18.04.1,18.04.2,18.04.3,18.04.4 (64-bit)
这里选择操作系统Ubuntu 18.04
2.2.1 软件需求
- 安装依赖软件
sudo dpkg --add-architecture i386
sudo apt-get updatesudo dpkg-reconfigure dashsudo localedef -v -c -i en_US -f UTF-8 en_US.UTF-8sudo apt install \iproute2 \gcc \g++ \net-tools \libncurses5-dev \zlib1g:i386 \libssl-dev \flex \bison \libselinux1 \xterm \autoconf \libtool \texinfo \zlib1g-dev \gcc-multilib \build-essential \screen \pax \gawk \python3 \python3-pexpect \python3-pip \python3-git \python3-jinja2 \xz-utils \debianutils \iputils-ping \libegl1-mesa \libsdl1.2-dev \pylint3 \rsync \cpio
- 安装tftp
install tftp
$ sudo apt-get install tftp-hpa tftpd-hpa$ mkdir ~/tftpboot$ chmod 777 ~/tftpboot/$ sudo gedit /etc/default/tftpd-hpa# /etc/default/tftpd-hpa TFTP_USERNAME="tftp"TFTP_DIRECTORY="/home/james/tftpboot" //tftpboot绝对路径TFTP_ADDRESS=":69"TFTP_OPTIONS="--secure -l -c -s"$ service tftpd-hpa restart
2.2 安装
安装命令:
$ ./petalinux-v2020.1-final-installer.run
安装过程中选择默认就可以了
3 使用
3.1 启动环境配置
james@james-desktop:~$ source /opt/xilinx/petalinux/2020.1/settings.sh
PetaLinux environment set to '/opt/xilinx/petalinux/2020.1'
WARNING: This is not a supported OS
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
james@james-desktop:~$
3.2 使用
调用petalinux-create命令有如下输出,说明安装成功了。
james@james-desktop:~$ petalinux-create
ERROR: No type is specified!
This command creates a new PetaLinux Project or componentUsage:petalinux-create [options] <-t|--type <TYPE> <-n|--name <COMPONENT_NAME>Required:-t, --type <TYPE> Available type:* project : PetaLinux project* apps : Linux user application* modules : Linux user module-n, --name <COMPONENT_NAME> specify a name for the component orproject. It is OPTIONAL to create aPROJECT. If you specify source BSP whenyou create a project, you are notrequired to specify the name.
Options:-p, --project <PROJECT> specify full path to a PetaLinux projectthis option is NOT USED for PROJECT CREATION.default is the working project.--force force overwriting an existing componentdirectory.-h, --help show function usage--enable this option applies to all types exceptproject.enable the created component--srcuri this option is to specify the source filesfrom outside project.This will copy specifiedfiles into recipe files directory and add toSRC_URI variable in .bb file.Specify the multiple files with space.Options for project:--template <TEMPLATE> versal|zynqMP|zynq|microblazeuser needs specify which template to use.-s|--source <SOURCE> specify a PetaLinux BSP as a projectsource.Options for apps:--template <TEMPLATE> <c|c++|autoconf|install>c : c user application(default)c++ : c++ user applicationautoconf: autoconf user applicationinstall: install data onlyfpgamanager: autoload .dtbo and .bin filesEnable 'FPGA Manager' to build the fpgamanager apps.-s, --source <SOURCE> valid source name format:*.tar.gz, *.tgz, *.tar.bz2, *.tar,*.zip, app source directoryOptions for modules: (No specific options for modules)EXAMPLES:Create project from PetaLinux Project BSP:$ petalinux-create -t project -s <PATH_TO_PETALINUX_PROJECT_BSP>Create project from template:
For microblaze project,$ petalinux-create -t project -n <PROJECT> --template microblaze
For zynq project,$ petalinux-create -t project -n <PROJECT> --template zynq
For zynqMP project,$ petalinux-create -t project -n <PROJECT> --template zynqMP
For versal project,$ petalinux-create -t project -n <PROJECT> --template versalCreate an app and enable it:$ petalinux-create -t apps -n myapp --enable
The application "myapp" will be created with c template in:<PROJECT>/project-spec/meta-user/recipes-apps/myappCreate an app with remote sources:$ petalinux-create -t apps -n myapp --enable --srcuri http://example.tar.gz$ petalinux-create -t apps -n myapp --enable --srcuri git://example.git\;protocol=https$ petalinux-create -t apps -n myapp --enable --srcuri https://example.tar.gzCreate a FPGAmanager application to load .dtsi and .bit/.pdi$ petalinux-create -t apps --template fpgamanager -n gpio --enable
The application "gpio" will be created with the fpgamanager class
include to build .dtbo and .bin files which will load on target
boot time(default).
NOTE: Make sure you have enabled the 'FPGA manager' in petalinux-configCreate an app with local source files:$ petalinux-create -t apps --template fpgamanager -n gpio --enable --srcuri \"<path>/pl.dtsi <path>/system.bit"
This will create "gpio" application with pl.dtsi and system.bit added
to SRC_URI and copied to files directory.Create an module and enable it:$ petalinux-create -t modules -n mymodule --enable
The module "mymodule" will be created with template in:<PROJECT>/project-spec/meta-user/recipes-modules/mymoduleCreate an module with source files:$ petalinux-create -t modules -n mymodule --enable --srcuri "<path>/mymoudle.c <path>/Makefile"james@james-desktop:~$
参考文档:
- PetaLinux 工具