使用Petalinux2022搭建ZYNQ系统镜像问题记录
-
背景:
使用Petalinux构建linux系统,虽然便利,但是对于驱动开发不够灵活,且将rootfs与内核打包在一起,导致启动速度慢,因此:
-
将FPGA bit文件从BOOT.BIN分开
-
image.ub文件分开为zImage和设备树
-
将rootfs放在EXT4分区
这样SD卡内容如下
-
boot分区(fat分区):BOOT.BIN(FSBL + u-boot)、system.dtb、boot.scr、zImage、system.bit及APP
-
rootfs(ext4分区):rootfs(驱动挂载在根文件系统目录下)
-
流程
-
创建Petalinux工程
sptl
petalinux-create -t project --template zynq -n MY_ZYNQ_PRJ
cd MY_ZYNQ_PRJ
petalinux-config --get-hw-description /<xsa location>注意:
petalinux-config需要配置 Image Packaging Configuration --> Root filesystem type 为EXT4,即从EXT4分区挂载根文件系统
打包BOOT.BIN
petalinux-build -c bootloader
petalinux-build -c u-boot
petalinux-package --boot --fsbl --u-boot --force
注意:对于Petalinux 21版本及以后版本:必须使用petalinux-package --boot --fsbl --u-boot --force命令构建BOOT.BIN,而不能加上--dtb no选项
原因如下:
2.2 生成boot.scr
petalinux-build //
修改boot.scr,详细见《正点原子领航者ZYNQ之嵌入式Linux开发指南》
主要是从image.ub改为zImage启动内核、添加system.bit启动
注意:编译boot.scr文件,需要使用u-boot-tools工具,使用
sudo apt install u-boot-tools安装
2.3 编译内核
我这里使用的linux内核版本为v5.15_2022,
具体流程同《正点原子领航者ZYNQ之嵌入式Linux开发指南》,
2.4 编译根文件系统
petalinux-config -c rootfs
petalinux-build -c rootfs
sudo tar -xzf rootfs.tar.gz -C /media/rootfs //将根文件系统压缩包解压至SD卡 ext4分区
2.5 启动开发板
将文件拷贝只SD卡:
-
boot分区(fat分区):BOOT.BIN(FSBL + u-boot)、system.dtb、boot.scr、zImage、system.bit及APP
-
rootfs(ext4分区):rootfs(驱动挂载在根文件系统目录下)
启动开发板,进入系统
-
驱动开发遇到的问题
- 驱动编译,报错:<linux/ide.h> :no such file
是因为我采用linux5.15版本内核编译,在5.14版本后,删除了<ide.h>,可以使用libata相关库替代
改为<linux/libata.h>就不报错了

浙公网安备 33010602011771号