Skip to content

System Setup

Brandon Perez edited this page Aug 2, 2016 · 2 revisions

Back to Home

Overview

This wiki outlines how to setup your host machine for compiling the code necessary to boot Linux on Xilinx's Zynq-7000 series process (Zedboard tested). It also shows how to setup your host machine for compiling the AXI DMA driver and userspace library.

System Configuration

These instructions were run and tested with the following software and hardware:

  • Laptop OS: Ubuntu 14.04 (64-bit)
  • Board OS: Ubuntu 14.04 (32-bit)
  • Board: Zedboard
  • Xilinx Tools:
    • Vivado Version: 2015.2
    • Xilinx SDK Version: 2015.2
    • Vivado HLS Version: 2015.2

Package Dependencies

Install the build tools, ARM cross-compiler, and serial console utilities:

sudo apt-get install -y git cmake pkg-config
sudo apt-get install -y dh-autoreconf xutils-dev gettext
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
sudo apt-get install -y screen minicom

Install package dependencies for U-Boot and the Linux Kernel:

sudo apt-get install -y libssl-dev
sudo apt-get install -y u-boot-tools
sudo apt-get install -y libncurses5-dev
sudo apt-get install -y device-tree-compiler

Install package dependencies for the core filesystem and chroot:

sudo apt-get install -y qemu-user-static

Install package dependendies for NFS and TFTP boots:

sudo apt-get install -y nfs-common nfs-kernel-server
sudo apt-get install -y tftpd-hpa

Environment Setup

Put Xilinx's Vivado, SDK, HLS, and cross-compilation tools in your $PATH:

cat << "EOF" >> "${HOME}/.bashrc"

export XILINX_ROOT=/opt/Xilinx/
export XILINX_VERSION=2015.2
export PATH=${PATH}:${XILINX_ROOT}/Vivado/${XILINX_VERSION}/bin/
export PATH=${PATH}:${XILINX_ROOT}/SDK/${XILINX_VERSION}/gnu/arm/lin/bin/
export PATH=${PATH}:${XILINX_ROOT}/SDK/${XILINX_VERSION}/bin/
export PATH=${PATH}:${XILINX_ROOT}/Vivado_HLS/${XILINX_VERSION}/bin/
EOF

If you installed Xilinx elsewhere, or you're using a different version, change XILINX_ROOT and XILINX_VERSION appropriately.

Setup an environment variable for the number of threads to use for compilation (this will be referenced in later steps):

export THRS=$((2 * `cat /proc/cpuinfo | grep processor | wc -l`))

Create the directory structure. Define where the top-level directory where all project files will be placed (this will be referenced in later steps):

export SW_DIR=<Desired location for your software>
mkdir -p "${SW_DIR}"
mkdir -p "${SW_DIR}/boot_files"
mkdir -p "${SW_DIR}/config"

It is recommended that you put the SW_DIR and THRS variables in your .bashrc file.

Update your shell's environment variables with the new values:

source "${HOME}/.bashrc"

Clone U-Boot and Linux Repositories

Clone the Xilinx U-boot repository:

git clone https://github.com/Xilinx/u-boot-xlnx.git "${SW_DIR}/uboot"

Clone the Xilinx Linux Kernel repository (also contains the device tree):

git clone https://github.com/Xilinx/linux-xlnx.git "${SW_DIR}/linux"

Clone the AXI DMA Repository

If you're planning on using the AXI DMA library and driver, then clone this repository:

git clone https://github.com/bperez77/xilinx_axidma "${SW_DIR}/xilinx_axidma"

Setup the chroot-full Command

The Ubuntu Core Filesystem essentially provides the bare minimum to run a userspace environment on a given board. It is missing a few features that are nice, but not necessary. Thus, we will want to install additional packages (e.g. libraries or utilities like an OpenSSH server). Naturally, these packages can be installed when running the board. However, since a local copy of the board's root filesystem will live on the host machine, they can also be installed on the host side by using the chroot command. This is easier and quicker than installing on the board, because you don't need to setup the network connection for the board, and the host is faster than the board.

In order to give chroot a good environment to run commands in, we need to provide it with versions of the special system files (e.g. /dev, /proc, etc.). This can be done by binding the host machine's system files to the board's root filesystem. We need to be careful that these bindings are unmounted after we exit the chroot; leaving them mounted could lead to system corruption if, for example, you decide to remove the root filesystem.

To that end, it's best if the setup is left to a function or alias to prevent that problem. Thus, we will define the function chroot-full to chroot into the board's root filesystem. Add this function to your .bashrc:

cat << "EOF" >> "${HOME}/.bashrc"

function chroot-full {
    num_args=$#
    if [ $num_args -ne 1 ]; then
        echo "Error: Improper number of command line arguments"
        echo "Usage: chroot-full <rootfs_path>"
        return
    fi

    fs_root=$1

    for mod in /sys /proc /dev /dev/pts /etc/resolv.conf
    do
        sudo mount -o bind $mod "$fs_root/$mod"
    done

    sudo LC_ALL=C chroot "$fs_root"

    for dev in /sys /proc /dev/pts /dev /etc/resolv.conf
    do
        sudo umount "$fs_root/$dev"
    done
}
EOF

Note that anywhere the chroot-full command is run, you can also run the command directly on the Xilinx board as the root user to achieve the same effect.

Since the root filesystem is targeted at a different architecture (ARM), it contains executables targeted for that architecture. Thus, we need an emulator to virtualize the executables' instructions. QEMU can accomplish this, and provides this functionality through the package qemu-user-static.

Last, make sure to update your shell environment with this new function:

source "${HOME}/.bashrc"

Next Steps

With the prerequisites installed, we can now setup the root filesystem for the Zedboard.

For creating the root filesystem, see Create a Root Filesystem

References

The chroot-full instruction was taken from the Texas Instruments Xen J6 Setup Wiki Page - Wiki Page

Files