H8S2472 Ethernet Application Note
Total Page:16
File Type:pdf, Size:1020Kb
APPLICATION NOTE H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example Introduction The demonstration project contains software that shows the features and capabilities of the Renesas H8S2472 Ethernet connectivity with open source uIP TCP/IP protocol stack. This project runs on a Renesas Starter Kit board that features an H8S2472 MCU with 34MHz system clock, 512KB of ROM and 40KB of RAM. This application note assumes some experience with Ethernet, TCP/IP, and HTTP. For more introductory material on these subjects please see the references. Target Device H8S2472 RSKH8S2472 Board Contents 1. Overview ........................................................................................................................................... 2 2. How to Run the Demo....................................................................................................................... 2 3. Changes Made to uIP Stack ............................................................................................................. 6 4. Steps to Create a New Web Page .................................................................................................... 6 5. uIP TCP/IP Stack Port Characterizations ......................................................................................... 7 6. Buffer Management........................................................................................................................... 9 7. uIP Stack Demo with DHCP Client ................................................................................................. 14 8. Driver APIs ...................................................................................................................................... 17 REU05B0075-0101/Rev.1.02 September 2008 Page 1 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example 1. Overview The uIP TCP/IP stack demonstration software provides an example of Ethernet connectivity and a sample web server application that controls LEDs on the Renesas RSKH8S2472 board. 2. How to Run the Demo The procedure below provides step by step instructions for how to connect demonstration platform to a PC and run it. 2.1 Procedure This application note serves two slightly different demonstration examples: The uIP TCP/IP stack with static IP address and uIP TCP/IP stack with DHCP client. For static IP demonstration, test procedure is given in Section 2.1. Section 7 describes the demonstration example with DHCP client. To execute the demo, configure an unused Ethernet port with a static IP address of 10.10.10.11. Make sure that this Ethernet port is not used to access a corporate network or to a workgroup. If there is not a spare Ethernet port available, follow the procedure in Appendix A to install an USB to Ethernet adaptor. The static IP address of the demonstration software is set to 10.10.10.10, a Class A private IP address. The steps below show how to configure an Ethernet port with a static IP address: 1. Launch Control Panel and open Network Connections. 2. Right click on Local Area Connection and select Properties. Select Internet Protocol (TCP/IP) as shown in Figure 1 and click on Properties. Figure 1 IP Configuration for PC 3. Configure the IP address as shown in Figure 2 and click OK to save. REU05B0075-0101/Rev.1.02 September 2008 Page 2 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example Figure 2 IP Address and Subnet Mask Configuration for PC Once the PC Ethernet port configuration is complete, connect a straight RJ-45 Ethernet cable from this port to the Ethernet port of the RSKH8S2472. Power up the RSKH8S2472 with 5V power supply adaptor and make sure that the E10A jumper is removed. This jumper is required when debugging with an E10A debugger and not used when running the demonstration software from the flash. Figure 3 shows the RSKH8S2472 board and its major components. Figure 3 Picture of RSKH8S2472 2.2 Sample Project Directory Structure Figure 4 shows the demonstration sample project directory structure. This application note is provided with the sample demonstration project and it is in the \doc folder. The \src folder contains the source code and has 3 main subfolders: REU05B0075-0101/Rev.1.02 September 2008 Page 3 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example bsp, driver and uip. The \src\bsp and \src\driver folders have Renesas board specific source code and the driver for the H8S2472 Ethernet peripheral. The uIP stack is in the \src\uip folder. The open source uIP TCP\IP stack comes with its own documentation and it is in the \src\uip\doc folder. The main.c file is in \src\uip\uip and all the example web pages are in src\uip\apps\webserver\httpd-fs folders. Figure 4 Directory Structure REU05B0075-0101/Rev.1.02 September 2008 Page 4 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example 2.3 What to do with the demo Launch a web browser and type in 10.10.10.10 in the URL field. The user sees the welcome page shown in Figure 5. This is also the Front page. Figure 5 uIP Welcome Page All other pages can be access by links provided in the top banner. The file statistics link shows the number of times a specific page is accessed. The network statistics link displays the number of IP, ICMP, and TCP packet reception and transmission information. The network connections link shows the current status of established TCP connections to the uIP stack. The Renesas H8S2472 and the LED control links are new web pages added to the uIP stack to demonstrate sample web applications. The Renesas H8S2472 page displays an H8S2472 logo as shown in Figure 6. Figure 6 H8S Logo Web Page The LED control link displays the page in Figure 7. This page uses the “POST” method to transmit a request to a server. The “POST” method was added by Renesas to uIP stack, which only supports the “GET” method. The difference between the two methods is the “POST” sends all the information from a web page separately from the URL. The “GET” method attaches the information from the web page to the end of the URL. REU05B0075-0101/Rev.1.02 September 2008 Page 5 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example Figure 7 LED Control Web Application Page From this web page, the user can turn on and off the LEDs on the RSKH8S2472. The Reset button selects the off setting for all LEDs. 3. Changes Made to uIP Stack The following changes were made to the uIP stack to create the demonstration software. The changes discussed below are shown in detail in Appendix C. 1. Added “POST” method processing to http.c. 2. Added LED control processing to main.c. 3. Exchanged uIP driver function calls with H8S2472 specific ones in main.c 4. Added logo.jpg, Renesas.shtml, and led.shtml files to apps\webserver\httpd-fs\ directory. 5. Created makefadata.exe from makefsdata Perl script. This executable is included into the demonstration software in apps\webserver\ directory to make it easier for the user to generate the httpd-fsdata.c file without the need to find and install a Perl interpreter. If a Perl interpreter is needed, a free copy of ActivePerl can be downloaded from http://www.activestate.com/Products/activeperl/. 6. Processed the files in apps\webserver\httpd-fs\ directory to generate the new httpd-fs.data.c file. This file contains static constant data to create web pages. 4. Steps to Create a New Web Page A new web page can be easily created and added to the demonstration software by following the steps below. With a little html language knowledge the user can create custom web page applications. All the tools and the information needed are provided with the demo project and in this application note. 1. Write a new web page application. See led.shtml example in Appendix C. 2. Copy it to apps\webserver\httpd-fs\ directory. 3. Run makefsdata.exe from apps\webserver\ direstory to generate the new fttpd-fsdat.c file. 4. Re-build the project. REU05B0075-0101/Rev.1.02 September 2008 Page 6 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example 5. uIP TCP/IP Stack Port Characterizations uIP stack was originally developed by Adam Dunkels of the Networked Embedded Systems Group at the Swedish Institute of Computer Science. Currently, is it part of the open source community and can be obtained freely from http://www.sics.se/~adam/uip/index.php/Main_Page. uIP stack includes some higher layer example applications such as web server, web client, Trivial File Transfer Protocol (TFTP), and DNS hostname server. uIP stack is ported to Renesas RSKH8S2472 platform and the web server application is used in the stack demonstration software. This section provides the characterization data for this port. 5.1 Data Throughput Analysis The fping command utility is used to send ICMP messages. ICMP messages are also known as ping requests and ping replies. The utility can be found free of charge at http://www.kwakkelflap.com/fping.html. More information on Fping is given in Appendix B. The other tool used is the network protocol analyzer Ethereal. It has powerful features to capture and analyze Ethernet frames. Ethereal is now called Wireshark and it can be downloaded free from http://www.wireshark.org/. For maximum throughput measurement, 5,000 ICMP requests with 1472 data bytes are sent at 1ms apart. At this data length IP packets fit perfectly in one maximum length Ethernet frame. The overhead for an ICMP message is 42 bytes. This includes 14 bytes Ethernet, 20 bytes IP, and 8 bytes ICMP headers. Test Input C:\>fping 10.10.10.10 -t 1 -n 5000 -s 1472 Test Output Ping statistics for 10.10.10.10: Packets: Sent = 5000, Received = 5000, Lost = 0 (0% loss) Approximate round trip times in milli-seconds: Minimum = 2.5 ms, Maximum = 3.5 ms, Average = 2.7 ms REU05B0075-0101/Rev.1.02 September 2008 Page 7 of 30 H8S/2472 uIP TCP/IP Protocol Stack Demonstration Example Ethereal Analysis Figure 8 Ethereal Statistical Analysis As seen in Figure 8, total of 10,000 Ethernet frames were captured and the average throughput was 5.348Mbps. 5.2 Analysis of Ethernet Frame Processing At worst case, the maximum processing time for an Ethernet frame is 2.1ms at 32MHz system clock.