Bar
SpaceWire UK
Specialist providers of VHDL Intellectual Property & Design Services
BarBarBarBar
Tutorial
Missing Image!
Part 11 - Create, run & rebuild PetaLinux project

Introduction

This tutorial details the steps required for creating, building & running PetaLinux on 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. Add Hardware Platform
  5. Configure PetaLinux
  6. Build PetaLinux
  7. Package PetaLinux
  8. Run PetaLinux on QEMU
  9. Run PetaLinux on Zedboard via JTAG
  10. Launch terminal emulator
  11. Check PetaLinux is working

1. Setup environment

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

Tools are as follows :-
vivado @ /opt/Xilinx/Vivado/2021.2/bin/vivado
vitis @ /opt/Xilinx/Vitis/2021.2/bin/vitis
petalinux-build @ /opt/Xilinx/PetaLinux/2021.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

3. Create PetaLinux project

Create a PetaLinux project using the Zynq FPGA template.
steve@Linux-Steve:/home/steve/projects$ petalinux-create --type project --template zynq --name petalinux
Examine the project directory.
steve@Linux-Steve:/home/steve/projects$ cd petalinux
steve@Linux-Steve:/home/steve/projects/petalinux$ ls -la
total 24
drwxr-xr-x  4 steve steve 4096 Nov  7 10:15 .
drwxrwxr-x 62 steve steve 4096 Nov  7 10:15 ..
-rw-r--r--  1 steve steve  248 Nov  7 10:15 config.project
-rw-rw-r--  1 steve steve  170 Nov  7 10:15 .gitignore
drwxrwxr-x  2 steve steve 4096 Nov  7 10:15 .petalinux
drwxr-xr-x  5 steve steve 4096 Nov  7 10:15 project-spec

4. Add Hardware Platform

Configure the PetaLinux project to use the exported hardware platform from the leds_switches Vivado project.
steve@Linux-Steve:/home/steve/projects/petalinux$ petalinux-config --get-hw-description ../leds_switches/fw/system_wrapper.xsa
The configuration menu now appears.

Select Exit to leave the configuration menu. Missing Image! Select Yes when prompted to save the new configuration. Missing Image! Examine the root directory again to see what's changed.
steve@Linux-Steve:/home/steve/projects/petalinux$ ls -la
total 32
drwxr-xr-x  6 steve steve 4096 Nov  7 10:24 .
drwxrwxr-x 62 steve steve 4096 Nov  7 10:15 ..
drwxrwxr-x  6 steve steve 4096 Nov  7 10:30 build
drwxrwxr-x  4 steve steve 4096 Nov  7 10:30 components
-rw-r--r--  1 steve steve  248 Nov  7 10:15 config.project
-rw-rw-r--  1 steve steve  170 Nov  7 10:15 .gitignore
drwxrwxr-x  2 steve steve 4096 Nov  7 10:38 .petalinux
drwxr-xr-x  5 steve steve 4096 Nov  7 10:15 project-spec

5. Configure PetaLinux

Configure PetaLinux to use Network Time Protocol (NTP) to obtain and maintain the correct date & time. Note this requires the Zedboard to be connected to the Internet.

Edit the petalinuxbsp.conf as shown below.
steve@Linux-Steve:/home/steve/projects/petalinux$ subl project-spec/meta-user/conf/petalinuxbsp.conf

petalinuxbsp.conf

  1. #User Configuration

  2. #OE_TERMINAL = "tmux"

  3. IMAGE_INSTALL_append = " ntp ntpdate ntpq sntp"

Remove the auto-login option to stop the console from dropping into a root shell.
steve@Linux-Steve:/home/steve/projects/petalinux$ petalinux-config -c rootfs
Navigate Image Features from the root menu. Missing Image! Unselect the auto-login option from the sub-menu. Missing Image! Select Exit to navigate back to the root menu. Missing Image! Select Exit again to exit the configuration session. Missing Image! Select Yes when prompted to save the new configuration. Missing Image!

6. Build PetaLinux

Set up a transfer directory for the built images.
steve@Linux-Steve:/home/steve/projects/petalinux$ sudo mkdir /tftpboot
steve@Linux-Steve:/home/steve/projects/petalinux$ sudo chmod -R 777 /tftpboot
steve@Linux-Steve:/home/steve/projects/petalinux$ sudo chown -R nobody /tftpboot
Build the PetaLinux project (this takes around 1-2 hours).
steve@Linux-Steve:/home/steve/projects/petalinux$ petalinux-build

7. Package PetaLinux

Package up the PetaLinux project ready for deployment.
steve@Linux-Steve:/home/steve/projects/petalinux$ petalinux-package --prebuilt --force

8. 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$ petalinux-boot --qemu --prebuilt 3

9. Run PetaLinux on Zedboard via JTAG

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

10. Launch terminal emulator

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

11. 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 that the bitstream from the leds_switches project 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 2021.2 petalinux /dev/ttyPS0

petalinux login:
Check for local area network (LAN) connectivity (ping DHCP server).
root@petalinux:~# 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@petalinux:~# 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@petalinux:~# 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

...