Board Support Package (BSP) for evaluation boards available form Xilinx Downloads is a great starting point for designs and KRIA kv260 starter kit is a powerful affordable hardware suitable for many designs. The project is walk through recently released 2021.1 BSP for the board towards simple Linux based example highlighting possible customization options.
In Vitis environment Board Support Packages (BSP) configure domains of platform project defining hardware. While in simple cases of standalone and RTOS projects the BSP can be derived from XSA exported from correspondent Vivado project, Linux domain configuration is quite complex and requires additional tool to prepare the BSP. PetaLinux is an embedded Linux Software Development Kit (SDK) targeting FPGA-based system on-a-chip (SoC) designs with Linux-centric approach and PetaLinux BSPs are reference designs on supported boards to start working with and customizing projects.
Petalinux configuration for K26/kv260Petalinux is a tool and it has to be installed in linux, this project uses Ubuntu 18.04 development machine, PetaLinux 2021.1 and the Kria K26 Starter Kit 2021.1 BSP Update 1. Please note that the BSP for kv260 Starter Kit is different from the K26 SoM one because it addresses the SoM and the carrier board together.
Petalinux installation for kv260/K26 requires petalinux-upgrade, the whole installation procedure is described in the Petalinux tool upgrade for SOM
Download The PetaLinux 2021.1 Installer From Below link:https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html
Install The Downloaded PetaLinux Tool:
$ ./petalinux-v2021.1-final-installer.run -d <PLNX_INSTALL_DIR>
Source The Installed PetaLinux Tool:
$ source <PLNX_INSTALL_DIR>/settings.sh
Upgrade The Installed PetaLinux Petalinux Tool With New eSDK:From Network:
$ petalinux-upgrade -u http://petalinux.xilinx.com/sswreleases/rel-v2021/sdkupdate/2021.1_update1/ -p "aarch64" --wget-args "--wait 1 -nH --cut-dirs=4"
From Local:
$ petalinux-upgrade -f <Local eSDK Directory Path> -p "aarch64"
On Successful Upgrade You will See The Below Console Logs.
INFO: Upgrading..
INFO: Start updating aarch64 esdk
INFO: Updating aarch64 esdk succeededPetalinux project
After the tool installation we are ready to create petalinux project. Raither than starting with --template zynqMP
option, we can use the downloaded BSP with -s xilinx-k26-starterkit-v2021.1-final.bsp
to initialize the project
petalinux-create -t project -s xilinx-k26-starterkit-v2021.1-final.bsp
cd xilinx-k26-starterkit-2021.1
ls
build components config.project hardware images pre-built project-spec README README.hw
The generated directory contains README, please take a look to the pre-built and hardware directories description in the file which can be used as starting point or references for customized designs.
echo 'BOARD_VARIANT = "kv"' >> project-spec/meta-user/conf/petalinuxbsp.conf
There are more details about BOARD_VARIANT in the petalinux build instructions page.
There are some prepared Linux configuration available in the components/yocto/layers/meta-petalinux/recipes-core/images
sub-directory. If you explore .inc files, you'll find the "minimal"/"common" configuration doesn't include gstreamer and ivas while the "full" one does
tree components/yocto/layers/meta-petalinux/recipes-core/images
components/yocto/layers/meta-petalinux/recipes-core/images
├── petalinux-image-common.inc
├── petalinux-image-everything.bb
├── petalinux-image-full.bb
├── petalinux-image-full.inc
├── petalinux-image-minimal.bb
├── petalinux-initramfs-image.bb
└── xsct-tarball-esdk.inc
We will build the petalinux-image-full
petalinux-build -c petalinux-image-full
SD ImageThere are instructions in Kria K26 SOM - XIlinx Wiki to package the built image and we'll use .wic format allowing to flash the image with Balena Etcher application. Please refer to the README file in the petalinux project if you prefer to prepare the SD card with dd command in your Linux development environment
petalinux-package --boot --u-boot --dtb images/linux/u-boot.dtb --force
petalinux-package --wic
cd images/linux/ && ls -lh petalinux-sdimage.wic
-rw-r--r-- 1 alex-fae alex-fae 6.1G Sep 14 15:07 petalinux-sdimage.wic
zip -m petalinux-sdimage.zip petalinux-sdimage.wic
adding: petalinux-sdimage.wic (deflated 83%)
ls -lh petalinux-sdimage.zip
-rw-rw-r-- 1 alex-fae alex-fae 1.1G Sep 14 15:16 petalinux-sdimage.zip
The
1st command generates BOOT.BIN necessary to update QSPI flash to boot the image properly.
While
the SD card image is 6.1 GB, it can be zipped into 1.1 GB. Zipped "minimal" image requires less than 300 GB, the "full" one is 3 times bigger.
I've tried to boot the image and the linux started but it could not find root fs and I've realized that boot FW on the QSPI flash has to be updated with BOOT.BIN corresponding to the image
Boot FW updateAt this stage I've connected to the K26 UART with microUSB cable (connector J4 on kv260) and I've followed Kria K26 SOM - XIlinx Wiki to update BOOT.BIN from factory QSPI image. The 1st attempt was to perform the update with xmutil in the prebuilt 2020.2.2 image:
xilinx-k26-starterkit-2020_2:~$ sudo xmutil bootfw_status
Image A: Bootable
Image B: Bootable
Requested Boot Image: Image A
Last Booted Image: Image A
XilinxSom_QspiImage_v1.0_20210225
The update terminated normally and looked promising
xilinx-k26-starterkit-2020_2:~$ sudo xmutil bootfw_update -i /media/sd-mmcblk0p1/BOOT.BIN
Marking last booted image as bootable
Reading Image..
Marking target image non bootable
Writing Image..
Marking target image as non bootable and requested image
/media/sd-mmcblk0p1/BOOT.BIN updated successfully
Status check looked good too
xilinx-k26-starterkit-2020_2:~$ sudo xmutil bootfw_status
Image A: Bootable
Image B: Non Bootable
Requested Boot Image: Image B
Last Booted Image: Image A
XilinxSom_QspiImage_v1.0_20210225
But after reboot I've got
xilinx-k26-starterkit-2020_2:~$ sudo xmutil bootfw_update -v
Persistent registers are corrupted
Reading persistent registers backup
Persistent registers are corrupted
Unable to retrieve persistent registers
and found on the wiki page that it's known issue with factory QSPI image
The xmutil bootfw_update and bootfw_status utilities have a known issue with the factory QSPI image (20210225) in which it will always return a “persistent registers are corrupted” message. If your board has this factory QSPI image you must use the “Image Recovery Tool” to update your Starter Kit boot firmware.
Another attempt to update the QSPI Image with recovery tool: pressing FWUEN button (it's located between the QR code and power adapter connector on the carrier board) and RESET (the button between the QR code and FWUEN on the carrier board) the kv260 printed out
Xilinx boot image recovery tool web server is running on port 80
Please point your web browser to http://192.168.0.111
When using Image Recovery Tool on the boards with factory QSPI image 20210225; always upload your new boot FW as Image A by selecting the Image A radial button in the Select Image to be recovered and the Requested Boot Image sections of the Image Recovery Tool.
Replacing SD card with the fresh 2021.1 image and trying to boot, this time the process proceeds successfully till login prompt,.
Besides that I notice that jupiter lab server is started, I try to open the suggested link to the server running on the MPSoC and I'm connected.
Next step is to extend rootfs partition to the SD card size according to the instructions (NOTE: in our case the SD card device is mmcblk1 instead of the mmcblk0). By default the partition doesn't have any free space
xilinx-k26-starterkit-2021_1:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1488700 0 1488700 0% /dev
/dev/mmcblk1p2 3997376 3731876 39404 99% /
tmpfs 2013688 352 2013336 1% /run
tmpfs 2013688 88 2013600 1% /var/volatile
/dev/mmcblk1p1 2093048 46508 2046540 3% /media/sd-mmcblk1p1
cgroup 2013688 0 2013688 0% /sys/fs/cgroup
To resize the partition:
sudo umount /media/sd-mmcblk1p2
sudo parted /dev/mmcblk1 resizepart 2
--Enter yes--Enter size in MB, or enter -1 in order to maximize the size of the new partition
sudo resize2fs /dev/mmcblk1p2
sudo reboot
I've got 27% free space in the partition on my 8 GB SD card
There are more useful tips on the https://forums.xilinx.com/t5/Kria-SOMs/bd-p/SOM
SSH and SCP accessThe petalinux is up and running allowing ssh access over network. Apparently it allows to use the kv260 in headless mode connecting to it over IP.
Files transfers are supported with scp protocol. MS Windows users can use MobaXterm application opening both connections (ssh and scp) automatically when you connect to the board
Linux users can use ssh client from their favorite terminal and transfer files with FileZilla selecting SFTP-SSH protocol
Gstreamer installation quick testTyping gst followed by TAB finds gstreamer commands available in the system
xilinx-k26-starterkit-2021_1:~$ gst
gst-client gst-device-monitor-1.0 gst-inspect-1.0 gst-n-launch-1.0 gst-play-1.0 gst-typefind-1.0 gstd-client
gst-client-1.0 gst-discoverer-1.0 gst-launch-1.0 gst-play gst-stats-1.0 gstd
and gst-device-monitor-1.0 returns audio/video devices connected to the kv260, for instance it finds my Logitech c920 web camera connected to the board's USB port.
Simple gstreamer pipeline capturing from USB cameragst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=30/1 ! matroskamux ! filesink location=tmp1.mp4
The pipeline can be interrupted with Ctrl+C and the video file will be ready for download over scp, alternatively the video stream can be redirected to udpsink gstreamer filter.
dnf and xmutilAt the moment the linux image is still not equivalent to the distributed by Xilinx one, we don't have xmutil installed in the system and we are going to install it will dnf.
sudo dnf install xmutil
sudo xmutil platformstats -a
sudo xmutil boardid -b som
upgrading dnf packages is relatively long operation but it will allow you install applications from Xilinx App Store like in the prebuilt SD card image
sudo dnf update
after reboot the applications list enquiry works properly
sudo xmutil listapps
dateBy default the date in the built is not synchronized over ethernet, my one returned 'Fri Mar 9 06:53:09 PST 2018
'. It can be fixed installing ntp server and rebooting the board
sudo dnf install ntp
sudo reboot
The date synchronization fixes 'wget' and allows to download files directly to the board's SD card.
treetree is quite handy utility, it can be installed with
sudo dnf install tree
The
following combination shows 2 levels of directories with file sizes in human readable format for instance
tree -h -L 2
If you are looking for alternative to system default vi text editor without GUI (l3afpad is available in dnf), nano can be built from source on the system
wget http://www.nano-editor.org/dist/v2.0/nano-2.0.6.tar.gz
tar -zxvf nano-2.0.6.tar.gz
cd nano-2.0.6
./configure --build=aarch64-unknown-linux-gnu
make
sudo make install
The same approach can be used for other handy GUI-less applications, for example tio if you need serial communication
wget https://github.com/tio/tio/releases/download/v1.32/tio-1.32.tar.xz
tar -xf tio-1.32.tar.xz
cd tio-1.32
./configure --build=aarch64-unknown-linux-gnu
make
sudo make install
We are going to explore the tools that we touched briefly on the kv260 Vision AI Starter Kit: Vitis Video Analytics SDK (VVAS), gstreamer, VCU encoding/decoding capabilities in the ZU5EV MPSoC oon the K26 SoM, coprocessing options with R5 real time cores.
Please stay tuned and thanks for reading till here.
Comments