I recently decided to reinstall my Linux VM and re-step my FPGA development environment after saying yes to an update in Ubuntu that I shouldn't have (see my video about it here). I also decided this would be a good time to start updating my projects to the latest version of Vivado/Vitis/PetaLinux, which at the time I am writing this is version 2021.2. After the initial installation, I started experimenting with rebuilding projects for some of my choice FPGA boards and found some key differences in the project flow of a select few, in particular the new Kria KV260 Vision AI Starter Kit.
Upgrade PetaLinux to Add Vitis AI LayerPetaLinux version 2021.2 still requires a manual upgrade to add the Vitis AI layer to it (the same as 2021.1). I believe this should no longer be the case starting with version 2021.3 whenever it is released.
Change directories into the PetaLinux installation directory and source PetaLinux tools in your environment:
~$ cd /tools/Xilinx/PetaLinux/2021.2/
~$ source ./settings.sh
Then run the upgrade:
~$ petalinux-upgrade -u http://petalinux.xilinx.com/sswreleases/rel-v2021/sdkupdate/2021.2/ -p "aarch64" --wget-args "--wait 1 -nH --cut-dirs=4"
It is import to note that I only specified the aarch64 platform for the Zynq UltraScale platform. If you want to use the Vitis AI layer in projects targeting the Zynq-7000 or MicroBlaze, you'll also need to specify those platforms:
~$ petalinux-upgrade -u http://petalinux.xilinx.com/sswreleases/rel-v2021/sdkupdate/2021.2/ -p "aarch64 arm mb-full mb-lite" --wget-args "--wait 1 -nH --cut-dirs=4"
The --wget-args option is also important to pass to the petalinux-upgrade command. This option is how PetaLinux tunnels flags specific to wget as it is running under the hood of PetaLinux. Since the updates from the PetaLinux remote server is 4 directories deep into it, we have to tell wget to ignore those top 4 directories of /sswreleases/rel-v2021/sdkupdate/2021.2/ and the overall host directory of petalinux.xilinx.com which is what "-nH --cut-dirs=4" is doing. The wait option is spacing out the requests to the remote server by one second to lighten the load and avoid the download failing if retries are required in connecting.
Download the BSP for the Kria KV260 Vision AI kit here:
I recommend saving it to an easy to remember/access file path for future reference.
Create PetaLinux ProjectChange directories into the desired path you want the PetaLinux project to be generated in and create a new PetaLinux project using the BSP:
~$ petalinux-create -t project -s /<path to>/xilinx-k26-som-v2021.2-final.bsp
You can name the PetaLinux project whatever you like using the --name or -n option like this:
~$ petalinux-create -t project -s /<path to>/xilinx-k26-som-v2021.2-final.bsp -n linux_os
Otherwise PetaLinux will just name the project xilinx-k26-som-v2021.2. PetaLinux will create a new directory within the current directory to generate the project files into. After the project as been generated, change directories into it:
~$ cd ./xilinx-k26-som-v2021.2
ConfigureThe PetaLinux remote server where all of the rpm packages needed for cross compilation of the embedded linux image for the target FPGA must be manually specified in petaliuxbsp.conf located in /<project directory>/project-spec/meta-user/conf. The remote server for the PetaLinux 2021.2 version packages is located at petalinux.xilinx.com/sswreleases/rel-v2021.2/
From what I can tell so far with PetaLinux 2021.2, this specification of PACKAGE_FEED_URIS and PACKAGE_FEED_BASE_PATHS at minimum is required for any and all projects. Otherwise the PetaLinux project will spend 4 hours outputting "ConnectionResetError: [Errno 104] Connection reset by peer" for each and every package trying to be built into the embedded Linux image.
PACKAGE_FEED_URIS = "http://petalinux.xilinx.com/sswreleases/rel-v2021.2/generic-updates \
http://petalinux.xilinx.com/sswreleases/rel-v2021.2/generic"
PACKAGE_FEED_BASE_PATHS = "rpm"
And since the Kria KV260 also has a dedicated directory on the PetaLinux remote server of packages and configurations, the Kria-specific board variant directory must also be specified:
BOARD_VARIANT = "kv"
Now it's worth mentioning that you do not call out the accelerated smart applications here to add to the root filesystem configuration as you did in PetaLinux version 2021.1. From what I can tell, you can not build any of the accelerated applications directly into the PetaLinux project in version 2021.2, you can only install them from the Xilinx Embedded App Store on the Kria itself running the embedded Linux image generated by the Petalinux project using DNF (which I'll show in the later steps).
There is no other configuration necessary to the PetaLinux project unless you want to change things like the filesystem type (default is INITRD) or add additional kernel modules, file system packages, etc.
BuildAfter configuring the Petalinux project, run a build:
~$ petalinux-build
The Kria project from the BSP is fairly large, so full build from scratch or after cleaning it like this can take some time depending on the configuration of your host machine (amount of RAM, processor speed, etc.).
Load SD CardCreate a wic image to flash the SD card with using the petalinux-package command. The wic image is output to ./<project directory>/images/linux.
~$ petalinux-package --wic --bootfiles "ramdisk.cpio.gz.u-boot boot.scr Image system.dtb"
Then flash the SD card with the wic image. I personally like like balenaEtcher.
Install the SD card in the slot on the topside of the carrier board of the Kria and plug in the wall adapter power supply. Connect a USB cable to J4 on the carrier board and an ethernet cable to a router to provide an internet connection to the Kria.
Open serial terminal application to monitor the boot process. The first time a new Linux image is booted on the Kria, the username for the root user is petalinux and it will prompt you to create your own password.
After getting logged in, verify the network connection via a method such as pinging a website like Google:
xilinx-k26-starterkit-2021_2:~# ping google.com
Now the nice thing about PetaLinux 2021.2 for the Kria KV260 is a new filesystem package group called packagegroup-petalinux-som which installs this cool new GUI webserver in the Linux image for controlling the accelerated applications versus doing evething from the command line. This GUI is built on the Bokeh visualization library and dashboard service packages included in packagegroup-petalinux-som.
Start by verifying the local IP address assigned to the Kria on the network:
xilinx-k26-starterkit-2021_2:~# ifconfig
Since it's a webserver of sorts, it's installed as a Dameon internet service so you can launch it by starting that service:
xilinx-k26-starterkit-2021_2:~# sudo /etc/init.d/som-dashboard-init start
Or launch it using the Bokeh library using the locally assigned IP address of the Kria:
xilinx-k26-starterkit-2021_2:~# sudo bokeh serve --show --allow-websocket-origin=192.168.x.x:5006 /usr/lib/python3.8/site-packages/som-dashboard
Then access the GUI from your browser using the Kria's local IP address:
http://192.168.x.x:5006/som-dashboard
The homepage of the dashboard is a graphical representation of some of the benchmarking commands I demonstrated from the command line in PetaLinux version 2020.2.2 in my previous post here.
In the upper lefthand corner of the window, you'll notice two tabs for each of the webpages. Switching over to the Application Cockpit tab, you'll be presented with a webpage that uses a few button clicks to download and DNF install a new accelerated app and then load/unload them. Which in my previous post in version 2021.1 we did using the xmutil commands listapps, unloadapp, and loadapp. Which you can still do directly from the command line that same way if you so chose. This dashboard is just a new option running those commands in the background for you.
Using the dashboard I tested out the smartcam accelerated application again.
And with the base image tested and running, I'm now working towards custom accelerated application development to add to it. I'm hoping to do something security camera related, so stay tuned!
Comments