Bar
SpaceWire UK
Specialist providers of VHDL Intellectual Property & Design Services
BarBarBarBar
Tutorial
Missing Image!
Part 7 - Create & test a PetaLinux application that runs automatically at startup

Introduction

This tutorial details the steps required to build an application into PetaLinux that will run at boot time.

Aims

The aims of this tutorial are as follows :-

    Part 1 - Project Setup

    1. Setup environment
    2. Change present working directory

    Part 2 - Create auto-run application

    1. Create auto-run application

    Part 3 - Build & package PetaLinux

    1. Build PetaLinux
    2. Package PetaLinux

    Part 4 - 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 6 - Revision Control

    1. Commit to repository

    Part 5 - 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

    Change the present working directory to be the project directory.
    steve@Desktop:~$ cd ~/projects/zedboard_linux/os/petalinux
    #### Part 2 - Create auto-run application ####

    3. Create auto-run application

    Create a blank application component (auto enabled).
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-create --type apps --template install --name led-runner --enable
    Change the default source code to do something a little more obvious.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ subl project-spec/meta-user/recipes-apps/led-runner/files/led-runner

    led-runner

    1. #!/bin/sh

    2. poke 0x41200000 0x18
    3. usleep 125000
    4. poke 0x41200000 0x3C
    5. usleep 125000
    6. poke 0x41200000 0x7E
    7. usleep 125000
    8. poke 0x41200000 0xFF
    9. usleep 125000
    10. poke 0x41200000 0x7E
    11. usleep 125000
    12. poke 0x41200000 0x3C
    13. usleep 125000
    14. poke 0x41200000 0x18
    15. usleep 125000
    16. poke 0x41200000 0x00

    Change the BitBake receipe to make it suitable for an auto-start application.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ subl project-spec/meta-user/recipes-apps/led-runner/led-runner.bb

    led-runner.bb

    1. #
    2. # This file is the led-runner recipe.
    3. #
    4. SUMMARY = "Simple led-runner application"
    5. SECTION = "PETALINUX/apps"
    6. LICENSE = "MIT"
    7. LIC_FILES_CHKSUM ="file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

    8. SRC_URI = "file://led-runner"

    9. S = "${WORKDIR}"

    10. FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

    11. inherit update-rc.d

    12. INITSCRIPT_NAME = "led-runner"
    13. INITSCRIPT_PARAMS = "start 99 S ."

    14. do_install() {
    15.   install -d ${D}${sysconfdir}/init.d
    16.   install -m 0755 ${S}/led-runner ${D}${sysconfdir}/init.d/led-runner
    17. }
    18. FILES_${PN} += "${sysconfdir}/*"

    #### Part 3 - Build & package PetaLinux ####

    4. Build PetaLinux

    Rebuild the project to include the updated files.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ petalinux-build

    5. Package PetaLinux

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

    6. 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.

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

    8. Run PetaLinux on Zedboard via JTAG

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

    9. Check everything is working as expected

    The following sequence of events should be observed.
    #### Part 6 - Revision Control ####

    10. Commit to repository

    Add and commit the new & updated files, create an annotated tag and push the commit & tag up to the remote repository.
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ git add project-spec/meta-user/recipes-apps/led-runner
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ git commit -am "Added & enabled LED runner auto-start application."
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ git tag -a v3.0 -m "PetaLinux, Peek/Poke & LED Runner with XSA from zedboard_leds_switches v1.0"
    steve@Desktop:~/projects/zedboard_linux/os/petalinux$ git push
    #### Part 5 - Quickstart ####

    11. 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 v3.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