petalinux工程创建启动

参考文档:ug1144, xilinx文档搜索及下载地址: https://docs.xilinx.com/

前言

本文主要说明petalinux从工程创建到加载xsa到编译启动的步骤,以及vitis软件开发步骤。
环境基于ZYNQ UltraScale+ MPSoc EG系列,默认petalinux及vitis已安装完毕。
另一种方式,从BSP文件创建工程,不在本文说明。

预备条件

已安装Vivado工具,并配置Vivado tool工作环境:

source <path-to-installed-Xilinx-Vivado>/settings64.sh
示例:source ~/petalinux/settings.sh

Vivado下载链接:Vivado
熟悉vitis使用,参考UG1400

一、创建一个新的petelinux工程

示例:
<plnx-proj-root> petalinux-create --type project --template zynqMP --name test_pro

参数说明:
–template - The following platform types are supported:
○ versal-net (for Versal-Net adaptive SoC)
○ versal (for Versal adaptive SoC)
○ zynqMP (for Zynq UltraScale+ MPSoC)
○ zynq (for Zynq 7000 devices)
○ microblaze (for MicroBlaze processor)
Note: The MicroBlaze template option cannot be used with Zynq 7000 devices or Zynq UltraScale+ designs in the Programmable Logic (PL).
• --name <PROJECT_NAME> - The name of your project.
分类说明

导入硬件描述文件XSA

<plnx-proj-root> petalinux-config --get-hw-description  [SRC]

参数SRC是文件所在“路径”,XSA文件是从vivado导出的自己硬件平台,vivado工程创建和使用本文不关心,后续有需要再单独成文。

编译创建系统Image

<plnx-proj-root> petalinux-build 

参数说明:
编译之后会在<proj_root>/images/linux/目录和/tftpboot目录生成镜像文件

When you run petalinux-build, it generates FIT images for Versal adaptive SoC, Zynq
UltraScale+ MPSoC, Zynq 7000 devices, and MicroBlaze platforms. The RAM disk image
rootfs.cpio.gz.u-boot is also generated.
The full compilation log build.log is stored in the build sub-directory of your PetaLinux
project. The final image, /images/linux/image.ub, is a FIT image. The
kernel image (including RootFS, initramfs, if any,) is Image for Zynq UltraScale+ MPSoC and
Versal platform, zImage for Zynq 7000 devices, and image.elf for MicroBlaze processors.

生成启动镜像boot image

A boot image usually contains a PDI file (imported from hardware design), PLM, PSM firmware,
Arm® trusted firmware, U-Boot, and DTB.

petalinux-package 
生成引导BOOT.BIN文件:petalinux-package --boot --u-boot
示例:
<plnx-proj-root> petalinux-package--boot --format BIN --fsbl images/linux/zynqmp_fsbl.elf --u-boot images/linux/u-boot.elf --pmufwimages/linux/pmufw.elf --fpga images/linux/*.bit --force

参数:
–bsp 打包生成.bsp文件,可用于直接创建新的petalinux工程

示例1:Clean the project and generate the BSP installation image (.bsp file).
$ petalinux-package --bsp --clean -o [PATH-TO-BSP] -p [PATH-TO-PROJECT]
示例2:Generate the BSP installation image that includes a reference hardware definition.
$ petalinux-package --bsp -p [PATH-TO-PROJECT] --hwsource [PATH-TO-HWEXPORT] -o [PATH-TO-BSP]

生成vitis sdk所需文件

<plnx-proj-root/images/linux/> petalinux-build  --sdk
<plnx-proj-root/images/linux/> petalinux-package  --sysroot

–sdk,builds SDK and copies it at <proj_root>/images/linux/sdk.sh,用于sdk应用开发
–sysroot 安装sdk在指定路径用于应用开发

打包预编译镜像

petalinux-package --prebuilt --fpga  images/linux/*.bit

– prebuilt 发布BSP工程使用
另外还有很多参数,可以配置u-boot dtb,下载地址等,暂不详细说明,后续再补充。

启动

前提:packaged prebuilt images


petalinux-boot --jtag --prebuilt  3(LEVEL)
petalinux-boot --qemu --prebuilt 3

Level 1: Download the prebuilt FPGA bitstream.
Level 2: Download the prebuilt FPGA bitstream and boot the prebuilt U-Boot.
Level 3: Download and boot the prebuilt Linux

vitis 配置

https://mp.weixin.qq.com/s/YV1fC0NBYWpxtrS4KVqJgw

### 创建和配置基于 Xilinx ZCU104 开发板的 PetaLinux 工程 创建和配置基于 Xilinx ZCU104 开发板的 PetaLinux 工程需要以下几个关键步骤: 1. **准备开发环境** - 确保系统已安装 Xilinx Vivado 和 PetaLinux 工具。PetaLinux 工具版本需与 Vivado 版本兼容,例如使用 2019.2 版本时,需安装对应的 PetaLinux 工具。 - 设置 PetaLinux 环境变量,通过 `source settings.sh` 命令初始化 PetaLinux 环境。 2. **创建 PetaLinux 工程** 使用 `petalinux-create` 命令创建基于 ZCU104 的工程,命令如下: ```bash petalinux-create -t project -n zcu104_project --template zynqMP ``` 其中 `zcu104_project` 是工程名称,`--template zynqMP` 指定使用 Zynq UltraScale+ MPSoC 模板。 3. **配置硬件设计** 进入工程目录并使用 `petalinux-config` 命令配置硬件设计: ```bash cd zcu104_project petalinux-config --get-hw-description=<path_to_hardware_description> ``` 其中 `<path_to_hardware_description>` 是指向 Vivado 导出的 `.hdf` 文件路径。该步骤将硬件设计导入 PetaLinux 工程,并配置系统架构。 4. **配置根文件系统(rootfs)** 在 PetaLinux 工程中,可以使用 `petalinux-config -c rootfs` 命令配置根文件系统。例如,使能 OpenCV 和 X11 支持: ```bash petalinux-config -c rootfs ``` 在配置界面中,选择 `Petalinux Package Groups` 并启用以下选项: - `packagegroup-petalinux-opencv`:提供 OpenCV 相关库和工具。 - `packagegroup-petalinux-x11`:提供 X11 图形支持[^1]。 5. **构建 PetaLinux 工程** 配置完成后,使用以下命令构建 PetaLinux 工程: ```bash petalinux-build ``` 该命令将编译内核、设备树、根文件系统以及生成 BOOT.BIN 文件。 6. **生成启动镜像** 构建完成后,使用 `petalinux-package` 命令生成启动镜像: ```bash petalinux-package --boot --fsbl images/linux/zynqmp_fsbl.elf --pmufw images/linux/pmufw.elf --u-boot ``` 该命令将生成 `BOOT.BIN` 文件,用于启动 ZCU104 开发板。 7. **部署和测试** 将生成的 `BOOT.BIN`、`image.ub` 和 `rootfs.cpio.gz` 文件复制到 SD 卡或 QSPI 闪存中,并在 ZCU104 开发板上启动系统进行测试。 ### 示例代码 以下是一个简单的示例代码片段,用于在 ZCU104 上启动 PetaLinux 系统: ```bash # 创建 PetaLinux 工程 petalinux-create -t project -n zcu104_project --template zynqMP # 进入工程目录并配置硬件设计 cd zcu104_project petalinux-config --get-hw-description=<path_to_hardware_description> # 配置根文件系统 petalinux-config -c rootfs # 构建 PetaLinux 工程 petalinux-build # 生成启动镜像 petalinux-package --boot --fsbl images/linux/zynqmp_fsbl.elf --pmufw images/linux/pmufw.elf --u-boot ``` ###
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值