Networked Systems

With the increasing popularity of Internet of Things(IoT), its very common now to have a network-enabled embedded system. Network-enabled devices can be monitored and controlled remotely, and they can also communicate and coordinate with each other. One of the major advantages of using an embedded operating system such as PetaLinux is the accessibility to a rich network stack which supports a number of network protocols and applications. Using an embedded operating system can significantly simplify the process of making an embedded system network-capable.

Lab11 teaches how to get a Zynq chip connect to an Ethernet network and expand its capabilities to include network capabilities. This lab gives an overview of the network capabilities of PetaLinux. Different network applications and protocols supported by PetaLinux are explained and tested in this lab(dhcp, ping, ssh, httpd, ftp/tftp). Kernel menus responsible for configuring the network stack/applications are also reviewed.

Lab11 Design Flow

Lab11 Design Flow

Lab11 Block Diagram

Lab11 Block Diagram

Lab11 Board Interface

Lab11 Board Interface

Objectives

1.Assign Zedboard an IP address dynamically using a DHCP server running on a host machine.
2.Use FTP  protocol to exchange files with Zedboard over a network.
3.Utilize SSH to access PetaLinux shell remotely.
4.Explore the different network stack related sub-menus in menuconfig of PetaLinux.
5.Communicate with the default webpage server of Petalinux running on Zedboard using a browser running on the host machine.

Procedures

     A-Setup PetaLinux working environment
Follow the same steps in Procedures-D of Lab10 to setup the environment variables and search paths for PetaLinux tools.

     B-Configure roof file system to include dropbear and httpd 

In this step, configuration menu (menuconfig) of root filesystem is launched to configure the different components of PetaLinux network stack.

1.Make sure you are still logged in as root (# symbol should appear next to cursor – otherwise log in as root using sudo su)

2.Change directory to PetaLinux project directory by issuing the following command.( assumes you have already downloaded and configured PetaLinux using lab10 steps)

cd /opt/embeddedcentric/zedboard/Avnet-Digilent-ZedBoard-2015.2/

3.Launch menuconfig of root filesystem by issuing the following command.

petalinux-config -c rootfs

4.Select Filesystem Packages, then use the down arrow key to navigate to console/network. In console/network, select dropbear and hit enter. Press the ‘y‘ key to include both dropbear and dropbear-openssh-sftp-server in the root filesystem.

rootfs menuconfig – Navigate to Filesystem Package

rootfs menuconfig – Navigate to Filesystem Packages

console_network

Filesystem Packages -> Console/Network

dropbear

Filesystem Packages -> Console/Network -> dropbear

include_dropbear

Include both dropbear and dropbear-openssh-sftp-server (Use the Y key)

Dropbear is a light weight SSH(Secure SHell) server and client, which allows remote login to the shell of the board. The PetaLinux shell was accessed in the previous lab by using the relatively slow  UART /USB serial port, which was opened through gtkterm application. In this lab, we will learn how we can access PetaLinux shell in a more optimized and convenient way by using SSH. By adopting dropbear we can access PetaLinux terminal (i.e. Zedboard) from any machine connected to the network.

Hit the Escape (Esc) key four times to return to the Filesystem Packages window. Then, use the Down key to navigate to base . In base, select busybox and hit enter.  Press the ‘y‘ key to include busybox-httpd .

base

Filesystem Packages -> base

busybox

Filesystem Packages -> base -> busybox

Include

Include busybox-http

httpd ( short for  HTTP Daemon) is a network application that runs in the background of a web server and waits for incoming server requests. httpd answers requests automatically and serves the hypertext and multimedia documents over the network using HTTP.

In this lab, we will access the default webpage that comes with PetaLinux using a web browser running on the host machine. This can be easily done by typing the name IP address assigned to Zedboard in the address bar of your favorite browser on your host machine . In the screenshot below , the IP address of Zedboard was 192.168.1.10.

PetaLinux Default Webpage

PetaLinux Default Webpage

Use the right key to navigate to Save, Then hit enter three times to save the new configuration. Finally, select Exit to exit menuconfig and return to command line.

rootfs menuconfig -Confirm new configuration

rootfs menuconfig -Confirm new configuration

By this, both dropbear and httpd network applications have been included in the source code of the kernel to be generated. The next step is to compile the kernel and build a new image.

     C-Build PetaLinux Image

Follow the same steps in Procedure-G of Lab10 to build the new PetaLinux image with network applications dropbear and httpd included

    D-Generate deployment binary package (BOOT.BIN)

Follow the same steps in Procedure-H of Lab10 to generate the boot file to be loaded on the SD card.

     E-Copy BOOT.BIN and Linux Kernel image (image.ud) to SD card

Follow the same steps in Procedure-I of Lab10 to copy the two files to SD card.

     F-Setup Zedboard to boot from SD card

Follow the same steps in Procedure-J of Lab10 to prepare the Zedboard to boot from SD card.

     G-Connect host machine and Zedboard via Ethernet cable

The simplest way to establish a network connection between a host machine and a Zedboard is via an Ethernet cable which directly connects the two. This effectively establish a peer-to-peer connection between the two.

Ethernet Connection

Ethernet Connection

Another alternative, which is more of what you would see in real life is to connect Zedboard through a network switch. The steps explained in this lab work on both ways.

     H-Download, install and configure DHCP server on host machine 

The Dynamic Host Configuration Protocol (DHCP) is a network service that enables machines to be automatically assigned settings from a DHCP server as opposed to be manually configured. machines configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer’s user. A DHCP server is responsible for automatically providing a machine an IP address(given that the client machine is running a client DHCP ). In our case, The server is running on a host machine running Ubuntu, and  the machine to be given an IP address is Zedboard running PetaLinux, which has by default a DHCP client running.

1.Access terminal as root. Open a terminal and log in as a root by typing sudo su and entering your password.

sudo su

Access as root

Access as root

2.Download and install DHCP server for Ubuntu by issuing the following command

sudo apt-get install isc-dhcp-server

Download and Install DHCP Server

Download and Install DHCP Server

Type ‘y‘ when prompted. Download and installation will take some time. On a successful installation, you should get a similar output:

Successful installation of DHCP Server

Successful installation of DHCP Server

With this, the DHCP server is installed on your host machine. The next step is to configure the server.

3.Open the configuration settings file of the DHCP  server /etc/dhcp/dhcp.conf  . Issue the command

gedit /etc/dhcp/dhcp.conf

gedit_dhcp_conf

Open configuration file of the DHCP Server

4.Change default configuration settings of DHCP server by adding the following lines to the end of file

option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name “mydomain.example”;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100;
range 192.168.1.150 192.168.1.200;
}

Change DHCP Server settings

Change DHCP Server settings

The new settings will result in the DHCP server giving a client( like a Zedboard) an IP address from the range 192.168.1.10 – 192.168.1.100 or 192.168.1.150 – 192.168.1.200. It will lease an IP address for 600 seconds if the client doesn’t ask for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also “advise” the client that it should use 255.255.255.0 as its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers. Hit the save button and close the file.

5.Specify on what physical interface card should the DHCP server (dhcpd) serve requests. Since we are connecting Zedboard using an Ethernet cable connected to the Ethernet port of the host machine, specify  “eth0” , which represents the default Ethernet card of the machine. Issue the following command to open the file isc-dhcp-server associated with the interfaces for DHCP server:

gedit /etc/default/isc-dhcp-server

In the last line add eth0 between the double quotation mark. Click on Save and close the file.

chage interfaces

Specify the interface dhcpd should serve

Note: If you are using a USB-Ethernet connector, you need to use the command ifconfig to figure out the name of the interface the cable is connected to.

6.Restart the server so that the new configuration settings will take effect. Issue the following command

service isc-dhcp-server restart

Restart DCHP server to apply new configuration settings

Restart DCHP server to apply new configuration settings

On a successful restarting, you should get something similar to the screenshot above (process number might be different )

7. Launch Network Connections by clicking on the network manager icon and selecting Edit Connections.

Launch Network Connections

Launch Network Connections

8.In Network Connections, select eth0 and click Edit.

Network Connections

Network Connections

9.Select IPv4 Settings. Set Method to Manual and enter the addresses as shown in the figure below:

IPv4Settings

IPv4Settings

Click Save and then click Close to exit Network Connections. This step is needed to give the host machine a fixed IP address.

     I-Open GtkTerm serial port terminal

1.Change permission modes of device file associated with the serial port ttyACM0 to readable/writable by issuing the following command.

sudo chmod 666 /dev/ttyACM0

Make ttyACM0 readable/writable

Make ttyACM0 readable/writable

2.Launch GtkTerm by typing serial  in the dashboard search field and hitting enter.

serial luanch

Launch GtkTerm

3.Press the PS-RST button to reboot PetaLinux , so that we can see the booting sequence.

PS-RST Button

PS-RST Button

4.Observe PetaLinux boot screen on GtkTerm and memorize the IP address assigned to Zedboard by the DHCP server running on the host machine.

PetaLinux Reboot

PetaLinux Reboot

Several things are noted from the above figure. First, the DHCP server on the host machine had assigned dynamically IP 192.168.1.10 to Zedbord (THIS IP ADDRESS MIGHT VARY FROM RUN TO RUN AND IT COULD NOT BE THE ONE THAT YOU WILL GET). Second , the SSH server on Zedboard is up and running and ready to be used.

Record the IP address that you got on your screen. This is the piece of information that you need to log in to PetaLinux remotely.

     J-Log-in to Zedboard using SSH

Open a new terminal on your host machine, log in as root(in case you are not already root). Then type the following command

ssh root@IP address of Zedboard

Note that in the IP address field above, you need to put the IP address obtained in the previous step.

A message will be promoted asking you to confirm log in. Type the word ‘yes‘ and hit enter(you need to type the complete word ‘yes’ not just the letter ‘y’ ). After that, you need to provide the password for the root access of Zedboard which is the word ‘root‘ without quotation marks.

ssh

Log-in to Zedboard using SSH

 with this remotely accessed PetaLinux shell, you have full access to the Zedboard resources.

     K-Test connectivity using PING Network Application  

PING (Packet INternet Groper) network application is the easiest way to test connectivity between two machines on a network. Whether it is Local Area Network (LAN) or Wide Area Network (WAN). Ping use ICMP (Internet Control Message Protocol) to communicate to other devices. For our basic setup, we have only two machines. The host machine with the fixed IP (192.168.1.1) and the Zedboard ( Dynamic IP), however if you had connected your Zedboard to a network containing multiple devices, the connectivity between different devices can be easily tested using the command ping followed by IP address of the machine to test the connection with.

Try the following command from the SSH terminal (PetaLinux Shell).

ping 192.168.1.1

The IP address provided is the IP address of the host machine ( which of course should get you a positive result as we already managed  to launch SSH through it) . Hit Ctrl+C to exit the ping command.

PING_Command

Testing Connectivity using PING command

However, if you try to ping an IP address that is unreachable, you will get an output saying “time out ” or ” network unreachable”.

     L-Exchange Files using FTP 

The File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one machine to another over a TCP-based network. FTP is built on a client-server architecture and uses separate control and data connections between the client and the server.

We can use FTP to transfer files between the host computer and Zedboard easily. Assume we have a directory names Exchange on your host machine desktop ( containing two files to be exchanged with Zdboard ) .

Exchange directory on host machine

Exchange directory(FTP Directory) on host machine

Content of Test1

Content of Test1

Content of Test2

Content of Test2

First, browse to the directory containing the files to be exchanged with Zedboard. using the cd command. After that,  issue the following command

ftp IP address of Zedboard

Then enter the name root , followed by the password root and hit enter 

FTP Login

FTP Session( Host-Zedboard)

 by this, an FTP session is established between Zedboard and the host machine.

Now keep in mind that directory Exchange on the host machine will contain all files exchanged with Zedboard. On the Zedboard side, there is a similar directory where files exchanged through FTP are stored. This directory is found in /var/ftp .

Now in PetaLinux terminal(SSH) , browser to the FTP directory on Zedboard by issuing the following command :

cd /var/ftp/

Browse to FTP directory on Zedboard

Browse to FTP directory on Zedboard

Let’s create a file using the touch command. Name this file Zedlog.txt

touch Zedlog.txt

Create a new file in Zedboard FTP directory

Create a new file in Zedboard FTP directory

Now back to the FTP session, type the following command ls . It will list files of the remotely connected device ( Zedboard in this case).

ls

Lists files on Zedboard FTP directory.

Lists files on Zedboard FTP directory.

You can notice that file Zedlog.txt is seen. To get this file from the remote machine (Zedboard) to the host machine, use the command get “name of the file”

get  Zedlog.txt

Copy a file from Zedboard using FTP

Copy a file from Zedboard

Now if you browse to the FTP directory on the host machine (Exchange) you will find file Zedlog.txt in there.

FTP Directory - Host Machine

FTP Directory – Host Machine

To do the opposite, To send a file from the host machine to Zedboard, use the command send “name of the file” . For example :

send Test1

send Test2

Send files to Zedboard using FTP

Send files to Zedboard using FTP

To verify that the files were received on the Zedboard side, In PetaLinux terminal(SSH) type ls 

FTP Directory - Zedboard

FTP Directory – Zedboard

You can see the files Test1 and Test2 of the host machine have been copied to Zedbaord . You can verify its content using the command cat

cat Test1

cat Test2

Verify content - Test1

Verify content – Test1

Verify Content - Test2

Verify content – Test2


By this you have completed Lab11-Networked-Systems.