Introduction: Blinking the LEDs on a Zedboard Using Bluespec and Connectal

In this tutorial, we'll compile and run a Connectal project on your Zedboard. Though many of the steps are covered again, we recommend that you attempt to build and simulate a project as shown in How to Build and Run a Bluespec Example prior to attempting this tutorial.

I hardly ever use the USB cable to connect to my Zedboard. Instead, I use the ethernet to connect via TCP. All I need to know is the ethernet address, so we'll update the LED example to blink the IP address of the board, eliminating the need for the USB connection.

Step 1: What You Will Need

For this tutorial, you will need:

  1. A Zedboard, connected to your local network
  2. An SD Card containing a Zynq-Boot image, as described in How to boot Linux on a Zedboard without U-Boot
  3. A github account, because Connectal Build pulls source code from github
  4. Python and curl on a Linux machine or Mac

Boot the Zedboard from the SD card, and use a shell session to determine its IP address.

Step 2: Create Your Repo on Github

Point your browser at and press the "Fork" button to create your own branch of the repository.

For this tutorial, I'm logged in as github user "zedblue", so the resulting repository is

For the remaining steps of this tutorial, you can edit through github's web interface, or you can check it out, edit locally, and push you results back. Substitute your own username for "zedblue" in the following command:

git clone

Step 3: Add a Zedboard Project on Connectal Build

Now point your browser to and login using your github username and password.

Use the "Add Project" link to add your project to be built. The screenshot shows me adding project "zedblue-leds", building for the zedboard.

Step 4: Edit Testleds.cpp

We are going to modify testleds.cpp so that it shows some useful information: the IP address of the zedboard. We will have it blink each byte for a second and then all blank for a second.

Edit testleds.cpp. You can do this on the github web interface or in your favorite editor.

First add

#include <string.h>

to the list of includes, because we are going to call memset().

The easiest way to determine the board's IP address is to run ifconfig, so add the following lines after "Starting LED test.":

  FILE *pipe = popen("ifconfig eth0", "r");
  char buf[256];
  // read the first line and discard it
  fgets(buf, sizeof(buf), pipe);
  // read the second line
  fgets(buf, sizeof(buf), pipe);
  printf("address line: %s", buf);
  // done with the pipe, close it

Now buf contains a string of the form " inet addr:", so add a call to scanf:

int addr[5];<br>  memset(addr, 0, sizeof(addr));
  int status = sscanf(buf, "          inet addr:%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]);
  printf("eth0 addr %d.%d.%d.%d\n", addr[0], addr[1], addr[2], addr[3]);

Finally, update the code that sends the LED values to use the addr bytes:

for (int i = 0; i < 20; i++) {<br>    printf("led value %x\n", addr[i % 5]);
    device->setLeds(addr[i % 5], blinkinterval);

Now save the file, commit it and push to github. If you're editing on the github web interface, it does the push automatically.

Step 5: Watch It Build

Connectal Build polls GitHub, so it will see the change and build it automatically.

Here is the waterfall view of zedblue's leds project showing the build in progress.

Step 6: Run.zedboard

We are going to use the run.zedboard script to download and run the application and bitfile. This script is part of the Connectal framework. You can install the script by downloading just the script or by checking out the connectal repo.

Use the following commands to install the Connectal framework, if you haven't already done so:

sudo apt-add-repository -y ppa:jamey-hicks/connectal
sudo apt-get update
sudo apt-get install connectal 

The installation script writes the Connectal source to /usr/share/connectal. You can test that it runs:

jamey@sj6:/scratch/jamey$ /usr/share/connectal/scripts/run.zedboard -h
usage: Run Connectal apps on Android Zynq boards. [-h] [-t TIMELIMIT]<br>                                                  [-a IPADDR]
                                                  [-u BUILDBOT_URL]
                                                  [-p PROJECT]
                                                  [-b BUILD_NUMBER]
                                                  [bitfile] [androidexe]
                                                  [file [file ...]]

positional arguments:
  bitfile               Gzipped binary bit file for the FPGA
  androidexe            Android executable for the Zynq
  file                  Additional files to transfer to the target

optional arguments:
  -h, --help            show this help message and exit
  -t TIMELIMIT, --timelimit TIMELIMIT
                        Time limit for jobs running on the zedboard. Defaults
                        to value of environment variable RUNTIMELIMIT or 600
  -a IPADDR, --ipaddr IPADDR
                        IP address of target board
  -u BUILDBOT_URL, --buildbot-url BUILDBOT_URL
                        Base URL of buildbot.
  -p PROJECT, --project PROJECT
                        Name of project on buildbot.
  -b BUILD_NUMBER, --build-number BUILD_NUMBER
                        Build number on buildbot.

Will download the bit file and executable from buildbot if buildbot-url,
project, and build-number are specified. The buildbot-url defaults to  <a href="<br"><br>></a>>>

Step 7: Running the Application

Now that Connectal Build has completed building the application, we can run it locally.

We will have run.zedboard download the executable "android.exe" and bitfile "mkTop.xdevcfg.bin.gz" and then connect to the zedboard, configure the FPGA, and run the application. The zedboard I'm using has IP address

jamey@sj6:/scratch/jamey/leds$ /usr/share/connectal/scripts/run.zedboard -p 'leds2/zedboard' -b 1 -a
connecting to
Enabling root on the device
Sending files to the zedboard
Running android.exe with timelimit 600
init_directory: set fclk0 (100000000,99999999)
init_directory: scan(fpga0)
timestamp=Thu Jan  1 00:00:00 1970
portal[0]: ifcid=0, ifctype=60a9312c
Portal::registerInstance fpga1
Starting LED test
address line:           inet addr:  Bcast:  Mask:
eth0 addr</p><p>portalExec::about to enter loop, numFds=1
led value ac
led value 11
led value 1
led value b9
led value 0
led value ac
led value 11
led value 1
led value b9
led value 0

Step 8: FPGA Action Video

And there you have it. In the video, the blue LED lights when the FPGA is programmed and then the red LEDS blink out the bytes of the IP address.