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 Zynq ZC702 using Yocto can be found at the Xilinx pages https://github.com/Xilinx/meta-xilinx/blob/master/meta-xilinx-bsp/README.building.md and https://github.com/Xilinx/meta-xilinx/blob/master/meta-xilinx-bsp/README.booting.md.
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
poky release for this tutorial:
Now enter the poky directory:
Switch to the
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
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
Add the following line to the
We then start the build with:
Go have lunch! This build is going to take a while…
Booting Via SD Card
The ZC702 can be configured to boot a Yocto Linux distribution from the SD card. The following instructions show how:
Setting Up A Bootable SD Card
dd to erase the first sector (replace
X with the number of the SD card):
Now let’s partition the SD card using the interactive
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/deploy/<image>/ onto the first partition (boot partition) of the SD card.
We now will extract the root filesystem onto the second partition:
uEnv.txt should contain information similar to the following:
Booting From SD Card
Insert the SD card onto the ZC702 dev board. Make sure the DIP switches (SW16) on the ZC702 board 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
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!
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 kernel image, root filesystem and device tree.
The above command assumes you have set up tftp on your server and then copied the Yocto build output into your tftpboot folder (e.g.
/tftpboot/). Even better, you can make
/tftpboot a symlink to your build directory:
You can then run this command by simply typing:
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 (for a 100MiB or so filesystem).
Booting Via Flash
Yocto produces a
boot.bin file when building a Linux image for the ZC-702 (using the meta-xilinx layer), but this 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.
Enter a name:
Click Next. Select FSBL.
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
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
Use the following command:
This creates a
BOOT.bin file from the
bootimage.bif and the sources listed in the
More information about bootgen can be found in Appendix A - Using Bootgen (page 55) of https://www.xilinx.com/support/documentation/user_guides/ug821-zynq-7000-swdev.pdf.
Program The Flash
You can program the flash connected to the Zynq on the ZC-702 using Xilinx’s
Firstly, make sure the micro-USB cable to the JTAG device on the ZC-702 (
U23) is connected to your Linux OS (see the Installing xsdb And JTAG Drivers page for more info).
The, connect to the target using
Then use the
program_flash utility to write the
BOOT.bin file generated above to the flash:
More information on the Program Flash Utility can be found in the Embedded System Tools Reference Manual (UG1043).
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.
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.
http://www.wiki.xilinx.com/Prepare+Boot+Medium explains how to make a bootable SD card using Linux.
This work is licensed under a Creative Commons Attribution 4.0 International License .
- April 2017 Updates
- How To Add A Custom App To A Yocto Build
- How To Change The IO Scheduling Class And Priority In Linux