没有合适的资源?快使用搜索试试~ 我知道了~
首页Xilinx FPGA上lwIP应用指南XAPP1026(v3.1)
资源详情
资源评论
资源推荐
XAPP1026 (v3.1) April 21, 2011 www.xilinx.com 1
© Copyright 2008-2009, 2011 Xilinx, Inc. Xilinx, the Xilinx logo, Artix, ISE, Kintex, Spartan, Virtex, Zynq, and other designated brands included herein are trademarks of Xilinx in
the United States and other countries. All other trademarks are the property of their respective owners.
Summary Lightweight IP (lwIP) is an open source TCP/IP networking stack for embedded systems. The
Xilinx
®
Software Development Kit (SDK) provides lwIP software customized to run on Xilinx
embedded systems containing either a PowerPC
®
or a MicroBlaze™ processor. The
information in this application notes applies to MicroBlaze processors only. This application
note describes how to utilize the lwIP library to add networking capability to an embedded
system. In particular, lwIP is utilized to develop these applications: echo server, Web server,
TFTP server and receive and transmit throughput tests.
Included
Systems
Included with this application note are PLB and AXI4-based reference systems for the Xilinx
ML605, SP605, and SP601 FPGA Starter Kit boards:
https://secure.xilinx.com/webreg/clickthrough.do?cid=107743.zip
Hardware and
Software
Requirements
The hardware and software requirements are:
• One of Xilinx ML605, SP605, or SP601 Development Boards
• Xilinx Platform USB Cable
• RS232 USB Cable
• A crossover ethernet cable connecting the board to a Windows or Linux host
• Serial Communications Utility Program, such as HyperTerminal or Teraterm
• Xilinx Platform Studio 13.1 for making hardware modifications
• Xilinx SDK 13.1 for running or making modifications to the software
Introduction lwIP is an open source networking stack designed for embedded systems. It is provided under
a BSD style license. The objective of this application note is to describe how to use lwIP
shipped along with the Xilinx SDK to add networking capability to an embedded system. In
particular, this application note describes how applications such as an echo server or a Web
server can be written using lwIP.
Application Note: Embedded Processing
XAPP1026 (v3.1) April 21, 2011
LightWeight IP (lwIP) Application Examples
Author: Stephen MacMahon, Nan Zang, Anirudha Sarangi
XAPP1026 (v3.1) April 21, 2011 www.xilinx.com 2
Reference
System
Specifics
The reference design for this application note is structured as follows:
• The ML605_AXI, ML605_PLB, SP605_AXI, SP605_PLB, SP601_AXI, and SP601_PLB
folders correspond to the three supported boards and six supported hardware designs.
• In each of these folders, the hw subdirectory contains the XPS hardware design, and the
sw subdirectory contains the application software and software platforms that need to be
imported into SDK.
•The sdk folder contains the software drivers and lwIP stack that need to be imported into
SDK before building the software applications.
•The ready_for_download folder contains these relevant files for getting started with the
applications:
• download.bit: bitstream to be downloaded to the board
• system_bd.bmm: for downloading the bitstream
• image.mfs: memory file system used for tftp, Web server applications
• raw_apps.elf: application ELF image to be downloaded to test the RAW API
(application programming interface)
• socket_apps.elf: application ELF image to be downloaded to test the socket API
•The memfs folder contains the contents of the memory file system (MFS) image.
• The image itself is also present as the image.mfs file in the respective
ready_for_download folders.
Hardware Systems
The hardware systems for the three boards were built using Base System Builder (BSB), with
minor modifications in XPS. For more information on hardware requirements for lwIP, see the
lwIP documentation available as part of SDK installation. Ta bl e 1 provides a summary of the
hardware designs for the three boards:
Notes:
1. The ML605_AXI and SP605_AXI hardware systems support full checksum (both TCP and IP checksums)
offload feature.
2. The ML605_PLB and SP605_PLB hardware systems support partial checksum (TCP checksum) offload
feature.
3. The SP601_AXI and SP601_PLB systems are Ethernetlite systems and built with PING-PONG buffers.
Table 1: Hardware Design Details
Board Processor
Processor
Frequency
EMAC DMA
ML605_AXI MicroBlaze 100 MHz axi_ethernet AXIDMA
SP605_AXI MicroBlaze 100 MHz axi_ethernet AXIDMA
SP601_AXI MicroBlaze 100 MHz axi_ethernetlite None
ML605_PLB MicroBlaze 100 MHz xps_ll_temac SDMA
SP605_PLB MicroBlaze 83.33 MHz xps_ll_temac SDMA
SP601_PLB MicroBlaze 83.33 MHz xps_ethernetlite None
XAPP1026 (v3.1) April 21, 2011 www.xilinx.com 3
Software
Applications
The reference design includes these software applications:
• Echo server
• Web server
•TFTP server
• TCP RX throughput test
• TCP TX throughput test
All of these applications are available in both RAW and socket modes.
Echo Server
The echo server is a simple program that echoes input that is sent to the program via the
network. This application provides a good starting point for investigating how to write lwIP
applications.
The socket mode echo server is structured as follows:
1. A main thread listens continually on a specified echo server port.
2. For each connection request, it spawns a separate echo service thread.
3. It then continues listening on the echo port.
while (1) {
new_sd = lwip_accept(sock, (struct sockaddr *)&remote, &size);
sys_thread_new(process_echo_request, (void*)new_sd,
DEFAULT_THREAD_PRIO);
}
The echo service thread receives a new socket descriptor as its input on which it can read
received data. This thread does the actual echoing of the input to the originator.
while (1) {
/* read a max of RECV_BUF_SIZE bytes from socket */
n = lwip_read(sd, recv_buf, RECV_BUF_SIZE));
/* handle request */
nwrote = lwip_write(sd, recv_buf, n));
}
Note: These code snippets are not complete and are intended to show the major structure of the code
only.
The socket mode provides a simple API that blocks on socket reads and writes until they are
complete. However, the socket API requires many pieces to achieve this, including primarily a
simple multi-threaded kernel (xilkernel). Because this API contains significant overhead for all
operations, it is slow.
The RAW API provides a callback style interface to the application. Applications using the RAW
API register callback functions to be called on significant events like accept, read or write. A
RAW API based echo server is single threaded, and all the work is done in the callback
functions. The main application loop is structured as follows:
while (1) {
xemacif_input(netif);
transfer_data();
}
XAPP1026 (v3.1) April 21, 2011 www.xilinx.com 4
The function of the application loop is to receive packets constantly (xemacif_input), then
pass them on to lwIP. Before entering this loop, the echo server sets up certain callbacks:
/* create new TCP PCB structure */
pcb = tcp_new();
/* bind to specified @port */
err = tcp_bind(pcb, IP_ADDR_ANY, port);
/* we do not need any arguments to callback functions */
tcp_arg(pcb, NULL);
/* listen for connections */
pcb = tcp_listen(pcb);
/* specify callback to use for incoming connections */
tcp_accept(pcb, accept_callback);
This sequence of calls creates a TCP connection and sets up a callback on a connection being
accepted. When a connection request is accepted, the function accept_callback is called
asynchronously. Because an echo server needs to respond only when data is received, the
accept callback function sets up the receive callback by performing:
/* set the receive callback for this connection */
tcp_recv(newpcb, recv_callback);
When a packet is received, the function recv_callback is called. The function then echoes
the data it receives back to the sender:
/* indicate that the packet has been received */
tcp_recved(tpcb, p->len);
/* echo back the payload */
err = tcp_write(tpcb, p->payload, p->len, 1);
Although the RAW API is more complex than the socket API, it provides much higher
throughput because it does not have a high overhead.
Web Server
A simple Web server implementation is provided as a reference for a TCP based application.
The Web server implements only a subset of the HTTP 1.1 protocol. Such a Web server can be
used to control or monitor an embedded platform via a browser. The Web server demonstrates
these features:
• Accessing files residing on a Memory File System via HTTP GET commands
• Controlling the LED lights on the development board using the HTTP POST command
• Obtaining status of DIP switches (push buttons on the ML403) on the development board
using the HTTP POST command
The Xilinx Memory File System (xilmfs) is used to store a set of files in the memory of the
development board. These files can then be accessed via a HTTP GET command by pointing
a Web browser to the IP address of the development board and requesting specific files.
Controlling or monitoring the status of components in the board is done by issuing POST
commands to a set of URLs that map to devices. When the Web server receives a POST
command to a URL that it recognizes, it calls a specific function to do the work that has been
requested. The output of this function is sent back to the Web browser in Javascript Object
Notation (JSON) format. The Web browser then interprets the data received and updates its
display.
剩余18页未读,继续阅读
jiayou0909
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3