Bar
SpaceWire UK
Specialist providers of VHDL Intellectual Property & Design Services
BarBarBarBar
Tutorial
Missing Image!
Part 1 - Installation of tools, setup of environment and creation of project area

Introduction

This tutorial details the steps required for downloading, installing and setting up the Vitis, Vivado, Vitis HLS & PetaLinux tools.

Aims

The aims of this tutorial are as follows :-

    Part 1 - Customize tutorial

    1. Change instructions & commands to match the tutorial to the readers own system (optional)

    Part 2 - Download, install & setup design tools

    1. Download tools
    2. Create installation directories
    3. Install Vitis, Vivado & Vitis HLS
    4. Install PetaLinux dependencies
    5. Install PetaLinux
    6. Install 3rd party tools

    Part 2 - Create common project & useful assistance scripts

    1. Create common project area
    2. Create scripts for initial root project creation, Vivado project recreation & Vitis project recreation
    3. Create scripts for setting up the Xilinx design tools
    4. Setup shell initialization script

    Part 3 - Setup revision control environment

    1. Setup revision control tools & environment

    Part 3 - Perform housekeeping

    1. Cleanup downloads
    2. Remove startup programs

    Part 2 - Revision Control

    1. Create repository & commit files

    Part 6 - Quickstart

    1. Obtain tutorial files from Bitbucket for the common project
    #### Part 1 - Customize tutorial ####

    1. Change instructions & commands to match the tutorial to the readers own system (optional)

    The pages in this tutorial are dynamically reconfigurable to allow marrying up instructions and commands to the readers own system. The options below can be used to change directory locations, IP addresses, usernames and host details. This allows commands to be directly copied into the readers own terminal and executed without the need to edit. Cookies are used to store the modifications such that they are applied to all pages within the same browser session. Note the screenshots will not dynamically change and may not reflect the instructions, the instructions take precedence.

    : Downloads location

    : Projects location

    : Repositories location

    : Linux user (whoami)

    : Linux host (hostname)

    : Zedboard location

    #### Part 2 - Download, install & setup design tools ####

    2. Download tools

    Download the following files from Xilinx & Avnet into ~/Downloads.
    1. Xilinx Unified Installer 2021.2 SFD (71.9 GB)
    2. ZED BSP (117.4 MB)
    3. ZedBoard Master XDC Rev C_D v3 (3.9 KB)

    3. Create installation directories

    Create Xilinx installation directory structure and change its ownership for user installation.
    steve@Desktop:~$ sudo mkdir /opt/Xilinx
    steve@Desktop:~$ sudo chown $(id -un):$(id -gn) /opt/Xilinx

    4. Install Vitis, Vivado & Vitis HLS

    Unzip the tarball & kick off the installation process.
    steve@Desktop:~$ tar -xzf ~/Downloads/Xilinx_Unified_2021.2_1021_0703.tar.gz -C ~/Downloads
    steve@Desktop:~$ ~/Downloads/Xilinx_Unified_2021.2_1021_0703/xsetup
    In the Welcome dialog click Next to proceed. Missing Image! In the Select Product to Install dialog select Vitis and click Next to proceed. Missing Image! In the Vitis Unified Software Platform dialog, expand the menu items and select only what is required based on licensing and disk space. The default is to install everything which uses 192.89 Gb of disk space. The following shows the minimum required to use the ZedBoard with a WebPack license. Once happy with the selections click Next to proceed. Missing Image! In the Accept License Agreements dialog, tick both I Agree boxes and click Next to proceed. Missing Image! In the Select Destination Directory dialog, enter /opt/Xilinx for the installation directory, untick the Create program group entries, untick the Create desktop shortcuts and click Next to proceed. Note the location of DocNav, this is not versioned like Vitis, Vivado & Vitis HLS, hence any existing DocNav installation at this location will be overwritten. Missing Image! In the Installation Summary dialog, review the details provided and click Install to proceed. Missing Image! The Installation Progress dialog will now appear showing the progress of the installation (takes around 45 minutes to complete). Missing Image! Once installation is complete the Xilinx Software Install dialog will appear, click OK to proceed. Missing Image! Depending on what devices were selected for installation will ultimately determine whether or not further dialogs appear regarding licensing arrangements. With just Zynq-7000 selected no further dialogs appear and the WebPack license will be used as default.

    Install the cable drivers to gain access to the Zedboard hardware.
    steve@Desktop:~$ cd /opt/Xilinx/Vivado/2021.2/data/xicom/cable_drivers/lin64/install_script/install_drivers
    steve@Desktop:/opt/Xilinx/Vivado/2021.2/data/xicom/cable_drivers/lin64/install_script/install_drivers$ sudo ./install_drivers
    steve@Desktop:~$ cd ~

    5. Install PetaLinux dependencies

    PetaLinux has a number of dependencies that the installer does not automatically install. These can be found in the 2020.2 PetaLinux Package List spreadsheet along with the command required to install them. To make the installation run smoother the auto-approve option (-y) can be added to the command. For Xubuntu an extra package (libncurses5) is also required. Execute the modified install command to install the dependencies.
    steve@Desktop:~$ sudo apt-get install -y iproute2 gawk python3 python build-essential gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget git-core diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib automake zlib1g:i386 screen pax gzip cpio python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 libncurses5

    6. Install PetaLinux

    Kick off the installation process.
    steve@Desktop:~$ ~/Downloads/Xilinx_Unified_2021.2_1021_0703/xsetup
    In the Welcome dialog click Next to proceed. Missing Image! In the Select Product to Install dialog select PetaLinux (Linux only) and click Next to proceed. Missing Image! In the Select Edition to Install dialog select PetaLinux arm and click Next to proceed. Missing Image! In the Accept License Agreements dialog, tick both I Agree boxes and click Next to proceed. Missing Image! In the Select Destination Directory dialog, enter /opt/Xilinx for the installation directory, untick the Create program group entries, untick the Create desktop shortcuts and click Next to proceed. Missing Image! In the Installation Summary dialog, review the details provided and click Install to proceed. Missing Image! Once installation is complete the Xilinx Software Install dialog will appear, click OK to proceed. Missing Image!

    7. Install 3rd party tools

    Although Vitis does have a terminal emulator built in having a standalone tool kicking around is very desirable. Quite a few are available, however for this tutorial MiniCom will be the tool of choice. If not already installed install it as shown below. Access to the serial port requires superuser privileges, to remove this restriction the user must be added to the dialout group as shown below (log out and back in for this to take effect).
    steve@Desktop:~$ sudo apt-get install minicom
    steve@Desktop:~$ sudo adduser $(id -un) dialout
    Communicating with the Zedboard via MiniCom is achieved as shown below.
    steve@Desktop:~$ minicom -D /dev/ttyACM0 -b 115200
    Squirreling projects away for later retrieval is a must have capability. There are many RCS tools available, however for this tutorial GIT will be the tool of choice. If not already installed install as shown below.
    steve@Desktop:~$ sudo apt-get install -y git
    A decent text editor is a must have, ideally something with good column editing capabilities. There are loads of editors to choose from, however for this tutorial Sublime will be the tool of choice. If not already installed install it as shown below.
    steve@Desktop:~$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
    steve@Desktop:~$ sudo apt-add-repository "deb https://download.sublimetext.com/ apt/stable/"
    steve@Desktop:~$ sudo apt install -y sublime-text
    To add Verilog & VHDL syntax highlighting to Sublime, launch the tool and firstly install Package Control by going to Menu » Tools » Install Package Control.... Now goto Menu » Preferences » Package Control » Install Package and select SystemVerilog. Do the same for VHDL but select Smart VHDL at the end instead of SystemVerilog.

    To achieve remote command line URL access to the Zedboard Client URL (curl) will be used. If not already installed, install as shown below.
    steve@Desktop:~$ sudo apt-get install -y curl
    To copy files to PetaLinux Secure Copy (scp) will be used. To make this easier SSH Password (sshpass) will be used to provided the password to the Secure Copy command. If not already installed, install as shown below.
    steve@Desktop:~$ sudo apt-get install -y sshpass
    #### Part 2 - Create common project & useful assistance scripts ####

    8. Create common project area

    Create root projects directory and a common project to hold shared and general files used across multiple projects (sudo & 2nd command may not be necessary depending on location).
    steve@Desktop:~$ sudo mkdir -p ~/projects
    steve@Desktop:~$ sudo chown $(id -un):$(id -gn) ~/projects
    steve@Desktop:~$ mkdir -p ~/projects/common/{fw/src/{constraint,script},sw/src/{bsp,script},other/src/script}
    Copy Zedboard master constrains into common firmware area.
    steve@Desktop:~$ unzip ~/Downloads/zedboard_master_XDC_RevC_D_v3.zip -d ~/projects/common/fw/src/constraint
    Move Zedboard BSP into common software area.
    steve@Desktop:~$ mv ~/Downloads/avnet-digilent-zedboard-v2021.2-final.bsp ~/projects/common/sw/src/bsp

    9. Create scripts for initial root project creation, Vivado project recreation & Vitis project recreation

    Create a simple shell script to create a new project containing a consistent directory structure that will be used on all new projects.
    steve@Desktop:~$ subl ~/projects/common/other/src/script/create_project_structure.sh

    create_project_structure.sh

    1. #!/bin/bash


    2. #
    3. # File .......... create_project_structure.sh
    4. # Author ........ Steve Haywood
    5. # Version ....... 1.0
    6. # Date .......... 29 December 2021
    7. # Description ...
    8. #   Simple script to create a possible project directory structure for combined
    9. # firmware, hardware, operating system & software development. Very much work
    10. # in progress and by all means not a golden solution to anything.
    11. #


    12. # Print instructions
    13. function print_args {
    14.   printf "\n"
    15.   printf "Create project (FW, HW, OS & SW) directory structure\n"
    16.   printf "\n"
    17.   printf "Usage: %s dir\n" $1
    18.   printf "\n"
    19.   printf "Where: dir .... Project directory to create & populate\n"
    20.   printf "\n"
    21.   printf "Example: %s ~/projects/example_project\n" $1
    22.   printf "Example: %s /usr/projects/hello_world\n" $1
    23.   printf "\n"
    24.   exit 1
    25. }


    26. # Deal with command line arguments
    27. if [ $# != 1 ]; then
    28.   print_args $0
    29. fi


    30. # Get project base directory
    31. base=$1


    32. # Echo operation
    33. echo "Creating project directory structure @ ${base}"


    34. # Project directories
    35. declare -a dirs=(
    36.   # Firmware
    37.   "fw/src/constraint"
    38.   "fw/src/design"
    39.   "fw/src/diagram"
    40.   "fw/src/document"
    41.   "fw/src/ip"
    42.   "fw/src/ip_repo"
    43.   "fw/src/other"
    44.   "fw/src/script"
    45.   "fw/src/testbench"
    46.   "fw/vivado"
    47.   # Hardware
    48.   "hw/src/schematic"
    49.   # Operating System
    50.   "os/src/other"
    51.   # Software
    52.   "sw/src/c"
    53.   "sw/src/other"
    54.   "sw/src/script"
    55.   "sw/vitis"
    56. )


    57. # Iterate through directories
    58. for dir in "${dirs[@]}"
    59. do
    60. #  echo "Creating ... ${base}/${dir}"
    61.   mkdir -p "${base}/${dir}"
    62. done


    63. # Create C source starter file
    64. touch "${base}/sw/src/c/$(basename $base).c"

    Create a shell script and a Tcl script that recreates a Vivado project from base source files.
    steve@Desktop:~$ subl ~/projects/common/fw/src/script/{create_vivado_project.sh,create_vivado_project.tcl}

    create_vivado_project.sh

    1. #!/bin/bash

    2. #
    3. # File .......... create_vivado_project.sh
    4. # Author ........ Steve Haywood
    5. # Version ....... 1.0
    6. # Date .......... 03 May 2021
    7. # Description ...
    8. #   Very simple script to launch Vivado and run the TCL script. Should be run
    9. # in the project host directory that contains the fw & sw subdirectories, for
    10. # example :-
    11. #
    12. # user@host:~/projects/project$ create_vivado_project.sh
    13. # user@host:~/projects/project$ create_vivado_project.sh build
    14. #

    15. # Get command line arguments
    16. if [ $# == 1 ]; then
    17.   arg1=$1
    18. else
    19.   arg1=""
    20. fi

    21. # Get script location
    22. dir_script=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

    23. # Get present working directory
    24. dir_pwd=$(pwd)

    25. # Set directory structure
    26. dir_base="fw"
    27. dir_fw_project="vivado"

    28. # Sanity check directory structure
    29. if [ -d "${dir_pwd}/${dir_base}" ]; then
    30.   if [ ! -e "${dir_pwd}/${dir_base}/${dir_fw_project}" ]; then

    31.     # Launch Vivado
    32.     if [ "$arg1" == "build" ]; then
    33.       vivado -nojournal -nolog -notrace -mode gui -source "${dir_script}/create_vivado_project.tcl" -tclargs build &
    34.     else
    35.       vivado -nojournal -nolog -notrace -mode gui -source "${dir_script}/create_vivado_project.tcl" &
    36.     fi

    37.   else
    38.     echo "Error: Firmware project directory \"${dir_base}/${dir_fw_project}\" already exists, exiting."
    39.   fi
    40. else
    41.   echo "Error: Firmware base directory \"${dir_base}\" does not exists, exiting."
    42. fi

    create_vivado_project.tcl

    1. #
    2. # File .......... create_vivado_project.tcl
    3. # Author ........ Steve Haywood
    4. # Version ....... 1.0
    5. # Date .......... 23 December 2021
    6. # Description ...
    7. #   Simple Tcl script to create a new Vivado project, import external
    8. # sources and (optionally) generate the bitstream & export the hardware.
    9. #

    10. puts "Set Global variables"
    11. set dir_firmware    "fw/vivado"
    12. set dir_user        "../src"
    13. set dir_diagram     "$dir_user/diagram"
    14. set dir_design      "$dir_user/design"
    15. set dir_ip          "$dir_user/ip"
    16. set dir_ip_repo     "$dir_user/ip_repo"
    17. set dir_constraint  "$dir_user/constraint"
    18. set dir_testbench   "$dir_user/testbench"
    19. set dir_script      "$dir_user/script"

    20. puts "NOTE: Create project directory, project & change PWD"
    21. create_project project $dir_firmware -part xc7z020clg484-1
    22. cd $dir_firmware

    23. puts "NOTE: Add local IP Repository"
    24. if {[file exist $dir_ip_repo]} {
    25.   set_property  ip_repo_paths  $dir_ip_repo [current_project]
    26.   update_ip_catalog
    27. }

    28. puts "NOTE: Add scripts"
    29. add_files -quiet -norecurse -fileset utils_1 $dir_script
    30. set tcls [get_files *.tcl]
    31. foreach tcl $tcls {
    32.   set tcl_name [file tail $tcl]
    33.   switch $tcl_name {
    34.     "pre_synth.tcl" {
    35.       set_property STEPS.SYNTH_DESIGN.TCL.PRE [ get_files $tcl -of [get_fileset utils_1] ] [get_runs synth_1]
    36.     }
    37.     "post_bit.tcl" {
    38.       set_property STEPS.WRITE_BITSTREAM.TCL.POST [ get_files $tcl -of [get_fileset utils_1] ] [get_runs impl_1]
    39.     }
    40.     default {
    41.       puts "NOTE: Unfamiliar tcl script found - $tcl_name"
    42.     }
    43.   }
    44. }

    45. puts "NOTE: Add block designs"
    46. add_files -quiet -norecurse [glob -nocomplain "$dir_diagram/*/*.bd"]

    47. puts "NOE: Add design sources"
    48. add_files -quiet -norecurse $dir_design

    49. puts "NOTE: Add IPs"
    50. add_files -quiet [glob -nocomplain "$dir_ip/*/*.xci"]

    51. puts "NOTE: Add constraints"
    52. add_files -quiet -norecurse -fileset constrs_1 $dir_constraint

    53. puts "NOTE: Add testbench sources"
    54. add_files -quiet -norecurse -fileset sim_1 $dir_testbench

    55. puts "NOTE: Recreate (by opening) all block designs..."
    56. set bds [glob -nocomplain "$dir_diagram/*/*.bd"]
    57. foreach bd $bds {
    58.   puts "NOTE: Open \"$bd\" block design"
    59.   open_bd_design $bd
    60. }

    61. puts "NOTE: Generate all (none-overwrite) block designs wrappers..."
    62. set bds [get_bd_designs -quiet]
    63. foreach bd $bds {
    64.   puts "NOTE: Generate \"$bd\" block design wrapper"
    65.   set bd_file [get_files $bd.bd]
    66.   set bd_path [file dirname $bd_file]
    67.   set wrapper_files [glob -nocomplain $bd_path/hdl/${bd}_wrapper.*]
    68.   if {[llength $wrapper_files] == 0} {
    69.     set wrapper_file [make_wrapper -files $bd_file -top]
    70.   }
    71.   add_files -quiet -norecurse $bd_path/hdl
    72. }

    73. puts "NOTE: Close all block designs..."
    74. set bds [get_bd_designs -quiet]
    75. foreach bd $bds {
    76.   puts "NOTE: Close \"$bd\" block design"
    77.   close_bd_design $bd
    78. }

    79. puts "NOTE: Check for build argument..."
    80. if { $argc == 1 } {
    81.   set arg0 [lindex $argv 0]
    82.   if { $arg0 == "build" } {
    83.     puts "NOTE: Generate bitstream & export hardware"
    84.     launch_runs impl_1 -to_step write_bitstream -jobs 4
    85.     wait_on_run impl_1
    86.     write_hw_platform -fixed -include_bit -force -file ../system_wrapper.xsa
    87.   }
    88. }

    89. puts "NOTE: That's all folks!"

    Create a shell script and a Tcl script that recreates a Vitis project from base source files.
    steve@Desktop:~$ subl ~/projects/common/sw/src/script/{create_vitis_project.sh,create_vitis_project.tcl}

    create_vitis_project.sh

    1. #!/bin/bash

    2. #
    3. # File .......... create_vitis_project.sh
    4. # Author ........ Steve Haywood
    5. # Version ....... 1.0
    6. # Date .......... 03 May 2021
    7. # Description ...
    8. #   Very simple script to launch the Xilinx software command-line tool,
    9. # run the TCL script and launch Vitis. Should be run in the project host
    10. # directory that contains the fw & sw subdirectories, for example :-
    11. #
    12. # user@host:~/projects/project$ create_vitis_project.sh
    13. # user@host:~/projects/project$ create_vitis_project.sh build
    14. #

    15. # Get command line arguments
    16. if [ $# == 1 ]; then
    17.   arg1=$1
    18. else
    19.   arg1=""
    20. fi

    21. # Get script location
    22. dir_script=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

    23. # Get present working directory
    24. dir_pwd=$(pwd)

    25. # Set directory structure
    26. dir_base="sw"
    27. dir_sw_project="vitis"

    28. # Sanity check directory structure
    29. if [ -d "${dir_pwd}/${dir_base}" ]; then
    30.   if [ ! -e "${dir_pwd}/${dir_base}/${dir_sw_project}" ]; then

    31.     # Get last element of path (project name)
    32.     dir_project=${dir_pwd##*/}

    33.     # Call Xilinx Software Commandline Tool
    34.     if [ "$arg1" == "build" ]; then
    35.       xsct "${dir_script}/create_vitis_project.tcl" "${dir_project}" build
    36.     else
    37.       xsct "${dir_script}/create_vitis_project.tcl" "${dir_project}"
    38.     fi

    39.     # Launch Vitis
    40.     vitis -workspace "${dir_base}/${dir_sw_project}" &

    41.   else
    42.     echo "Error: Software project directory \"${dir_base}/${dir_sw_project}\" already exists, exiting."
    43.   fi
    44. else
    45.   echo "Error: Software base directory \"${dir_base}\" does not exists, exiting."
    46. fi

    create_vitis_project.tcl

    1. #
    2. # File .......... create_vitis_project.tcl
    3. # Author ........ Steve Haywood
    4. # Version ....... 1.0
    5. # Date .......... 21 Dec 2021
    6. # Description ...
    7. #   Simple Tcl script to create a new Vitis application, import external
    8. # sources and (optionally) build the application.
    9. #

    10. # Check for project name argument, exit if not found.
    11. if { $argc == 0 } {
    12.   puts "Error: No project name provided, exiting..."
    13.   exit 1
    14. }
    15. set project [lindex $argv 0]

    16. # Create and build new project.
    17. setws sw/vitis
    18. app create -name $project -hw fw/system_wrapper.xsa -os standalone -proc ps7_cortexa9_0 -template {Empty Application(C)}
    19. set abs_path [file normalize sw/src/c]
    20. importsources -name $project -path $abs_path -soft-link
    21. if { $argc > 1 } {
    22.   set arg1 [lindex $argv 1]
    23.   if { $arg1 == "build" } {
    24.     app build -name $project
    25.   }
    26. }

    Set execute permission on the shell scripts.
    steve@Desktop:~$ chmod +x ~/projects/common/other/src/script/create_project_structure.sh
    steve@Desktop:~$ chmod +x ~/projects/common/fw/src/script/create_vivado_project.sh
    steve@Desktop:~$ chmod +x ~/projects/common/sw/src/script/create_vitis_project.sh

    10. Create scripts for setting up the Xilinx design tools

    Create a simple shell script to setup the PetaLinux, Vitis & Vivado 2021.2 tool paths.
    steve@Desktop:~$ subl ~/projects/common/other/src/script/xilinx_2021_2.sh

    xilinx_2021_2.sh

    1. #!/bin/bash

    2. # Setup Vitis, Vivado, Vitis HLS & DocNav environment
    3. source /opt/Xilinx/Vivado/2021.2/settings64.sh
    4. # Setup PetaLinux environment
    5. source /opt/Xilinx/PetaLinux/2021.2/tool/settings.sh

    If multiple versions of the tools are required then having a more comprehensive shell script that detects and allows the selection of specific tool versions can be very useful. Create this script as shown below.
    steve@Desktop:~$ subl ~/projects/common/other/src/script/xilinx.sh

    xilinx.sh

    1. #!/bin/bash

    2. #
    3. # File .......... xilinx.sh
    4. # Author ........ Steve Haywood
    5. # Version ....... 1.0
    6. # Date .......... 8 February 2021
    7. # Description ...
    8. #   Determine and list which Xilinx tools are available and let the user select
    9. # the require ones to use. Does not reverse any previously selected tools upon
    10. # selecting news ones so to is cleaner to use in a new Terminal session.
    11. #

    12. # Define install base location
    13. dir_base="/opt/Xilinx"

    14. # Define number of tools (Vivado, SDK, Vitis & PetaLinux)
    15. tools=4

    16. # Define tool directories, executables & settings scripts
    17. dir_tool=("Vivado" "SDK" "Vitis" "PetaLinux")
    18. exe_tool=("vivado" "xsdk" "vitis" "petalinux-build")
    19. set_tool=("settings64.sh" "settings64.sh" "settings64.sh" "tool/settings.sh")

    20. # Define terminal colours
    21. col_default=$(tput sgr0)
    22. col_red=$(tput setaf 1)
    23. col_green=$(tput setaf 2)
    24. col_blue=$(tput setaf 4)
    25. col_fail_pass=(${col_red} ${col_green})

    26. # Exit if script wasn't sourced
    27. if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    28.   printf "Script needs to be sourced : source ${BASH_SOURCE[0]}\n"
    29.   exit 1
    30. fi

    31. # Get array of directories at base location
    32. readarray -t dirs < <(find "${dir_base}/${dir_tool[0]}" -mindepth 1 -maxdepth 1 -printf '%P\n')

    33. # Sort directories array
    34. dirs=($(IFS=$'\n'; echo "${dirs[*]}" | sort))

    35. # Determine and list what tools are installed
    36. declare -A table
    37. printf "Xilinx tools available tools at ${dir_base} :-\n"
    38. for ((dir=1; dir<=${#dirs[@]}; dir++)); do
    39.   printf "${dir}) ${dirs[$((dir-1))]}"
    40.   for ((tool=0; tool<${tools}; tool++)); do
    41.     table[${dir}, ${tool}]=$([ ! -d "${dir_base}/${dir_tool[${tool}]}/${dirs[$((dir-1))]}" ]; echo $?)
    42.     printf "${col_default} - "
    43.     printf "${col_fail_pass[${table[${dir}, ${tool}]}]}"
    44.     printf "${dir_tool[${tool}]}"
    45.     printf "${col_default}"
    46.   done
    47.   printf "\n"
    48. done
    49. printf "0) Exit\n"
    50. printf "Please select tools required or exit"

    51. # Obtain user input and source settings for selected tools
    52. while true; do
    53.   read -p " : " sel
    54.   if ! [[ "${sel}" =~ ^[0-9]+$ ]] ; then
    55.     # User input is not a number
    56.     printf "Invalid choice, select again"
    57.   elif [ ${sel} -ge 1 ] && [ ${sel} -le ${#dirs[@]} ]; then
    58.     # User input is out of range
    59.     printf "\nTools are as follows :-\n" "${sel}"
    60.     for ((tool=0; tool<${tools}; tool++)); do
    61.       if [ ${table[${sel}, ${tool}]} -eq 1 ]; then
    62.         source "${dir_base}/${dir_tool[${tool}]}/${dirs[$((sel - 1))]}/${set_tool[${tool}]}" > /dev/null 2>&1
    63.         printf "${col_blue}${exe_tool[${tool}]}${col_default} @ "
    64.         bin=$(which "${exe_tool[${tool}]}")
    65.         if [ -z ${bin} ]; then
    66.           printf "${col_red}Not found!"
    67.         else
    68.           printf "${col_green}%s" "${bin}"
    69.         fi
    70.         printf "${col_default}\n"
    71.       fi
    72.     done
    73.     break
    74.   elif [ ${sel} -eq 0 ]; then
    75.     printf "Quiting without selection!\n"
    76.     break
    77.   else
    78.     printf "Invalid choice, select again"
    79.   fi
    80. done

    Set execute permission on the shell scripts.
    steve@Desktop:~$ chmod +x ~/projects/common/other/src/script/{xilinx_2021_2.sh,xilinx.sh}
    Execution of the above latter script will yield something similar to what is shown below.
    steve@Desktop:~$ source ~/projects/common/other/src/script/xilinx.sh
    Xilinx tools available tools at /opt/Xilinx :-
    1) 2013.4 - Vivado - SDK - Vitis - PetaLinux
    2) 2015.2 - Vivado - SDK - Vitis - PetaLinux
    3) 2019.1 - Vivado - SDK - Vitis - PetaLinux
    4) 2020.2 - Vivado - SDK - Vitis - PetaLinux
    5) 2021.2 - Vivado - SDK - Vitis - PetaLinux
    0) Exit
    Please select tools required or exit : 5

    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

    11. Setup shell initialization script

    Make life easier by adding useful aliases and search paths within the shell initialization script.
    steve@Desktop:~$ subl ~/.bashrc

    .bashrc (partial)

    1. # Aliases
    2. alias xilinx='source xilinx.sh'
    3. alias minized='minicom -D /dev/ttyACM0 -b 115200'

    4. # Paths
    5. PATH="~/projects/common/fw/src/script:"$PATH
    6. PATH="~/projects/common/other/src/script:"$PATH
    7. PATH="~/projects/common/sw/src/script:"$PATH
    #### Part 3 - Setup revision control environment ####

    12. Setup revision control tools & environment

    If GIT provision are not already in place then a GIT server can easily be established. The example below shows the setup for a remote Linux Server (Ubuntu Server 20.04 LTS) and a local Linux Desktop (Xubuntu Desktop 20.04 LTS). The Server will be used to host the repositories and the Desktop used to access them.

    Open up two terminals, one for the Desktop and one for the Server.

    Create a new user on the Server called git and create the SSH directory structure.
    steve@Desktop:~$ ssh 192.168.2.20
    steve@Server:~$ sudo useradd -r -m -U -d /home/git -s /bin/bash git
    steve@Server:~$ sudo su - git
    git@Server:~$ mkdir .ssh
    git@Server:~$ chmod 0700 .ssh
    git@Server:~$ touch .ssh/authorized_keys
    git@Server:~$ chmod 0600 .ssh/authorized_keys
    Check for the existence of a SSH key pair on the Desktop.
    steve@Desktop:~$ cat .ssh/id_rsa.pub
    If the return from the above is No such file or directory then create a SSH key pair on the Desktop. Press enter at the key location prompt to use the suggested location. Enter a password at the passphase prompt and confirm this at the next passphase prompt.
    steve@Desktop:~$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/steve/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    The key fingerprint is:
    SHA256:0l/Upmt2lqfE81I72v5Zm5/mOR3L8/2Mr5Wjwi805Pg steve@Desktop
    The key's randomart image is:
    +---[RSA 4096]----+
    |                 |
    |             .   |
    |            . o  |
    |       .   o o   |
    |      . S + o    |
    |       . o = o oo|
    |          = = O+O|
    |           E ++^@|
    |            ++O&^|
    +----[SHA256]-----+
    Copy the already existing or newly generated Public Key to the Server.
    steve@Desktop:~$ scp ~/.ssh/id_rsa.pub steve@192.168.2.20:/home/steve
    Add the copied Public Key to the Authorized Keys on the Server and then delete the copied Public Key.
    git@Server:~$ cat /home/steve/id_rsa.pub >> .ssh/authorized_keys
    git@Server:~$ sudo rm /home/steve/id_rsa.pub
    Perform a quick check to ensure that everything is working as expected.

    Create an example repository on the Server.
    git@Server:~$ git init --bare example.git
    Setup GIT credentials on the Desktop.
    steve@Desktop:~$ git config --global user.email your@email_address
    steve@Desktop:~$ git config --global user.name "Your Name"
    Clone the example repository on the Desktop, add a new file, commit the changes to the staging area and then push the changes back to the Server. Check status throughout.
    steve@Desktop:~$ cd /tmp
    steve@Desktop:/tmp$ git clone git@192.168.2.20:example.git
    Cloning into 'example'...
    warning: You appear to have cloned an empty repository.
    steve@Desktop:/tmp$ cd example
    steve@Desktop:/tmp/example$ git status
    On branch master

    No commits yet

    nothing to commit (create/copy files and use "git add" to track)
    steve@Desktop:/tmp/example$ echo "Some wise words required..." > readme.txt
    steve@Desktop:/tmp/example$ git status
    On branch master

    No commits yet

    Untracked files:
      (use "git add <file>..." to include in what will be committed)
      readme.txt

    nothing added to commit but untracked files present (use "git add" to track)
    steve@Desktop:/tmp/example$ git add readme.txt
    steve@Desktop:/tmp/example$ git status
    On branch master

    No commits yet

    Changes to be committed:
      (use "git rm --cached <file>..." to unstage)
      new file:   readme.txt
    steve@Desktop:/tmp/example$ git commit -m "Added readme file, alas no wise words yet!"
    [master (root-commit) cac7986] Added readme file, alas no wise words yet!
    1 file changed, 1 insertion(+)
    create mode 100644 readme.txt
    steve@Desktop:/tmp/example$ git status
    On branch master
    Your branch is based on 'origin/master', but the upstream is gone.
      (use "git branch --unset-upstream" to fixup)

    nothing to commit, working tree clean
    steve@Desktop:/tmp/example$ git push
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 258 bytes | 258.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To 192.168.2.20:example.git
    * [new branch]      master -> master
    steve@Desktop:/tmp/example$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.

    nothing to commit, working tree clean
    Clone the repository again, this time into a named directory. Check the new file does indeed exist.
    steve@Desktop:/tmp/example$ cd ..
    steve@Desktop:/tmp$ git clone git@192.168.2.20:example.git example_check
    Cloning into 'example_check'...
    remote: Enumerating objects: 3, done.
    remote: Counting objects: 100% (3/3), done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (3/3), done.
    steve@Desktop:/tmp$ cd example_check
    steve@Desktop:/tmp/example_check$ cat readme.txt
    Some wise words required...
    steve@Desktop:/tmp/example_check$ git log
    commit cac798667af67d2ed245672cb36a786f0c3208ed (HEAD -> master, origin/master, origin/HEAD)
    Author: Steve <steve@Desktop>
    Date:   Thu Dec 30 12:24:54 2021 +0000

        Added readme file, alas no wise words yet!
    #### Part 3 - Perform housekeeping ####

    13. Cleanup downloads

    Delete the unzipped installer directory and either delete or archive the installer tarball. Delete the constraints archive.
    steve@Desktop:~$ rm -r ~/Downloads/Xilinx_Unified_2021.2_1021_0703
    steve@Desktop:~$ # rm ~/Downloads/Xilinx_Unified_2021.1_0610_2318.tar.gz
    steve@Desktop:~$ rm ~/Downloads/zedboard_master_XDC_RevC_D_v3.zip

    14. Remove startup programs

    Remove the Xilinx Information Center from the list of autostart application by going to Xubuntu's Whisper Menu and navigating to Settings » Session and Startup. Click on the Application Autostart tab within the Session and Startup window, untick Xilinx Information Center and then click Close.
    #### Part 2 - Revision Control ####

    15. Create repository & commit files

    Create a fresh repository for the common project, commit the newly added files and push the commit up to the remote repository.
    steve@Desktop:~$ ssh -t git@192.168.2.20 'git init --bare common.git'
    steve@Desktop:~$ cd ~/projects/common
    steve@Desktop:~/projects/common$ git init
    steve@Desktop:~/projects/common$ git add -A
    steve@Desktop:~/projects/common$ git commit -m "Initial commit of common files."
    steve@Desktop:~/projects/common$ git remote add origin git@192.168.2.20:common.git
    steve@Desktop:~/projects/common$ git push -u origin master
    #### Part 6 - Quickstart ####

    16. Obtain tutorial files from Bitbucket for the common project

    The tutorial files can be obtained from Bitbucket for the common project.

    If the common project is not already present, clone it from the repository.
    steve@Desktop:~$ cd ~/projects
    steve@Desktop:~/projects$ git clone https://bitbucket.org/spacewire_firmware/common
    If the common project is present, update it to the latest version.
    steve@Desktop:~$ cd ~/projects/common
    steve@Desktop:~/projects/common$ git pull