Skip to content

Create a Root Filesystem

Brandon Perez edited this page Mar 20, 2017 · 6 revisions

Back to Home

Overview

This wiki describes how to setup a root filesystem for the Zedboard. This is used to run the userspace environment, and provide a place to store files.

Prerequisites

Your host machine must be setup according to the method outlined in System Setup.

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

  • Board Architecture: ARM

  • Xilinx Tools:

    • Vivado Version: 2015.2
    • Xilinx SDK Version: 2015.2
    • Vivado HLS Version: 2015.2
  • U-Boot Version:

    • Version: 2016.03
    • Branch: master
  • Linux

    • Version: 4.4.0
    • Branch: master

For reference, we assume that the following environment variables are defined:

export SW_DIR=<Path to your software>
export THRS=$((2 * `cat /proc/cpuinfo | grep processor | wc -l`))

Download and Extract the Ubuntu 14.04 Filesystem

Download and untar the Ubuntu 14.04 image:

mkdir "${SW_DIR}/ubuntu_14.04_corefs"
wget http://cdimage.ubuntu.com/ubuntu-base/releases/14.04/release/ubuntu-base-14.04.5-base-armhf.tar.gz -P "${HOME}/Downloads"
sudo tar -xzvpf "${HOME}/Downloads/ubuntu-base-14.04.5-base-armhf.tar.gz" -C "${SW_DIR}/ubuntu_14.04_corefs/"

Cleanup the archive file:

rm -f "${HOME}/Downloads/ubuntu-base-14.04.4-core-armhf.tar.gz"

Setup Core Filesystem Environment

Enable the ttyPS0 serial console for login over serial:

sudo bash -c "cat << 'EOF' > \"${SW_DIR}/ubuntu_14.04_corefs/etc/init/ttyPS0.conf\"

# ttyPS0 - getty
#
# This service maintains a getty on ttyPS0 from the point the system is
# started until it is shut down again.

start on runlevel [2345] and (
            not-container or
            container CONTAINER=lxc or
            container CONTAINER=lxc-libvirt)

stop on runlevel [!2345]

respawn
exec /sbin/getty -8 115200 --autologin root ttyPS0
EOF"

Resolve the local host and enable QEMU emulation for the filesystem chroot environment:

sudo cp /usr/bin/qemu-arm-static "${SW_DIR}/ubuntu_14.04_corefs/usr/bin/"
sudo bash -c "echo \"127.0.0.1  localhost.localdomain  localhost\" >> \"${SW_DIR}/ubuntu_14.04_corefs/etc/hosts\""

Fix an issue with the ARM cross compiler using the incorrect path for the ld-linux library:

cd "${SW_DIR}/ubuntu_14.04_corefs/lib/"
sudo ln -s ld-linux-armhf.so.3 ld-linux.so.3
cd -

To get the root NFS (network filesystem) boot working properly, we must setup the Ethernet (eth0) interface on the board to be manually configured. This prevents the network-manager service from trying to set the IP address, so the IP address set by the kernel during boot will not be changed. Without this setting, a root NFS boot will hang, because when init runs, the network-manager will try to update the IP address for the eth0 interface, which will kill the connection to the NFS server. Setup Ethernet to be manually configured, so that the kernel can set the IP address at boot-time:

sudo bash -c "cat << 'EOF' > \"${SW_DIR}/ubuntu_14.04_corefs/etc/network/interfaces\"

auto eth0
iface eth0 inet manual
EOF"

Enable SSH and Install Convenience Packages

Enable additional packages from the universe repository (e.g. gdb-minimal):

sudo sed -i -e 's|# \(deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe\)|\1|g' "${SW_DIR}/ubuntu_14.04_corefs/etc/apt/sources.list"

Install packages to make the shell environment more friendly, and upgrade existing packages:

chroot-full "${SW_DIR}/ubuntu_14.04_corefs/"
apt-get update 
apt-get upgrade --no-install-recommends -y
apt-get install --no-install-recommends -y python-minimal vim-tiny 
apt-get install --no-install-recommends -y mlocate bash-completion
exit

Install build and debug tools to compile and debug code on the board:

chroot-full "${SW_DIR}/ubuntu_14.04_corefs/"
apt-get install --no-install-recommends -y g++ gcc git 
apt-get install --no-install-recommends -y dh-autoreconf xutils-dev gettext cmake pkg-config 
apt-get install --no-install-recommends -y strace gdb-minimal
exit

Install the OpenSSH server to enable SSH for the Zedboard, and set the root user's password to allow for SSH'ing as the root user:

chroot-full "${SW_DIR}/ubuntu_14.04_corefs/"
apt-get install --no-install-recommends -y openssh-server
passwd root
exit

Allow for the root user to login over SSH:

sudo sed -i -e 's/^PermitRootLogin.*$/PermitRootLogin yes/g' "${SW_DIR}/ubuntu_14.04_corefs/etc/ssh/sshd_config"

You will then be prompted to enter a new password. Enter the new password, this is what you'll use to SSH into the board.

Next Steps

With the core filesystem setup, we are now ready to build the boot files from source.

To build the files needed for booting, see Build the Boot Sources.

References

The solution to the NFS root hang at boot was found on the NVIDIA forums - Forum

Files