By Adam Taylor
We introduced the concept of the IP stack in the previous instalment of the MicroZed Chronicles. (See “Adam Taylor’s MicroZed Chronicles Chronicles Part 79: Zynq SoC Ethernet Part III.”) The next step is to use this stack in our design. The SDK development environment gives us the ability to include a lightweight IP stack (lwIP) when we create a BSP. lwIP is an open-source IP stack that’s used in a number of embedded systems. Originally it was developed by the Swedish Institute of Computer Sciences to reduce the resources required to create an IP stack.
Including lwIP in a Zynq-based design is very simple. You simply check the lwIP option on the BSP settings overview tab. If you are planning on using your Zynq system to host a web page, you will also need to check the xilmfs (Xilinx Memory File System) box to set up a file system within the Zynq system’s DDR memory.
Once you have included this library, you can configure it by selecting lwIP under standalone as shown below:
This option allows you to configure the lwIP as required, however your actual application will define parameters including IP addresses and subnets.
One way to use lwIP is to host a web page that provides system telemetry. You can use the same Web page to control the system using HTTP commands. These sorts of Web interfaces are very useful for Ethernet-connected embedded systems.
We’ll also need a file system to host a web page. The file system will be located within the Zynq SoC system’s DDR memory. The procedure for setting up this file system is very similar to the one for configuring the lwIP stack. Select the xilmfs option to define the memory location where the file system will reside:
We can create a file using the mfsgen command in a Vivado tcl command line if required. We can also import webpages and pictures into the file system to be accessed by the lwIP stack using this command.
During software development, we will be using SDK and JTAG to download and run the lwIP application. As SDK downloads the ELF application, it must also download the file system memory contents to the correct location. This is achieved by adding a reference to the file system image created by mfsgen to the run or debug configuration. This image will then be downloaded to the correct memory location before the application executes so that it can find the required files (e.g. the websites to serve).
With the file system and the lwIP installed correctly, we can now focus on application development. There are two main methods that we can use to interface our application to the lwIP stack:
A good example that pulls all of these concepts together and provides both Raw and Socket use cases can be found in XAPP1026 (LightWeight IP Application Examples), which implements a simple echo server and Web page server. Note that we are using the MicroZed board in this series and not the ZC7002 board so we need to use the port available on zedboard.org.
Going forward, I want to look at some very new and interesting developments in the Zynq world. I will be returning to this topic op IP use on the Zynq SoC in a little while.
Incidentally I am at the Embedded Systems Conference in Boston next week presenting on processor selection criteria for space-based applications. If you are attending this event, please drop by and say “hello.” It would be great to talk other Zynq users.
Now, you can have convenient, low-cost Kindle access to the first year of Adam Taylor’s MicroZed Chronicles for a mere $7.50. Click here.
Please see the previous entries in this MicroZed Chronicles series by Adam Taylor: