Abstract: Introduced develops the platform based on the new generation Capsicum anomalum i.MX series chip MC9328MXl(ARM920T) smallest system’s embedded system, has carried on the embedded network service system’s circuit design to its ether network card part regarding network card chip CS8900A, based on this, through to the application layer Socket programming’s research and the analysis, has realized the development board and PC machine under the embedded Linux environment between C/S pattern correspondence.
Key word: Embedded system; ARM; MC9328MXl; CS8900A; Socket programming
1 introduction
At present, the embedded system already widely applied in people’s work, the life, in 2003 our country embedded system amounted to the l 100,000,000 Yuan using the product economy total quantity. Along with the technical development, 8 MCU markets have tended to gradually stably, 32 MPU is representing the embedded technical development direction, is accelerating to send is long. In 32 embedded microprocessor markets, is in the absolute leading positions based on the ARM essence’s microprocessor.
The embedded system is take the application as a center, take the computer technology as the foundation, the software and hardware may cut out, adaptation application system to function, reliable, cost, volume, power loss strict request special purpose computer system. The embedded system besides has, stable, the performance highly effective single-minded and so on merits, but also has timeliness high operating system. The embedded system and the correspondence, networking’s union may strengthen the network enormously the intellectualization and the spirit words, development correspondence function, thus realizes between each kind of communications system’s interconnection intercommunication. This article gave one kind to suit in the/low end application communications platform design proposal, it might support between ethernet’s data transmission, and had connections and so on RS232, RS485, USB. In article regarding embedded Linux environment design based on MC9328MXl(ARM920T) smallest system’s hardware communications platform, thus has realized the embedded Socket correspondence.
2 smallest system analysis
Motorola Corporation’s MC9328MXl is take ARM920T as the essence high performance-to-price ratio 16/32 RISC micro controller, contains ARM corporate design 16/32 ARM920T the RISC processor nucleus, ARM920T is the low power loss, the high performance 16/32 nucleus, most suits to the price and the power loss sensitive application situation. Besides the ARM920T nucleus, MC9328MXl has also contained many periphery functional module. The processor and these modules integrate on the nuclear core, its concrete structure as shown in Figure 1.

As seen in Figure 1, besides the ARM920TDMI essence, MC9328MXl also integrated many periphery functional module: A LCD controller, an impulse modulation controller, a USB controller and many expansion channels, but does not have the integration to use in the network service the ethernet controller. Therefore, needs to design contains the appropriate ethernet controller’s peripheral circuit.
3 peripheral circuit design
This system selects CS8900A which matches with MC9328MXl to take the ethernet controller. CS8900A is the low power loss 16 ethernet controllers which Cirrus Logic Corporation produces, the function is formidable. This component’s prominent characteristic is the use is flexible, its physical level connection, the data transmission pattern and the working pattern and so on can according to need the dynamic alignment, adapts to the different application circumstances through the internal register’s establishment.
CS8900A internal structure diagram as shown in Figure 2, the interior functional module is mainly 802.3 medium visit control block (MAC). 802.3 medium visit control block supports the full-duplex working pattern, defers to the IEEE802.3 ethernet standard completely, uses 100 pin TQFP seal, is responsible to process the related ethernet data frame the transmission and the receive, including: Collision detection, frame head’s production and examination, CRC verification code production and confirmation. Through to transmits control register (TxCMD) the initialization disposition, after MAC can complete the frame automatically the conflict, the re-transmit. If the frame data part is short in 46 bytes, it can produce the packing field to enable the data frame to achieve the shortest length which 802.3 request.

The CS8900A main feature is as follows:
Conforms to the IEEE802.3 ethernet standard, and has the ISA connection;
Internal 4KB RAM;
Is suitable in the I/O working pattern, the memory working pattern and the DMA working pattern;
Has the transmission, the receive low-pass filtering’s lOBase2T connection port;
Supports lOBase2, lOBase5 and the lOBase2F AUI connection;
The automatic production masthead, carries on the CRC examination automatically, after the conflict, automatic reproduction;
The maximum current consumption is 55mA (5 V power sources);
Full-duplex working pattern;
Supports exterior EEPROM.
Moreover, must realize between CS8900A and main engine’s data communication, when circuit design may act according to the special details nimble choice appropriate data transmission pattern. The CS8900A support’s mode of transmission includes: I/O pattern and Memory pattern, in addition has the DMA pattern. And, the I/O pattern is visits the CS8900A memory block the default pattern, simple easy to use.
May see by the MC9328MXl pin description, the MCU data is through the D[3l:0] transmission, but ethernet controller CS8900A most uses 16 modes of transmission, therefore MC9328MXl data bus first 16 (D[15:0]) should be connected with CS8900A SD[O:15], does not match the question for the solution speed, must use has the cushion function main line transceiver. Considered from the cost that this system uses two 8 74LS245. The address message is connected through MC9328MXI address bus connection’s A[DO:03] and CS8900A SA[00:03] through buffer 74HC244, A[04:19] and SA[04:19] direct use in establishing network card’s initial base address connected. Moreover, CS8900A (changes through belt power choke coil’s insulating transformer 20F001N the CPU transmission’s data ratio is l:1.414) transmits to the network in; When receives the data, the network transmission’s data (changes after the insulating transformer ratio is 1:1). Insulating transformer’s function is mainly separates the outside plant and CS8900A, the interference protection and burns out the part, realizes charged inserts pulls out the function. Between XTALl and the XTAL2 crystal oscillator is CS8900A provides the stable clock pulse. Its circuit diagram as shown in Figure 3.

4 based on embedded Linux Socket correspondence
By is loaded with overlapping compiler’s PC machine generally based on the embedded Linux development environment and the hardware development board is composed. This design takes the client side by the PC host machine, realizes the correspondence by the MC9328MXl development board as the server. First after PC machine translates client procedure (server), through the serial port reads in the development board, will then develop the board and PC machine through the ethernet mouth establishment connection.
Socket (sleeve joint character) is through the standard UNIX document descrptor and a other procedure communication method, its essence has provided the advancement correspondence vertex, may regard as is one kind of special pipeline. May realize the network service through the Sock-et programming. A complete sleeve joint character has a related description: Agreement, local address, local port, long-distance address, long-distance port.
The general wrap connection address structure struct sockaddr definition is as follows:

The sleeve joint character operation function mainly has:
(1) founds Sockets
sockfd=socket (family, type, protocol)
And assigns this Socket use by the address class (family) parameter the address class. By the type (type) parameter stipulated requested correspondence type. The agreement (protocol) parameter is zero generally, will cause the default the agreement to be automatic is selected.
(2) connection local address
This function’s major function is a stipulation address with a Sockets union, a service advancement must use the following function: bind(sockfd, address, addrlen) in which, the sockfd parameter is transfers the returns by socket() the sockets descrptor. address aimed at an address structure, the addrlen parameter has stipulated the address byte length.
(3) customer advancement connects the service advancement
Realizes the customer advancement with this function to serve the advancement connection the initialization. This system call is:
connect(sockfd, address, addrlen)
And, sockfd is the local Sockets Sockets descrptor. address stipulated in the goal machine to serve the advancement the address which used, addrlen has been stipulating the address byte length.
When the connect() function is transferred, if customer Sockets has not unified to a local address, then a system automatic selection local address and a suitable port number, and unifies them with this customer’s Sockets.
(4) network monitor
int listen (int sockfd, int backlog);
sockfd is Socket the system call returns Socket descrptor; backlog assigns the biggest request number which permits in the Request queue, enters the connection request will wait for accept in the formation () (reference as follows). backlog to the formation in waited for that the service request’s number has carried on the limit, the majority system default values are 20. If time a service request arrival, the input formation has been full, this Socket will refuse to connect requested that the customer will receive an error message. When presents the mistake listen function returns - l, juxtaposes the corresponding errno wrong error code.
(5) receive request function
the accept() function lets the server receive customer the connection request. After establishing the good input formation, the server transfers the accept function, then the sleep and waits for the customer the connection request.
int accept (int sockfd, void*addr, int*addrlen);
sockfd is the Socket descrptor which monitors, addr usually is one aims the sockaddr_in variable the indicator, this variable uses for to deposit proposes the connection demand service main engine’s information; addrlen usually is a directional value is sizeof (struct sockaddr_in) trueing pointer variable.
(6) data transmission
Send() and Recv() these two functions apply in face the connection on Socket to carry on the data transmission.
The Send() function prototype is: int send (int sockfd, const void*msg, int len, int flags); sockfd is uses for to transmit the data socket descrptor; msg is a direction must transmit the data the indicator; len is take the byte as unit’s data length; in the flags ordinary circumstances sets is 0.
Recv () the function prototype is: int Recv (int sockfd, void*buf int len, unsigned int flags); sockfd is accepts the data the Socket descrptor; buf is stores the receive data the buffer; len is the cushion length. flags is also set at is O. The Recv() returns in fact receives byte count, when presents the mistake, returns - 1 juxtaposition corresponding errno value.
This part of design’s goal is through analyzes Socket the programming method, compiles server procedure server, translates after arm-linux-gcc moves on the ARM development board, client side procedure client translates after gcc moves on PC.
The overall programming model is the client and server’s course of communications see Figure 4.

4.1 server ends
(1) initialization


4.2 client ends
(1) obtains server’s IP address through the server domain name

Function gethostbyname () completes the domain name transformation. When gethostname() transfers is successful, the returns aims at struct hosten the indicator, when transfers is defeated returns - 1.
(2) founds Socket (to realize method and server looks carefully with)
(3) and server establishment connection

Thus, for ARM development board CS8900A network card assignment address, and after translating server and the client procedure, may develop the board to serve as the server, PC serves as the client side, realizes both’s correspondence.
5 concluding remark
This article designed has developed based on the MC9328MXl ethernet communications system, and has realized the Socket correspondence using the embedded linux operating system formidable network function. In the article client side application procedure already in processor’s embedded development platform succeeded based on ARM9TDMI in the nucleus MC9328MXl the movement, has realized the Socket correspondence using the host PC machine server end application procedure success. Certainly, may also develop the goal hardware the platform to treat as the server end, but treats as host PC machine the client side to carry on the bidirectional file transfer.