New Horizons

Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company


You are welcome to contact me
and ask questions or make comments
about my blog.

View Sven Andersson's profile on LinkedIn


New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Zynq Design From Scratch
Started February 2014
Changes and updates
Zynq-7000 All Programmable SoC
ZedBoard and other boards
Computer platform and VirtualBox
Installing Ubuntu
Fixing Ubuntu
Installing Vivado
Starting Vivado
Using Vivado
Lab 1. Create a Zynq project
Lab 1. Build a hardware platform
Lab 1. Create a software application
Lab 1. Connect to ZedBoard
Lab 1. Run a software application
Lab 1. Benchmarking ARM Cortex-A9
Lab 2. Adding a GPIO peripheral
Lab 2. Create a custom HDL module
Lab 2. Connect package pins and implement
Lab 2. Create a software application and configure the PL
Lab 2. Debugging a software application
Running Linux from SD card
Installing PetaLinux
Booting PetaLinux
Connect to ZedBoad via ethernet
Rebuilding the PetaLinux kernel image
Running a DHCP server on the host
Running a TFTP server on the host
PetaLinux boot via U-boot
PetaLinux application development
Fixing the host computer
Running NFS servers
VirtualBox seamless mode
Mounting guest file system using sshfs
PetaLinux. Setting up a web server
PetaLinux. Using cgi scripts
PetaLinux. Web enabled application
Convert from VirtualBox to VMware
Running Linaro Ubuntu on ZedBoard
Running Android on ZedBoard

Chipotle Verification System

Four soft-core processors
Started January 2012

Xilinx FPGA Design
New start August 2011
Problems, fixes and solutions
FPGA design from scratch. Part 51
FPGA design from scratch. Part 52
FPGA design from scratch. Part 53
FPGA design from scratch. Part 54
FPGA design from scratch. Part 55
FPGA design from scratch. Part 56
FPGA design from scratch. Part 57
FPGA design from scratch. Part 58
FPGA design from scratch. Part 59
FPGA design from scratch. Part 60
Using the Spartan-6 LX9 MicroBoard
Table of contents
FPGA design from scratch. Part 61
FPGA design from scratch. Part 62
FPGA design from scratch. Part 63
FPGA design from scratch. Part 64
FPGA design from scratch. Part 65
FPGA design from scratch. Part 66
FPGA design from scratch. Part 67
FPGA design from scratch. Part 68
FPGA design from scratch. Part 69
FPGA design from scratch. Part 70
FPGA design from scratch. Part 71
FPGA design from scratch. Part 72
FPGA design from scratch. Part 73
FPGA design from scratch. Part 74
FPGA design from scratch. Part 75
FPGA design from scratch. Part 76
FPGA design from scratch. Part 77
FPGA design from scratch. Part 78
FPGA design from scratch. Part 79
FPGA design from scratch. Part 80
FPGA design from scratch. Part 81
FPGA design from scratch. Part 82
FPGA design from scratch. Part 83
FPGA design from scratch. Part 84
FPGA design from scratch. Part 85
FPGA design from scratch. Part 86
FPGA design from scratch. Part 87
FPGA design from scratch. Part 88
FPGA design from scratch. Part 89
FPGA design from scratch. Part 90
FPGA design from scratch. Part 91
Started December 2006
Table of contents
FPGA design from scratch. Part 1
FPGA design from scratch. Part 2
FPGA design from scratch. Part 3
FPGA design from scratch. Part 4
FPGA design from scratch. Part 5
FPGA design from scratch. Part 6
FPGA design from scratch. Part 7
FPGA design from scratch. Part 8
FPGA design from scratch. Part 9
FPGA design from scratch. Part 10
FPGA design from scratch. Part 11
FPGA design from scratch. Part 12
FPGA design from scratch. Part 13
FPGA design from scratch. Part 14
FPGA design from scratch. Part 15
FPGA design from scratch. Part 16
FPGA design from scratch. Part 17
FPGA design from scratch. Part 18
FPGA design from scratch. Part 19
FPGA design from scratch. Part 20
FPGA design from scratch. Part 21
FPGA design from scratch. Part 22
FPGA design from scratch. Part 23
FPGA design from scratch. Part 24
FPGA design from scratch. Part 25
FPGA design from scratch. Part 26
FPGA design from scratch. Part 27
FPGA design from scratch. Part 28
FPGA design from scratch. Part 29
FPGA design from scratch. Part 30
FPGA design from scratch. Part 31
FPGA design from scratch. Part 32
FPGA design from scratch. Part 33
FPGA design from scratch. Part 34
FPGA design from scratch. Part 35
FPGA design from scratch. Part 36
FPGA design from scratch. Part 37
FPGA design from scratch. Part 38
FPGA design from scratch. Part 39
FPGA design from scratch. Part 40
FPGA design from scratch. Part 41
FPGA design from scratch. Part 42
FPGA design from scratch. Part 43
FPGA design from scratch. Part 44
FPGA design from scratch. Part 45
FPGA design from scratch. Part 46
FPGA design from scratch. Part 47
FPGA design from scratch. Part 48
FPGA design from scratch. Part 49
FPGA design from scratch. Part 50
Acronyms and abbreviations
Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5
A hardware designer's best friend
Zoo Design Platform
Installing Cobra Command Tool
A processor benchmark
Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true
The New York City Marathon
Kittelfjäll Lappland
Tour skating in Sweden and around the world
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Books, photos, films and videos
Weather forecasts

38000 feet above see level
A trip to Spain
Florida the sunshine state

Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
Kittelfjäll Lapland
Landsort Art Walk
Skating on thin ice

100 Power Tips for FPGA Designers

Adventures in ASIC
Computer History Museum
Design & Reuse
d9 Tech Blog
EDA Cafe
EDA DesignLine
Eli's tech Blog
FPGA Arcade
FPGA Central
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
Mac 2 Ubuntu
Programmable Logic DesignLine
World of ASIC

If you want to be updated on this weblog Enter your email here:

rss feed

Sunday, April 20, 2014
What's New
2013-04-20 The comment field has been opened for all my reader. I am sorry for having stopped you from making comments.
2013-03-15 The Zynq blog has been added to the Xilinx Wiki.
2012-03-13 A link to my Zynq blog has been added in
2012-03-11 I have written an article for EE Times about my Zynq blog
2012-02-18 Xilinx writes about my Zynq blog
2012-02-10 ElektronikTidningen writes about my Zynq blog (in Swedish)
2014-02-06 Starting a new blog called "Zynq Design From Scratch"
2014-01-14 Updated

Posted at 07:26 by svenand
Comments (3)  

Thursday, April 17, 2014
Zynq design from scratch. Part 1.

Almost a year ago I received a parcel by post from US. When I opened the parcel I found this box.

The ZedBoard was a present from someone involved in promoting the new Zynq device from Xilinx, but with no strings attached. At that time I was busy working as an ASIC designer and had no time to play with the board. It wasn't until December in 2013 that I had a chance to unpack the box and power-up the ZedBoard.

At that time I got an email from Per and Andreas at  Silica (Avnet) here in Stockholm, where they offered a one day hands-on training class on the Zynq-7000 using the ZedBoard, part of the "Xilinx Speedway Design Workshops". Here is what this workshop covered:

Introduction to the Zynq-7000 in Vivado AP SoC

"This class demonstrates the techniques and tools used to create a basic Zynq-7000 AP SoC design. Through a series of instructor presentations and hands-on labs, hardware and firmware developers will learn the required steps for creating a complete Zynq-7000 AP SoC design on ZedBoard. The Zynq-7000 AP SoC architecture is explained, including the ARM® Cortex™-A9 processing system (PS) and the 7 series programmable logic (PL). The course also details the individual components that comprise the PS such as I/O peripherals, clocking, interrupt, AXI interfaces and memory controllers. Emphasis will be placed on efficient PL-to-PS interfacing including processing interrupts generated from a PL peripheral. To complete the design flow, the critical steps of hardware and software debugging techniques will be shown".

This training session was the head start I needed. I went home and started to play with my ZedBoard. At the same time a decided to write this blog and here we are. All of you who have read my "FPGA design from scratch" blog will feel at home. I will follow the same idea and describe the whole design flow in an easy to understand fashion.

Reading instruction

At the end of every blog entry there are three links called:   Top   Previous  Next

  • Top takes us to the top of the current blog entry.
  • Previous takes us to the previous entry
  • Next takes us to the next entry 

Table of content

In the left sidebar there is a clickable TOC where you can access all blog entries:

Learning by doing

Aristotle once said, "For the things we have to learn before we can do them, we learn by doing them". So true. Let's practice some learning by doing.

Not reinventing the wheel

We will use a lot of material already available from Xilinx, Avnet and other companies. We will  try to find solutions to our problems by searching on internet.

An interactive meeting place

A would like the blog to be interactive and not a one-way document. I invite all of you,
newbies to professionals to ask questions, make comments and suggestions for subjects you are missing.


It wouldn't make sense writing a tutorial like this and not using Avnet's and Xilinx's in-depth knowledge about their products found in their web pages, user guides and other documents. I would like to thank Avnet and Xilinx for allowing me to use images and text from their documents and to link to their web pages.


Here is a link to the Xilinx
documentation library.


Xilinx provides recorded
E-Learning for courses at our convenience. They are available at no charge.


There are several forums discussing FPGA design. The Xilinx forum is one of them. The Avnet forum and ZedBoard forum are two others.


Subscribe for FREE to the new Xcell Journal Digital. Here are links to old XCell magazines.

Search engines

There are a number of dedicated search engines, searching for FPGA information.
FPGASeek is one ChipHit is another.

Support, Answers Database

You may find an answer to your question in the
Xilinx support page.


Xilinx provides targeted, high-quality education services designed by experts in programmable logic design, and delivered by Xilinx-qualified trainers. They offer instructor-led classes (both in person and online) and recorded e-learning for self-paced training. Some courses are completely free!  Doulos is running a 3 days course called "ARM Cortex-A9 for Zynq System Design".


To post a question to Xilinx you should use


The goal of the Xilinx Wiki site is to provide technical information and collaborate with the community on Open Source projects that are being done in Xilinx. Xilinx also provides a Git repository to help with open source development and collaboration, and all sources can be downloaded from the GIT repository

Xcell Daily Blog

Here is Xilinx own blog, Xcell Daily Blog.

Xilinx University Program

The Xilinx University Program (XUP) includes academics from top-tiered universities across the world. XUP provides top-quality teaching materials that are easily accessible to professors to incorporate into their curriculum. XUP offers workshops to professors and academic staff at no cost. These workshops are conducted by Xilinx as well as application area experts, providing in-depth practical and theoretical aspect of FPGA technology.

What to expect from this blog

You are welcome to follow my blog. I hope it will give you a head start in using the Zynq-7000 All Programmable SoC. Here is what I plan to do first.

  1. Select a computer to use. In my case a MacBook Air
  2. Setup a virtual machine using VirtualBox.
  3. Install Ubuntu Linux 13.10 64bit in the virtual machine
  4. Install Xilinx Vivado Design Suite (the Linux version)
  5. Use the Vivado software to generate a configuration bitstream
  6. Use Vivado SDK to write a simple program
  7. Connect the ZedBoard to the computer
  8. Configure the Zynq FPGA part and load the program
  9. Run the program that will light up some LEDs on the board

Just one last thing

We are going to have fun.

This time you are not left alone. Click Next to continue reading.

Top   Previous   Next

Posted at 11:50 by svenand
Comments (2)  

Zynq design from scratch. Part 39.
Running Android on ZedBoard

I was very impressed when I saw this video demonstrating how you can run Android on the Mars ZX3 Zynq module from Enclustra. If they can do it we can do it. Let's give it a try.


Android is an operating system based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Initially developed by Android, Inc., which Google backed financially and later bought in 2005.

Touchscreen display

To make full use of the Android operating system we have to add a touchscreen display to our ZedBoard. We have to figure out what is the best and cheapest solution but until then I will will continue the experiment without the display.

Software preparations

To build the Android system we need to download and install a number of software packages:

  • Java SE Development Kit
  • Sourcery CodeBench Lite Edition

Top   Previous   Next

Posted at 07:56 by svenand
Make a comment  

Saturday, April 12, 2014
Zynq design from scratch. Part 38.
Running Linaro Ubuntu on the ZedBoard

Open-source solution

To use PetaLinux in a commercial product we need to buy a license. Let's look for an open-source solution.


Linaro is a not-for-profit engineering organization that works on open-source software for the ARM architecture, including the GCC toolchain, the Linux kernel, ARM power management, graphics and multimedia interfaces
. Linaro focuses on open-source support of the ARM v7 and ARM v8 Architecture, including SoCs that contain ARM Cortex-A9, Cortex-A15, Cortex-A53 and Cortex-A57 processor(s).

Linaro software

We can read more about Linaro and download the software from the Linaro web page.

Where to start

Digilent has published two very informative documents called "Embedded Linux Development Guide" and "Getting Started With Embedded Linux - ZedBoard". The second document describes the Linaro Ubuntu installation. Avnet has written a document called "Ubuntu Desktop Linux" (Register and login to needed). Probably the best one to use. Let's start there.

Booting Linux on ZedBoard

Booting the Zynq-7000TM All Programmable SoC (Zynq AP SoC) from an SD card, or another form of compatible memory, requires that you first place four items onto your storage device. The four required items are the Linux file system (either Linaro or BusyBox), a Linux kernel image, a BOOT.BIN file, and a compiled device tree.

The Linux file system

The ZedBoard currently supports two different Linux file systems, a BusyBox ramdisk (used by PetaLinux) and a Linaro Ubuntu distribution.
The BusyBox ramdisk is a very small file system that includes basic functionality and runs through RAM. BusyBox is non-persistent, which means it will not save any changes we make during our operating session after we power down the ZedBoard.

The Linaro file system is a complete Linux distribution based on Ubuntu. It includes a graphical desktop that displays via the onboard HDMI port. Linaro executes from a separate partition on the SD card, and all changes made are written to memory. The utility of Linaro is that it will save files even after you power down and reboot the ZedBoard. In this experiment we will use the Linaro file system.

The SD card

I will use a SanDisk SDHC 16GB card (speed grade 4). I tried first using a SanDisk Ultra card (speed grade 10) but couldn't get it work.

Connecting a SD card reader/writer to VirtualBox

1. Shutdown the VirtualBox guest operating system.
2. Connect a SD card reader with the SDcard inserted to one of the USB connectors on the host computer. Make sure the SD card reader is USB 2. VirtualBox can not handle USB 3 memory card readers (for the moment).

3. Open the Settings window in VirtualBox and select Ports->USB. Add the USB Storage device and  click OK.

4. Unmount the SD card reader.
5. Start Ubuntu guest operating system.
6. Connect the SD card reader.
7. If everything works as expected, the SD card will show up in the file browser.

8. The file system is mounted in the /media/<user name> directory.

Formatting the SD card

Booting Linux on the ZedBoard from an SD card requires that we first set up the correct partitions on the SD card. We must format the first two partitions on the SD card to specific parameters. The first partition must have a FAT file system and be at least 52 MB and the second partition must have an ext4 file system and be at least 3.6GB. The second partition is only necessary when using the Linaro file system.

Using GParted

GParted is a free partition editor for graphically managing our disk partitions. It is used for creating, deleting, resizing, moving, checking and copying partitions, and the file systems on them. This is useful for creating space for new operating systems, reorganizing disk usage, copying data residing on hard disks and mirroring one partition with another (disk imaging).

Installing Gparted

Use the following command to install GParted.

->sudo apt-get install gparted

Running Gparted

Use the following command to start GParted:

->sudo gparted

1. When the GParted partitioning window is displayed we select the SD card (/dev/sdb) from the GParted->Devices menu.

2. Before doing any formatting of the card we must unmount the FAT32 partition. Select the partition, right-click and choose Unmount.

3. We will start by deleting the partition.
Select the partition, right-click and choose Delete.

4. To execute the command we have to click  .

5. We now have a completely unallocated SD card. Let's go ahead and add two new partitions. We make the first partition about 52MB and formatted in FAT32. Don't forget to leave 4MB of free space preceding the partition. Click the new button to add a new partition.

We make the second partition 8GB (3.6GB would be enough) with ext4 file system.

6. Here is the result.
Click  the  button to finish the partitioning.

7. The two partitions are mounted in the /media/svenand directory.

Quick check

Let's do a quick check to find out if our newly formatted SD card can boot Linux on the ZedBoard. We will copy the boot files found on the original SD card, to the BOOT partition on the new SD card. Like this:

Now we can follow the instruction in part 21 to boot Linux on the ZedBoard. If this works we can continue and install the Linaro file system. If not we have to go back to the drawing board.

Downloading the Linaro file system

The first step in preparing the Linaro file system is to obtain the tarball of our preferred Linaro Ubuntu distribution. We can obtain these from Linaro at by clicking the desired version and then traversing to ubuntu/precise-images. Linaro provides several different Ubuntu builds, some of which are very lightweight and do not use a desktop. We can find a version that does contain a graphical desktop and that has been tested on the ZedBoard at:

Creating the Linaro root file system

We create a folder named linaro under /tmp and copy the zipped linaro image there.

->mkdir -p /tmp/linaro
->sudo cp linaro-precise-ubuntu-desktop-20120923-436.tar.gz /tmp/linaro/.
->cd /tmp/linaro

Unpack the disk image using the tar command:

->sudo tar zxf

Here is the result.

Observe. The /tmp directory will be cleaned when rebooting the Ubuntu system.

Copy the disk image to the SD card

After unpacking the disk image, the root filesystem lies at /tmp/linaro/binary/boot/filesystem.dir. So the next step to do is to copy the root filesystem into the second partition of our SD Card, mounted already to /media/svenand/rootfs. A lot of files in the root filesystem are special files with special attributes, I would recommend to use rsync to do the copy, which keeps the attibutes for every file. It takes a while to copy the file to SD card, basically depended on our SD card speed.

-> cd binary/boot/filesystem.dir
-> sudo rsync -a --progress ./ /media/svenand/rootfs/

To make sure all the files have been sychronized to the SD card, we need to unmount the /media/svenand/rootfs before we unplug the SD card. It may take several minutes to get everything synchronized onto the SD Card.

-> sudo umount /media/svenand/rootfs/

Adding device tree blob file

We need to change the bootargs defined in the device tree blob (DTB) to let the kernel use the second partition of SD card as root file system. To make our life easier, we can download a precompiled dtb file available at: devicetree_linaro.dtb

Fixing the BOOT files

We will delete the ramdisk8M.image.gz and devicetree_ramdisk.dtb files and add the devicetree_linaro.dtb file.

Prepare the ZedBoard

Once we complete these guide instructions, the SD card will have everything it needs to boot Linux on the ZedBoard. Set the jumpers on the ZedBoard as follows:
  • MIO 6: set to GND (JP7)
  • MIO 5: set to 3V3 (JP8)
  • MIO 4: set to 3V3 (JP9)
  • MIO 3: set to GND (JP10)
  • MIO 2: set to GND (JP11)
  • VADJ Select: Set to 1V8 (JP18)
  • JP6: Shorted
  • JP2: Shorted
  • All other jumpers should be left untouched

Boot Linaro Ubuntu

Insert the SD Card into the ZED Board, connect a monitor to the ZED Board with an HDMI cable, connect the UART port to our computer, open a terminal for it (115200 baud rate, 8 bit, 1 stop bit, no parity, no flow control).

We power up the ZedBoard and after a few seconds the blue LED will light up. However, automatically, the boot loader (U-Boot) will still look for ramdisk by default. So, we need to stop the autoboot by pressing a key during the 3-second count down, and type the command: run sdboot_linaro to boot up the Linaro Ubuntu Desktop.

The boot process will start and after a minute or so the display will show the Linaro home screen.

Here is the Linaro Ubuntu screen.

Connect keyboard and mouse

Linaro Ubuntu has support for both a USB keyboard and a USB mouse. They will be connected to the USB OTG contact.

USB On-The-Go

USB On-The-Go, often abbreviated USB OTG or just OTG, is a specification that allows USB devices such as digital audio players or mobile phones to act as a host, allowing other USB devices like a USB flash drive, digital camera, mouse, or keyboard to be attached to them.

We will start by adding a "USB MicroB to USB A" OTG adapter.

Now we can add a USB hub, a USB keyboard and a USB mouse.

The USB devices will be detected and can be used to control our Linux system.

Top   Previous   Next

Posted at 17:21 by svenand
Make a comment  

Thursday, April 10, 2014
Zynq design from scratch. Part 37.
Convert a virtual machine from VirtualBox to VMware

Some of you may prefer VMware instead of VirtualBox. I have already installed VMware Fusion on my Mac. You PC users can use VMware Workstation or VMware Player. Instead of setting up our virtual machine from scratch we will try to convert the VirtualBox VM to run in VMware. Will it work? Let's see.

Open Virtualization Format (OVF)

VirtualBox and VMware use different virtual machine formats, but each supports the standard Open Virtualization Format. Convert our existing virtual machine to OVF or OVA and you’ll be able to import it into another virtual machine program.

Unfortunately, this may not always work perfectly, as VirtualBox and VMware both seem to use slightly different OVA/OVF implementations that aren’t entirely compatible. If this doesn’t work, we may want to reinstall our virtual machine’s guest operating system from scratch.

VirtualBox to VMware

Before migrating a virtual machine from VirtualBox to VMware, ensure it’s “powered off” in VirtualBox and not suspended. If it’s suspended, launch the virtual machine and shut it down.

1. Click the File menu in VirtualBox and select Export Appliance. We will export the Ubuntu 64bit VM.

2. Select settings. We will keep the defaults.

3. Don't touch.

4. Click Export to start the conversion. This may take some time, depending on the size of our virtual machine’s disk file.

5. Here is the result.

Import the OVA file in VMware

6. Start VMware and select Import from the File menu.

7. Click "Choose File" and browse to our OVA file. Click Continue and specify where to store the imported and converted VMware virtual machine (Ubuntu 64bit.vmwarevm).

8. Click "Save" to start the import. VirtualBox and VMware aren’t perfectly compatible, so we’ll probably receive a warning message saying the the file “did not pass OVF specification performance” �" but if we click Retry, the virtual machine should import and function properly.

9. The import starts.

10. When the import has finished we can start our virtual machine.

11. Uninstall VirtualBox guest additions.

->sudo /opt/VBoxGuestAdditions-4.3.10/

Install VMware Tools

12. Select "Install VMware Tools" from the Virtual Machine menu.

13. Copy the file VMwareTools-9.6.1-1378637.tar.gz to a temporary directory.

14. Unzip and untar

15. Execute the perl script from the vmware-tools-distrib directory.

->sudo ./

16. Restart the virtual machine to enable the full screen view.

Top   Previous   Next

Posted at 16:46 by svenand
Make a comment  

Tuesday, April 08, 2014
Zynq design from scratch. Part 36.

Building a web enabled application

Web serving embedded applications become a lot more useful when the web interface can be used to control the device, or monitor sensor inputs. In this step, we will build and experiment with a simple web-enabled application controlling the LEDs on the ZedBoard.

Create an application

We will create a CGI script called LEDcontrol by running the petalinux-create command from inside a PetaLinux project on our workstation.

->cd Projects/PetaLinux/Avnet-Digilent-ZedBoard-2013.3
->petalinux-create -t apps --name LEDcontrol

Download the program code

The program code can be downloaded from here. I would like to thank John Williams (the father of PetaLinux) at Xilinx for providing me with the source code.

Copy the code to the application directory

Unzip, unpack and copy the downloaded files to the LEDcontrol directory. Here is the result.

Build and install the application program

For more information see part 29 and part 35.

->petalinux-build -c rootfs/LEDcontrol -x build

Controlling hardware from the web browser

We can now control the LEDs on the ZedBoard from our web browser.

  1. Make sure the web server is running in PetaLinux: ->httpd -p 8080 -h /home/httpd
  2. Open a web browser on the host
  3. Enter the webaddress: <IP address of the board>:8080/cgi-bin/LEDcontrol
  4. ZedBoard LED Control window will open
  5. Enter the LED GPIO ID. In our case it is 243
  6. Click the ON/OFF links to turn on/off the LEDs on the ZedBoard

This is just one small example. We could include much more control from our web application. It is up to your imagination.

Top   Previous   Next

Posted at 17:09 by svenand
Make a comment  

Sunday, April 06, 2014
Zynq design from scratch. Part 35.
Using CGI scripts

The Common Gateway Interface (CGI) is a standard method for web servers software to delegate the generation of web pages to executable files. Such files are known as CGI scripts; they are programs, often stand-alone applications, usually written in a scripting language like Perl. In this example we will write the CGI script using the C language.

Create a CGI script

Create a user application by running petalinux-create -t apps from inside a PetaLinux project on our workstation.

->cd Projects/PetaLinux/Avnet-Digilent-ZedBoard-2013.3
->petalinux-create -t apps --name HelloWorld

HelloWorld C program

As usual when starting work with some new programming technology, we should probably first make a trivial program work. This avoids fighting with many potential problems at a time and concentrating first on the issues specific to the environment, here CGI.

We will use the following program that just prints Hello world but preceded by HTTP headers as required by the CGI interface. Here the header specifies that the data is plain ASCII text.

#include <stdio.h>

int main(void) {
  printf("Content-Type: text/plain;charset=us-ascii ");
  printf("Hello world ");
  return 0;

HelloWorld makefile

The CGI script will be installed in directory: /home/httpd/cgi-bin

APP = HelloWorld

# Add any other object files to this list below
APP_OBJS = HelloWorld.o

all: build install

build: $(APP)

    $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

    -rm -f $(APP) *.elf *.gdb *.o

.PHONY: install image

install: $(APP)
    $(TARGETINST) -d $(APP) /home/httpd/cgi-bin/$(APP)

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

Build and boot PetaLinux

Follow the instructions in part 29 to add a new appliction, build and boot PetaLinux.

Start the web server

Login to PetaLinux and start httpd (Hypertext Transfer Protocol Daemon) using port 8080:

->httpd -p 8080 -h /home/httpd

Displaying the web page

Open a web browser on the host machine and enter the following web address:

The CGI script will execute on the server side and display the text: Hello world.

Modifying the HelloWorld program

Writing C programs normally means we have to do a number of iterations including bug fixing and adding more code, which means we have to go through this process every time.
  1. Change the source code
  2. Rebuild the Linux kernel
  3. Load and boot the kernel

This will take several minutes to be completed and we will spend a lot of time waiting for things to finish. Let's find a faster way to modify and test a C program. Here is the modification:

printf("Hello world from Zoocad Consulting ");

Build the the application

To find out what other possibilities we have to build our application we use the command:

->petalinux-build --help

We will use this command to build only the HelloWorld application:

->petalinux-build -c rootfs/HelloWorld -x build

The result from the build is stored in the directory: build/linux/rootfs/apps/HelloWorld

Copy the HelloWorld application

As we have the Ubuntu file system NFS mounted on our host we can copy the executable file HelloWorld to PetaLinux using the curl command (see part 34).

-> cd ..../build/linux/rootfs/apps/HelloWorld
-> curl -T HelloWorld -u root:root

On the PetaLinux side:

->cd /var/ftp
->chmod 755 HelloWorld
->cp HelloWorld /home/httpd/cgi-bin/.

Top   Previous   Next

Posted at 19:15 by svenand
Make a comment  

Saturday, April 05, 2014
Zynq design from scratch. Part 34.
Installing custom web server content

By default, system images built with PetaLinux SDK include a web application demo built using the uWeb (MicroWeb) framework from WorkWare Systems. If we prefer to create our own Embedded Web interfaces, PetaLinux also includes the BusyBox httpd server.  This tutorial describes how to configure the BusyBox web server and create/install our own custom web content into a PetaLinux system image.

Create a new application

We will create a dummy application to hold the web content. We call it TourSkating, you will soon see why.

->cd Projects/PetaLinux/Avnet-Digilent-ZedBoard-2013.3
->petalinux-create -t apps --name TourSkating

Building a new application

Once we have created the new application, the next step is to compile and build it. The required steps are shown below.

Select your new application to be included in the build process. The application is not enabled by default. Launch the rootfs configuration menu:

->petalinux-config -c rootfs

3. We will include the TourSkating app and exclude the uWeb app.

4. We need to include the built-in web server (httpd). It can be found in base->busybox->busybox-httpd

5. Exit and save the configuration.

Build a new PetaLinux kernel

6. Execute the command:


Create the index.html file

The web page will display two pictures.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <title>Tour skating in Sweden and around the world</title>
 <h3> The ice is like a mirror</h3>
 <img src="MirrorLike.png">
 <h3> On the ice</h3>
 <img src="TourStart.png">
 <a href="">For more information see my blog</a>

Boot PetaLinux

Follow the instructions in part 28 to boot PetaLinux.

Copying files to the PetaLinux installation

We will use the cURL command to transfer the files from our host to the guest. cURL is a command line tool for doing all sorts of interesting and essential URL manipulations and data transfers. The original goal of the program was to transfer files programmatically via protocols such as http, ftp, gopher, sftp, ftps, scp, tftp, and many others, via a command line interface. The main benefit of using the command line interface is that you can use the program in your Windows batch file or Linux shell scripts to automate many URL related processes. Here are the command to transfer the three files used to display our web page.

->curl -T index.html -u root:root
->curl -T MirrorLike.png -u root:root
->curl -T TourStart.png -u root:root

Moving the files to the httpd directory

The files will be copied to the directory: /var/ftp. We have to move them to the: /home/httpd directory:

->cd /var/ftp
->mv index.html /home/httpd/.
->mv MirrorLike.png /home/httpd/.
->mv TourStart.png /home/httpd/.

Displaying the web page

Enter the web address: in your web browser.

Include the files in the build process

We add the web page files to the httpd directory in the TourSkating apps directory.

We then modify the makefile to include the web page files during the build. Here is the modified makefile:

$(error "Error: PETALINUX environment variable not set.  Change to the root of your PetaLinux install, and source the file")


APP = TourSkating

# Add any other object files to this list below
APP_OBJS = TourSkating.o

all: build install

build: $(APP)

    $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

    -rm -f $(APP) *.elf *.gdb *.o

.PHONY: install image

install: $(APP)
    $(TARGETINST) -d $(APP) /bin/$(APP)
    $(TARGETINST) httpd/index.html /home/httpd
    $(TARGETINST) httpd/MirrorLike.png /home/httpd
    $(TARGETINST) httpd/TourStart.png /home/httpd
%.o: %.c
    $(CC) -c $(CFLAGS) -o $@ $<

After building and booting PetaLinux we can access the web page without any modifications.

Top   Previous   Next

Posted at 16:15 by svenand
Make a comment  

Saturday, March 29, 2014
Zynq design from scratch. Part 33.
Mounting guest file system

We have already seen that we can login to the Ubuntu guest using ssh and that we can transfer files using sftp. Now let's find out how we can mount a file system from Ubuntu in our host computer.


SSHFS (SSH Filesystem) is a filesystem client to mount and interact with directories and files located on a remote server or workstation. SFTP provides secure file transfer and a secure remote file system. While SFTP clients may transfer files and directories, the related file system may not be mounted locally using SFTP alone. Using SSHFS a remote file system may be treated in the same way as other volumes (such as CDs, DVDs, USB flash drives and shared disks). Let's take the easy path and use some available software.


ExpanDrive is a Network file system client for Mac OS X and Microsoft Windows that facilitates mapping of local volume to any SFTP server the user can access. It also can connect to FTP, Amazon S3, RackSpace Cloud Files, OpenStack Swift Object Storage, DreamObjects, WebDAV, Dropbox, Google Drive and When a server is mounted with ExpanDrive any program can read, write, and manage remote files (that is, files that only exist on the server) as if they were stored locally.

Download and install

We will download a free trial version for a  start.

Setup ExpanDrive

We will fill in the values for our Ubuntu guest and click Connect.

The home directory of our Ubuntu guest is mounted in Mac OS X and visable in the Finder.

Click Reveal to update file system display.

Using sshfs from the command line

SSH’ing to a server and doing all the configuration through terminal is easy and very fast, but when we want to edit files and set a remote development environment on our local machine, mounting a remote filesystem over ssh and editing them as the files were in your computer is the way to go. Right now I’m using OSX Mavericks (OSX 10.9), so for mounting a remote system we will need to do some tricks and tweaks to have it working. I will try to explain step-by-step on how to do it.


First of all, we will have to install OSX Fuse, the successor of the MacFuse software. Here is the download link: With the file downloaded, right click on the dmg file, open and install it.

MacFuse (OSXFuse) can be found in the System Preference pane.

Install sshfs

Click this link to install sshfs 2.4.1: Run through the installer with the default options.

Mount the guest file system

Open a terminal on the host and use the following command to mount a guest file system:

-> sshfs <guest username>@<guest IP address>:<Guest mount directory> <Host mount point>

Mount the guest's Projects directory in the host 's UbuntuShare directory:

->sshfs svenand@ /Users/zoocad/UbuntuShare

Displayed in the Finder

Top   Previous   Next

Posted at 12:29 by svenand
Make a comment  

Tuesday, March 25, 2014
Zynq design from scratch. Part 32.
VirtualBox Seamless Mode

When we have the Guest Additions up and running it’s time for the real fun, trying out seamless mode. Select “View,” then “Switch to Seamless Mode.” After we done this, our host operating system and our virtual operating system should seem to combine. We’ll have a taskbar from each and programs from each will be visible over our native operating system’s desktop. This a very good solution when we don't have access to an extra display. Here is an example.

Starting a terminal on the host

When in Seamless Mode we can now start a terminal on the host instead of fighting with GTKterm on the guest. Open a Mac terminal window on the host and type the following command:

screen /dev/tty.usbmodemxxx 115200

replacing the xxx with the actual modem number (use tab completion to find the number). Here is what it looks like after PetaLinux has booted.

Type <ctrl a> and then <k> to end the screen session.

Top   Previous   Next

Posted at 10:53 by svenand
Make a comment  

Next Page