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