速通Petalinux:Basics #1

如何快速部署petalinux

按照要求,我现在开始速通Petalinux在zynq 7010上的部署。

关键词列表:

BSP:Board Support Package. 顾名思义是为了板级外设而准备的。BSP含有启动用的固件和设备的驱动。

Yocto Project:用来部署嵌入式linux的一组工具集。(参见https://www.yoctoproject.org/software-overview/

0x00 引入

什么是Petalinux?实际上并不是一个发行版,而是一组工具集。按照AMD的说法,含有:

  • Yocto 可扩展 SDK(Yocto Extensible SDK)
  • 赛灵思软件命令行工具XSCT(Xilinx Software Command-Line Tool)及工具链
  • Petalinux命令行工具
AMD Adaptive Computing Documentation Portal
Petalinux 工具文档(UG1144)
PetaLinux Tools

0x01 Petalinux安装

下载Petalinux SDK:

Downloads
Vivado, Vitis, Vitis Embedded Platform, PetaLinux, Device models

需要安装xterm和bc。将文件移动到安装目录,给下载下来的文件一个运行权限,然后运行就行。

0x02 Petalinux Design Flow

In general, the PetaLinux tool follows a sequential workflow model. The following table provides an example design workflow, demonstrating the order in which the tasks should be completed and the corresponding tool or workflow for that task.
Design Flow Overview
Design Flow Step Tool / Workflow
Hardware platform creation (for custom hardware only) AMD Vivado™ design tools
Create a PetaLinux project petalinux-create -t project
Initialize a PetaLinux project (for custom hardware only) petalinux-config --get-hw-description
Configure system-level options petalinux-config
Create user components petalinux-create -t COMPONENT
Configure U-Boot petalinux-config -c u-boot
Configure the Linux kernel petalinux-config -c kernel
Configure the root filesystem petalinux-config -c rootfs
Build the system petalinux-build
Package for deploying the system petalinux-package
Boot the system for testing petalinux-boot
Upgrades the workspace petalinux-upgrade
Use Yocto devtools command petalinux-devtool
Use debug utilities petalinux-util

在开始design flow之前,先开一个bash,把环境配置一下:

[skyli@skyli-desktop Petalinux]$ source settings.sh
PetaLinux environment set to '/home/skyli/Petalinux'
WARNING: /usr/bin/zsh is not bash! 
/bin/bash is Petalinux recommended SHELL variable. Please set your SHELL variable to /bin/bash.
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
WARNING: No tftp server found - please refer to "UG1144 2023.1 PetaLinux Tools Documentation Reference Guide" for its impact and solution
[skyli@skyli-desktop Petalinux]$ 
你疑似有点多嘴了

按照AMD的说法,如果自己配置板的话,就是在Vivado里面把Hardware Platform手动配置好,最小的配置需要:

  • TTC;
  • 至少512MB的内存;
  • UART;

(BTW,RedlightASl如是说:)

还有部分可选项,例如:

  • 非易失性存储器(SD卡、SPI闪存)等;
  • 以太网。

首先创建Block Design,然后选择一个Zynq处理核,配置并生成Block Design之后在Vivado里面Export Hardware。取得了这个xsa文件就行。

随后,在已经有环境变量的bash里面运行:

$ petalinux-create -t project -n <project_name> --template zynq
$ petalinux-config --get-hw-description <PATH-TO-XSA Directory>
$ petalinux-build
$ petalinux-package
$ petalinux-package --wic

注意:

  • petalinux-build 的时候如果开了TUN代理,那就得把它关掉,否则bitbake可能没法解析到本地(离谱得很)。
  • 后面再次生成petalinux的bootimg时,应使用如下命令:
$ petalinux-package --boot --uboot --kernel --offset 0xF40000
  • 当对kernel进行了修改之后,应当一同更新rootfs,避免因为rootfs中新引入的kernel modules未加载。

随后将wic烧写至sd卡,应当能够boot了。