This article was posted when I was trying to get XRT (Xilinx Runtime) to work on Debian GNU / Linux for Ultra96 / Ultra96-V2, and it contains old content. Please refer to the following article posted on March 26, 2020.
XRT (Xilinx Runtime) is an environment for running programs developed in the development environment (Vitis) provided by Xilinx on the platform. XRT is implemented as a combination of userspace and kernel driver components. The source code of XRT is available on github.
The figure below shows the XRT software stack (quoted from the github repository above).
Fig.1 XRT Software Stack
I have built and provided Debian GNU / Linux as an UltraZed / Ultra96 / Ultra96-V2 platform on github.
XRT is based on Petalinux provided by Xilinx, but I would like to run it on Debian GNU / Linux provided by ZynqMP-FPGA-Linux.
This article will walk you through building XRT from source code and creating Debian packages.
The pre-built Debian Package is available on github. It is difficult to build the environment to build, and it takes 1 to 2 hours to build, so if you have trouble, please download it from here.
https://github.com/ikwzm/ZynqMP-FPGA-XRT
Also, refer to the following article for installation.
__ At the moment (March 23, 2020), I can install it, but it is not working yet. This article is just a trial defense record. __
Building XRT for UltraZed / Ultra96 / Ultra96-V2 is a bit tedious. A Linux distribution such as Ubuntu or CentOS is required to build XRT. Various development tools must be installed in the build. Furthermore, it is very troublesome to cross-compile for ARM64 with a PC as a host, probably to make a Debian Package.
So I run Ubuntu 18.04 on Ultra96-V2 and self-build on it.
Ubuntu 18.04 for Ultra96-V2 is available at the following URL:
Download the XRT source code from the following URL.
fpga@ubuntu-fpga:~$ cd work
fpga@ubuntu-fpga:~/work$ git clone https://github.com/Xilinx/XRT
Cloning into 'XRT'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 43591 (delta 13), reused 7 (delta 0), pack-reused 43561
Receiving objects: 100% (43591/43591), 58.10 MiB | 2.57 MiB/s, done.
Resolving deltas: 100% (33849/33849), done.
Checking out files: 100% (1682/1682), done.
fpga@ubuntu-fpga:~/work$ cd XRT
fpga@ubuntu-fpga:~/work/XRT$
Modify some files to build XRT for Ultra96 / Ultra96-V2. So it's better to fork than to clone https://github.com/Xilinx/XRT directly.
We'll make some modifications to the XRT build file, so create a branch.
fpga@ubuntu-fpga:~/work/XRT$ git checkout -b 2019.2_Ultra96
Switched to a new branch '2019.2_Ultra96'
In the original XRT, the Debian Package you built would be named xrt_202010.2.6.0_18.04-arm64-xrt.deb, but to make it clear that it is a package for Ubuntu xrt_202010.2.6.0_Ubuntu_18.04- Make it arm64-xrt.deb.
fpga@ubuntu-fpga:~/work/XRT$ git diff src/CMake/cpackLin.cmake
diff --git a/src/CMake/cpackLin.cmake b/src/CMake/cpackLin.cmake
index 4f45f97a..9f6eebe4 100644
--- a/src/CMake/cpackLin.cmake
+++ b/src/CMake/cpackLin.cmake
@@ -79,7 +79,7 @@ else ()
SET (CPACK_GENERATOR "TGZ")
endif()
-SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${XRT_VERSION_RELEASE}.${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_${CPACK_REL_VER}-${CPACK_ARCH}")
+SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${XRT_VERSION_RELEASE}.${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_${LINUX_FLAVOR}_${CPACK_REL_VER}-${CPACK_ARCH}")
message("-- ${CMAKE_BUILD_TYPE} ${PACKAGE_KIND} package")
fpga@ubuntu-fpga:~/work/XRT$ git add src/CMake/cpackLin.cmake
fpga@ubuntu-fpga:~/work/XRT$ git commit -m "[add] linux flavor name to built debian package name"
[2019.2_Ultra96 f6d3236b] [add] linux flavor name to built debian package name
1 file changed, 1 insertion(+), 1 deletion(-)
Originally, the Package on which the Debian Package you built depends is set in src / CMake / cpackLin.cmake as follows:
src/CMake/cpackLin.cmake
SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0),
libboost-dev (>= ${Boost_VER_STR}), libboost-dev (<< ${Boost_VER_STR_ONEGREATER}),
libboost-filesystem-dev (>=${Boost_VER_STR}), libboost-filesystem-dev (<<${Boost_VER_STR_ONEGREATER}),
uuid-dev (>= 2.27.1), dkms (>= 2.2.0), libprotoc-dev (>=2.6.1), libssl-dev (>=1.0.2), protobuf-compiler (>=2.6.1),
libncurses5-dev (>=6.0), lsb-release, libxml2-dev (>=2.9.1), libyaml-dev (>= 0.1.6),
libc6 (>= ${GLIBC_VERSION}), libc6 (<< ${GLIBC_VERSION_ONEGREATER}),
python (>= 2.7), python-pip, libudev-dev ")
There is an upper limit on the versions of libboost-dev, libboost-filesystem-dev, and libc6 that the Debian Package you build depends on. If this is the case, the distribution to be installed may be too restrictive and the installation may fail. For example, trying to install this Debian Package on Debian 10 will fail.
So, which may be a problem later, modify cpackLin.cmake to remove the version limit as follows:
fpga@ubuntu-fpga:~/work/XRT$ git diff src/CMake/cpackLin.cmake
--- a/src/CMake/cpackLin.cmake
+++ b/src/CMake/cpackLin.cmake
@@ -49,7 +49,7 @@ if (${LINUX_FLAVOR} MATCHES "^(Ubuntu|Debian)")
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "OFF")
SET(CPACK_DEBIAN_AWS_PACKAGE_DEPENDS "xrt (>= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH})")
SET(CPACK_DEBIAN_XBTEST_PACKAGE_DEPENDS "xrt (>= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}), libjson-glib-dev")
- SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0), libboost-dev (>= ${Boost_VER_STR}), libboost-dev (<< ${Boost_VER_STR_ONEGREATER}), libboost-filesystem-dev (>=${Boost_VER_STR}), libboost-filesystem-dev (<<${Boost_VER_STR_ONEGREATER}), uuid-dev (>= 2.27.1), dkms (>= 2.2.0), libprotoc-dev (>=2.6.1), libssl-dev (>=1.0.2), protobuf-compiler (>=2.6.1), libncurses5-dev (>=6.0), lsb-release, libxml2-dev (>=2.9.1), libyaml-dev (>= 0.1.6), libc6 (>= ${GLIBC_VERSION}), libc6 (<< ${GLIBC_VERSION_ONEGREATER}), python (>= 2.7), python-pip, libudev-dev ")
+ SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0), libboost-dev (>= ${Boost_VER_STR}), libboost-filesystem-dev (>=${Boost_VER_STR}), uuid-dev (>= 2.27.1), dkms (>= 2.2.0), libprotoc-dev (>=2.6.1), libssl-dev (>=1.0.2), protobuf-compiler (>=2.6.1), libncurses5-dev (>=6.0), lsb-release, libxml2-dev (>=2.9.1), libyaml-dev (>= 0.1.6), libc6 (>= ${GLIBC_VERSION}), python (>= 2.7), python-pip, libudev-dev ")
elseif (${LINUX_FLAVOR} MATCHES "^(RedHat|CentOS|Amazon)")
execute_process(
fpga@ubuntu-fpga:~/work/XRT$ git add src/CMake/cpackLin.cmake
fpga@ubuntu-fpga:~/work/XRT$ git commit -m "[remove] upper limit of version of depend packages"
[2019.2_Ultra96 b69d97cd] [remove] upper limit of version of depend packages
1 file changed, 1 insertion(+), 1 deletion(-)
Install the packages required for the build. Fortunately, XRT provides a script that installs the packages needed for the build.
If you run ./src/runtime_src/tools/scripts/xrtdeps.sh with super user privileges, the apt program will install the missing Debian Package.
fpga@ubuntu-fpga:~/work/XRT$ sudo ./src/runtime_src/tools/scripts/xrtdeps.sh
Installing packages...
Reading package lists... Done
Building dependency tree
Reading state information... Done
:
(Omission)
:
The following packages were automatically installed and are no longer required:
libgl2ps1.4 libibverbs1 liblept5 libnetcdf-c++4 libnl-route-3-200
libopencv-flann-dev libopencv-flann3.2 libopencv-ml-dev libopencv-ml3.2
libopencv-photo-dev libopencv-photo3.2 libopencv-shape-dev
libopencv-shape3.2 libopencv-ts-dev libopencv-video-dev libopencv-video3.2
libtcl8.6 libtesseract4 libtk8.6 libxss1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
Go to the build directory and run build.sh there to start the build. Ultra96 / Ultra96-V2 takes a lot of time. It took about 1-2 hours in my environment.
fpga@ubuntu-fpga:~/work/XRT$ cd build/
fpga@ubuntu-fpga:~/work/XRT/build$ ./build.sh
cmake -DRDI_CCACHE=0 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_TOOLCHAIN_FILE= ../../src
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/gcc-8
-- Check for working C compiler: /usr/bin/gcc-8 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-8
-- Check for working CXX compiler: /usr/bin/g++-8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Host system processor is aarch64
-- Target system processor is aarch64
:
(Omission)
:
fpga@ubuntu-fpga:~/work/XRT/build$
When the build is finished, you will have a Debian Package under the build / Release directory.
fpga@ubuntu-fpga:~/work/XRT$ cd build/
fpga@ubuntu-fpga:~/work/XRT/build$ ls -1 Release/xrt_*
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-aws.deb
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-aws.tar.gz
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-azure.deb
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-azure.tar.gz
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-container.deb
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-container.tar.gz
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-xbtest.deb
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-xbtest.tar.gz
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-xrt.deb
Release/xrt_202010.2.6.0_Ubuntu_18.04-arm64-xrt.tar.gz
Of these, the Debian Package required for Ultra96 / Ultra96-V2 is Release / xrt_202010.2.6.0_Ubuntu_18.04-arm64-xrt.deb.
Xrt_202010.2.6.0_Ubuntu_18.04-arm64-xrt.deb built in the previous chapter does not include zocl (see Fig.1 XRT Software Stack for zocl). zocl is a Linux kernel module for Edge Devices such as Ultra96 / Ultra96-V2.
So this chapter describes how to build zocl's Debian Package. Here we will build using dkms.
First, create a directory called zocl-2.6.0 under / usr / src /. zocl is the name of the kernel module and 2.6.0 is the XRT version number.
fpga@ubuntu-fpga:~/work/XRT$ sudo mkdir /usr/src/zocl-2.6.0
fpga@ubuntu-fpga:~/work/XRT$ sudo chmod o+w /usr/src/zocl-2.6.0
The source code for zocl can be found in XRT's src / runtime_src / core / edge / drm / zocl. You also need some header files in other directories. Copy these files to the directory prepared in the previous section.
fpga@ubuntu-fpga:~/work/XRT$ mkdir /usr/src/zocl-2.6.0/src
fpga@ubuntu-fpga:~/work/XRT$ mkdir /usr/src/zocl-2.6.0/src/edge
fpga@ubuntu-fpga:~/work/XRT$ mkdir /usr/src/zocl-2.6.0/src/edge/drm
fpga@ubuntu-fpga:~/work/XRT$ cp -r src/runtime_src/core/edge/drm/zocl /usr/src/zocl-2.6.0/src/edge/drm
fpga@ubuntu-fpga:~/work/XRT$ cp -r src/runtime_src/core/include/ /usr/src/zocl-2.6.0/src
fpga@ubuntu-fpga:~/work/XRT$ cp -r src/runtime_src/core/edge/include /usr/src/zocl-2.6.0/src/edge/
fpga@ubuntu-fpga:~/work/XRT$ cp src/runtime_src/core/common/drv/xrt_drv.h /usr/src/zocl-2.6.0/src/edge/drm/zocl
fpga@ubuntu-fpga:~/work/XRT$ cp LICENSE /usr/src/zocl-2.6.0/
The following tools must be installed to build.
Create /usr/src/zocl-2.6.0/dkms.conf as follows:
Makefile:/usr/src/zocl-2.6.0/dkms.conf
PACKAGE_NAME="zocl-dkms"
PACKAGE_VERSION="2.6.0"
MAKE="make -C src/edge/drm/zocl/ KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make -C src/edge/drm/zocl/ clean"
BUILT_MODULE_NAME="zocl"
BUILT_MODULE_LOCATION="src/edge/drm/zocl/"
DEST_MODULE_LOCATION="/updates"
Add zocl-2.6.0 to dkms.
fpga@ubuntu-fpga:/usr/src/zocl-2.6.0$ sudo dkms add -m zocl -v 2.6.0
Creating symlink /var/lib/dkms/zocl/2.6.0/source ->
/usr/src/zocl-2.6.0
DKMS: add completed.
Try building the kernel module with dkms and see if it succeeds.
fpga@ubuntu-fpga:/usr/src/zocl-2.6.0$ sudo dkms build -m zocl -v 2.6.0
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j4 KERNELRELEASE=4.19.0-xlnx-v2019.2-zynqmp-fpga -C src/edge/drm/zocl/ KERNELDIR=/lib/modules/4.19.0-xlnx-v2019.2-zynqmp-fpga/build.......
cleaning build area...
DKMS: build completed.
fpga@ubuntu-fpga:/usr/src/zocl-2.6.0$ sudo dkms mkdsc -m zocl -v 2.6.0 --source-only
Using /etc/dkms/template-dkms-mkdsc
copying template...
modifying debian/changelog...
modifying debian/compat...
modifying debian/control...
modifying debian/copyright...
modifying debian/dirs...
modifying debian/postinst...
modifying debian/prerm...
modifying debian/README.Debian...
modifying debian/rules...
copying legacy postinstall template...
Copying source tree...
Building source package... dpkg-source --before-build zocl-dkms-2.6.0
debian/rules clean
dh_clean: Compatibility levels before 9 are deprecated (level 7 in use)
dpkg-source -b zocl-dkms-2.6.0
dpkg-source: warning: no source format specified in debian/source/format, see dpkg-source(1)
dpkg-genbuildinfo --build=source
dpkg-genchanges --build=source >../zocl-dkms_2.6.0_source.changes
dpkg-genchanges: info: including full source code in upload
dpkg-source --after-build zocl-dkms-2.6.0
DKMS: mkdsc completed.
Moving built files to /var/lib/dkms/zocl/2.6.0/dsc...
Cleaning up temporary files...
The Debian Package you built here is located at /var/lib/dkms/zocl/2.6.0/dsc.
fpga@ubuntu-fpga:/usr/src/zocl-2.6.0$ sudo dkms mkdeb -m zocl -v 2.6.0 --source-only
Using /etc/dkms/template-dkms-mkdeb
copying template...
modifying debian/changelog...
modifying debian/compat...
modifying debian/control...
modifying debian/copyright...
modifying debian/dirs...
modifying debian/postinst...
modifying debian/prerm...
modifying debian/README.Debian...
modifying debian/rules...
copying legacy postinstall template...
Copying source tree...
Building binary package...dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-source --before-build zocl-dkms-2.6.0
fakeroot debian/rules clean
dh_clean: Compatibility levels before 9 are deprecated (level 7 in use)
debian/rules build
fakeroot debian/rules binary
dh_installdirs: Compatibility levels before 9 are deprecated (level 7 in use)
dh_strip: Compatibility levels before 9 are deprecated (level 7 in use)
dh_compress: Compatibility levels before 9 are deprecated (level 7 in use)
dh_installdeb: Compatibility levels before 9 are deprecated (level 7 in use)
dh_shlibdeps: Compatibility levels before 9 are deprecated (level 7 in use)
dpkg-genbuildinfo --build=binary
dpkg-genchanges --build=binary >../zocl-dkms_2.6.0_arm64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
dpkg-source --after-build zocl-dkms-2.6.0
DKMS: mkdeb completed.
Moving built files to /var/lib/dkms/zocl/2.6.0/deb...
Cleaning up temporary files...
The Debian Package you built here is located at /var/lib/dkms/zocl/2.6.0/deb.
Copy the Debian Package built in the previous section.
fpga@ubuntu-fpga:/usr/src/zocl-2.6.0$ cd ~/work/XRT/build
fpga@ubuntu-fpga:~/work/XRT/build$ cp /var/lib/dkms/zocl/2.6.0/deb/* .
fpga@ubuntu-fpga:~/work/XRT/build$ cp /var/lib/dkms/zocl/2.6.0/dsc/* .
In order to install the built Debian Package, you need to remove zocl from dkms once so that it does not conflict with the Debian Package.
fpga@ubuntu-fpga:~/work/XRT/build$ sudo rm -r /var/lib/dkms/zocl/
["Running XRT (Xilinx Runtime) on Debian GNU / Linux for Ultra96 / Ultra96-V2 (Overview)" @Qiita]: https://qiita.com/ikwzm/items/0d3a8adfe725cd17f932 "For Ultra96 / Ultra96-V2 Running XRT (Xilinx Runtime) on Debian GNU / Linux (Overview) "@Qiita" ["Running XRT (Xilinx Runtime) on Debian GNU / Linux for Ultra96 / Ultra96-V2 (Build)" @Qiita]: https://qiita.com/ikwzm/items/d8013ea91125a3fc46aa "For Ultra96 / Ultra96-V2 Running XRT (Xilinx Runtime) on Debian GNU / Linux (Build) "@Qiita" ["Running XRT (Xilinx Runtime) on Debian GNU / Linux for Ultra96 / Ultra96-V2 (Installation)" @Qiita]: https://qiita.com/ikwzm/items/6612eacc4a0d324a0a68 "For Ultra96 / Ultra96-V2 Running XRT (Xilinx Runtime) on Debian GNU / Linux (Installation) "@Qiita"
Recommended Posts