为 UltraZed/Ultra96/Ultra96-V2/KV260/KR260 设备提供 Debian (11.7) GNU/Linux 的引导镜像

首先

这篇文章的目的是什么。

為了UltraZed/Ultra96/Ultra96-V2/KV260/KR260設置Boot Loader(U-Boot等)、Linux内核、Debian11.7(bullseye)根文件系統的安裝方法,本文準備了以下URL。如果您覺得編譯Boot Loader或Linux内核麻煩的話,請參考以下說明。

    https://github.com/ikwzm/ZynqMP-FPGA-Debian11

请留意事项。

在这篇文章中介绍的存储库中提供的Linux内核和Debian11根文件系统不是AMD公司(之前的Xilinx公司)官方提供的原始版本。作者根据个人兴趣对其进行了个人定制。请在使用时注意这一点,并自行承担责任。

请记录

目前为止,我们停止了对旧文中介绍的 https://github.com/ikwzm/ZynqMP-FPGA-Linux 的更新。原因是该存储库中包含大量二进制文件,难以进行维护。我们决定以后为每个发行版提供单独的存储库。

特征

处理板

    • UltraZed-EG-IOCC : Xilinx Zynq UltraScale+ MPSoC Starter Kit by Avnet.

 

    • Ultra96 : Xilinx Zynq UltraScale+ MPSoC development board based on the Linaro 96Boards specification.

 

    • Ultra96-V2 : updates and refreshes the Ultra96 product that was released in 2018.

 

    • KV260 : Kria KV260 Vision AI Startar Kit.

 

    KR260 : Kria KR260 Robotics Startar Kit.

引导程序

    • FSBL(First Stage Boot Loader for ZynqMP)

 

    • PMU Firmware(Platform Management Unit Firmware)

 

    • BL31(ARM Trusted Firmware Boot Loader stage 3-1)

 

    U-Boot xilinx-v2019.2 (customized)

Linux 内核

    • Linux Kernel Version 5.15.108-zynqmp-fpga-generic

https://github.com/ikwzm/ZynqMP-FPGA-Linux-Kernel-5.15/tree/5.15.108-zynqmp-fpga-generic-5

linux-stable 5.15.108 がベース
Patched equivalent to linux-xlnx v2022.2
Enable Device Tree Overlay with Configuration File System
Enable FPGA Manager
Enable FPGA Bridge
Enable FPGA Reagion
Enable ATWILC3000 Linux Driver for Ultra96-V2
Other Configuration

https://github.com/ikwzm/ZynqMP-FPGA-Linux-Kernel-5.15/blob/5.15.108-zynqmp-fpga-generic-5/files/zynqmp_fpga_generic_defconfig

Debian11.7(牛眼)根文件系统

    • Installed build-essential

 

    • Installed device-tree-compiler

 

    • Installed ruby ruby-msgpack ruby-serialport

 

    • Installed python python3 msgpack-rpc-python

 

    • Installed u-boot-tools

 

    • Installed Other package

https://github.com/ikwzm/ZynqMP-FPGA-Debian11/blob/v1.0.1/files/debian11-dpkg-list.txt

安装

下载

请从GitHub下载以下内容。

shell$ wget https://github.com/ikwzm/ZynqMP-FPGA-Debian11/archive/refs/tags/v1.0.1.tar.gz
shell$ tar xfz v1.0.1.tar.gz
shell$ cd ZynqMP-FPGA-Debian11-1.0.1

文件说明

    • target/Kv260/boot/

boot.scr : Stage Script file
uEnv.txt : U-Boot environment variables for linux boot
devicetree-5.15.108-zynqmp-fpga-generic-kv260-revB.dtb : Linux Device Tree Blob
devicetree-5.15.108-zynqmp-fpga-generic-kv260-revB.dts : Linux Device Tree Source

target/Kr260/boot/

boot.scr : Stage Script file
uEnv.txt : U-Boot environment variables for linux boot
devicetree-5.15.108-zynqmp-fpga-generic-kr260-revB.dtb : Linux Device Tree Blob
devicetree-5.15.108-zynqmp-fpga-generic-kr260-revB.dts : Linux Device Tree Source

target/Ultra96/boot/

boot.bin : Stage 1 Boot Loader
uEnv.txt : U-Boot environment variables for linux boot
devicetree-5.15.108-zynqmp-fpga-generic-ultra96.dtb : Linux Device Tree Blob
devicetree-5.15.108-zynqmp-fpga-generic-ultra96.dts : Linux Device Tree Source

target/Ultra96-V2/boot/

boot.bin : Stage 1 Boot Loader
uEnv.txt : U-Boot environment variables for linux boot
devicetree-5.15.108-zynqmp-fpga-generic-ultra96v2.dtb : Linux Device Tree Blob
devicetree-5.15.108-zynqmp-fpga-generic-ultra96v2.dts : Linux Device Tree Source

files/

vmlinuz-5.15.108-zynqmp-fpga-generic-5 : Linux Kernel Image
config-5.15.108-zynqmp-fpga-generic-5 : Linux Kernel Configuration File

debian11-rootfs-vanilla.tgz.files/ : Debian11 Root File System

x00 .. x08 : (splited files)

debian/

linux-image-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb : Linux Image Package
linux-headers-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb : Linux Headers Package
fclkcfg-5.15.108-zynqmp-fpga-generic_1.7.2-1_arm64.deb : fclkcfg(1.7.2) Device Driver and Services Package
u-dma-buf-5.15.108-zynqmp-fpga-generic_4.4.1-0_arm64.deb : u-dma-buf(4.4.1) Device Driver and Services Package

SD卡的格式化

    1. 用 VFAT 文件系统在 SD 卡的分区 1 上创建文件系统。

 

    用 ext4 文件系统在 SD 卡的分区 2 上创建文件系统。

请参考以下链接以了解在Linux系统下的SD卡格式化方法。

    https://github.com/ikwzm/ZynqMP-FPGA-Debian11/blob/main/doc/install/format-disk.md

写入SD卡

0. SD卡的挂载

将SD卡的第一个分区(引导分区)和第二个分区(根分区)挂载为可读写。
在此示例中,将引导分区挂载到/mnt/usb1,将根分区挂载到/mnt/usb2。

shell# mount /dev/sdc1 /mnt/usb1
shell# mount /dev/sdc2 /mnt/usb2

创建引导分区

如果是KV260的情况下

将target/Kv260/boot/目录下的文件和Linux内核镜像复制到SD卡的引导分区(例如/mnt/usb1)。

shell# cp target/Kv260/boot/*                                    /mnt/usb1
shell# gzip -d -c files/vmlinuz-5.15.108-zynqmp-fpga-generic-5 > /mnt/usb1/image-5.15.108-zynqmp-fpga-generic
对于KR260,假设只需要给出一种选项

将target/Kr260/boot/目录下的文件以及Linux内核映像复制到SD卡的引导分区(例如/mnt/usb1)。

shell# cp target/Kr260/boot/*                                    /mnt/usb1
shell# gzip -d -c files/vmlinuz-5.15.108-zynqmp-fpga-generic-5 > /mnt/usb1/image-5.15.108-zynqmp-fpga-generic
对于Ultra96 来说

将 target/Ultra96/boot/ 目录中的文件和 Linux 内核镜像复制到 SD-Card 的引导分区(例如/mnt/usb1)。

shell# cp target/Ultra96/boot/*                                  /mnt/usb1
shell# gzip -d -c files/vmlinuz-5.15.108-zynqmp-fpga-generic-5 > /mnt/usb1/image-5.15.108-zynqmp-fpga-generic
对于Ultra96-V2来说

将目标/Ultra96-V2/boot/目录下的文件和Linux内核映像复制到SD卡的引导分区(例如/mnt/usb1)。

shell# cp target/Ultra96-V2/boot/*                               /mnt/usb1
shell# gzip -d -c files/vmlinuz-5.15.108-zynqmp-fpga-generic-5 > /mnt/usb1/image-5.15.108-zynqmp-fpga-generic
对于UltraZed来说

将 target/UltraZed-EG-IOCC/boot/ 下的文件和 Linux 内核镜像复制到 SD 卡的引导分区(例如/mnt/usb1)。

shell# cp target/UltraZed-EG-IOCC/boot/*                         /mnt/usb1
shell# gzip -d -c files/vmlinuz-5.15.108-zynqmp-fpga-generic-5 > /mnt/usb1/image-5.15.108-zynqmp-fpga-generic

2. 创建根分区

将 debian11-rootfs-vanilla.tgz.files 中的内容解压到 SD-Card 的根分区(例如/mnt/usb2)。最好事先将设备驱动程序的 Debian 包复制到已解压的根文件系统的 home/fpga 目录中。稍后也可以通过网络进行复制。

shell# cat debian11-rootfs-vanilla.tgz.files/* | tar xfz - -C /mnt/usb2
shell# mkdir                                                  /mnt/usb2/home/fpga/debian
shell# cp debian/*                                            /mnt/usb2/home/fpga/debian

3. 配置 fstab 以使得引导分区可见。

让Linux始终能够看到引导分区是很方便的。在这种情况下,最好事先将引导分区配置为在fstab中自动挂载。请注意,fstab已经配置了configfs的挂载。

Ultra96/Ultra96-V2的引导分区是/dev/mmcblk0p1。

shell# mkdir /mnt/usb2/mnt/boot
shell# cat <<EOT >> /mnt/usb2/etc/fstab
/dev/mmcblk0p1	/mnt/boot	auto	defaults	0	0
EOT

KV260/UltraZed的引导分区是/dev/mmcblk1p1。

shell# mkdir /mnt/usb2/mnt/boot
shell# cat <<EOT >> /mnt/usb2/etc/fstab
/dev/mmcblk1p1	/mnt/boot	auto	defaults	0	0
EOT

KR260 的启动分区是 /dev/sda1。

shell# mkdir /mnt/usb2/mnt/boot
shell# cat <<EOT >> /mnt/usb2/etc/fstab
/dev/sda1	/mnt/boot	auto	defaults	0	0
EOT

余談:如果只是这样的描述,事先写在 debian11-rootfs-vanilla.tgz 中会更好,为什么要在之后才进行设置,可能会有疑问。原因在于 debian11-rootfs-vanilla.tgz 是与 Ultra96/Ultra96V2/UltraZed/KV260/KR260 共享的。Ultra96/Ultra96-V2 的 SD 卡引导分区是 /dev/mmcblk0p1,而 UltraZed/KV260 的 SD 卡引导分区是 /dev/mmcblk1p1,而 KR260 的 SD 卡引导分区是 /dev/sda1。此外,UltraZed 还存在 /dev/mmcblk0p1,如果事先写在 debian11-rootfs-vanilla.tgz 中,会在 UltraZed 中错误地访问到其他设备。因此,尽管麻烦些,我们选择在之后进行设置。

4. 网络设置

Ultra96/Ultra96-V2 通过WiFi连接到网络。建议事先在主机上创建配置文件并写入RootFS,这样可能会更好。当然,也可以稍后启动Ultra96/Ultra96-V2并在其中进行设置。

在这里,将SSID设置为ssssssss,将密码设置为ppppppppp,并将加密的访问密钥设置为xxxx。

首先,我们使用 wpa_passphrase 输入网络名称(SSID)和密码,生成一个加密的访问密钥。

shell# wpa_passphrase ssssssss ppppppppp
network={
	ssid="ssssssss"
	#psk="ppppppppp"
	psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
4.1 直接在/etc/network/interfaces.d/wlan0中进行记录。

将SSID和加密的访问密钥直接写入网络配置文件(/etc/network/interfaces.d/wlan0)。


auto  wlan0
iface wlan0 inet dhcp
	wpa-ssid ssssssss
	wpa-psk  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
4.2 将内容写入 /etc/wpa_supplicant/wpa_supplicant.conf

在网络设置文件(/etc/network/interfaces.d/wlan0)中,您需要像下面这样描述,以便在启动时加载wpa_supplicant.conf并设置Wifi。


auto  wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

将SSID和加密后的访问密钥写入WiFi设置文件(/etc/wpa_supplicant/wpa_supplicant.conf)中。

ctrl_interface=/run/wpa_supplicant
update_config=1

network={
	ssid="ssssssss"
	psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

另外,对于隐形SSID,需要强制进行扫描。在这种情况下,请在/etc/wpa_supplicant/wpa_supplicant.conf文件中添加scan_ssid=1。

ctrl_interface=/run/wpa_supplicant
update_config=1

network={
	ssid="ssssssss"
	scan_ssid=1
	key_mgmt=WPA-PSK
	psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

如果要连接没有密码的SSID,请将key_mgmt设置为NONE(注意,NONE应为大写)。

ctrl_interface=/run/wpa_supplicant
update_config=1

network={
	ssid="ssssssss"
	scan_ssid=1
	key_mgmt=NONE
}

5. 取下SD卡

shell# umount /mnt/usb1
shell# umount /mnt/usb2

安装设备驱动程序包。

目标的启动

为了安装Debian包,如设备驱动程序等,您需要使用上述创建的SD卡引导目标。

通过 root 用户登录

使用root帐户登录。debian11-rootfs-vanilla.tgz的root密码为admin。建议您定期更改root密码。

debian-fpga login: root
Password:
root@debian-fpga:~#

安装Linux镜像包

debian11-rootfs-vanilla.tgz中已经安装了Linux Image Package(linux-image-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb)。因此,以下操作是不需要的,但如果需要重新安装的话,请参考以下步骤。

请务必安装Linux Image Package,因为它包含了内核模块,对于Debian的正常启动是必需的。

root@debian-fpga:~# cd /home/fpga/debian
root@debian-fpga:/home/fpga/debian# dpkg -i linux-image-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb
(Reading database ... 27341 files and directories currently installed.)
Preparing to unpack linux-image-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb ...
Unpacking linux-image-5.15.108-zynqmp-fpga-generic (5.15.108-zynqmp-fpga-generic-5) over (5.15.108-zynqmp-fpga-generic-5) ...
Setting up linux-image-5.15.108-zynqmp-fpga-generic (5.15.108-zynqmp-fpga-generic-5) ...

安装Linux Header软件包。

请使用dpkg工具安装linux-headers-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb。在过程中,如果询问如何处理ARM64_BTI、ARM64_E0PD、ARCH_RANDOM、ARM64_MTE、KASAN,请无视并按下回车键。

然而,Linux Header Package 的安装并非必须,但在自行构建设备驱动程序或安装第三方提供的驱动程序时,可能会需要使用DKMS。根据需要安装即可。

root@debian-fpga:~# cd /home/fpga/debian
root@debian-fpga:/home/fpga/debian# dpkg -i linux-headers-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb
Selecting previously unselected package linux-headers-5.15.108-zynqmp-fpga-generic.
(Reading database ... 27341 files and directories currently installed.)
Preparing to unpack linux-headers-5.15.108-zynqmp-fpga-generic_5.15.108-zynqmp-fpga-generic-5_arm64.deb ...
Unpacking linux-headers-5.15.108-zynqmp-fpga-generic (5.15.108-zynqmp-fpga-generic-5) ...
Setting up linux-headers-5.15.108-zynqmp-fpga-generic (5.15.108-zynqmp-fpga-generic-5) ...
make: Entering directory '/usr/src/linux-headers-5.15.108-zynqmp-fpga-generic'
  SYNC    include/config/auto.conf.cmd
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
*
* Restart config...
*
*
* ARMv8.5 architectural features
*
Branch Target Identification support (ARM64_BTI) [Y/n/?] y
Enable support for E0PD (ARM64_E0PD) [Y/n/?] y
Enable support for random number generation (ARCH_RANDOM) [Y/n/?] y
Memory Tagging Extension support (ARM64_MTE) [Y/n/?] (NEW)
*
* KASAN: runtime memory debugger
*
KASAN: runtime memory debugger (KASAN) [N/y/?] (NEW)
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  HOSTCC  scripts/dtc/libfdt/fdt.o
  HOSTCC  scripts/dtc/libfdt/fdt_ro.o
  HOSTCC  scripts/dtc/libfdt/fdt_wip.o
  HOSTCC  scripts/dtc/libfdt/fdt_sw.o
  HOSTCC  scripts/dtc/libfdt/fdt_rw.o
  HOSTCC  scripts/dtc/libfdt/fdt_strerror.o
  HOSTCC  scripts/dtc/libfdt/fdt_empty_tree.o
  HOSTCC  scripts/dtc/libfdt/fdt_addresses.o
  HOSTCC  scripts/dtc/libfdt/fdt_overlay.o
  HOSTCC  scripts/dtc/fdtoverlay.o
  HOSTLD  scripts/dtc/fdtoverlay
  HOSTCC  scripts/selinux/genheaders/genheaders
  HOSTCC  scripts/selinux/mdp/mdp
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/sorttable
  HOSTCC  scripts/asn1_compiler
  HOSTCC  scripts/extract-cert
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  CC      scripts/mod/devicetable-offsets.s
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
scripts/Makefile.build:459: warning: overriding recipe for target 'modules.order'
Makefile:1508: warning: ignoring old recipe for target 'modules.order'
make: Leaving directory '/usr/src/linux-headers-5.15.108-zynqmp-fpga-generic'

安装 fclkcfg 设备驱动程序。

使用dpkg工具来安装fclkcfg-5.15.108-zynqmp-fpga-generic_1.7.2-1_arm64.deb。

这个包不是必须的。

root@debian-fpga:~# cd /home/fpga/debian
root@debian-fpga:/home/fpga/debian# dpkg -i fclkcfg-5.15.108-zynqmp-fpga-generic_1.7.2-1_arm64.deb
Selecting previously unselected package fclkcfg-5.15.108-zynqmp-fpga-generic.
(Reading database ... 43883 files and directories currently installed.)
Preparing to unpack fclkcfg-5.15.108-zynqmp-fpga-generic_1.7.2-1_arm64.deb ...
Unpacking fclkcfg-5.15.108-zynqmp-fpga-generic (1.7.2-1) ...
Setting up fclkcfg-5.15.108-zynqmp-fpga-generic (1.7.2-1) ...

udmabuf 设备驱动程序的安装

使用dpkg来安装u-dma-buf-5.15.108-zynqmp-fpga-generic_4.4.1-0_arm64.deb。

这个包不是必须的。

root@debian-fpga:~# cd /home/fpga/debian
root@debian-fpga:/home/fpga/debian# dpkg -i u-dma-buf-5.15.108-zynqmp-fpga-generic_4.4.1-0_arm64.deb
Selecting previously unselected package u-dma-buf-5.15.108-zynqmp-fpga-generic.
(Reading database ... 43889 files and directories currently installed.)
Preparing to unpack u-dma-buf-5.15.108-zynqmp-fpga-generic_4.4.1-0_arm64.deb ...
Unpacking u-dma-buf-5.15.108-zynqmp-fpga-generic (4.4.1-0) ...
Setting up u-dma-buf-5.15.108-zynqmp-fpga-generic (4.4.1-0) ...

请看一下

    • https://github.com/ikwzm/ZynqMP-FPGA-Debian11

 

    • https://github.com/ikwzm/ZynqMP-FPGA-Linux-Kernel-5.15

 

    • https://github.com/ikwzm/ZynqMP-U-Boot-Ultra96

 

    • https://github.com/ikwzm/ZynqMP-U-Boot-Ultra96-V2

 

    • https://github.com/ikwzm/ZynqMP-U-Boot-UltraZed-EG-IOCC

 

    • https://github.com/ikwzm/ZynqMP-FPGA-Ubuntu22.04-Console

 

    https://github.com/ikwzm/ZynqMP-FPGA-Ubuntu22.04-Desktop

过去的新闻

如果您想安装早期版本,请参考以下文章。目前最新版本为ZynqMP-FPGA-Debian11 v1.0.1。

    • 「UltraZed/Ultra96/Ultra96-V2/KV260 向け Debian GNU/Linux (v2021.1版) ブートイメージの提供」 @Qiita

 

    • 「UltraZed/Ultra96/Ultra96-V2 向け Debian GNU/Linux (v2020.2版) ブートイメージの提供」 @Qiita

 

    • 「UltraZed/Ultra96/Ultra96-V2 向け Debian GNU/Linux (v2019.2版) ブートイメージの提供」 @Qiita

 

    • 「UltraZed/Ultra96/Ultra96-V2 向け Debian GNU/Linux (v2019.1版) ブートイメージの提供」 @Qiita

 

    • 「Ultra96 向け Debian GNU/Linux (v2018.2版) ブートイメージの提供」 @Qiita

 

    「UltraZed 向け Debian GNU/Linux (v2018.2版) ブートイメージの提供」 @Qiita