Share this

Design and Research of Embedded Gateway Based on S3C2410

2026-04-06 07:21:30 · · #1
1 Introduction With the rapid development of communication network technology and integrated circuit design, mature open network communication technologies, represented by the TCP/IP network transmission communication protocol, are penetrating various automation systems, connecting and controlling all devices. However, in industrial control and various communication devices, serial port devices conforming to the RS-232 standard are more prevalent. To forward serial port data to the network for remote data transmission, a gateway system is necessary. A gateway, also known as an inter-network protocol converter, is used to connect networks using different communication protocols, enabling data transmission between networks. This paper proposes a design scheme for data transmission between serial and Ethernet ports based on an embedded system. This paper uses the 32-bit embedded microprocessor S3C241O as the core, porting the embedded operating system Linux, and developing corresponding drivers and applications on Linux to build a convenient and practical gateway. 2 Structured Design of the Embedded Gateway This gateway mainly implements data transmission between the serial port and Ethernet port. Its overall structure can be simplified into two parts: a hardware layer and a software layer. The hardware layer consists of a high-performance microprocessor and multiple functional modules, while the software layer consists of an embedded operating system and application software. 2.1 Hardware Design The system adopts a structured design and consists of three parts: a serial port module, a protocol conversion module, and an Ethernet interface module. The serial port data is sent to the protocol conversion module with S3C2410 as the core in the form of a message. The protocol conversion module completes the reception and translation of the message and forwards it to the Internet through the Ethernet interface module, thus realizing the protocol conversion from serial port device to Ethernet. The basic composition of each module is described as follows: (1) Microprocessor MCU The S3C2410 microprocessor based on the ARM92OT core is a multi-purpose general-purpose chip that integrates a microprocessor and common peripheral components, and is particularly suitable for handheld devices; (2) 10000 Ethernet interface The RTL8200i chip produced by Realtek is selected as the physical layer interface control chip for Ethernet. Then it can be connected to the Ethernet via RJ45; (3) The flash memory uses a HY29LV16O to build a flash memory system with a storage capacity of 2MB; (4) The SDRAM memory uses two HY57V64162O chips from Hynix to build an SDRAM memory system in parallel; (5) The JTAG interface can access all components inside the chip. The system can be debugged and programmed through this interface; (6) The S3C241O serial interface itself has two UART controllers. We connect them to MAX232 for level conversion to obtain two standard RS-232 serial interfaces; (7) The I/O interface mainly includes the keyboard control module and the LCD display module. 2.2 Software Design The software architecture design of the gateway is divided into three layers: (1) Linux kernel: provides file system management, interrupt and interrupt handling, system initialization, network protocol stack, etc.; (2) Hardware driver layer: includes driver serial port, Ethernet, etc.; (3) Application program: such as serial communication program, network service program, etc. ● Establishing a Linux Development Environment. The Linux-based application development environment consists of an S3C2410 development board and a host PC. The host PC handles the kernel compilation, application development, and debugging of the target board's operating system. The two systems are connected via serial and Ethernet interfaces. First, install the Linux operating system on the host machine. Then, download the toolchain, such as arm-elf-gcc-2.95.3-2.i386.rpm, from the internet. Copy it to any directory on the host machine, and install the cross-compiler, establishing the cross-development environment. The arm-elf-gcc cross-compiler can then be used to compile the operating system kernel and user applications. ● Device Drivers. Device drivers are the interface between the kernel and the hardware. They are a collection of data structures and functions, with the `init_module` and `cleanup_module` functions and the `file_operations`, `inode`, and `file` data structures being the most important. These are defined in `linux/fs.h`. These data structures and functions control one or more devices through the defined interface. Device drivers reside at the lowest level of the kernel and interact directly with the hardware. The kernel provides unified system calls, through which user programs access hardware devices. The hardware drivers to be developed in this design include: Ethernet card controller, serial port, LCD, and keypad drivers. Writing drivers for the Linux kernel only requires writing a few basic functions for the corresponding devices and registering them with VFS. Generally, it involves modifying an existing driver for specific hardware devices. After the driver is written, it provides interface functions for upper-layer applications, and then the application for that device can be written. Finally, the kernel is recompiled, the Linux binary is burned into the flash memory, and the external devices can be used. ● Application Design. The main function of this gateway is to implement the conversion between serial port protocols and network protocols. Since the Linux operating system is ported, we only need to write serial port and network applications on the Linux operating system to meet the gateway design requirements. The application design block diagram is shown in Figure 3. It mainly includes three applications: serial port programming under Linux, socket programming, and inter-process communication. 2.3 Serial Port Programming under Linux. The serial port is the simplest and most commonly used interface in communication applications. In Linux, the serial port is treated as a file, and each serial port is assigned a file descriptor. The basic steps to open and configure a serial device in Linux are as follows: (1) Open the serial port. In Linux, the serial port file is located under /dev. Serial port 1 is /dev/ttys0 and serial port 2 is /dev/ttys1. The serial port is opened by using the standard file open function. (2) Configure the serial port. Serial port configuration includes baud rate setting, parity bit and stop bit setting. It mainly sets the values ​​of each member of the struct termios structure: c_illag, c_oflag, c_cflag and c_1nag. Setting this structure is quite complex. Below is the function for setting the baud rate: void set_speed(int fd, int speed) { //fd is the file handle for opening the serial port, speed is the serial port speed int i; int status; struct termios opt; tcgetattr(fd, &opt); //Use tcgetattr to get the current device mode for (i = 0; i if (speed == name_arr[i]) { tcflush(fd, tcioflush); cfsetispeed(&opt, speed_arr[i]); //Set the baud rate, speed_arr[i] is a value in the baud rate table cfsetispeed(&opt, speed_arr[i]); status = tcsetattr(fd1, tcsanow, &opt); //Use tcsetattr to set the device mode if (status != 0) { perror("tcsetattr fd1"); return; } tcflush(fd, tcioflush); } } } (3) Read and write serial port After setting up the serial port, treat it as a file and use read and write to read and write the serial terminal. The function prototypes are write(fd, buffer, length) and read(fd, buffer, length). (4) Close serial port After the input and output processing is complete, use close to close the serial port. Closing the serial port is the same as closing the file, i.e., close(fd). 2.4 In Linux, the socket interface is the API for TCP/IP networks. It's a socket specification built on top of transport layer protocols (mainly TCP and UDP). The socket interface defines many functions and routines that programmers can use to develop applications for TCP/IP networks. Network socket data transmission is a special type of I/O, and a socket is also a file descriptor. A socket has a function call similar to opening a file, `socket()`, which returns an integer socket descriptor. Subsequent connection establishment, data transmission, and other operations are implemented through this socket. There are two common socket types: stream sockets (`sock_stream`) and datagram sockets (`sock_dgram`). Stream sockets are connection-oriented, designed for connection-oriented TCP services; datagram sockets are connectionless, corresponding to connectionless UDP services. This solution uses stream sockets because they provide a reliable connection-oriented data transmission method, have their own error detection and correction mechanisms, and offer a streaming data transmission method for both individual datagrams and data packets. Inter-process Communication (IPC) In Linux, each process has its own independent execution space. For processes to communicate, they need to use the communication mechanisms provided by the system. Mechanisms used for inter-process communication and synchronization in Linux include: shared memory, semaphores, message queues, pipes, named pipes, sockets, etc. This system uses shared memory and semaphores. Shared memory is used for communication between two processes, and semaphores are used to implement mutual exclusion access to it. Shared memory allows two or more processes to share a block of memory. In Linux tasks, this memory is addressed through the `/dev/mem` device, and processes obtain information by reading data from this memory. Theoretically, shared memory should be the fastest way for two processes to communicate because it directly maps information into memory, eliminating the intermediate steps of other IPG methods. Synchronization is particularly important when using shared memory. Semaphores were introduced to solve this problem. Semaphores allow programmers to implement a locking mechanism for arbitrary events. Conclusion This paper designs an embedded gateway system for serial device and Ethernet communication based on the S3C2410 embedded processor and Linux operating system. This gateway can realize Ethernet communication with serial devices, and with improvements, it can be adapted to communicate with more types of serial devices. With the development of Ethernet and the increasing attention paid to embedded system design, this design scheme will find wider application in industrial control, building automation, smart homes, and other fields, showing broad application prospects.
Read next

CATDOLL 133CM Kiki Shota Doll

Height: 133cm Male Weight: 28kg Shoulder Width: 31cm Bust/Waist/Hip: 64/59/73cm Oral Depth: 3-5cm Vaginal Depth: N/A An...

Articles 2026-02-22