An embedded system is a system that integrates application programs, operating systems, and computer hardware. It is application-centric, based on computer technology, and its hardware and software can be customized. Therefore, it is a special-purpose computer system that can meet the application system's strict requirements for functionality, reliability, cost, size, and power consumption.
This paper presents a communication platform design suitable for mid-range and low-end applications. It can support data transmission between Ethernet networks and has RS232, RS485, USB and other interfaces.
In this paper, a hardware communication platform based on embedded communication microprocessor S3C44B0X is designed around the embedded uClinux environment, thus realizing embedded Socket communication?
1 Embedded Network Communication System Architecture
As a special type of computer system, embedded systems are usually composed of embedded processors, embedded peripherals, embedded operating systems and embedded application software. The embedded processor is the core component of the embedded system, which can be divided into embedded microprocessors, embedded microcontrollers, embedded DSPs (Digital Signal Processors) and highly integrated embedded SoCs (System on Chips). Embedded peripherals refer to other auxiliary components such as storage, communication, protection, debugging, and display in embedded hardware systems except for the central control components. Embedded operating systems are generally considered for use in relatively large applications or those that require multi-tasking. They can facilitate the design of embedded application software and greatly improve the functions of embedded systems, but they also occupy precious embedded resources. Embedded application software is different from ordinary application software. It is targeted at specific practical professional fields, based on corresponding embedded hardware platforms, and is computer software that can complete the user's expected tasks.
There are many popular processor cores for embedded processors. This article mainly introduces the design and implementation of the hardware and software platform for Socket communication using Samsung's S3C44B0X processor based on ARM's 32-bit RISC ARM7TDMI core.
S3C44B0X is a cost-effective and high-performance microcontroller. It uses the ARM7TDMI core and can operate at 66MHz. ARM7TDMI is a 32-bit embedded RISC processor, but it is also equipped with a 16-bit compressed instruction set Thumb. It supports on-chip debugging, allowing the processor to pause in response to a debug request. The enhanced multiplier in the chip can multiply two 32-bit numbers to directly generate a 64-bit result, and can also provide on-chip breakpoint and debug point support for embedded ICE hardware. In addition, it can also provide a three-stage pipeline and von Neumann structure. In fact, S3C44B0X has expanded a complete series of general peripheral devices based on the ARM7TDMI content. Figure 1 shows the hardware architecture of an embedded network communication system.
2 Peripheral circuit design
As an excellent network controller, the system based on S3C44B0X processor must have a matching control chip. Here, the author selected CirrusLogic's CS8900A. CS8900A is a single-chip full-duplex Ethernet solution, which integrates all the analog and digital circuits necessary to complete the Ethernet circuit. Figure 2 shows the CS8900A Ethernet interface circuit in the system. The signal sending and receiving ends in the figure are connected to the transmission media through the network isolation transformer and RJ45 interface. In addition, in order for the system to work properly, an external 20MHz crystal oscillator is required.
3 Socket communication based on uCliunx
The software of this system is designed based on the embedded operating system uClinux. uClinux is an operating system that fully complies with the GNU/GPL convention. It is compatible with the UNIX system and its code is completely open. uClinux is an operating system that is appropriately tailored and optimized based on the standard Linux. uClinux is a highly optimized and compact embedded subset of Linux. Although it is small in size, it still retains most of the advantages of Linux, such as: stability, good portability, excellent network functions, complete support for various file systems, and standard and rich APIs. uClinux is an embedded operating system specifically for processors without a memory management unit (MMU), and has done a lot of miniaturization work specifically for embedded systems. It can run directly on Flash or be loaded into memory to run. u-Cliunx has a complete TCP/IP protocol and also supports many other network protocols. For embedded systems, it is a complete network operating system, so it has been widely used. [page]
In order to realize the development of application systems based on uClinux, it is necessary to establish or have a complete uCliunx development environment. The application development environment based on the uClinux operating system is generally composed of the target system hardware development board and the host PC (3). It is usually necessary to install a cross compiler on the host PC with Linux installed to compile the user application into a flat format executable file currently only supported by uClinux and compile the operating system kernel. The target hardware development board is used to run the operating system and system application software. The target hardware development board and the PC host are generally connected through a serial port, parallel port or Ethernet interface. The software development and simulation environment used for Socket communication in this article is shown in Figure 3.
Socket is "socket", which indicates the ID of the network communication process. The most commonly used are stream socket and datagram socket. In Linux, they are called "SOCK STREAM" and "SOCKDGRAM" respectively. The tailored uClinux retains most of the socket library functions in Linux. The main library functions to be called for embedded socket communication based on S3C44B0X processor are as follows:
(1)socketint socket(int domain int type int proto-col)
This function is used to create a new socket to notify the system to establish a communication port? The domain parameter in the function is used to specify the address type to use; the type parameter is used to specify the socket type; the protocol parameter is usually 0, indicating the use of the default protocol?
(2)bind intbind(int sockfd,struct sockaddr*myaddr,int addrlen)
The bind function associates the socket port returned by the socket with the physical location on the network. The sockfd parameter is the socket descriptor returned by the socket function; the myaddr parameter is the local address; and the ad-drlen parameter is the length of the socket address structure. Both the server and the client can call the bind function to bind the socket address, but it is usually the server that calls the bind function to bind its own recognized port number.
(3)listenint listen(int sockfd,int backlog)
This function can be used to make the socket port accept connection requests sent from the client. The backlog parameter is the maximum number of clients that can be accepted. The combined call of the three functions of socket, bind, and listen can eventually generate a file descriptor sockfd on the server that can accept client requests.
(4)acceptint accept(int sockfd,struct sockaddr*address,int*address_len)
When a client sends a connection request, this function initializes the connection. The parameter address is used to store the client information, which is filled in by accept. When connecting to the client, the client's address and port will be filled in here; addresslen is the number of bytes of the client's address length, which is also filled in by accept.
(5)connectint connect(int sockfd,struct sockaddr*address,size_t address_len)
After the client calls socket to establish the transmission port, it will then call the connect function to establish a connection line with the remote server. The parameters of this function are the same as those of bind.
The Socket communication designed in this paper adopts the server/client mode, that is, the server-side application is used to accept the client's connection request, receive the client's information, process the client's calculation request, send the calculation result and response information to the client, etc. The client application is used to apply for connection with the server, send calculation request to the server, and process the calculation result and other information sent back by the server.
After creating a socket, the server will then bind the socket to the local address/port number. After success, it will connect to the corresponding socket. When accpet captures a connection service request, a new connection is completed, and data can be sent to the client later.
The client code is relatively simple. First, it obtains the IP address through the server domain name, then creates a socket, and then calls the connect function to establish a connection with the server. After the connection is successful, it receives the data sent from the server, and finally closes the socket after the communication is completed.
mso-ascii-font-family: \'Times New Roman\'; mso-hansi-font-family: \'Times New Roman
\'">To sum up, the steps to establish Socket communication between the network program client and the server are as follows
Server side: socket →bind →listen→accept
Client: socket →bind →connect
The socket used in this design is a stream socket. The following is a client application running on the 32-bit microprocessor S3C44B0X embedded development platform:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main(int argc,char *argv[])
{
int s;
char buffer[256];
struct sockaddr_in addr;
struct hostent *hp;
struct in_addr in;
struct sockaddr_in local_addr;
if (argc < 2) return;
if(!(hp=gethostbyname (argv[1]))){
fprintf(stderr,"Can't resolve host.n");
exit (1);
}[page]
if ((s = socket(AF_
INET,SOCK_STREAM,0)) <0){
perror("socket");
exit (1);
}
bzero (&addr,sizeof (addr));
addr.sin_family = AF_INET;
addr.sin_port=htons((unsigned short)atoi(argv[2]));
hp = gethostbyname(argv[1]);
memcpy(&local_addr.sin_addr.s_addr,hp->h addr,4);
in.s_addr = local_addr.sin_addr.s_addr;
printf ("Domain Name %sn" argv
printf ("IP address:%sn",inet_ntoa (in));
printf("%s,%sn",hp->h_name,argv[2]);
addr.sin_addr.s_addr=inet_addr(hp->h_name);
if connect(s,(struct sockaddr *)&addr,sizeof (addr))<0){
perror("connect");
exit (1);
}
recv (s,buffer,sizeof (buffer),0);
printf ("%sn", buffer);
while(1);
bzero(buffer,sizeof (buffer));
read (STDIN_FILENO,buffer,sizeof(buffer));
if (send (s,buffer,sizeof (buffer),0)<0){
perror ("send");
exit (1);
}
}
}
4 Conclusion
The Ethernet communication system based on S3C44B0X is designed and developed, and Socket communication is realized by using the powerful network function of uClinux operating system. Since uClinux currently only supports executable files in flat format, this design is to convert the user-developed application program into flat format through the cross compiler on the host PC after the uClinux development environment is established first, and then add it to the target hardware development platform through FTP for operation. The client application in this article has been successfully run on the embedded development platform based on the S3C44B0X processor of ARM7TDMI core, and successfully realized Socket communication with the server application of the host PC. Of course, the target hardware development platform can also be used as the server, and the host PC can be used as the client for two-way file transfer.
Previous article:Design and implementation of Bluetooth audio gateway based on S3C4480X control
Next article:Design of reversing audio and video system based on embedded Linux
Recommended ReadingLatest update time:2024-11-17 04:22
- Popular Resources
- Popular amplifiers
- Mission-oriented wireless communications for cooperative sensing in intelligent unmanned systems
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
- ICCV2023 Paper Summary: Fairness, Privacy, Ethics, Social-good, Transparency, Accountability in Vision
- Beej\'s Guide to C Programming-Chinese version
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- EEWORLD University Hall----Live Replay: Secure Boot of Microprocessors
- Texas Instruments Action Camera and Handheld Gimbal Solutions
- Reading Notes on the Good Book "Operational Amplifier Parameter Analysis and LTspice Application Simulation" 05--LTspice Simulation
- Revealed: Tektronix's first oscilloscope for you is now on the market
- Avnet MT3620 module accelerates Azure Sphere IoT security implementation
- [Non-contact automatic disinfection system] Material unpacking - a little surprise
- What microcontroller can be connected to the network via optical fiber using the CAN bus?
- >>See here "New Trend Report: How to Effectively Respond to Current Challenges in the Field of Test and Measurement" and download to win prizes!
- itop4412 development board-QtE4.7-UVC camera usage examples
- Some problems with nested make