Building Linux For The Zynq ZC702 Eval Kit Using Yocto

Overview

Xilinx provides device and board information for the Zynq SoC for Yocto through the repository meta-xilinx. This includes board information for the ZC702 Evaluation Kit.

This tutorial has been tested on Ubuntu 16.04 64bit, running inside a VMware virtual machine on a Windows host. Exact procedure and commands might have to be changed slightly for other configurations.

More information on building and booting Linux on the Zyqn ZC702 using Yocto can be found at the Xilinx pages https://github.com/Xilinx/meta-xilinx/blob/master/README.building.md and https://github.com/Xilinx/meta-xilinx/blob/master/README.booting.md.

Download/Setup Yocto

If you want to get more familiar with Yocto, check out the Yocto Quick Start guide.

Firstly, install all the dependencies needed by Yocto:

Then we need to get a Yocto release. We will use the pocky release for this tutorial:

 Now enter the poky directory:

Switch to the morty branch:

Configuring Yocto For The ZC702 Eval Kit

Now that Yocto has been setup, we need to configure it for the Xilinx ZC702 Evaluation Kit.

To start this step, we need to clone the meta-xilinx repository into the Yocto source directory (e.g. poky/).

This should clone the repo into ~/poky/meta-xilinx/.

We then need to make sure the branch of meta-xilinx is the same as the branch of poky.

Then go back to the poky directory, and initialise the build environment:

You should now automatically be in the ~/poky/build directory. Tell bitbake about the new meta-xilinx layer:

Add the following line to the conf/local.conf file:

We then start the build with:

Go have lunch! This build is going to take a while…

Screenshot while building embedded Linux for the ZC702 Eval Kit board using Yocto.

Booting Via SD Card

Setting Up A Bootable SD Card

Use dd to erase the first sector (replace X with the number of the SD card):

~$ dd if=/dev/zero of=/dev/sdX bs=1024 count=1 

Now let’s partition the SD card using the interactive fdisk command:

Follow the following procedure, entering commands such as n, a and t where shown (the rest is fdisk output).

Now set the bootable flag for the first partition, and set the partition IDs:

Check the new partition table is correct, and then write the changes:

Create file systems on the new partitions (this would cause VirtualBox to crash, but seemed to work fine using VMWare Workstation):

Mount the partitions, sdX1 being the first partition (boot), and sdX2 being the second partition (where the root filesystem will be placed).

Copying Build Output Onto SD Card

You will want to copy over the following files from poky/build/tmp/ onto the first partition (boot partition) of the SD card. 

We now will extract the root filesystem onto the second partition:

Booting From SD Card

Insert the SD card onto the ZC702 dev board. Make sure the DIP switches are set as follows:

  • 1 -> LOW
  • 2 -> LOW
  • 3 -> HIGH
  • 4 -> HIGH
  • 5 -> LOW

Connect a cable from the mini-USB port on the dev. board (labelled J17 or “USB UART”) to your computer. Open a terminal on the COM port with the following settings:

  • Baud rate = 115000
  • Num. data bits = 8
  • Parity = None
  • Num. stop bits = 1
  • Flow control = None

Now turn on the power switch to the dev. board. Hopefully, you should see it boot up!

The terminal output during the start of a Linux boot built using Yocty, and running on the Xilinx ZC702 dev. board.

You should be able to log in as user root, with no password.

Booting Via TFTP

You can also use TFTP to transfer and boot compiled images from your desktop computer to the embedded device. The embedded device must have an internet/intranet connection to do so (e.g. Ethernet).

You must remember that U-Boot is required to be already present on the embedded device to support TFTP (you obviously need TFTP drivers to perform the communication, and this is what U-Boot provides). You can use TFTP to download the Linux kernal image, root filesystem and device tree.

You can then run this command by simply typing:

boot 

In my experience, it usually takes about 30s from the time you type boot to the time to get to the Linux login screen, which includes downloading the files via TFTP and then booting the Linux image.

Booting Via Flash

The Yocto output doesn’t seem to be directly suitable for QSPI flash boot. 

Create A FSBL Using Xilinx SDK

Load up the SDK. Select New->Application Project.

Creating a “New Application” in the Xilinx SDK.

Enter a name:

Give the Zynq FSBL project a name and make sure the right platform/processor is selected.

Click Next. Select FSBL.

Select “Zynq FSBL” as the template for the application.

The Xilinx SDK should now create all the necessary files and run the build once.

This should create a FSBL as a .elf file in the Debug build directory.

Xilinx also has instructions for creating a Zynq FSBL at https://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_4/SDK_Doc/tasks/sdk_t_project_creation_zynq_fsbl.htm

Create bootimage.bif

Manually create a bootimage.bif ( bif is an acronym for Bootable Image Format) file using a text editor. It is pretty simple, and just needs to contain the following code:

This file is used as a configuration file for bootgen (see below).

Create Flash Image Using bootgen

bootgen is a command-line application provided by the Xilinx SDK. It is used to stitch together the many files needed for an embedded OS to boot properly into one image file. For myself, it was located at /opt/Xilinx/SDK/2017.1/bin/.

Use the following command:

This creates a BOOT.bin file from the bootimage.bif and the sources listed in the bootimage.bif file.

Program The Flash

program_flash -f BOOT.bin -offset 0x0 -flash_type qspi_single -verify -cable type xilinx_tcf url tcp:localhost:3121

Running In The Simulator (QEMU)

This assumes you have poky already downloaded onto your computer (see above). Create a new build directory for the QEMU build.

Note how an argument was provided to oe-init-build-env this time ( build-qemu). This tells oe-init-build-env to initialise a build directory called build-qemu/ instead of the default, which is just build/ (we will keep build/ for the Linux build that runs on the real hardware).

Start the Linux build:

Now run QEMU, passing in the location of the just-built QEMU configuration file.

The final stages of a Yocto Linux (built for the Xilinx ZC702 dev. board) boot running in QEMU.

You should be able to log onto the Linux system with the username root, no password required.

Help! I Get A “No Recipes Available For…” Error

Is your error similar to:

This can happen if you forgot to checkout the correct branch of meta-xilinx. Remember, when you use the command git clone https://github.com/Xilinx/meta-xilinx, it will checkout the master branch. You then need to checkout the branch which matches the branch of poky you are using (this was morty  when I did it), e.g.

Other Resources

http://www.wiki.xilinx.com/Prepare+Boot+Medium explains how to make a bootable SD card using Linux.