在Ultra96/Ultra96-V2上运行Debian GNU/Linux并使用X Window(视频驱动)
首先
筆者為 Ultra96/Ultra96-V2(ZynqMP)提供 Debian GNU/Linux 1。我們提供的 Debian GNU/Linux 是基於 CUI 的,但為了支持 GUI,我們在 Ultra96/Ultra96-V2 上運行了 X Window System。
以下将Ultra96/Ultra96-V2上运行X Window System的步骤进行分解并进行说明。
-
概要編
Video Driver 編(この記事)
Mali Driver 編
LibMali 編
fbdev 編
glmark2 編
本文介绍了如何在ZynqMP-FPGA-Linux上构建Video Driver(xserver-xorg-video-armsoc-xilinx)的Debian Package并进行安装的步骤。
xserver-xorg-video-armsoc-xilinx是什么?
这是对应于ZynqMP的X Window服务器的DDX驱动程序(视频驱动程序)。通过Xilinx提供的内核模块(xlnx_drv)的DRM / KMS(内核模块设置),可以获取显示信息并进行显示设置。

图1 xserver-xorg-video-armsoc-xilinx
Debian软件包的构建流程
在这一章中,我们将解释如何创建 xserver-xorg-video-armsoc-xilinx 的 Debian 软件包的步骤。
另外,在此提供了使用以下URL创建的存储库的说明步骤。如果创建存储库很麻烦,请使用以下存储库。
-
https://github.com/ikwzm/xf86-video-armsoc-xilinx.git
此外,我们在以下仓库中提供了预编译的xserver-xorg-video-armsoc-xilinx Debian软件包。如果您觉得编译过程麻烦,请使用此选项。
https://github.com/ikwzm/ZynqMP-FPGA-Xserver
xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb
建置环境
在构建环境中有一个需要注意的地方。那就是 xserver-xorg-video-armsoc-xilinx 必须作为 xserver-xorg-core 的插件模块进行构建。为此,需要先构建 xserver-xorg-core 的环境。在此过程中,如果目标环境(例如Debian10(ARM64))与构建环境(例如Ubuntu(amd64)等)不同,则可能会出现构建失败或其他问题。
要解决这个问题,最快的方法是在Ultra96/Ultra96-V2上使用Debian 10,自己构建xserver-xorg-video-armsoc。本文将解释在Ultra96/Ultra96-V2上构建Debian 10的步骤。
获取原始资源
xserver-xorg-video-armsoc-xilinx 是基于 xf86-video-armsoc 开发的。然而,事实上 xf86-video-armsoc 存在多个版本。仅在 GitHub 上就能找到32个仓库。除了 GitHub,Linaro.org 和 freedesktop.org 也有 git 仓库。可以说千奇百怪,琳琅满目。以下是简要介绍找到的仓库列表。
-
https://git.linaro.org/arm/xorg/driver/xf86-video-armsoc.git
https://anongit.freedesktop.org/git/xorg/driver/xf86-video-armsoc.git
https://github.com/endlessm/xf86-video-armsoc.git
https://github.com/paolosabatino/xf86-video-armsoc.git
https://github.com/prahal/xf86-video-armsoc.git
https://github.com/tmarques/xf86-video-armsoc.git
我会选择使用我提到的存储库中的 xserver-xorg-video-armsoc-xilinx, 因为这是由 freedesktop.org 提供的。选择这个存储库的原因是,据我所了解,它是 Xilinx 公司在他们提供的 PetaLinux 中使用的。我尝试了其他存储库,但无论是构建还是显示都无法成功。
因为 freedesktop.org 的代码库不是在 github 上,所以无法进行 fork。因此,我们将通过以下步骤创建本地代码库。
shell$ mkdir xserver-xorg-video-armsoc-xilinx
shell$ cd xserver-xorg-video-armsoc-xilinx
shell$ git init
shell$ git remote add freedesktop https://anongit.freedesktop.org/git/xorg/driver/xf86-video-armsoc.git
shell$ git fetch freedesktop
shell$ git merge freedesktop/master
为Xilinx应用补丁。
在 Xilinx 公司的 PetaLinux 中,我们对 freedesktop.org 提供的代码库进行了补丁,并进行构建。补丁文件位于以下 URL:
https://github.com/Xilinx/meta-xilinx/blob/master/meta-xilinx-bsp/recipes-graphics/xorg-driver/xf86-video-armsoc/0001-src-drmmode_xilinx-Add-the-dumb-gem-support-for-Xili.patch
下载此补丁文件并应用于代码库,顺便也进行 git 提交。
shell$ git clone https://github.com/Xilinx/meta-xilinx/
Cloning into 'meta-xilinx'...
remote: Enumerating objects: 1209, done.
remote: Counting objects: 100% (1209/1209), done.
remote: Compressing objects: 100% (605/605), done.
remote: Total 11725 (delta 678), reused 1045 (delta 551), pack-reused 10516
Receiving objects: 100% (11725/11725), 8.88 MiB | 6.21 MiB/s, done.
Resolving deltas: 100% (6448/6448), done.
shell$
shell$ patch -p1 < meta-xilinx/meta-xilinx-bsp/recipes-graphics/xorg-driver/xf86-video-armsoc/0001-src-drmmode_xilinx-Add-the-dumb-gem-support-for-Xili.patch
patching file src/Makefile.am
patching file src/armsoc_driver.c
patching file src/drmmode_driver.h
patching file src/drmmode_xilinx/drmmode_xilinx.c
shell$
shell$ git add --update
shell$ git add src/drmmode_xilinx
shell$ git commit -m "[add] src/drmmode_xilinx"
[master 84e3cef] [add] src/drmmode_xilinx
4 files changed, 80 insertions(+), 1 deletion(-)
create mode 100644 src/drmmode_xilinx/drmmode_xilinx.c
添加文件以创建Debian软件包
创建一个debian目录,并添加以下文件。
debian/
README.Debian
README.source
changelog
compat
control
copyright
rules
xserver-xorg-video-armsoc-xilinx.docs
xserver-xorg-video-armsoc-xilinx.install
这里不会对这些文件进行解释。请参考https://github.com/ikwzm/xf86-video-armsoc-xilinx获取更多详细信息。
当你添加文件后,执行 git commit。
shell$ git add debian/
shell$ git commit -m "[add] debian/"
[master 3961b1d] [add] debian/
8 files changed, 68 insertions(+)
create mode 100644 debian/README.Debian
create mode 100644 debian/README.source
create mode 100644 debian/changelog
create mode 100644 debian/compat
create mode 100644 debian/control
create mode 100644 debian/copyright
create mode 100755 debian/rules
create mode 100644 debian/xserver-xorg-video-armsoc-xilinx.docs
create mode 100644 debian/xserver-xorg-video-armsoc-xilinx.install
需要构建所需的软件包
为了构建 xserver-xorg-video-armsoc 的 Debian 软件包,需要安装以下软件包。请使用 apt install 进行安装。
-
drm-dev
libudev-dev
libxext-dev
pkg-config
x11proto-core-dev
x11proto-fonts-dev
x11proto-gl-dev
x11proto-xf86dri-dev
xutils-dev xserver-xorg-dev
quilt
dh-autoreconf
debhelper
生成 configure 和 Makefile
首先运行autogen.sh以生成configure和Makefile。然后必须运行make distclean以清除由autogen.sh生成的临时文件。
shell$ autogen.sh
:
中略
:
shell$ make distclean
:
後略
编译Debian软件包
运行debian/rule binary来构建xserver-xorg-video-armsoc-xilinx的Debian软件包。构建后的软件包将在上一级目录中生成。
shell$ sudo debian/rule binary
:
中略
:
shell$ dpkg --info ../xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb
new Debian package, version 2.0.
size 32924 bytes: control archive=856 bytes.
540 bytes, 12 lines control
611 bytes, 7 lines md5sums
Package: xserver-xorg-video-armsoc-xilinx
Source: xf86-video-armsoc-xilinx
Version: 1.4-1
Architecture: arm64
Maintainer: ikwzm <ichiro_k@ca2.so-net.ne.jp>
Installed-Size: 100
Depends: libc6 (>= 2.17), libdrm2 (>= 2.4.36), libpixman-1-0, xorg-video-abi-24, xserver-xorg-core (>= 2:1.18.99.901)
Provides: xorg-driver-video
Section: x11
Priority: optional
Homepage: <https://github.com/ikwzm/xf86-video-armsoc-xilinx>
Description: X.Org X Server -- ARM SoC display driver for rockchip, amlogic, sunxi and Xilinx(ZynqMP) DRM (mainline kernel)
安装
介绍Debian包
在这一节中,我们将解释如何将在前一章中构建的 xserver-xorg-video-armsoc-xilinx 的 Debian 包安装到 ZynqMP-FPGA-Linux 上。
另外,我们已经为Debian软件包构建了以下仓库。您可以安装这个仓库进行安装。
https://github.com/ikwzm/ZynqMP-FPGA-Xserver
xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb
请注意
这里的安装步骤是在不进行GPU(Mali-400)渲染的情况下。如果要进行GPU渲染,则需要安装libMali和Mali Kernel驱动程序,但这种情况下的安装步骤会变得复杂。请参考以下文章获取详细信息。
-
『Ultra96/Ultra96-V2 向け Debian GNU/Linux で X Window を動かす(LibMali編)』@Qiita
安装Debian软件包
首先,安装 X Window System。
shell$ apt install x-window-system-core
:
後略
接下来,我们将安装 xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb。
shell$ sudo dpkg -i xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb
[sudo] password for fpga:
(Reading database ... 66644 files and directories currently installed.)
Preparing to unpack xserver-xorg-video-armsoc-xilinx_1.4-1_arm64.deb ...
Unpacking xserver-xorg-video-armsoc-xilinx (1.4-1) over (1.4-1) ...
Setting up xserver-xorg-video-armsoc-xilinx (1.4-1) ...
Processing triggers for man-db (2.8.5-2) ...
我将安装您喜欢的窗口管理器。
shell$ apt install jwm
:
後略
xorg.conf 的配置
需要在 /etc/X11/xorg.conf 的设备部分的 Driver 属性中指定 armsoc。
Section "Device"
Identifier "ZynqMP"
Driver "armsoc"
Option "DEBUG" "true"
EndSection
Section "Screen"
Identifier "DefaultScreen"
Device "ZynqMP"
EndSection
运行
我会使用root登录并尝试使用startx来启动。
shell# startx &
:
後略
只要在显示屏上能够看到X Window,就代表成功了。