Xilinx ZYNQ UltraScale+ MPSoC - Xilinx Kria - Enable the VCU on Ubuntu 2022.4

From RidgeRun Developer Wiki





Previous: Xilinx Kria Index Next: Development/Petalinux





Introduction

The Xilinx Kria does not have the VCU in their default design in Ubuntu 2022.4. Moreover, it does not have GStreamer installed either, so it is not possible to perform encoding or decoding.

To cover this part, there are two main steps to follow:

  • Install the Xilinx packages for encoding/decoding, including GStreamer for easiness.
  • Add an application overlay to connect the VCU to the ARM microprocessor.

We are going to assume you are using Ubuntu 2022.4. If you are interested in installing this version, please, check this wiki.

Adding the PPA Repositories

AMD/Xilinx provides packages for installing a custom version of GStreamer, OpenMAX, V4L2 and others. The repositories to add these packages can be added by using:

sudo add-apt-repository ppa:ubuntu-xilinx/updates
sudo add-apt-repository ppa:xilinx-apps/ppa
sudo apt update
Do not install the GStreamer offered by Ubuntu since it does not have the proper patches from Xilinx

Installing V4L2, LIBDRM and GStreamer

AMD/Xilinx provides patched or custom versions of the Video 4 Linux framework, GStreamer, and OpenMAX. They are required for proper multimedia interaction with the hard-cores from the Kria System on Module (SoM).

You can install these custom versions by using:

sudo apt install gstreamer-xilinx1.0-plugins-base gstreamer-xilinx1.0-tools gstreamer-xilinx1.0-omx-zynqmp gstreamer-xilinx1.0-plugins-bad gstreamer-xilinx1.0-plugins-good

You will notice that most of the packages required for the encoder will be installed. Some of them are:

  • libdrm-xlnx-common
  • libdrm2-xlnx
  • libv4l-0-xlnx
  • libv4lconvert0-xlnx

As you may notice, they have the -xlnx suffix to indicate that they come from the PPAs added above.

Installing the Kria Demo with VCU

The Xilinx Kria has come to innovate in the way how we use the FPGA in the FPGA-based SoC. The predominant workflow is based on Vitis, which is a framework that allows the use of the FPGA by compiling an OpenCL-like kernel that can be mounted at runtime. Precisely, this adds flexibility to the users to configure the FPGA without restarting the entire system, making the experience more "interactive".

For the case of the VCU, it is contained in the SmartCam demo application, which is installable through:

sudo apt install xlnx-firmware-kv260-smartcam

You can verify if it has been installed by using the command:

sudo xmutil listapps

and the kv260-smartcam should be shown as an accelerator.

Testing

For testing the VCU, we are going to use GStreamer because of usability reasons. Before trying to execute GStreamer with encoding/decoding, it is important to load the accelerator. The process is described below.

1. Unload any default accelerator

sudo xmutil unloadapp

2. Load the demo application installed above

sudo xmutil loadapp kv260-smartcam

it should give error 0:

kv260-smartcam: loaded to slot 0

At this point, the VCU is connected to the ARM.

Encoding

You can test the encoder by using the following pipeline:

sudo gst-launch-1.0 -v videotestsrc is-live=true num-buffers=200 ! "video/x-raw,format=NV12" ! omxh264enc ! h264parse ! mpegtsmux ! filesink location=test.ts -v

Notice that GStreamer is executed using sudo. The reason is merely API permissions.

Decoding

For decoding, you can use the decodebin element, which will take the OpenMAX decoder which utilises the VCU.

sudo gst-launch-1.0 -v filesrc location=test.ts ! decodebin ! fakesink silent=false -v

Notice that GStreamer is executed using sudo. The reason is merely API permissions.


Previous: Xilinx Kria Index Next: Development/Petalinux