Configuring the NicheLit TCPIP stack.pdf
(
1005 KB
)
Pobierz
Configuring the NicheLite TCP/IP stack for the STM32F107xx microcontroller
AN3000
Application note
Configuring the NicheLite™ TCP/IP stack
for the STM32F107xx microcontroller
Introduction
STM32F107xx connectivity line microcontrollers feature a complete 10/100 Ethernet MAC
supporting MII and RMII with hardware support for the IEEE1588 precise time protocol,
enabling Ethernet connectivity for real-time applications.
The NicheLite TCP/IP stack, from InterNiche Technologies, supports STM32F107xx
connectivity line microcontrollers and is provided free-of-charge to ST customers. This stack
is a scaled down version of the full stack available from InterNiche. For download
information, please refer to STMicroelectronics web site www.st.com
The objective of this application note is to introduce the NicheLite stack for STM32F107xx
and describe the integration considerations to be taken into account when developing a user
application including the performance and memory size aspects.
This application note is structured as follows:
■
A short glossary is provided in
Section 1
■
A general introduction to TCP/IP is presented in
Section 2
■
The
Section 3
introduces the NicheLite stack
■
Section 4
and
5
describe the NicheLite stack configuration and optimization
■
NicheLite stack debugging tips are given in
Section 6
■
Section 7
presents the NicheTask OS and how to use it in your application
■
Lastly,
Section 8
describes the NicheLite package for STM32F107xx and the available
demonstrations
This application note is intended to complement the documentation provided by InterNiche,
which should be referred to for detailed information.
August 2009
Doc ID 15903 Rev 1
1/54
www.st.com
Contents
AN3000
Contents
1
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2
TCP/IP introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1
TCP/IP a layered protocol stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1
The application layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2
The transport layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.3
The Internet layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.4
Link layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.5
Example of network devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2
The protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3
Introduction to some TCP/IP protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 IP: Internet protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.2 ARP: address resolution protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.3 ICMP: internet control message protocol . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.4 UDP: user datagram protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.5 TCP: transmission control protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3.6 BOOTP: bootstrap protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3.7 DHCP: dynamic host configuration protocol . . . . . . . . . . . . . . . . . . . . . 15
2.3.8 TFTP: trivial file transfer protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.9 FTP: file transfer protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.10 PPP: point-to-point protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.11 SMTP: simple mail transfer protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.12 POP3: post office protocol version 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.13 SNMP: simple network management protocol . . . . . . . . . . . . . . . . . . . . 16
2.3.14 HTTP: hypertext transfer protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.15 Telnet: remote terminal protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3
NicheLite TCP/IP stack overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1
Stack structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2
NicheLite protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3
NicheLite implementation introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.1
Packet demultiplexing flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.2
Packet buffer memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3.3
Memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2/54
Doc ID 15903 Rev 1
AN3000
Contents
4
NicheLite TCP/IP stack configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1
NicheLite modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2
IP address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3
MAC address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4
Keepalive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4.1
Enabling Keepalive in NicheLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4.2
Keepalive timeout tuning in NicheLite . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5
NicheLite TCP/IP stack optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6
Debug tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.1
NicheTool diagnostic console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.2
Network statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.3
Packet debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.4
Socket and packet queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7
NicheTask OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.1.1
Superloop (OS disabled) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.1.2
Multitasking system (OS enabled) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.2
Configuring the NicheTask OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.3
Implementing your own system menus and tasks . . . . . . . . . . . . . . . . . . 42
7.3.1
Task declaration (in demo_server.c file) . . . . . . . . . . . . . . . . . . . . . . . . 42
7.3.2
Task function definition (in demo_server.c file) . . . . . . . . . . . . . . . . . . . 43
7.3.3
Task creation (in tk_misc.c file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8
NicheLite package for STM32F107xx . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.1
File structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.2
Description of available demonstration programs . . . . . . . . . . . . . . . . . . 46
8.3
UDP/TCP client/server demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8.3.1
Client processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8.3.2
Server processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Doc ID 15903 Rev 1
3/54
List of tables
AN3000
List of tables
Table 1.
ICMP errors and queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 2.
SMTP commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 3.
Mini-socket and BSD socket APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 4.
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4/54
Doc ID 15903 Rev 1
AN3000
List of figures
List of figures
Figure 1. Protocol stack layers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 2. Network devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 3. Protocol interconnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 4. User data path example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 5. Data encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 6. IP protocol transmission and reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 7. UDP datagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 8. UDP protocol transmission and reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 9. TCP protocol transmission and reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 10. Connectivity application layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 11. Stack components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 12. Protocols available in NicheLite stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 13. Demos available in STM32 package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 14. Packet demultiplexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Figure 15. Buffer management (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Figure 16. Buffer management (2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 17. Buffer management (3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 18. Buffer management (4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 19. Buffer management (5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Figure 20. Buffer management (6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Figure 21. Memory management: a serious situation that may become critical . . . . . . . . . . . . . . . . . 28
Figure 22. Memory management: a critical situation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 23. NicheTool console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 24. Packet log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Figure 25. NicheLite package file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Figure 26. Client task processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Figure 27. Server task processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Doc ID 15903 Rev 1
5/54
Plik z chomika:
masterkom
Inne pliki z tego folderu:
50896956-ARM-CORTEX-M3.pdf
(10631 KB)
37980850-STM32-Cortex-M3.pdf
(6627 KB)
stm32f10x_stdperiph_lib.zip
(21616 KB)
an2824.zip
(1505 KB)
an2821.zip
(1417 KB)
Inne foldery tego chomika:
# Elektronika
# LCD
-=Arduino=-
► AVR-USB
2007-07-03(1)
Zgłoś jeśli
naruszono regulamin