Embedded WEB Server Design Based on ARM and eCos

Source: Internet
Author: User
Embedded WEB Server Based on ARM and eCos design time: 10:43:56 Source: MCU and embedded system Author: Yangtze University Zhu Xiaotao Xu Aijun

Introduction

With the rapid development of modern communication technology and network technology, Ethernet technology is becoming more and more mature, especially the Web Technology Based on TCP/IP communication protocol has been widely used. We can use a microcontroller to add Ethernet
Network interface chip instead of PC for field control, forming an embedded Web
Serv-er system. On-site sensors automatically track the information of various monitoring sites, store the detected data in non-volatile memory, and release the data to the Internet in a timely manner. Relevant staff can use the Web
The technology remotely controls, manages, and maintains devices, and directly monitors the operation of on-site devices from the browser, which greatly improves the production efficiency and management level.

To implement the functions of Web servers, an embedded operating system and an executable TCP/IP protocol stack are required. Therefore, the embedded processor has higher requirements. Compared with traditional 8/16-Bit Single-Chip Microcomputer
Compared with ARM core processors, ARM core processors have significant advantages in computing speed, power consumption, and storage capacity. In addition, ARM core processors can easily implement embedded TCP/IP protocol stacks, therefore, the ARM core processor
Become the preferred processor for Embedded Web Server devices. The system design model 1 is shown in.

1. System Hardware Design

The ARM core processor LPC2210 is based on a 32/16-bit ARM7TDMI-S CPU that supports real-time simulation and embedded tracking. 16 In-Chip
KBSRAM is configured into four groups through the external memory interface, with each group capacity up to 16
MB. The LPC2210 is a 144-foot package with extremely low power consumption. It has multiple 32-bit timers, 8-way 10-bit ADC, and pwm output, and can provide up to 76 GPIO and up to 9 External interruptions.
It uses three-level pipeline technology to greatly improve the efficiency of command execution. It can achieve a maximum CPU operation frequency of 60 MHz through a programmable in-chip PLL.
The EMC combination of the lpc2210 complies with the pl090 standard of arm. The bus width can be set to 8-bit, 16-bit, or 32-bit. Generally, the memory with a 16-bit bus width has a high cost effectiveness.
The network interface chip uses RealTek's ne2000 compatible chip RTL8019AS. It has a built-in 10base-t transceiver and is connected to Ethernet through hr901170a. The hardware structure 2 is shown in.


In Figure 1, the lpc2210 is expanded to 2 MB nor flash (the chip model is sst39vfl60) and 8.mb
Psram (the chip model is mt45w4mwl6 ). To facilitate debugging and final code solidification, the address of banko and bankl using the lpc2210 external memory interface is empty.
The address space bank0 and bankl are allocated to psram and Flash respectively through nce_f and nce_r. Usually the code is solidified to flash and allocated
Flash is bank0, and psram is bankl, because bank0 can be used to guide program running.

The large-capacity on-chip memory of lpc2210 provides sufficient storage space for the implementation of TCP/IP protocol stack and data processing. It uses the lpc2210spi interface to expand MMC/SD card as the external
Non-volatile memory allows you to store data, IP addresses, physical addresses of NICs, and update webpages collected by the ADC at the site. You can change the MMC/SD card whenever necessary. With
Arm and thumb instruction sets, using pipeline processing technology, can pre-process the next instruction during instruction execution, greatly improving the instruction execution efficiency and providing an effective network application for fast data transmission
.

2 System Software Design
ECos (embedded retriable
Operating
Embedded and Configurable operating system) is a portable embedded real-time operating system for 16-bit, 32-bit, and 64-bit processors. Because of its open source code, more and more designers are opening
Focus on the eCos operating system. ECos features modularity and configurable kernel. The minimum version of eCos is only several hundred bytes, which is very suitable for the development of small embedded systems. And embedded Linux
Compared with eCos, eCos has the advantages of flexible configuration and resource saving. Its other advantages include the use of multi-task preemption mechanism, minimal interrupt latency, support for all synchronization primitives required by embedded systems, and flexible adjustment
Policy and interrupt handling mechanism. Therefore, eCos have good real-time performance. Compared with operating systems such as μC Linux and μC/OS, eCos is more suitable for devices that process real-time signals, such as mobile communication,
Development of WLAN and other communication devices.

3 eCos porting

Figure 3 shows the eCos porting process. The transplantation of eCos is completed by three sub-modules, namely, the architecture Abstraction Layer
Hal, Variant Hal, and Platform
Hal ). For a new architecture, it is relatively difficult to establish the abstraction layer of the system structure. Currently, eCos supports various mainstream CPUs, that is, the eCos source code contains
CPU architecture layer and variant abstraction layer, so the porting work is mainly concentrated on the platform abstraction layer.

RedBoot porting is the best start for porting the abstraction layer of the platform. RedBoot is a command line interface located on the hardware abstraction layer and contains the GDB debugging tool and its debugging stub. Once the hardware abstraction layer is transplanted to the target board, RedBoot can load the program to the target board and debug the code on the target board.

4 TCP/IP protocol stack-Implementation of LwIP

LwIP is Adam, Swiss Emy of Computer Sciences
Open source TCP/IP protocol stack developed by dunkles and others for embedded systems. It can be transplanted to the operating system or run without an operating system. Implementation of LWIP
The point is to reduce the usage of RAM Based on the main functions of TCP; Generally, only dozens of bytes of Ram and 40
A rom of about KB can be run, which makes LWIP suitable for applications in low-end embedded systems.
LWIP can be divided into several layers as shown in Figure 4. Main functional modules include the Operating System Simulation layer, network interface functions, and various modules that implement the TCP/IP protocol (IP, UDP, TCP, IC-MP, ARP) buffer and storage management subsystem, checksum function.

Lwip api is a set of application interfaces through which programmers can use all functions of LWIP. In addition, LWIP provides developers with a more advanced BSD socket
APL enables it to use common socket functions to write network communication software. The operating system simulation layer enables LWIP to use some advanced management functions provided by the operating system, such as semaphores
Management, Message Queue Management, and thread creation.

4.1 IP address Processing
LWIP can only implement most basic functions at the IP layer. Although it can send, receive, and forward packets, it cannot receive or send IP segment packets, nor can it process packets carrying IP parameter options. But for most applications, this will not be a problem.
① Receive the information package. The network device driver can call the ip_input () function to start processing the arrived IP information package, and complete the initial integrity check on the IP version field and header length, the checksum of the header is also calculated and verified.
② Send the information package. The outgoing information package is processed by the ip_output () function. This function uses the ip_route () function to find the appropriate network interface to send the information package. When the outbound network interface is determined, the information package is sent to the ip_output_if () function with the parameter of the outbound network interface.
③ Forward the information package. If the address without a network interface is the same as the destination address of the information package, the information package should be forwarded. This is done by the IP _ forward () function.
④ ICMP processing. ICMP processing is quite simple. The ICMP information received by the ip_input () function is transferred to the icmp_input () function. The latter decodes the ICMP packet header and then performs the appropriate action.
4.2 UDP Processing
UDP is a simple protocol used to split information packets in different processes. The status of each UDP session is stored in a PCB structure. Udp pcb is stored in a linked list. When a UDP packet arrives, the linked list is matched for retrieval.
4.3 TCP Processing

TCP is a transport layer protocol that provides reliable byte stream services for the application layer. Its description is much more complex than that of other protocols, and its code accounts for 50% of the total LWIP code. Basic TCP
The processing process is divided into six function functions, tcp_input (), TEP _
The process () and tcp_receive () functions are related to TCP input, including tcp_write (), tcp_enqueue (), and tcp_output ()
Is used for TCP output. The process of TCP is shown in step 5.

4.4 Application Interface Design
LWIP
The API is designed for LWIP, so it can fully utilize the internal structure of LWIP to achieve its design goal. LWIP
APIs are similar to bsdapis, but operations are relatively low. The API does not need to copy data between the application and the protocol stack, because the application can skillfully process the internal buffer directly. In addition, BSD
The socket API is easy to understand and many applications write for it. Therefore, LWIP is useful to retain a BSD socket compatibility layer.

Considering the processing mode of the TCP/IP protocol stack, APl is implemented in two parts. As shown in figure 6, one part is implemented as the Connection Library of the application, and the other part is implemented in the TCP/IP process. These two parts
The inter-process communication mechanism (IPC) provided by the simulation layer of the operating system is used for communication. Currently, the following three IPC methods are used: Shared Memory, message transmission, and semaphore. Although these IPC methods are
Operating system support, but they do not need the underlying support of the operating system. In fact, the operating system simulation layer is simulating them.

Knot

Based on the Real-Time Kernel eCos, The LwIP protocol stack is transplanted and optimized in the embedded system. The optimized LwIP stack is transplanted to run as a network module, and the code occupies 40
Kb rom, implements the Ethernet/IP/TCP network function, and provides module APIs to achieve seamless connection with the system. LwIP-based network application tasks and other non-network applications
Coordinates the operation under the Real-Time Kernel Management of eGos. It further enhances the network security and stability of the protocol stack and develops corresponding network applications. The "eCos/LwIP protocol stack" architecture is expected to be applied
Information appliances and networked instruments and meters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.