Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits
Preparing Ubuntu 18.04 for running on Ultra96v2 has five sections
- Section 1: Preparing SDCard
- Section 2: Preparing Viviado .xsa file
- Section 3: Petalinux Project
- Section 4: Ubuntu rootfs
- Section 5: Boot Ubuntu 18.04
Section 1: Preparing SDCard
1- Insert the sdcard in the host computer USB port. (Ubuntu 18.04 OS is assumed as the host)
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 parttion 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
Section 2: Prepare Viviado .xsa file
1- In your workspace create a folder called e.g., Ultra96v2-Vitis-Ubuntu
mkdir Ultra96v2-Vitis-Ubuntu
cd Ultra96v2-Vitis-Ubuntu
2-Run Vivado, and create a project, with “Ultra96v2-Vivado” name in the created folder above.

3- Choose the “Ultra96v2 Evaluation Platform” boars in Default part window.

Note: If you cannot see the Ultra96v2 board in the list. Download the corresponding board definition file from here and copy that in the <Vivado installation directory>/data/boards/boardfiles folder. Then, run the Vivado again.
4- Select “Create a Block Design” on the left.

5- Add a Zynq UltraScale+ MPSoC to the design space and click on “Run Block Automation”

6- Make sure that “Apply Board Preset” is selected, then press OK

7- Double clock on the ZynqMP IP and configure that as below

8- Add a “Clocking Wizard” IP to the design.

9- Double clock on the clocking wizard IP and select the “Active Low” for the “Reset Type”.

10- Add a “Processor System Reset” IP to the design. Add connection as the following figure .

11- Select “Platform Interfaces” in the Window menue.

12- Click on “Enable platform interfaces” and enable ports in the list as the following figure.

13- Select clk_out_1 as default clock by clocking on is_defaultproperty in the Platform Interface Properties as figure below

14- Write click on design_1 in the Source pannel and “Create HDL Wrapper” for the design. Then generate the design bitstream.
15- to create the xsa file run the following tcl command in the Tcl Console pannel.
write_hw_platform -include_bit ultra96v2.xsa
Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits
Section 3: Petalinux Project
1- Go to the Ultra96v2-Vitis-Ubuntu folder (created earlier), and create a petalinux project
petalinux-create -t project --template zynqMP -n ultra96v2-ubuntu-petalinux

2- Got to the project folder
cd ultra96v2-ubuntu-petalinux
3- Configure the project (note the get-hw-description option refer to the path that contains the generated xsa file by Vivado.
petalinux-config --get-hw-description=../Ultra96v2-Vivado/

4- In the “DTG Settings –>MACHINE NAME”
change template to zcu100-revc
(Note: The Ultra96 was originally called zcu100)

5- In the “DTG Settings –>Kernel Bootargs–>” disable generate boot args automatically” option. then in the “user set kernel bootargs” enter the following arguments
earlycon clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait

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

7- In the “misc/config System Configuration” window, go to “Image Packaging Configuration–>Root filesystem type” and change the “INITRAMFS” to “EXT (SD/eMMC/QSPI/SATA/USB)”.
8- Configure the kernel by
petalinux-config -c kernel

9- In “Device Drivers–>Generic Driver Options–>Size in Mega Byte” change 256 to 1024

10- To activate the USB network interface select the Realtek RTL8152/RTL8153 Based USB Ethernet Adapter” in “Device Drivers–>Network device support–>USB Network Adapter”

11- Open the “./project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi” file and add following lines.
&sdhci1 {
max-frequency = <50000000>;
/delete-property/cap-power-off-card;
wilc_sdio@1 {
compatible = "microchip,wilc3000";
reg = <0>;
bus-width = <0x4>;
status = "okay";
};
/delete-node/wifi@2;
};
12- create a module for wifi driver
petalinux-create -t modules -n wilc --enable
13- replace the content of the “./project-spec/meta-user/recipes-modules/wilc/wilc.bb” file with (ref)
SUMMARY = "Recipe for building an external wilc Linux kernel module"
SECTION = "PETALINUX/modules"
LICENSE = "GPLv3"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-3.0;md5=c79ff39f19dfec6d293b95dea7b07891"
inherit module
SRC_URI = "git://github.com/Avnet/u96v2-wilc-driver;protocol=http;branch=v15_2"
SRCREV = "01ab7484e0e6b2191c69d7ec7c6e89da5ca51f0f"
DEPENDS += "virtual/kernel"
S = "${WORKDIR}/git/wilc"
EXTRA_OEMAKE = 'CONFIG_WILC=y \
WLAN_VENDOR_MCHP=y \
CONFIG_WILC_SDIO=m \
CONFIG_WILC_SPI=n \
CONFIG_WILC1000_HW_OOB_INTR=n \
KERNEL_SRC="${STAGING_KERNEL_DIR}" \
O=${STAGING_KERNEL_BUILDDIR}'
12- Build the project by runnig
petalinux-build
13- Genrate the BOOT file
petalinux-package --boot --format BIN --fsbl images/linux/zynqmp_fsbl.elf --u-boot images/linux/u-boot.elf --pmufw images/linux/pmufw.elf --fpga images/linux/*.bit
14- Copy BOOT.BIN and image.ub into the first sdcard parttion
cp images/linux/BOOT.BIN images/linux/image.ub /media/<username>/BOOT
15- Extract Linux kernel modules from generated rootfs.tar.gz to be used later.
cd images/linux
mkdir tmp
cp rootfs.tar.gz tmp/
cd tmp
tar -zxvf rootfs.tar.gz
Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits
Section 4: Ubuntu rootfs
1- Install qemu tool
sudo apt-get install qemu-user-static
2- Go to the Ultra96v2-Vitis-Ubuntu folder created earlier and download the Ubuntu rootfs
wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.3-base-arm64.tar.gz
3- Copy the Ubuntu rootfs in to the second partition in the sdcard
sudo tar xfvp ./ubuntu-base-18.04.3-base-arm64.tar.gz -C /media/<username>/rootfs/
sync
4- Copy these config files into the sdcard
sudo cp -av /usr/bin/qemu-aarch64-static /media/<username>/rootfs/usr/bin/
sudo cp -av /run/systemd/resolve/stub-resolv.conf /media/<username>/rootfs/etc/resolv.conf
5- Create these mount points
sudo mount --bind /dev/ /media/<username>/rootfs/dev
sudo mount --bind /proc/ /media/<username>/rootfs/proc
sudo mount --bind /sys/ /media/<username>/rootfs/sys
6- Boot the sdcard rootfs using the qemu
sudo chroot /media/<username>/rootfs/
7- add a new user and create a password (you can change username and password)
useradd -G sudo -m -s /bin/bash <username>
echo <username>:<password> | chpasswd
8- Install a few software on the sdcard rootfs
apt-get update
apt-get upgrade
apt-get -y install locales
apt-get -y install dialog perl
apt-get -y install sudo ifupdown net-tools ethtool udev wireless-tools iputils-ping resolvconf wget apt-utils wpasupplicant nano
apt-get -y install kmod openssh-client openssh-server
apt install -y build-essential cmake git
9- Quit the quem by running the “exit” command
10- Perfrom these umount commads
sudo umount /media/<username>/rootfs/dev
sudo umount /media/<username>/rootfs/proc
sudo umount /media/<username>/rootfs/sys
11- Copy Linux kernel modules generated in the previous part into sdcard. Go to the petalinux project forlder
cd images/linux/tmp
cp -R lib/modules/4.19.0-xilinx-v2019.2/ /media/<user-name>/rootfs/lib/modules/
12- Copy wifi firmware. Go to the following github and copy files into
/lib/firmware/mchp path in the sdcard rootfs parttion
https://github.com/linux4wilc/firmware
Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits
Udemy Course
Section 5: Boot Ubuntu 18.04
1- Connect the board to the netwrok using a USB network adapter

2- Boot the Ultra96v2 board using the sdcard.
3- Run a serial terminal such as screen or putty
screen /dev/ttyUSB1 115200
4- login using generated user and password. Then run the following command to find the USB network adapter properties. In my case the name is enx00e04c34ee4b
ifconfig -a

5- Open the /etc/network/interfaces file for editing
sudo nano /etc/network/interfaces
6- Add these lines
auto enx00e04c34ee4b
iface enx00e04c34ee4b inet dhcp

7- Run this command to enable the USB network. Then you should be able to connect to the Internet.
sudo ifup enx00e04c34ee4b
8- In order to set up wifi, two files are required
a) create a text file with the name of wpa_supplicant.conf and the following lines. Don’t forget to insert you wifi ssid and password in the file.
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="your wifi ssid"
psk="your wifi pssword"
}
b) Create a textfile called wifi.sh and copy the following lines
cp -rf ./wpa_supplicant.conf /etc/.
modprobe wilc-sdio
ifconfig wlan0 up
wpa_supplicant -dd -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf -B
dhcpcd -i wlan0
Note: if needed inatall dhcpd package.
9- Now run the following command to configure wifi.
chmod uog+x wifi.sh
sudo ./wifi.sh
Digital System Design with High-Level Synthesis for FPGA: Combinational Circuits
Hi Mohammad,
Thanks for your help 🙂
Just for information for other using zynq ultra scale+. On my platforme I had to change mmcblk0p2 to mmcblk1p2 twice.
1st : Step 5
earlycon clk_ignore_unused root=/dev/mmcblk1p2 rw rootwait
2nd : Step 7
Under Root filesystem type
I am a beginner so I do not know if I had to change both but It seem’s that mmcblk0p2 does not point to sd card.
— For info :
I will try to use a mali driver to have a windows manager
I will try also to creat a IHM to talk to the fpga and R5.
Regards,
Mathieu
0/,
In step 11.
You wrote:
cp -R lib/modules/4.19.0-xilinx-v2019.2/ /media//rootfs/lib/modules
Could it be that to add ”4.19.0-xilinx-v2019.2/” is better?
cp -R lib/modules/4.19.0-xilinx-v2019.2/ /media//rootfs/lib/modules/4.19.0-xilinx-v2019.2/
Regards,
Mathieu
Hello Mohammed,
I am working on trenz module and I have created a basic custom petalinux project (v2019.2). I did not experienced much problem in the installation/creation/ run the project.
My project has been successfully created and I can create boot files and move them to my SD card boot partitions and also I can run them successfully.
Untill here, I just customized only somes rootfs settings but not much in configuration settings.
Later I want to changes my confirmation settings such as, I want to change the boot files system from INITRAMFS to eMMC/SD card.
If change these option, the petalinux project is not getting successful. I mean, booting is not successful through SD card. I have followed all the instructions perfectly.
In other case, I want to make my project as a OS file such that I want to create some files/folders in my OS and make them save permanently. That means they should not get deleted if I reboot/power off the ultrascale board.
What should I do to achieve these goals. Can anybody please help me to overcome these problems.
I could not understand where I am making mistakes. I am very new to this area.
Thanks and regards
Shout out from Xilinx! This tutorial is awesome!
For those of you using this with a standard Ethernet cable, i.e. ZCU102, ZCU104…
You need to create a file, to get the internet connection working:
/etc/network/interfaces.d/eth0
With following contents:
auto eth0
iface eth0 inet dhcp
@Mohammad, have you looked at using a standard Linux kernel from Ubuntu’s upstream repositories? Ubuntu will not be able to install the kernel headers for this PetaLinux built kernel.
I haven’t checked the standard Linux kernel. But you can manually install the kernel headers by following these steps:
1) At the end of “Section 3: Petalinux Project”
16- Go to the “components/plnx_workspace/sources/” under the petalinux project and zip the Linux kernel source. Later we will transfer this to the sdcard for kernel module development on the board.
tar -zcvf linux-xlnx.tar.gz linux-xlnx/
2) At the end of “Section 4: Ubuntu rootfs”
16 – Copy the Linux kernel source generated in the previous part into the sdcard (e.g., username home directory)
sudo cp components/plnx_workspace/sources/linux-xlnx.tar.gz /media/numvar/rootfs/home/username/
sync
3) At the end of “Section 5: Boot Ubuntu 18.04”
10- Now we should compile the kernel source to generate the Linux header to be used later for driver compilations.
The Linux kernel zip file should be in the home directory. Unzip the file
tar -zxvf linux-xlnx.tar.gz
cd linux-xlnx
11- Install a couple of tools before compiling the kernel
sudo apt-get update
sudo apt-get -y install kernel-package fakeroot wget bzip2
sudo apt-get -y install bison flex bc device-tree-compiler libssl-dev
12- copy the kernel config file
zcat /proc/config.gz > .config
13- Compile the kernel. Note that it will take some time.
sudo apt-get install kernel-package
make-kpkg clean
fakeroot make-kpkg -j4 –initrd kernel_headers
14- Install kernel modules
sudo make modules_install
15- install the Linux kernel header
cd ..
sudo dpkg -i linux-headers-4.19.0-xilinx-v2019.2_4.19.0-xilinx-v2019.2-10.00.Custom_arm64.deb
I tried to follow your instructions as strictly as possible (twice) but both attempts failed with “Bad Linux ARM64 magic” message. I tried to change mmsblk0 to mmcblk1, same result.
Are you using the same board which is Ultra96v2 and your host OS platform is Ubuntu 18.04?
Yes, I am using Ultra96 and I run petalinux commands on Ubuntu 18.04. The only difference is in Xilinx tools rev 2019.2.
Will this work if we use micro usb in the ULTRA96 BOARD, instead of spending money on usb to network adapter ?
I haven’t checked that.
https://ultra96-pynq.readthedocs.io/en/latest/_images/ultra96_setup.png
https://ultra96-pynq.readthedocs.io/en/latest/getting_started.html#ultra96-setup-guide
In the pynq setup for ultra96V2 they are able to use a micro usb and get access to the system.
It should be possible.
Hello Mohammad, thanks for your tutorials. I have a question for you,
What about the same approach on 2020.1? Is there a wilc driver too?
I haven’t checked that. I think wilc should work. if it doesn’t, maybe you can find the new driver here
https://github.com/Avnet/Ultra96-PYNQ/releases
https://github.com/Avnet/Ultra96-PYNQ/tree/master/Ultra96/petalinux_bsp_v2/meta-user