Bar
SpaceWire UK
Specialist providers of VHDL Intellectual Property & Design Services
BarBarBarBar
Tutorial
Missing Image!
Part 5 - 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 :-

    Part 1 - Project Setup

    1. Setup environment
    2. Change present working directory

    Part 2 - Create PetaLinux project & configure it

    1. Create PetaLinux project
    2. Add Hardware Platform
    3. Configure PetaLinux

    Part 3 - Revision Control

    1. Create repository & commit files

    Part 4 - Build & package PetaLinux

    1. Build PetaLinux
    2. Package PetaLinux

    Part 5 - Emulator Deployment

    1. Run PetaLinux on QEMU

    Part 6 - Hardware Deployment

    1. Setup Zedboard hardware
    2. Launch MiniCom terminal emulator
    3. Run PetaLinux on Zedboard via JTAG
    4. Check everything is working as expected

    Part 7 - Quickstart

    1. Obtain tutorial files from Bitbucket, create & build project, deploy on Zedboard
    #### Part 1 - Project Setup ####

    1. Setup environment

    Setup Xilinx design environment for the 2021.2 toolset.
    steve@Desktop:~$ xilinx
    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

    Create the root project directory structure and change the present working directory (pwd) to be inside the OS part.
    steve@Desktop:~$ create_project_structure.sh ~/projects/zedboard_linux
    Creating project directory structure @ ~/projects/zedboard_linux
    steve@Desktop:~$ cd ~/projects/zedboard_linux/os
    #### Part 2 - Create PetaLinux project & configure it ####

    3. Create PetaLinux project

    Create a PetaLinux project using the Zynq FPGA template.
    steve@Desktop:~/projects/zedboard_linux/os$ petalinux-create --type project --template zynq --name petalinux
    Examine the project directory.
    steve@Desktop:~/projects/zedboard_linux/os$ cd petalinux
    steve@Desktop:~/projects/zedboard_linux/os/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 zedboard_leds_switches Vivado project.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-config --get-hw-description ../../../zedboard_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@Desktop:~/projects/zedboard_linux/os/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@Desktop:~/projects/zedboard_linux/os/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@Desktop:~/projects/zedboard_linux/os/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! Set up a transfer directory for the built images.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ sudo mkdir /tftpboot
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ sudo chmod -R 777 /tftpboot
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ sudo chown -R nobody /tftpboot
    #### Part 3 - Revision Control ####

    6. Create repository & commit files

    Create a fresh repository and commit the newly created & configured project along with its hardware platform. Create an annotated tag and push the commit & tag up to the remote repository.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ ssh -t git@192.168.2.20 'git init --bare zedboard_linux.git'
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ cd ../..
    steve@Desktop:~/projects/zedboard_linux$ git init
    steve@Desktop:~/projects/zedboard_linux$ git add -A
    steve@Desktop:~/projects/zedboard_linux$ git commit -m "Initial PetaLinux project configured for ZYNQ and using the XSA from zedboard_leds_switches v1.0."
    steve@Desktop:~/projects/zedboard_linux$ git tag -a v1.0 -m "PetaLinux with XSA from zedboard_leds_switches v1.0"
    steve@Desktop:~/projects/zedboard_linux$ git remote add origin git@192.168.2.20:zedboard_linux.git
    steve@Desktop:~/projects/zedboard_linux$ git push -u origin master
    steve@Desktop:~/projects/zedboard_linux$ cd os/petalinux
    #### Part 4 - Build & package PetaLinux ####

    7. Build PetaLinux

    Build the PetaLinux project (this takes around 20 minutes, hardware dependent).
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-build

    8. Package PetaLinux

    Package up the PetaLinux project ready for deployment.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-package --prebuilt --force
    #### Part 5 - Emulator Deployment ####

    9. 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@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-boot --qemu --prebuilt 3
    #### Part 6 - Hardware Deployment ####

    10. Setup Zedboard hardware

    Connect up the hardware as follows :-
    1. Xubuntu PC USB ⇄ Zedboard USB JTAG/Debug
    2. Xubuntu PC USB ⇄ Zedboard USB UART
    3. Zedboard Ethernet ⇄ Router
    4. Xubuntu PC Ethenet ⇄ Router
    5. Router ⇄ Internet
    Missing Image! Set the boot mode jumpers on the Zedboard for JTAG. Missing Image! Power on the Zedboard.

    11. Launch MiniCom terminal emulator

    If not already running, open up a new terminal and launch the MiniCom terminal emulator.
    steve@Desktop:~$ minized

    Welcome to minicom 2.7.1

    OPTIONS: I18n
    Compiled on Dec 23 2019, 02:06:26.
    Port /dev/ttyACM0, 06:34:25

    Press CTRL-A Z for help on special keys

    12. Run PetaLinux on Zedboard via JTAG

    Power cycle the Zedboard and deploy the project via JTAG.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-boot --jtag --prebuilt 3

    13. Check everything is working as expected

    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 zedboard_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

    ...
    As with all connected equipment it is highly recommended to assign a fixed IP address to the Zedboard via the DHCP server, in this case 192.168.2.87.
    #### Part 7 - Quickstart ####

    14. Obtain tutorial files from Bitbucket, create & build project, deploy on Zedboard

    The source files relating to this tutorial for the OS can be obtained from Bitbucket. The OS repository contains both PetaLinux and a local copy of the exported hardware (firmware).

    The instructions below assume that Part 1 - Installation of tools, setup of environment and creation of project area has been completed in full and that the environment has been setup as per 1. Setup environment. The root project area ~/projects should be present and contain the common project. The zedboard_linux projects should NOT be present. Adjust the commands below to suit if the above differs.

    Obtain OS source, build & deploy on Zedboard.
    steve@Desktop:~$ cd ~/projects
    steve@Desktop:~/projects$ git clone -b v1.0 https://bitbucket.org/spacewire_firmware/zedboard_linux
    steve@Desktop:~/projects$ cd zedboard_linux/os/petalinux
    Do something with the OS (if required) then perform the following steps :-
    1. Build PetaLinux
    2. Package PetaLinux
    3. Setup Zedboard hardware
    4. Launch MiniCom terminal emulator
    5. Run PetaLinux on Zedboard via JTAG
    6. Check everything is working as expected