cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating an Acceleration Platform for Vitis Part Two: Creating the software project for the Acceleration Platform in PetaLinux

stephenm
Moderator
Moderator
1 3 3,529

This is the second blog entry in the Acceleration Platform series. Previously, we discussed how to create the hardware and how to pass the metadata to Vitis™ via the XSA.

In this entry we will discuss how to use this XSA and create the software images needed to accelerate your design on your target platform.

You can find the other entries at the links below:

Part One: Creating the hardware project for the Acceleration Platform in Vivado

Part Three: Packaging the Accelerated Platform in Vitis 

Part Four: Testing the Custom Acceleration Platform in Vitis 

Introduction:

Users familiar with OpenCL might be aware of the term "kernel", where a function executing in OpenCL is called a "kernel".

The same nomenclature is used in the Vitis acceleration flows. However, the Xilinx Runtime (XRT) API is used to execute the kernels.

The XRT is Linux based, and will run on the x86, or on the development boards (aarch64 or arm). The XRT is functionality independent from the architecture it is executing on, meaning it does not know if it is executing on an x86 or a development board (aarch64, or arm).

However, for the edge (aarch64, or arm) platforms we need to add the ZOCL driver. The ZOCL driver is used to allocate resources for each kernel. In this blog we will discuss how to add the XRT and ZOCL to a new or existing PetaLinux project.

Adding the XRT to the PetaLinux Project:

petalinux-create -t project --template zynqMP -n zcu104_base_sw
cd zcu104_base_sw
petalinux-config --get-hw-description=<path to XSA>
Select DTG Settings -> (zcu104-revc) MACHINE_NAME

Open the project-spec/meta-user/conf/user-rootfsconfig, and add the following:

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv
petalinux-config -c rootfs
Filesystem Package -> base -> [*] dnf
User Packages, and select all here

Now add the zocl driver node to the system-user.dtsi.

/include/ "system-conf.dtsi"
/{
};

&axi_intc_0 {
	xlnx,kind-of-intr = <0x0>;
	xlnx,num-intr-inputs = <0x20>;
};


&amba {	
	zyxclmm_drm {
		compatible = "xlnx,zocl";
		status = "okay";
		interrupt-parent = <&axi_intc_0>;
		interrupts = <0  4>, <1  4>, <2  4>, <3  4>,
			     <4  4>, <5  4>, <6  4>, <7  4>,
			     <8  4>, <9  4>, <10 4>, <11 4>,
			     <12 4>, <13 4>, <14 4>, <15 4>,
			     <16 4>, <17 4>, <18 4>, <19 4>,
			     <20 4>, <21 4>, <22 4>, <23 4>,
			     <24 4>, <25 4>, <26 4>, <27 4>,
			     <28 4>, <29 4>, <30 4>, <31 4>;
	};
};

Then run the following commands:

petalinux-build
cd images/linux
petalinux-build --sdk
petalinux-package --sysroot

Sanity Check:

Before we package our platform it is worth doing a sanity check to make sure that the XRT is added to the rootfs, and that the ZOCL has also been added.

We can do this by booting the Linux image on our board:

cd images/linux
petalinux-package --boot --fpga --u-boot

Place the following files onto the boot device, and then boot

  • image.ub
  • BOOT.BIN
  • boot.scr
Verify the XRT library:

Do a grep on the XRT lib in the /usr/lib directory:

ls /usr/lib | grep libxrt_core

xrt_core.PNG

 
 

Repeat for libxilinxopencl:

ls /usr/lib | grep libxilinxopencl

ocl.PNG

Verify the ZOCL DT node:

List all of the nodes under amba

ls /sys/devices/platform/amba

stephenm_2-1597657313581.png

And that's it.

We now have a Linux image with XRT support enabled for our development board. We have also generated the sysroot that is needed in Vitis for cross compilation.

If you plan on a series of custom platforms for the same architecture, then you only need to create the one sysroot per version (for example, 2020.1).

For the next steps, see part three of this series: Packaging the Accelerated Platform in Vitis 

3 Comments
doonny
Adventurer
Adventurer

Hi @stephenm very helpful blog !

I have learned how to create a custom platform by referring your instructions.  But I still one question about the configurable user libs.  There are a lot libs that can be added to the rootfs, some I already know includes:

##XRT driver

CONFIG_packagegroup-petalinux-xrt

CONFIG_xrt-dev

## file orgnization

CONFIG_dnf

CONFIG_e2fsprogs-resize2fs

CONFIG_parted

##Vitis-AI

CONFIG_packagegroup-petalinux-vitisai

CONFIG_packagegroup-petalinux-self-hosted

## Gcc and Opencl headers

CONFIG_cmake

CONFIG_packagegroup-petalinux-vitisai-dev

CONFIG_opencl-clhpp-dev

CONFIG_opencl-headers-dev

CONFIG_packagegroup-petalinux-opencv

CONFIG_packagegroup-petalinux-opencv-dev

##GUI support

CONFIG_mesa-megadriver

CONFIG_packagegroup-petalinux-x11

CONFIG_packagegroup-petalinux-v4lutils

CONFIG_packagegroup-petalinux-matchbox

My question is that where can I find the complete list of the available libs /software packages in petalinux that can be added to rootfs ?

 

stephenm
Moderator
Moderator

@doonny Im glad the blog helped here.

Petalinux uses Yocto which uses the Openembedded metalayer

https://layers.openembedded.org/layerindex/branch/master/layer/meta-oe/

You can see UG1144 on how to add packages, for example

From 2020.1 release onwards, you have to use the <plnx-proj-root>/project-spec/
meta-user/conf/user_rootfsconfig file to append new root file system packages to
PetaLinux images. For example:
CONFIG_opencv

 

You can also add custom layers too. This is also covered in the UG1144

 

chepner
Contributor
Contributor

Hello @stephenm ,

I have a zcu102 board and using yocto to generate my custom Linux image. I used zcu102 platform xsa file shared by Xilinx [Link]

I've added the zocl driver node to the system-user.dtsi as you suggested. I can see that it exist in my device tree dts file under amba but when I load my Linux image on Board I cannot see the amba:zyxclmm_drm under /sys/devices/platform/amba/

Else, I can see that the kernel module is inserted successfully :

chepner_0-1612884570451.png

Do you have any suggestion what it can be the issue ?

I'm using the zocl XRT branch 2020.2

Thanks