January 5, 201611 minutes

This tutorial is the follow-up to Using AXI Ethernet Subsystem and GMII-to-RGMII in a Multi-port Ethernet design. In this part of the tutorial we will generate the bitstream, export the hardware description to the SDK and then test the echo server application on our hardware. The echo server application runs on lwIP (light-weight IP), the open source TCP/IP stack for embedded systems. Our hardware platform is the Avnet ZedBoard combined with the Ethernet FMC.
Firstly, for those of you who did not follow the first part of this tutorial, we will use the scripts in the Git repository for this project to regenerate the Vivado project. If you followed the first part of the tutorial correctly, you should not need to complete this step. Please note that the Git repository is regularly updated for the latest version of Vivado, so you must download the last “commit” for the version of Vivado that you are using.
build.bat file to run the batch file.cd command to navigate to the “Vivado” folder within the sources you just downloaded. Then type source build.tcl to run the build script.If you did not follow the first part of this tutorial, you may want to open the block diagram and get familiar with the design before continuing.
When you are ready to generate the bitstream, click “Generate Bitstream” in the Flow Navigator.

Once the bitstream is generated, the following window will appear. Select “View Reports” and click “OK”.

When the bitstream has been generated, we can export it and the hardware description to the Software Development Kit (SDK). In the SDK we will be able to generate the echo server example design and run it on our hardware.




At this point, the SDK loads and a hardware platform specification will be created for your design.
At this point, your SDK workspace should contain only the hardware description and no applications:

We add the echo server application by selecting New->Application Project from the File menu.

In the New Project wizard, we want to name the application appropriately, so type echo_server as the project name then click “Next”.

The next page allows you to create the new application based on a template. Select the “lwIP Echo Server” template and click “Finish”.

The SDK will generate a new application called echo_server and a Board Support Package (BSP) called echo_server_bsp, both of which you will find in the Project Explorer as shown below.

By default, the SDK is configured to build the application automatically.
The echo server template application will be setup to run on the first AXI Ethernet Subsystem block in our design. This corresponds to PORT0 of the Ethernet FMC. We want to add some code to the application to allow us to select a different port if we choose.
main.c file from the echo_server source folder.

#include "xlwipconfig.h"
/* Set the following DEFINE to the port number (0,1,2 or 3)
* of the Ethernet FMC that you want to hook up
* to the lwIP echo server. Only one port can be connected
* to it in this version of the code.
*/
#define ETH_FMC_PORT 0
/*
* NOTE: When using ports 0..2 the BSP setting "use_axieth_on_zynq"
* must be set to 1. When using port 3, it must be set to 0.
* To change BSP settings: right click on the BSP and click
* "Board Support Package Settings" from the context menu.
*/
#ifdef XLWIP_CONFIG_INCLUDE_AXIETH_ON_ZYNQ
#if ETH_FMC_PORT == 0
#define EMAC_BASEADDR XPAR_AXIETHERNET_0_BASEADDR // Eth FMC Port 0
#endif
#if ETH_FMC_PORT == 1
#define EMAC_BASEADDR XPAR_AXIETHERNET_1_BASEADDR // Eth FMC Port 1
#endif
#if ETH_FMC_PORT == 2
#define EMAC_BASEADDR XPAR_AXIETHERNET_2_BASEADDR // Eth FMC Port 2
#endif
#else /* XLWIP_CONFIG_INCLUDE_AXIETH_ON_ZYNQ is not defined */
#if ETH_FMC_PORT == 3
#define EMAC_BASEADDR XPAR_XEMACPS_1_BASEADDR // Eth FMC Port 3
#endif
#endifPLATFORM_EMAC_BASEADDR is used, and replace it with EMAC_BASEADDR.When you save the main.c file, the SDK should automatically start rebuilding the application.
The BSP for this project will also have to be modified slightly. There are a few reasons for these modifications, but we would be going off-track to discuss those reasons in detail at this point. If you’re using a version of Vivado between 2015.4 and 2016.2, you will have to use an earlier commit of the repo and read the the README.md file for instructions on applying the modifications:
If you are using Vivado 2016.3 or a newer version, find the last commit for your version of Vivado and the project repo will contain a copy of the modified source files. You will find the modified library files inside the EmbeddedSw directory of the repo.
I strongly recommend that you perform these modifications to the sources in the Vivado installation files - not the sources in the BSP of your SDK workspace. The reason is that the BSP sources will be written-over with the original sources every time that you re-build the BSP - so you’re better off modifying them at the true source.
Note: These modifications are specific to using the echo server application on the Ethernet FMC. If you are not using the Ethernet FMC, you may not need to make these modifications and you’re better off leaving the library sources as they are.
To setup our hardware, we need to configure the ZedBoard for configuration by JTAG, we need to set the VADJ voltage to the appropriate value and we need to correctly attach the Ethernet FMC. Follow these instructions to ensure that your setup is correct:








To be able to read the output of the echo server application, we need to use a terminal program such as Putty. Use the following settings:

With the terminal program open, we can now load our ZedBoard with the bitstream and then run the echo server application.


echo_server folder in the Project Explorer, then from the menu, select Run->Run.



The output indicates that:
Now that the application is running successfully, we can test the echo server by sending packets from our PC to the ZedBoard and looking at what gets sent back.
All Ethernet devices are required to respond to ping requests, so this is a very simple and easy test to perform using your computer. Just open a command window and type ping 192.168.1.10.

To test that the echo server is actually doing its job and echoing received packets, you will have to install software that allows you to send and receive arbitrary packets. The software that I use is called Packet Sender and can be downloaded here. Once the software is installed, follow the instructions below to send and receive packets:



If you want to experiment, you can play around with the software by sending more packets, or different kinds of packets.
So far we’ve been using PORT0 of the
Ethernet FMC to test the echo server, but suppose we wanted to use one of the other ports 1,2 or 3. You can configure the port on which to run lwIP by setting the ETH_FMC_PORT define that we added earlier to the main.c file of the SDK application. Valid values for ETH_FMC_PORT are 0,1,2 or 3.
One other thing to be aware of is the BSP setting called use_axieth_on_zynq. This parameter specifies whether the BSP will be used with
AXI Ethernet Subsystem or with something else: Zynq GEM, Ethernet lite, etc. Remember that in our Vivado design we connected ports 0, 1 and 2 to an
AXI Ethernet Subsystem block, and we connected port 3 to the GEM1 of the Zynq PS. Therefore, when selecting the port on which you wish to run lwIP, remember to correctly set the use_axieth_on_zynq parameter:
use_axieth_on_zynq must be set to 1.use_axieth_on_zynq must be set to 0.The application will not compile if the correct BSP settings have not been set. To change BSP settings: right click on the BSP and click Board Support Package Settings from the context menu.
The echo server application is actually a very good starting place for developing Ethernet applications on the ZedBoard or other Xilinx FPGAs. Here are some potential ways you could “tweek” the echo server application to be useful for other things:
Alternatively, if you’re interested in using Linux, take a look at this tutorial on bringing up multiple Ethernet ports in PetaLinux.
Below are the links to the source code Git repositories. There is a version of the project for the ZedBoard and the MicroZed. There is also a version that uses only the AXI Ethernet Subsystem IP.
If you enjoyed this tutorial or if you run into problems using it, please leave me a comment below.