By Adam Taylor

There are times when we want to configure our system over a network. This maybe because we are commissioning equipment in the lab and want to be able to pick up the latest development builds. Alternatively, we may have multiple systems all connected to a central hub, for example an inflight entertainment system, and configuring it over the network simplifies software updates.

In our Zynq SoC and Zynq UltraScale+ MPSoC designs, we can configure systems over the network using TFTP (the Trivial File Transfer Protocol) if we correctly configure U-Boot, the second-stage boot loader. To configure and implement this, we need the following:

A Linux machine (or a Virtual Machine running Linux) to modify and rebuild U-Boot

The latest PetaLinux Release for the Zynq SoC or MPSoC with uImage, Device Tree, and RAM Disk

The Xilinx SDK to create the Boot.bin file, which contains the FSBL and SSBL (first- and second-stage boot loaders)

The TFTP Server running on a network to serve the uImage, Device Tree, and RAM Disk

If this is a fresh Linux installation on a virtual machine, we need to ensure that we have the correct packages loaded to support the build. If not already present, we’ll need to install git, libssl, and ARM’s cross-compilation tools. We can do this by executing the following commands using a terminal (I am using Ubuntu 16.04.2 on my Virtual Machine):

sudo apt-get install git

sudo apt-get install libssl-dev

sudo apt-get install gcc-arm-linux-gnueabi

sudo apt-get install device-tree-compiler

sudo apt-get install device-tree-overlay

Once we have done this, we can clone the Xilinx U-Boot Git Hub onto the Linux installation and make the necessary changes to enable boot over TFTP. To clone the repository, use the following command:

git clone git://github.com/Xilinx/u-boot-xlnx.git

Now that we have the source code for U-Boot, we can make the necessary modifications. But first, we should understand a little about how it works. U-Boot is a second-stage boot loader (SSBL), which is loaded into memory by the FSBL. The SSBL then loads the Linux image, Ram Disk, and device tree into memory, allowing the kernel to start. To do this, U-Boot can read the image, device tree, and RAM disc from several different media including an SD card, QSPI flash memory, NOR or NAND flash memory, or it can download these files using TFTP over Ethernet.

To ensure that we can boot from TFTP within U-Boot, we need to update the currently selected boot method to configure over a network. Using this boot method, the system will load the FSBL and U-Boot first from an SD Card or QSPI and will then look for the remaining images on an TFTP server. It will not look for these images on the selected media. This process is simple and requires only one file in U-Boot to be updated, which is Zynq_Common.h. You can find this file in:

<Cloned Location>/u-boot-xlnx/include/configs

For this example, I am going to be using the ZedBoard configured to boot from an SD Card. That means I need to change Zynq_common.h stored on the SD Card to look for boot files over the network instead of loading further data from the SD Card. We need to change the original script from:

To the following:

We also need to define the ZedBoard’s IP addresses and the server’s address where the images are located. We do this by adding in the following commands within the CONFIG_EXTRA_ENV_SETTINGS definition:

Setting the server and ZedBoard IP Address

ipaddr is the IP address selected for the ZedBoard while serverip is the IP address of the TFTP server. This definition also defines the names of the image, device tree, and RAM Disk along with the addresses they will be loaded into. Unless you have a need to change them, I advise you to leave them unaltered.

Once these modifications have been completed, the next step is to re-build U-Boot and create a bin file to place on the SD Card. To build U-Boot, ensure that you are within the u-boot-xlnx directory and enter the following commands using a terminal:

export ARCH=arm

export CROSS_COMPILE=arm-linux-gnueabi-

make zynq_zed_config

make

These commands will produce an ELF file called u-boot. There will be no file extension. We can use this file with the Zedboard FSBL to create the necessary Boot.Bin file for our SD Card. For the purposes of this demo, I am using the latest release from here. I used the provided FSBL elf with the u-boot elf just created to generate a boot.bin within SDK’s create boot image tool.

Creating the BIN Image using SDK

Once the file has been created, we can copy it to the SD Card and insert the memory card into the ZedBoard. Then when we turn the ZedBoard on, it will attempt to locate the server. Therefore, we need to set up the TFTP server prior to this. I used my laptop and a program called TFTPD to create a server.

With the server set up and the ZedBoard connected to the network and powered on, the images were downloaded over the network and the Linux images were downloaded and successfully booted as shown below in the images.

Downloading the uImage over TFTP

PetaLinux running on the ZedBoard following the TFTP boot





Log File from the TFTP Server showing transfer of the images

I will upload the boot.bin file onto the GitHub for those who are using the ZedBoard. We can of course re-build u-boot for a range of development boards. There is more info on building u-boot here.

Code is available on Github as always.

If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.

First Year E Book here

First Year Hardback here