Creating the Ulra96v2 platform in the Xilinx Vitis 2020.2 has five steps:

  1. XSA design – Generating a Vivado project containing the underlying hardware (the hardware platform)
  2. Linux OS – Generating a PetaLinux project to configure Linux
  3. Prepare SDCARD and Test Linux
  4. Create Vitis Platform – Using Xilinx Vitis to generate the Platform
  5. Test– Create a simple application to test the generated platform

In the sequel, I am trying to briefly explain each step. I have installed Xilinx Vitis and Petalinux 2020.2 under the Ubuntu 20.04 OS . Note that, the Xilinx Vitis software includes Vivado, so you do not need to install that separately.

To make Vivado detects the board, copy the Avnet ultra96v2 board definition files (at here) to the <Vivado installation folder>/data/boards/board_files. You can also copy the files into <Vitis installation folder>/data/boards/board_files

1- XSA design

1- create a directory called ultra96v2-vitis-pkg

mkdir ultra96v2-vitis-pkg
cd ultra96v2-vitis-pkg/

2- create a directory called vivado

mkdir vivado 
cd vivado

3- Run Vivado and create a project called ultra96v2-xsa in the ultra96v2-vitis-pkg/vivado folder. Figures 1-6 show the flow of the project creation.

Figure 2
Figure 3
Figure 4

4- In the Vivado project, create a block design with the name of ultra96v2. It is better to choose our platform name here..

Figure 7

5- Add a Zynq UltraScale+ MPSoC IP into the Diagram view

Figure 8

6- Click on “Run Block Automation” and make sure “Apply Board Reset” is selected.

Figure 9

7- Double click on the Zynq IP and configure that as Figure 10

Figure 10

8- Add a Clocking Wizard IP to the design.

9- Double click on the added IP and configure that as Figure 12. Add four output clocks with different output frequencies, and make sure that the reset type is “Active Low”.

Figure 12

10- Add four Processor System Reset IPs corresponding to the four output clocks.

11- Add connections as Figure 14.

Figure 14

12- Add an AXI interrupt controller IP

Figure 15

14- Connect maxihpm0_lpd_aclk to the 100 MHz clock of Clocking Wizard IP.

16- Now, we should declare the platform (PFM) interface and properties. For this purpose, select “Platform Interfaces” option from the “Window” menu in the Vivado IDE. (Window–>Platform Interfaces).

17- Click on “Enable platform interfaces” if this the first time you select the Platform Interfaces option in the project.

18- Right-click on each port in the following list and select Enable

24- Press the right-click in Diagram view and in the popup menu select Validate Design.25- Press the right-click on the “ultra96v2_design (ultra96v2_design.bd)” option in the source view panel. And from the popup menu select “Generate Output Products…”.

26- Select the Generate button and wait for the process to finish.

27- Again, press the right-click on the “ultra96v2_design (ultra96v2_design.bd)” option in the source view panel. And from the popup menu select “Create HDL Wrapper… ” and select the “Let Viviado manage wrapper and auto-update” option in the dialog box.

28- Then under the PROGRAM AND DEBUG option in the left-hand side panel, select “Generate Bitstream” and wait until the end of the process.

29- After generating the bitstream, go to the TCL Console view and make sure you are in the right folder. you can use pwd command to check the folder. Go to “ultra96v2-vitis-pkg/vivado” that you have created. and run the following TCL command to generate the XSA file

2- Linux OS

1- Go to the “ultra96v2-vitis-pkg” folder generated in the first step (i.e., 1-XSA design) and run the following commands

mkdir linux_files
mkdir  linux_files/boot

2- Run the setting.sh file located at the PetaLinux installation folder by running this command

source /tools/Xilinx/petaliux/2020.1/settings.sh

3- In the “ultra96v2-vitis-pkg” folder create a PetaLinux project

petalinux-create -t project --template zynqMP -n ultra96v2-petalinux

4- Go to the generated project folder and configure the project

cd ultra96v2-petalinux
petalinux-config --get-hw-description=../vivado/ultra96v2-xsa

5- In the “misc/config System Configuration” window, go to “Subsystem AUTO Hardware Settings–>Serial Setting” and change all the “psu_uart_0” to “psu_uart_1” and back to the main menu.

6- select DTG Settings->MACHINE_NAME, modify it to avnet-ultra96-rev1

7- Under the “Image Packaging Configuration” option, change the “Root filesystem type” to “EXT4 (SD/eMMC/SATA/USB)”

8- Save and exit the configuration window.

9- The next step is kernel configuration using the following command

petalinux-config -c kernel

10- In the “Linux/arm64 4.19.0 Kernel Configuration” window, go to “Library routines->Size in Mega bytes” and change 256 to 1024

11- Turn off “CPU Power Mangement –> CPU Idle –> CPU idle PM support” and “CPU Power Management –> CPU Frequency scaling –> CPU Frequency scaling”

12- Save and exit the kernel configuration window

13- Open the “./project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi” file and modify that as follows.

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

&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>;
	};
};

&axi_intc_0 {
      xlnx,kind-of-intr = <0x0>;
      xlnx,num-intr-inputs = <0x20>;
      interrupt-parent = <&gic>;
      interrupts = <0 89 4>;
};

15- Edit the file “./project-spec/meta-user/conf/user-rootfsconfig” and add the following lines

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv

16- Configure the Linux rootfs by running the following command

petalinux-config -c rootfs

17- Go to the “user packages” menu and select the following packages

opencl-hpp-dev
opencl-headers-dev
packagegroup-petalinux-opencv
xrt
xrt-dev
zocl

18- Then build the peralinux project by running this command.

petalinux-build

19- The go to images/linux folder

cd images/linux

and run this command

petalinux-build --sdk

20- Then run the ./sdk.sh command and enter the full path of the linux_files folder that you created in the first phase.

21- Copy the following files from the image/linux folder into the linux_files/boot folder that you created in the first phase.

image.ub
zynqmp_fsbl.elf
pmufw.elf
bl31.elf
u-boot.elf
rootfs.cpio

22- In the linux_files/boot folder create the linux.bif file containing the following lines

the_ROM_image:
{
  [bootloader] <ultra96v2_base/boot/fsbl.elf>
  [pmufw_image] <ultra96v2_base/boot/pmufw.elf>
  [destination_device=pl] <bitstream>
  [destination_cpu=a53-0, exception_level=el-3, trustzone] <ultra96v2_base/boot/bl31.elf>
  [destination_cpu=a53-0, exception_level=el-2] <ultra96v2_base/boot/u-boot.elf>
}




3- Prepare SDCARD and Test Linux

1- Insert the sdcard in the host computer USB port (or a VirtualBox with Ubuntu) .

2- Run GParted program to perform the sdcard partitioning. Select the sdcard (e.g., /dev/sdc)

3- Create a new partion with

size=2048MB 
filesystem:fat32
Label: BOOT
Create as: Primary Partition

4- Assign the rest of the space on the sdcard to a new partition with

size = <the rest of spapce>
filesystem:ext4
Label: rootfs
Create as: Primary Partition

5- Apply all operations and then the sdcard with two partitions is ready.

Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits

6- cd <petalinux project folder>/images/linux/

7- Run this command to generate to files: BOOT.BIN and boot.scr.

petalinux-package --boot --format BIN --fsbl zynqmp_fsbl.elf --u-boot u-boot.elf --pmufw pmufw.elf --fpga system.bit --force

3- copy three files (BOOT.BIN, boot.scr, and image.ub) into the sdcard BOOT parttion

cp BOOT.BIN boot.scr image.ub /media/numvar/BOOT/

4- write the rootfs files into the sdcard rootfs partition

sudo tar -zxvf rootfs.tar.gz -C /media/numvar/rootfs/

5- Run the command sync and wait to finish.

6- Use a program that provides a serial terminal such as putty or “Tera Term” and connect to the board serial USB connection.

7- Then, unmount the SDCard and insert that to the Ultra96v2 board and turn on the board. You should see the login prompt in the serial terminal.

4– Create Platform

1- Create a folder named pfm in the ultra96v2-vitis-pkg folder that you created in the first step.

cd pfm

To create the ultra96v2 platform for Vitis. First, run the Vitis IDE and choose the pfm folder (that you created in the first step) as the workspace.

2- Create a new platform project by selecting “File–>New–>Platform Project…”. Choose “ultra96v2” as the project name and accept the default folder.

3- In the next window select the XSA option and press Next

4- Click on Browse … button and locate the ultra96v2.xsa file generated in the first step by Vivado, and then select the Linux as Operating System and click Finish button.

5- Clock the Welcome window if it is open. Select “Linux on psu_cortexa53” and configure the Linux domain as the following figure.

6- Press the right-click on the project name on the left panel and select Build Project.

Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits

5- Test the Platform

1- In the Vitis IDE, select “File–>New–>Application Project…” to create a new application.

2- Select vector_add as the Project name

4- Press the Next button in the next window.

5- Select the Vector Addition as the template and press Finish button.

6- Select Hardware as the active build configuration from the menu on the right.

7- Build the project by pressing the right-click on the project name and selecting the Build project option.

8- Copy the content of the sd_card folder generated by the application project under the into an SD-CARD and boot the Ultra96v2 board. Notice that you need to copy at least five files: binary_container_1.xclbin, BOOT.BIN, image.ub, vector_add and boot.scr. If you cannot find the boot.csr here, use the one that has been generated earlier during testing our Linux OS.

9- Using putty open a serial terminal with the following configuration

10- Boot the Ultra96v2 board with the SDCard and login to the board by using root as both username and password. Then go to /run/mnt/sd-mmcblk0p1 folder

11- Run the following commands to define the Xilinx XRT library

export XILINX_XRT=/usr

12- Run the application by running this command

./vector_add.exe binary_container_1.xclbin

Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits

2 thoughts on “How to create Ultra96v2 Linux-based Platform in Xilinx Vitis 2020.2”
  1. […] 準備が出来たらいよいよVivado ML v2022.2(以下、Vivado)でZynq UltraScale+内部のハード構成を作り、Vitis用にハードウェアプラットフォームとビットストリームを生成します。 2022.2版での参考出来るサイトが見つからず、いくつか試しましたが、.bifファイルのサンプルや、デバイスツリーでの割込の記述などあり、一番成功に近かったMohammadさん(Udemyにも投稿しています)の2020.2を参考にしています。 その為クロックが6個になっています。 しかし2022.2版はvaddのソースも変更されており、自分で変更しなければならないところもあり、2022.2版として備忘録を残しています。 […]

Leave a Reply to 組込みLinux Ultra96v2 でVitisやってみる その4 PetaLinux 2022.2 Linuxビルド | いちりのテクの部屋Cancel reply

Discover more from High-Level Synthesis & Embedded Systems

Subscribe now to keep reading and get access to the full archive.

Continue reading