Hi!

 

 

In this little guide I would like to show you how to create Minized project with Vitis 2020.1 support and PYNQ.

 

If have problems with reading this blog visit hackster.io

First thing first

 

First thing we need is to clone Avnet repositories, they will be used as starting point for our new designs.

mkdir Avnet20201;

cd Avnet 20201;

git clone https://github.com/Avnet/petalinux.git -b 2020.1;

git clone https://github.com/Avnet/hdl.git -b 2020.1;

git clone https://github.com/Avnet/bdf.git -b master;

You should get something like this:
Screenshot from 2020-09-13 20-23-06.png

Now, lets source our environment with Vivado and petalinux settings.

source /home/bartek/Xilinx/Vivado/2020.1/settings64.sh

source /home/bartek/petalinux20201/settings.sh

If you don't know where are these files, look in the installation folder.
Screenshot from 2020-09-13 20-24-58.png

Now, navigate to Avnet petalinux folder and run "make_minized.sh" script.

cd petalinux/scripts; ./make_minized.sh;

Screenshot from 2020-09-13 20-28-26.png

The script should build full fledged petalinux project and package it to BSP.

Screenshot from 2020-09-13 20-44-32.png

 

Non-essential cleanup

Let's free some space on Minized FPGA.

Open Vivado project.

 

Screenshot from 2020-09-13 20-56-04.png

 

It's not a good idea to work on already existing project that is used to generate BSP's. The Best thing to do is just to create copy
In top left corner click File → Project → save project as....
Screenshot from 2020-09-13 21-06-31.png

 

Now, as we have a backup project we can do some modifications.
Open block Design and remove unused Ipcore's.

 

Screenshot from 2020-09-13 21-09-39.png

 

I just removed everything besides the Wi-Fi controller and interrupt manager.
Screenshot from 2020-09-13 21-17-07.png

 

 

If you wish you can enable additional interfaces for Vitis.
I have enabled M02-M06 Interfaces on ps7_axi_periph
Screenshot from 2020-09-13 21-17-55.png

Save design and generate bitstream.

After bitstream generation is finished, export hardware project for petalinux and Vitis.

Click File → Export → Export

Screenshot from 2020-09-13 21-23-10.png

 

 

Constrains should be located in your project folder.

Screenshot from 2020-09-13 22-40-26.png

 

Inside "Boards" and "MINIZED" you will find project constrains
Now we have new.xsa ready. Let's create new petalinux project based on generated bsp.

petalinux-create -t project -s minized_2020_1.bsp -n MinizedFromBSP

Screenshot from 2020-09-13 23-07-52.png

 

 

Go to terminal and change referenced.xsa file for petalinux project

cd MinizedFromBSP;

petalinux-config --get-hw-description=/home/bartek/Avnet20201/MzWorkInProgress/

Enable FPGA Manager (for PYNQ)
Screenshot from 2020-09-13 23-03-39.png

Add extra.ext4 image format.

Screenshot from 2020-09-14 10-25-46.png

Exit and save.

We need to add Xilinx APF driver for XRT platforms.

Type:

petalinux-config -c kernel

 

Screenshot from 2020-09-13 23-16-03.png

And check Xilinx APF Accelerator driver and DMA support.
Exit and save changes.
Now let's make some modifications to the meta-avnet layer in our project.
Go to petalinux→projects→minized_2020_1
Screenshot from 2020-09-13 23-18-32.png

 

 

Meta-avnet provides yocto information about Avnet development boards, for example Minized. Petalinux automatically generate device-tree based on XSA you provided. As I have deleted Bluetooth and accelerometer interrupt I should remove their references from device-tree.
Open system-bsp.dtsi in meta-avnet layer.
Screenshot from 2020-09-13 23-22-38.png

 

First remove references to &bluetooth_uart and &axi_iic_0, also add:

zyxclmm_drm {

     compatible = "xlnx,zocl";

      status = "okay";

};

to &amba.

You should get something like this:

Screenshot from 2020-09-13 23-25-10.png

Go to terminal and type:

petalinux-create -t apps --template install -n jupyterandwifi --enable

Go to meta-user → reciepes-apps→jupyterandwifi
Screenshot from 2020-09-14 00-27-08.png

Open.bb append and change do_install()

do_install() {
install -d ${D}/${bindir}
install -m 0755 ${S}/jupyterandwifi ${D}/${bindir} 
}

 

to:

 

inherit update-rc.d
INITSCRIPT_NAME = "jupyterandwifi"
INITSCRIPT_PARAMS = "start 99 S ."
do_install() {
  install -d ${D}${sysconfdir}/init.d
  install -m 0755 ${S}/jupyterandwifi ${D}${sysconfdir}/init.d/jupyterandwifi
}
FILES_${PN} += "${sysconfdir}/*"

 

This will add "jupyterandwifi" script to init.d directory and run at startup.

Open "jupyterandwifi" script.

Screenshot from 2020-09-14 00-27-28.png

 

And write a little script.

#!/bin/sh
set -e

echo "Hello PetaLinux World"
FLAG="/usr/local/bin/quicksetup.log"

#Turn on WIFI
cp -f /usr/local/bin/wpa_supplicant.conf /etc/.
wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf -B
sleep 2
udhcpc -i wlan0 &
sleep 1

#Start jupyter
if [ ! -f $FLAG ]; then
#Setup jupyter-notebook
jupyter-notebook --generate-config
jupyter-notebook password
touch $FLAG
fi

Exit and save.

user-rootfsconfig and add PYNQ packages

#Note: Mention Each package in individual line
#These packages will get added into rootfs menu entry

CONFIG_gpio-demo
CONFIG_peekpoke
CONFIG_jupyterandwifi
CONFIG_python3-pynq
CONFIG_python3-audio
CONFIG_python3-pillow
CONFIG_pynq-overlay
CONFIG_python3-jupyter
CONFIG_python3-pandas
CONFIG_python3-numpy
CONFIG_libstdc++

Feel free to look at PYNQ forum to learn more about creating petalinux with PYNQ support https://discuss.pynq.io/c/tutorials-workshops/15

Let's activate these packages.

Open terminal and type:

petalinux-config -c rootfs

 

Screenshot from 2020-09-14 00-10-22.png

Also go to "Petalinux Package Groups" and activate:

"packagegroup-petalinux-xrt"
"packagegroup-petalinux-python-modules"
"packagegroup-petalinux-lmsensors"
"packagegroup-petalinux"

You can always activate more if you need. Minized have 8GB of memory, so just keep rootfs <8GB

 

Screenshot from 2020-09-14 00-11-48.png

You can use "/" to search for extra packages.
Exit and save changes.
Also, remember to change "wpa_supplicant.conf" to match your WI-FI SSID and password
Screenshot from 2020-09-14 00-19-46.png

 

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1

network={
  key_mgmt=WPA-PSK
  ssid="MySsidName"
  psk="MyPassword"
}

 

Now we can build the project.
Type:

petalinux-build -c avnet-image-full;

petalinux-build --sdk;

"petalinux-build --sdk" will be used later by Vitis.

Go to linux→image and copy "rootfs.wic" to USB stick.

*You should format USB to ext4 format, as "rootfs.wic" is bigger than 4GB.*

Screenshot from 2020-09-14 09-40-39.png

Open "minized_2020_1" folder (That generated by./make_minized script) and use "boot_qspi_INITRD.sh" to program QSPI.

If you need more information, look at documentation "how_to_boot.txt"

Screenshot from 2020-09-14 09-32-23.png

./boot_qspi_INITRD.sh

or

xsdb boot_jtag_INITRD_MINIMAL.tcl

Now lets program EMMC memory from Minized.
Open your favorite terminal, I will use Cutecom, because I can just copy and paste all commands and relax

sudo cutecom

use:

root

root

As a username and password.
Connect USB and second micro USB cable for it, to provide power.
You should see debug info after connecting USB device.

 

Screenshot from 2020-09-14 09-48-05.png

Now in Minized terminal type (I have added extra sleep commands just to be sure, that everything finishes unmounting):

umount /dev/mmcblk0*;
sleep 1;
dd if=/run/media/sda1/rootfs.wic of=/dev/mmcblk0;
sleep 1;
cp /media/sd-mmcblk0p1/avnet-boot/avnet_emmc.scr /media/sd-mmcblk0p1/boot.scr;
sleep 1;
umount /dev/mmcblk0*;
sleep 1;
parted /dev/mmcblk0 resizepart 2 100%;
sleep 1;umount /dev/mmcblk0*;
sleep 1;
e2fsck -f /dev/mmcblk0p2;
sleep 1;
resize2fs /dev/mmcblk0p2;
sleep 1;
flash_erase /dev/mtd2 0 0;
sleep 1;

reboot Minized

Vitis Platform

 

In the meantime let's create Vitis platform for Minized.
First create.bif

gedit bif.bif

Screenshot from 2020-09-14 09-57-41.png

 

And run "./sdk.sh" it should be located in MinizedFromBSP → images → linux folder.

./sdk.sh

Open Vitis 2020.1 and create new platform project.

 

Screenshot from 2020-09-14 10-08-38.png

Screenshot from 2020-09-14 17-10-55.png

Screenshot from 2020-09-14 17-06-29.png

 

Fill in the blank fields and build platform project.
Create new application project
Screenshot from 2020-09-14 17-13-23.png
Change project settings to hardware project and build vadd example.
Screenshot from 2020-09-14 17-17-15.png

 

After build is finished upload "MzPQ" and "vadd.xclbin" to Minized.
You can do it with jupyter notebook.
Screenshot from 2020-09-14 17-24-59.png
Screenshot from 2020-09-14 17-26-53.png

 

Now let's create BOOT.bin for Minized.
Click Xilinx → Create Boot Image
Screenshot from 2020-09-14 17-29-11.png

Click Xilinx → Program Flash and program QSPI memory.

Screenshot from 2020-09-14 17-33-14.png

 

Some tests

 

Reboot Minized and type:
export XILINX_XRT=/usr
chmod +x MzPQ
./MzPQ vadd.xclbin
Screenshot from 2020-09-14 17-39-50.png

 

*export XILINX_XRT=/usr* You can add it permanently by:
adding it to "/etc/environment"

echo XILINX_XRT=/usr >> /etc/environment

This will start jupyter-notebook.

jupyter-notebook --ip=0.0.0.0 --port=9090 --no-browser --allow-root &

Password for jupyter-notebook is generated at first startup where you entered password two times.
Create new notebook and run vadd
Screenshot from 2020-09-14 17-48-59.png

 

As you can see I got some errors with libsensors library, and FPGA isn't reprogrammed by PYNQ (which is good/bad for us because WI-FI driver won't crash). Soon there should be a proper tutorial how to make PYNQ image from petalinux, just wait for it and search at discuss.pynq.io
This is it, thank you for reading.

 

Take care!