Setting up the Xilinx Zynq based Zedboard for development


This blogpost should get you up and running if you want to develop applications for the Zedboard or another Xilinx Zynq-based platform without using the official SDKs (because let’s be honest, that shit’s bloaty!).

Requirements

I worked in an Ubuntu 14.10 virtual machine with OS X being the host operating system (which should not matter, I guess). Your experience may differ on other flavors of Linux.

Additionally you’ll need to install minicom for initial communication with the board until an ethernet connection has been established as well as the toolchain to build applications for the target platform. Lastly sshpass will help us make testing our applications on the board a little easier. You can install all dependencies by running:

sudo apt-get install gcc-4.9-arm-linux-gnueabihf minicom sshpass

Getting the board up and running

I’ve used the official Zynq Linux 2014.4, which was the latest available version at the time. Download the release of your choice, extract the archive to an SD card and copy the boot.bin and devicetree.dtb files appropriate for your Zynq platform to the root of the SD card.

Now insert the SD card, connect the micro-usb cable to the UART port of your board and turn it on. If you’re working on Linux there should now be a device named something like /dev/ttyACM0. You can connect to the board using minicom:

sudo minicom -D /dev/ttyACM0

Note that you need root permissions for this operation. After connecting to the board you can then enter username and password (root/root by default) which gets you into a shell.

Next up is configuring your network interface. If you have a DHCP server at hand you can simply plug in the board and it’ll receive an IP address which you can find out by running ifconfig. If, like me, you have the board directly connected to your computer it may be more convenient to configure a static IP address than to install a DHCP server (which this tutorial does not cover). You can achieve this by opening the /etc/network/interfaces file and replacing

iface eth0 inet dhcp

with

iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

and subsequently running ifdown eth0 && ifup eth0. Afterwards you should be able to SSH onto the board (don’t forget to configure your network interface locally to have the IP 192.168.1.1).

The first application

Okay, now let’s get the obligatory hello world application to run. I’ve created a file main.c with the following content:

#include 
int main() {
    printf("hello world\n");
    return 0;
}

To make our lives a little easier I’ve written the following Makefile which builds the application, transfers it to the board and runs it, displaying the output and the exit code on the local machine.

BOARD_IP=192.168.1.2
TARGET_DIR=/home/root/
CC=arm-linux-gnueabihf-gcc-4.9
LDFLAGS=-static
CFLAGS=-Wall -Wextra -O2 -std=gnu99 -g -mcpu=cortex-a9 -mfloat-abi=hard
DEPS=main.c
OBJ=main.o
NAME=hello-world

all: $(NAME)

run: $(NAME)
        sshpass -p root scp $(NAME) root@$(BOARD_IP):$(TARGET_DIR) && \
        sshpass -p root ssh root@$(BOARD_IP) "cd $(TARGET_DIR) && ./$(NAME); echo 'Return code: ' $$?"

%.o: %.c $(DEPS)
        $(CC)  $(CFLAGS) -c -o $@ $<

$(NAME): $(OBJ)
        $(CC) -o $@ $(CFLAGS) $(OBJ) $(LDFLAGS)

clean:
        rm -f $(NAME) $(OBJ)

The output of make run the example source code should thus be:

$ make run
hello world
Return code:  0

This concludes the “getting up and running” tutorial for the Zedboard (and similar Xilinx Zynq based platforms). If something doesn’t work for you or if you have suggestions on how this tutorial can be improved, feel free to leave a comment or drop me an email :)