While the Kria KV260 Vision AI Kit doesn't require a user to touch Vivado, Vitis, or PetaLinux to start developing their own end-user AI accelerated applications, there are still those of us that love to dig into the fine detail and make everything ourselves. This project serves as a starting point for those of us that want to start adding our own modifications to the base embedded Linux image that is loaded onto the SD card in Step 2 of the Kria KV260 getting started guide.
The versioning of PetaLinux 2020.2.2 might imply that it is a patch upgrade to PetaLinux 2020.2, it actually is its own full stand-alone install. Download the installer here.
Be sure to scroll down to the Kria K26 Special Release section, as the first link at the top of the page is just the regular PetaLinux 2020.2 installer.
Following regular PetaLinux install protocol, start by creating your desired target install directory:
~$ sudo mkdir -p /tools/Xilinx/PetaLinux/2020.2.2
Give it 755 permissions:
~$ sudo chmod -R 755 /tools/Xilinx/PetaLinux/2020.2.2/
Give the installer full read+write permissions:
~$ sudo chmod 777 ./Downloads/petalinux-v2020.2.2-final-installer.run
And finally give your user ownership of the target installation directory:
~$ sudo chown -R <user>:<user> /tools/Xilinx/PetaLinux/2020.2.2/
Run the installer (NOT as super user)
~$ ./Downloads/petalinux-v2020.2.2-final-installer.run --dir /tools/Xilinx/PetaLinux/2020.2.2/
A few screens will appear to ask you to agree to the terms+conditions/licensing. Press enter
to view the page, q
to escape it, and y
to agree. You'll have to repeat this three times before the installer will then run. Refer to the 2020.2 version of UG1144 for common errors and troubleshooting tips.
With the new version of PetaLinux installed, download the BSP for the Kria KV260 board here.
I personally like to create a directory in my home folder for BSPs to live in that's easy for me to find and reference for any future projects:
~$ mkdir -p ./kria_bsp
~$ mv ./Downloads/xilinx-k26-starterkit-v2020.2.2-final.bsp ./kria_bsp/
Next, source the PetaLinux 2020.2.2 tools:
~$ source /tools/Xilinx/PetaLinux/2020.2.2/settings.sh
And create a new project using the BSP:
~$ petalinux-create -t project -s ./kria_bsp/xilinx-k26-starterkit-v2020.2.2-final.bsp
Then change directories into the newly created PetaLinux project:
~$ cd ./xilinx-k26-starterkit-2020.2.2/
Whenever I create a PetaLinux project from a BSP, I like to run a build before I do anything else to verify everything populated properly before I start adding my own modifications. This is so when I run into errors, I at least have an idea of where they are stemming from. And I sure am glad I stuck to my policy on this because this first build did not go well and required some patching to correct.
Patching Up a Few Things for the BuildNow I can't tell if the following patches I had to make to the PetaLinux project are due to me using an unsupported OS or if it stems from a bug in PetaLinux 2020.2.2 (due to me not paying attention and always blindly agreeing to updates/upgrades, I'm running Ubuntu 18.04.5, when the official supported versions are 18.04.1, 18.04.2, 18.04.3, & 18.04.4). The reason I was suspicious of it potentially being a bug in PetaLinux 2020.2.2 is due to this forum thread here about a bug in the mirror pathways in PetaLinux 2020.2 when trying to run a build without internet access.
The first couple of times tried to build the project, tons of errors were thrown that PetaLinux couldn't find the right mirrors and/or network connection. Each time it threw an error about a different package/library so I knew it wasn't specific to any package/library:
Following the advice of the forum thread I referenced above, I applied a modified version of the patch it suggested, adding the git submodule pre-mirror to the BSP configuration file of the PetaLinux project.
Add the following line immediately after line 3 in <PetaLinux project directory>/project-spec/meta-user/conf/petalinuxbsp.conf
PREMIRRORS_prepend = "gitsm://.*/.* file:///opt/petalinux/data/downloads_2020.2.2 \n "
While this alone did not resolve the error, I noticed I got a little further along in the build before it started throwing the same types of errors so I knew I was at least on the right track.
Since I was pretty sure this was an error related to the mirror settings in the underlying Yocto project of the PetaLinux project, I decided to look through the Yocto settings under the System Configuration GUI accessed by running:
~$ petalinux-config
Then navigating to Yocto Settings, I found two places where the mirrors were set up for the project. I noticed that both instances were trying to pass the PetaLinux version as a variable by specifying it in the URLs as:
/rel-v${PETALINUX_VER%%.*}/
Since PetaLinux 2020.2.2 is a special release intended solely to support the Kria KV260 hardware and nothing else, I was immediately suspicious that this might be causing something weird and decided to hard-code the mirror URLs to specify the PetaLinux version as 2020.2.2 by changing it to:
/rel-v2020.2.2/
The first mirror URL I applied this fix to was under Yocto Settings --> Add pre-mirror url and the second was under Yocto Settings --> Network sstate feeds URL.
After exiting the System Configuration GUI and saving this new configuration, I launched another build and held my breath....
~$ petalinux-build
Now I figured this base project image for the Kria KV260 was pretty big, but I still underestimated it. This build pegged my CPU at 100% usage for about 40 minutes but the build succeeded!!
At this point, the project is in a known good state for custom modifications to be added. After any desired modifications are added and the PetaLinux project is successfully rebuilt, create the boot binary image for the SD card with the following command:
~$ petalinux-package --boot --fsbl ./images/linux/zynqmp_fsbl.elf --fpga ./images/linux/system.bit --u-boot
And that's it! The standard protocol for preparing the SD card as you would for any PetaLinux project version 2020.1 or later can be followed from here.
Comments