Home

UM1713 User manual - STMicroelectronics

image

Contents

1. 4 LwIP n doc a hi src de api de core Le include netif 4 de system de arch de noOS Ji os di test where doc contains documentation text files src contains source files of the LwIP stack api contains Netconn and Socket API files core contains LwIP core files include contains LwIP include files netif contains Network interface files system contains LwIP port hardware implementation files arch contains STM32 architecture port files used data types OS contains LwIP port hardware implementation files using an operating system noOS contains LwIP port hardware implementation files in Standalone mode 8 41 DoclD025731 Rev 4 Ly UM1713 LwIP TCP IP stack description 1 5 LwIP API overview As mentioned above three types of APIs are offered by LwIP stack e Raw API e Netconn API e Socket API 1 5 1 Raw API 2 The Raw API is based on the native LwIP API It is used to develop callback based applications When initializing the application the user needs to register callback functions to different core events such as TCP Sent TCP error The callback functions are called from the LwIP core layer when the corresponding event occurs Table 1 provides a summary of the Raw API functions for TCP applications Table 1 TCP Raw API functions API functions Description Creates a new TCP PCB protocol control tcp new block tcp bind Binds a TCP PCB to a local IP address
2. MEMP NUM TCP SEG Maximum number of simultaneously queued TCP segments PBUF POOL SIZE Total number of PBUF POOL type pbufs DoclD025731 Rev 4 Ly UM1713 LwIP configuration 2 Table 7 LwIP memory configuration continued LwIP memory option PBUF POOL BUFSIZE Definition Size of a PBUF POOL type pbufs TCP MSS TCP maximum segment size TCP SND BUF TCP send buffer space for a connection TCP SND QUEUELEN TCP WND Advertised TCP receive window size Maximum number of pbufs in the TCP send queue DoclD025731 Rev 4 17 41 Developing applications with LwIP stack UM1713 4 4 1 18 41 Developing applications with LwIP stack Developing in standalone mode using the Raw API Operation model In standalone mode the operation model is based on continuous software polling to check if a packet has been received When a packet has been received it is first copied from the Ethernet driver buffers into the LwIP buffers To copy the packet as fast as possible the LwIP buffers pbufs should be allocated from the pool of buffers PBUF POOL When a packet has been copied it is handed to the LwIP stack for processing Depending on the received packet the stack may or may not notify the application layer LwIP communicates with the application layer using event callback functions These functions should be assigned before starting the communication process Refer to
3. sis the actual mode of connection Server mode 5 When the Key button is pressed on the STM324xx EVAL board the client sends a string and the server echoes back the same string to the client Note Make sure the remote PC IP address is identical to the address defined in the main h file 192 168 0 11 by default Figure 6 shows an example of this command string and of the module response Figure 6 TCP echo client cx Command Prompt echotool p tcp s C gt echotool p tcp s Waiting for TCP connection on port 7 Press any Client 192 168 6 16 4697 accepted at 2 24 42 PM 2 24 42 PM received sending tcp client message Session closed by peer Waiting for TCP connection on port 7 Press any Messz ge counter Client 192 168 86 16 4698 accepted at 2 24 45 PM 2 24 45 PM received sending tcp client message Session closed by peer Waiting for TCP connection on port 7 Press any Client 192 168 8 16 4699 accepted at 2 24 46 PM 2 24 46 PM received sending tcp client message Session closed by peer Waiting for TCP connection on port 7 Press any 6 1 2 TCP Echo server This application is used to test a basic TCP connection The STM32 MCU acts as a TCP server that waits for client requests It simply echoes back whatever is sent To test the TCP echo server demo follow these steps 1 Make sure of the STM324xx EVAL jumper settings are correct 2 2 Build and program the demonstration code into the STM3
4. Statistics cx Command Prompt loj x C gt echotool 192 168 80 18 p udp r 7 1 7 n 15 t 2 d Testing LwIP UDP echo server Hostname 192 168 68 18 resolved as 192 168 B 18 192 168 6 1 7 time 192 168 80 1 7 time 192 168 80 1 7 time 192 168 1 7 time 192 168 8 1 7 time 192 168 8 1 7 time 192 168 8 1 7 time 192 168 1 7 time 192 168 1 7 time 192 168 8 1 7 time 192 168 8 1 7 time 192 168 8 1 7 time 192 168 8 1 7 time 192 168 8 18 7 time 192 168 A 1A 7_ time Received 15 Corupted 6 BOQSoeagogggoagogea 32 41 Statistics providing the number of received and corrupted packets are given at the end of the test UDP TCP echo server based on netconn AP This demonstration provides the echo service application both for TCP and UDP protocols To test the UDP TCP echo server netconn demonstration in TCP server mode refer to Section 6 1 2 TCP Echo server To test the UDP TCP echo server netconn demonstration in UDP server mode refer to Section 6 1 4 UDP echo server 2 DoclD025731 Rev 4 UM1713 Using the LwIP applications 6 2 6 2 1 2 Features applications Web server based on raw API This application implements a web server based on the LwIP raw API It is used to connect to the STM32 MCU from a web client and to load HTML pages The web server application implements the following features URL parsing CGI Common Gateway Interface SSI Server
5. bind echo pcb to port 7 ECHO protocol err tcp bind tcp echoserver pcb IP ADDR ANY 7 if err ERR OK start tcp listening for echo pcb tcp echoserver pcb tcp listen tcp echoserver pcb initialize LwIP tcp accept callback function tcp accept tcp echoserver pcb tcp echoserver accept j else deallocate the pcb memp free MEMP TCP PCB tcp echoserver pcb LwIP API calls tcp new to allocate a new TCP protocol control block PCB tcp echoserver pcb The allocated TCP PCB is bound to a local IP address and port using tcp bind function DoclD025731 Rev 4 Ly UM1713 Developing applications with LwIP stack 2 After binding the TCP PCB tcp listen function is called in order to start the TCP listening process on the TCP PCB Finally a tcp_echoserver_accept callback function should be assigned to handle incoming TCP connections on the TCP PCB This is done by using tcp accept LwIP API function Starting from this point the TCP server is ready to accept any incoming connection from remote clients tcp echoserver accept function description The following example shows how incoming TCP connections are handled by tcp echoserver accept user callback function This is an extract from this function static err t tcp echoserver accept void arg struct tcp pcb newpcb err t err allocate structure es to maintain tcp connection informations es struct tcp echoserver st
6. y life augmented User man ual Developing applications on STM32Cube with LwIP TCP IP stack Note May 2015 Introduction STMCube is an STMicroelectronics original initiative to ease developers life by reducing development efforts time and cost STM32Cube covers STM32 portfolio STM32Cube Version 1 x includes e The STM32CubeMNX a graphical software configuration tool that allows to generate C initialization code using graphical wizards e A comprehensive embedded software platform delivered per series such as STM32CubeF4 for STM32F4 series The STM32Cube HAL an STM32 abstraction layer embedded software ensuring maximized portability across STM32 portfolio Aconsistent set of middleware components such as RTOS USB TCP IP Graphics All embedded software utilities coming with a full set of examples Some STM32 microcontrollers feature a high quality 10 100 Mbit s Ethernet peripheral that supports both Media Independent Interface MII and Reduced Media Independent Interface RMII to interface with the Physical Layer PHY When working with an Ethernet communication interface a TCP IP stack is mostly used to communicate over a local or a wide area network This user manual is intended for developers who use STM32Cube firmware on STM32 microcontrollers It provides a full description of how to integrate a free middleware TCP IP stack using STM32Cube HAL drivers into an embedded application based o
7. HAL Init Initilaize the LwIP stack lwIP init Network interface configuration Netif Config tcp echo server Init tcp echoserver init Infinite loop while 1 Read a received packet from the Ethernet buffers and send it to the lwIP for handling ethernetif input amp gnetif Handle LwIP timeouts sys check timeouts DoclD025731 Rev 4 19 41 Developing applications with LwIP stack UM1713 20 41 The following functions are called 1 AHAL Init function is called to reset all peripherals and to Initializes the Flash interface and the Systick timer 2 wIP init function is called to initialize the LwIP stack internal structures and start stack operations 3 Netif config function is called to configure the network interface netif 4 tcp echoserver init function is called to initialize the TCP echo server application 5 Jethernetif input function in the infinite while loop polls for packet reception When a packet is received it is passed to be handled by the stack 6 sys check timeouts LwIP function is called to handle certain LwIP internal periodic tasks protocol timers retransmission of TCP packets tcp echoserver init function description The tcp echoserver init function code is the following void tcp echoserver init void create new tcp pcb tcp echoserver pcb tcp new if tcp echoserver pcb NULL err_t err
8. 0 11 by default Figure 8 shows an example of this command string and of the module response Figure 8 UDP echo client Waiting 2 46 11 2 46 11 2 46 12 2 46 12 2 46 13 2 46 13 2 46 13 2 46 13 2 46 14 2 46 14 2 46 15 C gt echotool p udp s for UDP conncetion on port 7 Press any key to exit from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 8 18 4896 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 6 16 4696 received sending udp client message from 192 168 8 18 4896 received sending udp client message fron 5 received sending udp client message fron 5 received sending udp client message fron received sending udp client message fron received sending udp client message fron received sending udp client message 2 46 16 PM c Command Prompt echotool p udp s counter BRR RRR OORT OU AWN at G2 IND e eel 2 UDP echo server This application is used to test basic UDP connections The STM32 MCU acts as a UDP server that waits for client requ
9. CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF TH POSSIBILITY OF SUCH DAMAGE El El This file is part of the lwIP TCP IP stack E LwIP architecture LwIP complies with the TCP IP model architecture which specifies how data should be formatted transmitted routed and received to provide end to end communications This model includes four abstraction layers which are used to sort all related protocols according to the scope of networking involved see Figure 1 From lowest to highest the layers are e The link layer contains communication technologies for a single network segment link of a local area network e The internet layer IP connects independent networks thus establishing internetworking e The transport layer handles host to host communications e The application layer contains all protocols for specific data communications services on a process to process level DoclD025731 Rev 4 7 41 LwIP TCP IP stack description UM1713 Figure 1 LwIP architecture dhcp c dns c Application layer udp c Transport layer ip C Internet layer netif c eee layer 1 4 LwIP stack folder organization of the When unzipped the LwIP stack files can be found under Middlewares Third_Party LwIP Figure 2 Figure 2 LwIP folder organization
10. Figure 4 for a description of the standalone operation model flowchart Figure 4 Standalone operation model Poll for packet reception New packet received Yes Copy packet from driver buffers to IwiP buffers Processing of the packet by the IwIP stack Application notification needed Yes Processing of application assigned callback function MS18174V1 2 DoclD025731 Rev 4 UM1713 Developing applications with LwIP stack 2 For TCP applications the following common callback functions must be assigned e Callback for incoming TCP connection event assigned by TCP_accept API call e Callback for incoming TCP data packet event assigned by TCP_recev API call e Callback for signaling successful data transmission assigned by TCP_sent API call e Callback for signaling TCP error after a TCP abort event assigned by TCP_err API call e Periodic callback every 1 or 2 s for polling the application assigned by TCP_poll API call Example of TCP echo server demonstration The TCP echo server example provided in the V w PV wIP TCP Echo Server folder is a simple application that implements a TCP server which echoes any received TCP data packet coming from a remote client The following example provides a description of the firmware structure This is an extract of the main c file int main void Reset of all peripherals Initializes the Flash interface and the Systick
11. Netconn API HTTP Server Socket API Integrated TFTP Server Getting started applications use the minimal configuration to run applications on top of the LwIP stack LEDs are used to inform the user of application status Features applications provide more flexibility and options They support network protocols like HTTP DHCP and use LCD messages to indicate application status Integrated application supports FatFS middleware component and TFTP protocol to transfer files to and from microSD card located on the evaluation board Getting started applications TCP echo client This application is used to test a basic TCP connection The STM32 MCU acts as a TCP client that connects to the TCP server The client sends a string and the server echoes back the same string to the client To test the TCP echo client application follow these steps 1 Make sure the STM324xx EVAL jumper settings are correct 2 Build and program the demonstration code into the STM32F4xx Flash memory LEDs indicates the LwIP initialization success or failure the dynamic address allocation DHCP is not supported for this application 3 Onthe remote PC open a command prompt window Under Windows select Start gt All Programs gt Accessories gt Command Prompt DoclD025731 Rev 4 Ly UM1713 Using the LwIP applications 4 Atthe command prompt enter C gt echotool p tcp s where ptop is the TCP protocol TCP protocol
12. Side Includes Dynamic Header generation HTTP Post request To test the web server application follow these steps 1 2 Make sure of the STM324xx EVAL jumper settings are correct In the main h file uncomment USE DHCP or USE LCD options to enable the DHCP client or LCD screen features Build and program the application code into the STM32F4xx Flash memory If USE DHCP and USE LCD are defined a message is displayed on the LCD screen to indicate the success or failure of the DHCP IP address allocation otherwise the LEDs indicate the result of this operation After an IP address has been assigned either a static or a dynamic address the user can start the application On the remote PC open a web client Mozilla Firefox or Internet Explorer and type the board IP address in a web browser By default the following static IP address is used 192 168 0 10 DoclD025731 Rev 4 33 41 Using the LwIP applications UM1713 Figure 10 Web server home page STM32F4xx Windows Internet Explorer provided by Corporate PackageFabric ST 6 y y http j192 168 0 10 File Edit View Favorites Tools Help We de stmszraxx STM32F4xx Webserver Demo Based on the IwIP TCP IP stack STM32 F 4 Series y A i 132 Releasi ivi A new generation on STM32 with significant improvement in STM3 Releasing your creativity features performance y e More Memory A e Advanced features Maintain
13. and port TOP cennecicn tcp_listen Starts the listening process on the TCP PCB setup tcp accept Assigns a callback function that will be called when new TCP connection arrives Informs the LwIP stack that an incoming TCP top_accepted connection has been accepted tcp_connect Connects to a remote TCP host tcp_write Queues up data to be sent Assigns a callback function that will be called Sending TCP data tcp_sent when data are acknowledged by the remote host tcp_output Forces queued data to be sent Sets the callback function that will be called tcp recv when new data arrives Receiving TCP Must be called when the application has tcp recved processed the incoming data packet for TCP window management Assigns a callback functions that will be called periodically It can be used by the application to Application polling tcp poll check if there are remaining application data that needs to be sent or if there are connections that need to be closed DoclD025731 Rev 4 9 41 LwIP TCP IP stack description UM1713 Table 1 TCP Raw API functions continued API functions Description tcp close Closes a TCP connection with a remote host Assigns a callback function for handling tcp err connections aborted by the LwIP due to errors such as memory shortage errors Closing and aborting connections tcp abort Aborts a TCP connection Table 2 provides a summar
14. based on netconn API Applications are located under Projects repository following this path Projects STM324xx_EVAL Applications LwIP where STM324xx EVAL refers to STM32F4xx evaluation board such as STM324xG EVAL for STM32F407xx 417xx devices Applications settings PHY interface configuration The Ethernet peripheral is interfaced with an external PHY to provide physical layer communications The PHY registers definition and define statements are located in the HAL configuration file stm32f4xx_hal_conf h The PHY can operates in MII or RMII mode To select the required mode fill the Medialnterface parameter in Init structure when initializing the Ethernet peripheral Refer to the readme file provided within your device Ethernet examples to know more about the available PHY interface modes on the supported boards DoclD025731 Rev 4 Ly UM1713 LwIP package description 5 2 2 5 2 3 Note Note 5 3 2 MAC and IP address settings The default MAC address is set to 00 00 00 00 00 02 To change this address modify the six bytes defined in the stm32f4xx hal conf h file The default IP address is set to 192 168 0 10 To change this address modify the four bytes defined in the main h file Firmware features This package includes modules to enhance and widen the use of the some applications The DHCP protocol is supported so that the STM32 MCU can act as a DHCP client to get a dynamic IP address when it is
15. focus of the LwIP TCP IP implementation is to reduce RAM usage while keeping a full scale TCP IP stack This makes LwIP suitable for use in embedded systems LwIP comes with the following protocols e Pv4 and IPv6 Internet Protocol v4 and v6 e ICMP Internet Control Message Protocol for network maintenance and debugging e IGMP Internet Group Management Protocol for multicast traffic management e UDP User Datagram Protocol e TCP Transmission Control Protocol e DNS Domain Name Server e SNMP Simple Network Management Protocol e DHCP Dynamic Host Configuration Protocol e PPP Point to Point Protocol e ARP Address Resolution Protocol LwIP has three application programming interfaces APIs e RawAPlisthe native LwIP API It enables the development of applications using event callbacks This API provides the best performance and optimized code size but adds some complexity to application development e Netconn API is a high level sequential API that requires a real time operating system RTOS The Netconn API enables multithreaded operations e BSD Socket API Berkeley like Socket API developed on top of the Netconn API The source code for the LwIP stack can be downloaded from http savannah nongnu org License LwIP is licensed under the BSD license Below is a copy of the LwIP license document that is included in the source codes Copyright c 2001 2004 Swedish Institute of Computer Science All
16. pbuf or a chain of pbufs 2 When working with the Netconn API netbufs network buffers are used for sending receiving data A netbuf is simply a wrapper for a pbuf structure lt can accommodate both allocated and referenced data A dedicated API implemented in file netbuf c is provided for managing netbufs allocating freeing chaining extracting data DoclD025731 Rev 4 13 41 Interfacing LwIP with STM32Cube Ethernet HAL driver UM1713 2 Interfacing LWIP with STM32Cube Ethernet HAL driver This package includes two implementations e Implementation without operating system standalone e Implementation with an operating system using CMSIS RTOS API For both implementations the ethernetif c file is used to link the LwIP stack to the STM32 Ethernet network interface The port of LwIP stack that must be connected to STM32F 4xx is located in the wip system folder The Ethernet handle of the HAL ETH_HandleTypeDef should be declared in the ethernetif c file as well as the Ethernet DMA descriptors ETH_DMADescTypeDef and the Rx Tx buffers of the Ethernet driver Table 6 provides a description of the LwIP interface API Table 6 Ethernet interface functions description Function Description Calls the Ethernet driver functions to initialize the STM32F4xx low levels Ethernet peripheral low_level_output Calls the Ethernet driver functions to send an Ethernet packet low_level_input Calls th
17. rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met 1 Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer DoclD025731 Rev 4 Ly UM1713 LwIP TCP IP stack description 1 3 2 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution 3 The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF DISCLAIMED IN Xj MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AR NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN
18. time time time time time C gt echotool 192 168 B 1B p tcp r 7 n 15 t 2 d Testing LwIP TCP echo server A 192 168 8 18 ms ms ms ms ms ms ms ms ms ms ms ms ms ms ms z Received 15 Corrupted 8 Note 6 1 3 30 41 Statistics provide the number of received and corrupted packets is the end of the test UDP echo client This application is used to test basic UDP echo connections The STM32 MCU acts as a UDP client that connects to a UDP server To test the UDP echo client demonstration follow steps below Make sure of the STM324xx EVAL jumper settings are correct Build and program the demonstration code into the STM32F4xx Flash memory LEDs indicates the LwIP initialization success or failure the dynamic address allocation DHCP is not supported for this application On the remote PC open a command prompt window Under Windows select Start gt All Programs gt Accessories gt Command Prompt At the command prompt enter 1 2 DoclD025731 Rev 4 Ly UM1713 Using the LwIP applications Note C gt echotool p udp s where pudpis the protocol UDP protocol sis the actual mode of connection Server mode When the Key button is pressed on the STM324xx EVAL board the client sends a string and the server echoes back the same string to the client Make sure that the remote PC IP adaress is identical to the address defined in the main h file 192 168
19. with section STM32Cube overview Changed STM32F4xx STM32F2x7xx into STM32F4xx in the whole document and removed STM322xG EVAL board 27 May 2015 4 Updated Section 5 1 LwIP package directories DoclD025731 Rev 4 Removed note related to RMII mode and added note concerning related boards in Section 5 2 1 PHY interface configuration Removed dedicated evaluation board settings sections in Section 5 2 Applications settings 2 UM1713 IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections enhancements modifications and improvements to ST products and or to this document at any time without notice Purchasers should obtain the latest relevant information on ST products before placing orders ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement Purchasers are solely responsible for the choice selection and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products No license express or implied to any intellectual property right is granted by ST herein Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product ST and the ST logo are trademarks of ST All other product or service names are the property of their respective owners Informa
20. 2F4xx Flash memory LEDs indicates the LwIP initialization success or failure the dynamic address allocation DHCP is not supported for this application 3 Onthe remote PC open a command prompt window Under Windows select Start gt All Programs gt Accessories gt Command Prompt DoclD025731 Rev 4 29 41 Using the LwIP applications UM1713 4 At the command prompt enter C gt echotool IP address p tcp r 7 n 15 t 2 d Testing LwIP TCP echo server Figure where IP address is the actual board IP address By default the following static IP address is used 192 168 0 10 ptop is the protocol TCP protocol ris the actual remote port on the echo server echo port nis the number of echo requests for example 15 ftis the connection timeout in seconds for example 2 dis the message to be sent for echo for example Testing LwIP TCP echo server 7 shows an example of this command string and of the module response Figure 7 TCP echo server cx Command Prompt from from from from from from from fron fron fron fron fron fron fron fron Hostname 192 168 B 192 168 192 168 8 192 168 8 192 168 8 192 168 192 168 192 168 192 168 6 192 168 6 192 168 6 B 8 8 8 192 168 192 168 6 192 168 6 192 168 6 B 192 168 18 resolved as 16 7 time time time time time time time time time time
21. API The following example shows a TCP echoserver application developed with the Netconn API This is extract of the main c file int main void Create the Start thread osThreadDef Start StartThread osPriorityNormal 0 configMINIMAL_STACK_SIZE 2 osThreadCreate osThread Start NULL Start the scheduler osKernelStart NULL NULL We should never get here as control is now taken by the scheduler for 77 The start thread has the following code static void StartThread void const argument Create tcp_ip stack thread tcpip init NULL NULL Network interface configuration Netif Config Initialize tcp echo server tcpecho init for The following functions are called 1 tocpip init function is called to initialize the LwIP stack modules and to start the TCP IP stack thread 2 Netif config function is called to configure the network interface netif 3 The TCP echo server thread is created in fcpecho init function DoclD025731 Rev 4 23 41 Developing applications with LwIP stack UM1713 24 41 void tcpecho init void sys_thread_new tcpecho_thread tcpecho_thread NULL DEFAULT THREAD STACKSIZE TCPECHO THREAD PRIO j tcpecho thread function description The TCP echo server thread has the following code static void tcpecho thread void arg Create a new connection identifier conn
22. close pin out compatibility Maintain close software compatibility Complement the existing family with more performance memory and features The STM32F4xx home page ir e Internet Server Side Includes SSI The SSI is a method used to dynamically include dynamic data in HTML code This is done by placing a specific tag inside the HTML code of the web page The tag should have the following format lt tag gt For the ADC conversion page the following tag is used inside the HTML code lt t gt When there is a request for the ADC webpage which has a shtml extension the server parses the webpage and when the tag is found it is replaced by the ADC conversion value 2 34 41 DoclD025731 Rev 4 UM1713 Using the LwIP applications Figure 11 SSI use in HTTP server gt STM32F4xxADC Windows Internet Explorer provided by Corporate PackageFabric ST eo gt http 192 168 0 10 STM32FAxxADC shtml ICE File Edit View Favorites Tools Help Y We de stmazr4xxapc fh El ah y 2 Page G Tools STM32F4xx ADC Conversion Led control ADO status bar This page allows you to get continuously the ADC 3 Channel 7 analog input converted value This ADC Channel is connected to the STM324xG EVAL board s potentiometer The ADC value is updated automatically each 1s with the last converted ADC Channel 7 value You could check this by changing the potentiometer posi
23. connected to a DHCP server To enable DHCP protocol uncomment the following macro define USE DHCP from main h file If the IP address is configured by DHCP and the application does not find a DHCP server on the network to which it is already connected the IP address is then automatically set to the static address 192 168 0 10 The user can enable the LCD controller by defining the define USE LCD macro in main h lf it is enabled text messages will be displayed to inform the user of the status of the application assigned IP address network link status Getting started applications do not support DHCP and LCD modules Refer to Section 6 Using the LwIP applications for more information Evaluation boards settings Before running an Ethernet example read the corresponding readme file to know how to configure the board jumper to ensure correct operation DoclD025731 Rev 4 27 41 Using the LwIP applications UM1713 6 6 1 28 41 Using the LwIP applications The STM32Cube LwIP package comes with several applications that use the different LwIP stack API sets The applications are divided into three categories as shown in Table 8 Table 8 LwIP applications categories Categories Applications TCP Echo client TCP Echo server Getting started basic UDP Echo client UDP Echo server TCP and UDP Echo server Netconn API HTTP Server Raw API Features HTTP Server
24. d ia p as eR A A A na D Ei 13 Ethernet interface functions description s sssaaa aaee 14 LwIP memory configuration ooooccocccon o 16 LwIP applications categories 0 0 0 28 Document revision history 0 2 0 0 00 ects 40 2 DoclD025731 Rev 4 UM1713 List of figures List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 2 LwIP architecture iia ee a Mev ede ded Xie ri een ee 8 Figure 2 LwIP folder organization isses RI 8 Phut str ct re n OL 12 Standalone operation model ooo 18 LwIP operation model with RTOS 000 ccc eee ee 22 TCP echo client uera a e ern RR ea ge oh ee ae Mal ex See Re afe les eee 29 TCP echo Server uuu Rs a Pee a a a Pa Da eee A ee p a 30 UDP echo client crei ce d SG AGG EE a ae e p Pa erem a ES ee a ace E d 31 UDP echo SVET 2 22 pne a weg pem Rus aca ER WR RENE YS 32 Web server home page co 34 SSI use in HTTP server o 35 Web server list of task page o ooooooccco n 36 TETP tool tftpd32 en rU petere ERO eho d a Ud eit E 37 DoclD025731 Rev 4 5 41 LwIP TCP IP stack description UM1713 1 1 1 2 6 41 LwIP TCP IP stack description Stack features LwIP is a free TCP IP stack developed by Adam Dunkels at the Swedish Institute of Computer Science SICS and licensed under a modified BSD license The
25. e Ethernet driver functions to receive an Ethernet packet Initializes the network interface structure netif and calls ethernettinit low_level_init to initialize the Ethernet peripheral Calls low level input to receive a packet then provide it to the ethernet input LwIP stack The following example shows how to initialize the Ethernet peripheral using HAL API into the interface API static void low level init struct netif netif uint8_t macaddress 6 MAC_ADDRO MAC_ADDR1 MAC_ADDR2 MAC_ADDR3 MAC_ADDR4 MAC ADDR5 EthHandle Instance ETH EthHandle Init MACAddr macaddress EthHandle Init AutoNegotiation ETH AUTONEGOTIATION ENABLE EthHandle Init Speed ETH SPEED 100M EthHandle Init DuplexMode ETH MODE FULLDUPLEX EthHandle Init MediaInterface ETH MEDIA INTERFACE MIT EthHandle Init RxMode ETH RXINTERRUPT MODE EthHandle Init ChecksumMode ETH CHECKSUM BY HARDWARE EthHandle Init PhyAddress DP83848 PHY ADDRESS 2 14 41 DoclD025731 Rev 4 UM1713 Interfacing LwIP with STM32Cube Ethernet HAL driver 2 configure ethernet peripheral GPIOs clocks MAC DMA HAL ETH Init amp EthHandle Initialize Tx Descriptors list Chain Mode HAL ETH DMATxDescListlInit amp EthHandle DMATxDscrTab amp Tx_Buff 0 0 ETH TXBUFNB Initialize Rx Descriptors list Chain Mode HAL ETH DMARxDe
26. e ens 28 6 1 2 TGP EGHO Server occ cows da Veet ewan ee he Reka 29 6 1 3 UDP echo client 0 0 eee eens 30 6 1 4 UDP echo s rver 2 2 ciii PIG EI oie hte sees 31 6 1 5 UDP TCP echo server based on netconn AP 000 00s 32 6 2 Features applications liliis 33 6 2 1 Web server based on raw API 1 ns 33 6 2 2 Web server based on netconn API 0 ccc eee ee eee 35 6 2 3 Web server based on socket API o ooo ocococoooooooooo 36 6 3 Integrated applications 00 eee 37 6 3 1 TETP server iue fee delet Sage Bea he ea BH a USER a 37 7 CONGIUSION lt lt lt cido eceg idence iai inay oe aes E RE ia 38 Appendix Ego PP rrrmT 39 A 1 How do choose between static or dynamic DHCP IP address allocation 1 eee eee 39 A 2 How does the application behave when the Ethernet cable is disconnected sss a RR ROR ERAS hac UR EA RR Rn 39 A 3 How can the application be ported on a different hardware 39 8 REVISION history P ks See a ds 40 ky DoclD025731 Rev 4 3 41 List of tables UM1713 List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 4 41 TCP Raw API FUNCIONS coi beer 255 fae Ves RUE VASE Sd tea eee eae 9 UDP Raw API functions 0 0000 cece ee 10 Netconn API functions 0 0 00 0 cece eee 10 Socket API functions cea iiae aan aon a aaa aa ioa tees 11 PDUTARIFURCIONS sau s
27. e most suitable pbuf type according to the data to be transmitted 1 6 2 pbuf management APIs LwIP has a specific API for working with pbufs This API is implemented in the pbuf c core file 12 41 DoclD025731 Rev 4 Ly UM1713 LwIP TCP IP stack description Table 5 Pbuf API functions API functions Description pbuf alloc Allocates a new pbuf pbuf realloc Resizes a pbuf shrink size only pbuf ref Increments the reference count field of a pbuf pbuf free Decrements the pbuf reference count If it reaches zero the pbuf is deallocated pbuf clen Returns the count number of pbufs in a pbuf chain pbuf cat Chains two pbufs together but does not change the reference count of the tail pbuf chain pbuf_chain Chains two pbufs together tail chain reference count is incremented pbuf_dechain Unchains the first pbuf from its succeeding pbufs in the chain pbuf_header Adjusts the payload pointer to hide or reveal headers in the payload pbuf_copy_partial Md part of the contents of a packet buffer to an application supplied pbuf take Copies application supplied data into a pbuf pbuf coalesce Creates a single pbuf out of a queue of pbufs pbuf memcmp Compare pbuf contents at specified offset with other memory pbuf memfind Find occurrence of memory in pbuf starting from an offset pbuf strstr Find occurrence of a string in pbuf starting from an offset Note pbuf can be a single
28. ed the DHCP protocol is enabled and the STM32 will act as a DHCP client How does the application behave when the Ethernet cable is disconnected When the cable is disconnected the Ethernet peripheral stops both transmission and reception traffics and the network interface is shut down If an LCD controller is used a message is displayed to inform the user that the cable is not connected otherwise the red LED of the evaluation board is switched on When the user re connects the cable the Ethernet traffic resumes and the network interface is set up If an LCD controller is used a message is displayed to inform the user of the new IP address either with static or dynamic allocation otherwise the yellow LED of the evaluation board is switched on How can the application be ported on a different hardware When another hardware platform is used check the GPIO configuration in the HAL ETH Mspinit function for the Ethernet peripheral and in HAL PPP Msplnit or HAL_Mspinit if the application needs more PPP peripheral DoclD025731 Rev 4 39 41 Revision history UM1713 8 40 41 Revision history Table 9 Document revision history Date Revision Changes 28 Mar 2014 1 Initial release Updated Figure 1 STM32Cube block diagram 14 Nov 2014 2 Updated Table 1 TCP Raw API functions and Table 3 Netconn API functions 05 Feb 2015 3 Updated Section Introduction Updated Section Introduction and merged
29. ere next contains the pointer to the next pbuf in a pbuf chain payload contains the pointer to the packet data payload len is the length of the data content of the pbuf tot len is the sum of pbuf len plus all the len fields of the next pbufs in the chain ref is the 4 bit reference count that indicates the number of pointers that point to the pbuf A pbuf can be released from memory only when its reference count is zero flags on 4 bits indicate the type of pbuf MS18173V1 LwIP defines three types of pbufs depending on the allocation type e PBUF POOL pbuf allocation is performed from a pool of statically preallocated pbufs of predefined size Depending on the data size that needs to be allocated one or multiple chained pbufs are required e PBUF RAM pbuf is dynamically allocated in memory one contiguous chunk of memory for the full pbuf e PBUF ROM No memory space allocation is required for user payload the pbuf payload pointer points to data in ROM memory that can be used only for sending constant data For packet reception the suitable pbuf type is PBUF POOL It allows to quickly allocate memory for the packet received from the pool of pbufs Depending on the size of the received packet one or multiple chained pbufs are allocated The PBUF RAM is not suitable for packet reception because dynamic allocation takes some delay It may also lead to memory fragmentation For packet transmission the user can choose th
30. ests To test the UDP echo server application follow these steps 1 2 Make sure of the STM324xx EVAL jumper settings are correct Build and program the demonstration code into the STM32F4xx Flash memory LEDs indicates the LwIP initialization success or failure the dynamic address allocation DHCP is not supported for this application On the remote PC open a command prompt window Under Windows select Start gt All Programs gt Accessories gt Command Prompt At the command prompt enter DoclD025731 Rev 4 31 41 Using the LwIP applications UM1713 C gt LwIP Ul where echotool IP address p udp r 7 1 7 n 15 t 2 d Testing DP echo server IP address is the actual board IP address By default the following static IP address is used 192 168 0 10 p is the protocol UDP protocol x is the actual remote port on the echo server echo port 1 is the actual local port for the client echo port n is the number of echo requests for example 15 t is the connection timeout in seconds for example 2 d is the message to be sent for echo for example Testing LwIP UDP echo server Figure 9 shows an example of this command string and of the module response Figure 9 UDP echo server Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply Reply from from from from from from from from from from from from from from from
31. ions netconn listen Description Sets a TCP connection to a listening mode netconn accept Accepts an incoming connection on a listening TCP connection netconn write Sends data on a connected TCP netconn netconn close Closes a TCP connection without deleting it 1 5 3 Socket API LwIP offers the standard BSD socket API This is a sequential API which is internally built on top of the Netconn API Table 4 provides a summary of the main socket API functions Table 4 Socket API functions API functions Description socket Creates a new socket bind Binds a socket to an IP address and port listen Listens for socket connections connect Connects a socket to a remote host IP address and port accept Accepts a new connection on a socket read Reads data from a socket write Writes data on a socket close Closes a socket socket is deleted 1 6 LwIP buffer management 1 6 1 Packet buffer structure LwIP manages packet buffers using a data structure called pbuf The pbuf structure enables the allocation of a dynamic memory to hold a packet content and lets packets reside in the static memory Pbufs can be linked together in a chain thus enabling packets to span over several pbufs 2 DoclD025731 Rev 4 11 41 LwIP TCP IP stack description UM1713 Figure 3 Pbuf structure payload next pbuf structure Room for packet headers wh
32. mains to be transmitted Developing with an RTOS using Netconn or Socket API Operation model The operation model when working with an RTOS has the following characteristics The TCP IP stack and the application run in separate threads The application communicates with the stack through sequential API calls that use the RTOS mailbox mechanism for inter process communications The API calls are blocking calls This means that the application thread is blocked until a response is received from the stack An additional thread the network interface thread is used to get any received packets from driver buffers and provide them to the TCP IP stack using the RTOS mailbox This thread is informed of a packet reception using the Ethernet receive interrupt service routine Refer to Figure 5 for a description of the IwIP operation model flowchart with RTOS Figure 5 LwIP operation model with RTOS Application HTTBPTFTP task Blocking Sequential API Call read write TCP IP Packet stack task Reception Packet Transfer to stack Network Interface Task J Semaphore MS18175V1 2 DoclD025731 Rev 4 UM1713 Developing applications with LwIP stack 4 2 2 2 Example of a TCP echoserver demonstration using the Netconn API From the application point of view the Netconn API offers a simpler way than the raw API for developing TCP IP applications This is because it has a more intuitive sequential
33. n STM32 microcontroller The middleware TCP IP stack is the LwIP Lightweight IP which is an open source stack intended for embedded devices A dedicated STM32Cube firmware package is provided for each series It includes Ethernet HAL driver LwIP middleware and application examples with and without RTOS running on ST evaluation boards This document is applicable to all STM32 series featuring an Ethernet peripheral However or simplicity reason STM32F4xx and STM32CubeF4 are used as reference platform The same description file names and screenshot are applicable as well to other series offering Ethernet connectivity such as STM32F107xx STM32F2x7xx and STM32F7xx To know more about the Ethernet examples implementation on your STM32 series refer to the documentation provided within the associated STM32Cube firmware package oy DoclD025731 Rev 4 1 41 www st com Contents UM1713 Contents 1 LwIP TCP IP stack description oooooooooomoomommooo 6 1 1 Stack features 0 0 0 0 teens 6 1 2 LICENSE sao Cee eR ROR Ke AE Ras ha Ae RAE ae 6 1 3 LwIP architecture 0 20 00 00 0c rh 7 1 4 LwIP stack folder organization ofthe 0 0 0 c ee eee eee 8 1 5 LwIP API overview o 9 1 5 1 Raw ARI ausos e RR ade ok iti e a s 9 1 5 2 NetcontmqAP 2 aide corns A CAD Us Dod RU RC ud din ER dada 10 1 5 3 Socket API sa aaa a cect G 11 1 6 LwIP buffer management 50 0c 11 1 6 1 Packet buffer str
34. n incoming connection the application can start receiving data by calling netconn_recv API function Incoming data is received in a netbuf The application can get the received data by calling netbuf_data netbuf API function The received data is sent back echoed to the remote TCP client by calling Netconn_write API function Netconn_close and Netconn_delete are used to close and delete the Netconn connection respectively DoclD025731 Rev 4 25 41 LwIP package description UM1713 5 5 1 5 2 5 2 1 Note 26 41 LwIP package description LwIP package directories The package contains a set of applications running on top of the LwIP stack and STM32Cube HAL and BSP drivers The firmware is composed from the following modules e Drivers contains the low level drivers of STM32F4xx microcontroller CMSIS BSP drivers HAL drivers e Middlewares contains libraries and protocol components LwIP TCP IP stack FatFS FreeRTOS e Projects contains the source file and configurations of the following applications Applications running in standalone mode without an RTOS based on Raw API A Web server A TFTP server A TCP echo client application A TCP echo server application A UDP echo client application A UDP echo server application A Applications running with the FreeRTOS operating system A Web server based on netconn API A Web server based on socket API A TCP UDP echo server application
35. netconn_new NETCONN_TCP if conn NULL Bind connection to well known port number 7 err netconn_bind conn NULL 7 if err ERR_OK Tell connection to go into listening mode netconn_listen conn while 1 Grab new connection accept_err netconn_accept conn amp newconn Process the new connection if accept_err ERR_OK while recv_err netconn_recv newconn amp buf ERR_OK do netbuf_data buf amp data amp len netconn_write newconn data len NETCONN_COPY j while netbuf next buf 0 netbuf delete buf j Close connection and discard connection identifier netconn close newconn netconn delete newconn 2 DoclD025731 Rev 4 UM1713 Developing applications with LwIP stack 2 j else netconn delete newconn The following sequence is executed 1 Netconn_new API function is called with NETCONN_TCP parameter will create a new TCP connection The newly created connection is then bound to port 7 echo protocol by calling Netconn_bind API function After binding the connection the application starts monitoring the connection by calling Netconn_listen API function In the infinite while 1 loop the application waits for a new connection by calling the API function Netconn_accept This API call blocks the application task when there is no incoming connection When there is a
36. or Modules support The user can choose the modules he needs for his application so that the code size will be optimized by compiling only the selected features As an example to disable UDP and enable DHCP the following code must be implemented in Iwipopts h file Disable UDP define LWIP_UDP 0 Enable DHCP define LWIP_DHCP 1 Memory configuration LwIP provides a flexible way to manage memory pool sizes and organization It reserves a fixed size static memory area in the data segment It is subdivided into the various pools that IwIP uses for the various data structures As an example there is a pool for struct tcp pcb and another pool for struct udp pcb Each pool can be configured to hold a fixed number of data structures This number can be changed in the wipopts h file For example MEMP NUM TCP PCB and MEMP NUM UDP PCB define the maximum number of tcp pcb and udb pcb structures that can be active in the system at a given time The user options can be changed in wipopts h Table 7 provides a summary of the main RAM memory options Table 7 LwIP memory configuration LwIP memory option Definition MEM SIZE pisi EE size used for all LwIP dynamic memory MEMP NUM PBUF Total number of MEM REF and MEM ROM pbufs MEMP NUM UDP PCB Total number of UDP PCB structures MEMP NUM TCP PCB Total number of TCP PCB structures MEMP NUM TCP PCB LISTEN Total number of listening TCP PCBs
37. r LCD screen features Build and program the application code into the STM32F4xx Flash memory If USE DHCP and USE LCD are defined a message is displayed on the LCD screen to indicate the success or failure of the DHCP IP address allocation otherwise the LEDs indicate the result of this operation After an IP address has been assigned either a static or a dynamic address the user can start the application On the remote PC open a web client Mozilla Firefox or Internet Explorer and type the board IP address in a web browser By default the following static IP address is used 192 168 0 10 Figure 12 Web server list of task page STM32F4xxTASKS Windows Internet Explorer provided by Corporate PackageFabric ST G v http 192 168 0 10 STM32F4xxTASkS html File Edit View Favorites Tools Help XR de S stmszr4xxtasks gt Bl dA Page gt G Tools STM32F4xx List of tasks and their status Number of page hits 27 286 105 91 313 113 876 internet 6 2 3 Web server based on socket API This application implement of a web server based on the socket API To test this demonstration refer to Section 6 2 2 Web server based on netconn API 36 41 2 DoclD025731 Rev 4 UM1713 Using the LwIP applications 6 3 Integrated applications 6 3 1 TFTP server The TFTP server is a file transfer application that requires a remote TFTP client The files are transfer
38. red to and from the microSD card located on the STM324xx EVAL board The TFTP server waits for a request from a remote TFTP client The STM324xx EVAL evaluation board must be connected through a remote PC to download or upload a file To do this a TFTP client must be installed on the remote PC This can be done by using the tftpd32 tool which can be found at http tftpd32 jounin net To test the TFTP server application follow these steps 1 Make sure of the STM324xx EVAL jumper settings are correct 2 Inthe main h file uncomment USE DHCP or USE LCD options to enable the DHCP client or LCD screen features 3 Build and program the application code into the STM32F4xx Flash memory 4 If USE_ DHCP and USE LCD are defined a message is displayed on the LCD screen indicating the success or failure of the DHCP IP address allocation otherwise the LEDs indicate the result of this operation 5 After an IP address has been assigned either a static or a dynamic address the user can start the application 6 Onthe remote PC open the TFTP client for example TFTPD32 and configure the TFTP server address host address in TFTPD32 7 Start transferring files to and from the micro SD card located on the STM324xx EVAL board Figure 10 gives an overview of the tftpd32 tool Figure 13 TFTP tool tftpd32 Tftpd32 by Ph Jounin The PC IP address Current Directory C Progeam Fies T ftpd32 y _ Browse Server inte
39. rfaces 192 168 01 v _ShowDi The board IP address Titp Server Thtp Client DHCP server Syslog server Log viewer 192 168010 Pot Directory for remote Directory for local Local File hen RA CI file to send receive file to receive send Remote File Block Defaut y Size Put a file into the STM324xx EVAL s SD Get Pa card Get a file from the STM324xx EVAL s SD card Configure the Tftpd32 tool TFTP client must be enabled Note Make sure that the microSD card is plugged into the dedicated connector prior to downloading uploading a file from to the STM324xx EVAL board 2 DoclD025731 Rev 4 37 41 Conclusion UM1713 7 Conclusion LwIP package allows to use IwIP TCP IP stack with the STM32Cube HAL API This open source stack offers the services of a full scale TCP IP stack while keeping relatively low RAM ROM usage Two approaches are described for developing TCP IP applications either in a Standalone mode or using a real time operating system RTOS for multi threaded operations 2 38 41 DoclD025731 Rev 4 UM1713 FAQ Appendix A FAQ A 1 A 2 A 3 2 How do choose between static or dynamic DHCP IP address allocation When the macro define USE DHCP located in main h is commented a static IP address is assigned to the STM32 microcontroller by default 192 168 0 10 this value can be modified from main h file If the macro define USE DHCP is uncomment
40. ruct mem_malloc sizeof struct tcp echoserver struct if es NULL es gt state ES_ACCEPTED es gt pcb newpcb es gt p NULL pass newly allocated es structure as argument to newpcb tcp_arg newpcb es initialize lwIP tcp recv callback function for newpcb tcp recv newpcb tcp echoserver recv initialize lwIP tcp err callback function for newpcb tcp err newpcb tcp echoserver error initialize lwIP tcp poll callback function for newpcb tcp poll newpcb tcp echoserver poll 1 ret err ERR OK DoclD025731 Rev 4 21 41 Developing applications with LwIP stack UM1713 4 2 4 2 1 22 41 The following functions are called 1 The new TCP connection is passed to tcp echoserver accept callback function through newpcb parameter 2 An es structure is used to store the application status It is passed as an argument to the TCP PCB newpcb connection by calling tcp arg LwIP API 3 ATCP receive callback function tcp echoserver recv is assigned by calling Lw P API tcp recv This callback handles all the data traffic with the remote client 4 ATCP error callback function tcp echoserver error is assigned by calling LwlIP API tcp err This callback handles TCP errors 5 ATCP poll callback function tcp echoserver poll is assigned by calling LwIP API tcp poll to handle periodic application tasks such as checking if the application data re
41. scListInit amp EthHandle DMARxDscrTab amp Rx Buff 01 0 ETH RXBUFNB Enable MAC and DMA transmission and reception HAL ETH Start amp EthHandle The ethernet_input function implementation differs between standalone and RTOS modes e n standalone applications this function must be inserted into the main loop of the application to poll for any received packet e In RTOS applications this function is implemented as a thread waiting for a semaphore to handle a received packet The semaphore is given when the Ethernet peripheral generates an interrupt for a received packet The ethernetif c file also implements the Ethernet peripheral MSP routines for low layer initialization GPIO CLK and interrupts callbacks In case of RTOS implementation an additional file is used sys_arch c This file implements an emulation layer for the RTOS services message passing through RTOS mailbox semaphores etc This file should be tailored according to the current RTOS that is FreeRTOS for this package DoclD025731 Rev 4 15 41 LwIP configuration UM1713 3 3 1 3 2 16 41 LwIP configuration LwIP provides a file named wipopts h that allows the user to fully configure the stack and all its modules The user does not need to define all the LwIP options if an option is not defined a default value defined in opt h file is used Therefore wipopts h provides a way to override much of the IwIP behavi
42. tion and check that the ADC value is updated by an automatic refresh of this page with the new converted value ADC Converted Value 1527 mv ee Internet 100 Common Gateway Interface CGI The CGl is a standard web technique used to execute a request coming from a client on the server side and then to return a response to the client In LwIP the CGI offered works only with GET method requests and can handle up to 16 parameters encoded in the URI The CGI handler function executed on the server side returns a HTML file that the HTTP server sends to the client In the HTTP server demonstration this method is used to control the four LEDs LED1 LED2 LED3 and LED4 of the evaluation board 6 2 2 Web server based on netconn API This application implement of a web server based on the netconn API It is used to connect to the STM32 MCU from a web client and to load HTML pages This web server contains two HTML pages The first one gives general information about STM32F4xx microcontrollers and the LwIP stack The second one lists the running tasks and their status This page is automatically updated every second see Figure 12 2 DoclD025731 Rev 4 35 41 Using the LwIP applications UM1713 To test the HTTP server netconn demo follow these steps 1 2 Make sure of the STM324xx EVAL jumper settings are correct In the main h file uncomment USE DHCP or USE LCD options enable the DHCP client o
43. tion in this document supersedes and replaces information previously supplied in any prior versions of this document 2015 STMicroelectronics All rights reserved 2 DoclD025731 Rev 4 41 41
44. ucture o oooocoooooooo 11 1 6 2 pbuf management APIs 0 000 cee eee less 12 2 Interfacing LwIP with STM32Cube Ethernet HAL driver 14 3 LwIP configuration lt lt lt m RR RRERRRREU ER E REX ER ERAE RR E 16 3 1 Modules support o 16 3 2 Memory configuration i sasskem cck een ee Ped een TERRE REESE AK E RE 16 4 Developing applications with LwIP stack 18 4 1 Developing in standalone mode using the Raw API 18 4 1 1 Operation model llllellllle rs 18 4 1 2 Example of TCP echo server demonstration 004 19 4 2 Developing with an RTOS using Netconn or Socket API 22 4 2 1 Operation model 000000 cee eee sse 22 4 2 2 Example of a TCP echoserver demonstration using the Netconn API 23 5 LwIP package description ssessessnss 26 5 1 LwIP package directories uscar rr da Ad 26 5 2 Applications settings oooooooooororooro o 26 5 2 1 PHY interface configuration 0 0 00 ee 26 5 2 2 MAC and IP address settings 000 0c eee eee 27 5 2 3 Firmware features 00 2000s 27 2 41 DoclD025731 Rev 4 Ly UM1713 Contents 5 3 Evaluation boards settings lt oooooooooonrronorrrros 27 6 Using the LwIP applicati0nS oo oooooooooomommmoo 28 6 1 Getting started applications lille 28 6 1 1 TCP echo client oc seas sae Fo mE E AVE R
45. y of the Raw API functions for UDP applications Table 2 UDP Raw API functions API functions Description udp new Creates a new UDP PCB udp remove Removes and de allocates a UDP PCB udp bind Binds a UDP PCB with a local IP address and port udp connect Sets up a UDP PCB remote IP address and port udp disconnect Removes a UDP PCB remote IP and port udp send Sends UDP data udp recv Specifies a callback function which is called when a datagram is received 1 5 2 Netconn API The Netconn API is a high level sequential API which model of execution is based on the blocking open read write close paradigm To operate correctly this API must run in a multithreaded operating mode implementing a dedicated thread for the LwIP TCP IP stack and or multiple threads for the application Table 3 provides a summary of the Netconn API functions Table 3 Netconn API functions API functions Description netconn new Creates a new connection netconn delete Deletes an existing connection netconn bind Binds a connection to a local IP address and port netconn connect Connects to a remote IP address and port petconn send Sends data to the currently connected remote IP port not applicable for TCP connections netconn_recv Receives data from a netconn 2 10 41 DoclD025731 Rev 4 UM1713 LwIP TCP IP stack description Table 3 Netconn API functions continued API funct

Download Pdf Manuals

image

Related Search

Related Contents

EXTRA ITEM STI COLLECTION  horno para electrodos hydroguard 350    Top D41 ISDN Mode d`emploi  詳細スペック(PDF  SCHNEIDER ELECTRIC LIMITED WARRANTY  13 原子スペクトルの観察と波長の測定  Radio Shack 21-417 User's Manual  Descargar ficha técnica  Descargar PDF  

Copyright © All rights reserved.
Failed to retrieve file