Part 11 - Create, run & rebuild PetaLinux project
Missing Image!Missing Image!Missing Image!

Introduction

This tutorial details the steps required for creating, running & rebuilding PetaLinux for both the QEMU emulator and Zedboard hardware.

Aims

The aims of this tutorial are as follows :-
  1. Setup environment
  2. Change present working directory
  3. Create PetaLinux project
  4. Caveat emptor
  5. Run PetaLinux on QEMU
  6. Run PetaLinux on Zedboard via JTAG
  7. Launch terminal emulator
  8. Check PetaLinux is working
  9. Rebuild PetaLinux

1. Setup environment

Setup Xilinx design environment for the 2020.2 toolset.
steve@Linux-Steve:/home/steve$ source xilinx.sh
Xilinx tools available tools at /opt/Xilinx :-
1) 2020.2 - Vivado - SDK - Vitis - PetaLinux
0) Exit
Please select tools required or exit : 1

Tools are as follows :-
vivado @ /opt/Xilinx/Vivado/2020.2/bin/vivado
vitis @ /opt/Xilinx/Vitis/2020.2/bin/vitis
petalinux-build @ /opt/Xilinx/PetaLinux/2020.2/tool/tools/common/petalinux/bin/petalinux-build

2. Change present working directory

Change the present working directory to be the project directory.
steve@Linux-Steve:/home/steve$ cd /home/steve/projects/petalinux

3. Create PetaLinux project

Create a PetaLinux project using the Zedboard's Board Support Package (bsp).
steve@Linux-Steve:/home/steve/projects/petalinux$ petalinux-create -t project -s /home/steve/projects/common/sw/avnet-digilent-zedboard-v2020.2-final.bsp
Examine the root directory.
steve@Linux-Steve:/home/steve/projects/petalinux$ cd avnet-digilent-zedboard-2020.2
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ ls -la
total 32
drwxr-xr-x 9 root  root  4096 Dec 24 06:02 .
drwxrwxr-x 3 steve steve 4096 Dec 24 05:55 ..
drwxr-xr-x 3 steve steve 4096 Nov 19 08:55 components
-rw-r--r-- 1 steve steve  248 Nov 19 08:46 config.project
-rw-r--r-- 1 root  root   170 Dec 24 05:55 .gitignore
drwxr-xr-x 3 steve steve 4096 Nov 19 09:02 hardware
drwxr-xr-x 2 root  root  4096 Dec 24 05:55 .petalinux
drwxr-xr-x 3 steve steve 4096 Nov 19 08:55 pre-built
drwxr-xr-x 5 steve steve 4096 Nov 19 08:56 project-spec
-rw-r--r-- 1 steve steve 6292 Nov 19 08:56 README
-rw-r--r-- 1 steve steve 1362 Nov 19 08:55 README.hw

4. Caveat emptor

Before going any further with the BSP it should be noted that the bitstream contained does not appear to using the correct pins for the LED's. The constraints used appear to be for the ZC702 instead of the Zedboard. Open the /home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2/hardware/avnet-digilent-zedboard-2020.2/avnet-digilent-zedboard-2020.2.xpr project for further information. Replacing the pre-built bitstream with the one from the leds_switches project is prudent at this point.
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ cp /home/steve/projects/leds_switches/fw/project.runs/impl_1/system_wrapper.bit /home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2/images/linux/system.bit

5. Run PetaLinux on QEMU

Launch PetaLinux on the QEMU software emulator. Login with either root:root or petalinux:petalinux. To quit QEMU use Ctrl-a then x.
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ petalinux-boot --qemu --prebuilt 3

6. Run PetaLinux on Zedboard via JTAG

Power cycle the Zedboard and deploy the project via JTAG.
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ petalinux-boot --jtag --prebuilt 3

7. Launch terminal emulator

Launch the MiniCom terminal emulator if not already running.
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ minicom -D /dev/ttyACM0 -b 115200

8. Check PetaLinux is working

The blue done LED should illuminate once the Programmable Logic (PL) has been programmed, then the two middle LED's should illuminate indicating the exchanged bitstream is in use. After this the software should run on the Processor System (PS) and ultimately provide a login prompt via the terminal emulator. The login credentials are as before. Login as root to gain full access rights.
...

PetaLinux 2020.2 avnet-digilent-zedboard-2020_2 /dev/ttyPS0

avnet-digilent-zedboard-2020_2 login:
Check for local area network (LAN) connectivity (ping DHCP server).
root@avnet-digilent-zedboard-2020_2:~# ping 192.168.2.1
PING 192.168.2.1 (192.168.2.1): 56 data bytes
64 bytes from 192.168.2.1: seq=0 ttl=64 time=1.926 ms

...
Check for wide area network (WAN) connectivity (ping Google).
root@avnet-digilent-zedboard-2020_2:~# ping google.com
PING google.com (216.58.210.206): 56 data bytes
64 bytes from 216.58.210.206: seq=0 ttl=114 time=21.701 ms

...
Find out what IP address the DHCP server issued and also what the MAC number is.
root@avnet-digilent-zedboard-2020_2:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0A:35:00:1E:53
          inet addr:192.168.2.87  Bcast:192.168.2.255  Mask:255.255.255.0

...

9. Rebuild PetaLinux

Set up the transfer directory.
steve@Linux-Steve:/home/steve$ sudo mkdir /tftpboot
steve@Linux-Steve:/home/steve$ sudo chmod -R 777 /tftpboot
steve@Linux-Steve:/home/steve$ sudo chown -R nobody /tftpboot
Build the PetaLinux project (this takes around 4 hours).
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ petalinux-build
Examining the root directory again reveals the newly created build & images directories.
steve@Linux-Steve:/home/steve/projects/petalinux/avnet-digilent-zedboard-2020.2$ ls -la
total 32
drwxr-xr-x 9 root  root  4096 Dec 24 06:02 .
drwxrwxr-x 3 steve steve 4096 Dec 24 05:55 ..
drwxr-xr-x 8 root  root  4096 Dec 24 05:58 build
drwxr-xr-x 3 steve steve 4096 Nov 19 08:55 components
-rw-r--r-- 1 steve steve  248 Nov 19 08:46 config.project
-rw-r--r-- 1 root  root   170 Dec 24 05:55 .gitignore
drwxr-xr-x 3 steve steve 4096 Nov 19 09:02 hardware
drwxr-xr-x 3 root  root  4096 Dec 24 06:02 images
drwxr-xr-x 2 root  root  4096 Dec 24 05:55 .petalinux
drwxr-xr-x 3 steve steve 4096 Nov 19 08:55 pre-built
drwxr-xr-x 5 steve steve 4096 Nov 19 08:56 project-spec
-rw-r--r-- 1 steve steve 6292 Nov 19 08:56 README
-rw-r--r-- 1 steve steve 1362 Nov 19 08:55 README.hw
Relaunch on both QEMU and the Zedboard to check all is well with the rebuild.

'projects' location : 'repos' location : 'downloads' location :
Copyright © 2021 Steve Haywood
Missing Image!
Missing Image!Missing Image!Missing Image!