Share this

Design of Embedded Real-Time Operating Systems and Network Components

2026-04-06 05:13:23 · · #1
1. Introduction In recent years, the integration of embedded real-time operating systems (RTOS) with networks has made remote monitoring, remote control, remote diagnostics, and remote maintenance increasingly easier. Fundamentally, the network protocols currently used for embedded devices are primarily based on TCP/IP communication protocols. Since embedded systems are dedicated systems based on computer technology, with customizable hardware and software and strict requirements on cost, size, and power consumption, their support for TCP/IP communication protocols has its own characteristics. These characteristics determine the architecture of the embedded real-time operating system and network components. This paper studies the hardware circuit of the embedded real-time operating system and network components using the LPC2210 as the core component, and simultaneously develops application software programs on the μC/OS-Ⅱ platform. 2. Overall System Structure of the Embedded Real-Time Operating System and Network Components The hardware schematic diagram of the embedded real-time operating system and network components is shown in Figure 1. The system uses a PHILIPS LPC2210 microprocessor, an external FLASH SST 39VF160, and connects to an RTL8019AS Ethernet chip (Webchip), which is then connected to an interface connector HR901170A. The open-source TCP/IP protocol stack LwIP was ported to the μC/OS-Ⅱ system. Figure 1 shows the hardware structure schematic. The RTL8019AS Ethernet chip (Webchip) is a dedicated network interface chip independent of various microcontrollers. It connects to the MCU through standard input and output ports. It has a 16-bit data bus and a 24-bit address bus, and integrates a DMA controller, ISA bus controller, integrated 16k SRAM, and a network PHY transceiver, compatible with the NE2k standard. Users can write the data to be sent into the on-chip SRAM via DMA, allowing the chip to automatically send the data; after the chip receives the data, the user can read it out via DMA. The HR901170A is an RJ45 interface connector (with network transformer/filter) manufactured by Zhongshan Hanren Electronics Co., Ltd. This connector meets the IEEE 802.3 and IEEE 902.3ab standards and can effectively suppress electromagnetic interference. The system can be connected to Ethernet via the HR901170A. The design of this scheme is relatively simple. The hardware circuit uses the LPC2210, a microprocessor from PHILIPS, which features 16k RAM, 76 general-purpose I/O ports, 12 independent external interrupt pins, and an integrated 8-channel 10-bit A/D converter, enabling the design of complex systems based on this chip. Although the LPC2210 has a fast access speed, it does not have integrated FLASH memory, so a 16Mbit FLASH SST 39VF160 is used to store the user program. Its architecture meets the basic requirements for the normal operation of μC/OS-II. 3. Software Design of Embedded Real-Time Operating System and Network Components To ensure good real-time performance and stability of the embedded real-time operating system and network components, system software is designed on the μC/OS-II real-time multi-tasking operating system platform. In the system, various tasks work in parallel according to certain relationships, fully utilizing CPU resources, greatly ensuring system reliability, and facilitating the organization of development tasks. On the μC/OS-II platform, the software design work mainly includes three aspects: porting μC/OS-II to the LPC2210, implementing the LwIP protocol on μC/OS-II, and writing system application software. The system architecture diagram of this design is shown in Figure 2: [Figure 2 System Architecture Diagram] This system uses the open-source embedded real-time operating system μC/OS-II, version V2.52. Its characteristics include open source code, high readability, good portability, configurability, and customizability. It adopts a priority-based preemptive scheduling scheme; once the highest priority task is ready, it acquires ownership of the CPU and begins execution. The hardware and software architecture diagram of μC/OS-II is shown in Figure 3. The application program is built on top of the operating system, at the top level of the system, and each task runs in parallel on a macroscopic level. CPU-type independent code provides system services, namely the kernel, task management, memory management, etc. The μC/OS-II porting part is used to complete the interface work with different processors. Porting μC/OS-II requires the processor and its compiler to meet certain conditions. Figure 3 shows the schematic diagram of the μC/OS-II hardware and software architecture. The porting work for μC/OS-II mainly focuses on the following files: OS_CPU.H, OS_CPU_A.ASM, and OS_CPU_C.C. Additionally, the LPC2210 file LPC2210.H must be included in INCLUDES.H; OS_CFG.H is used for initialization configuration in the system application of μC/OS-II. OS_CPU.H mainly includes some constants and type definitions related to the processor and compiler. It's important to note that the LPC2210 stack direction is from high to low, and OS_STK_GROWTH is used to set the stack growth direction. Therefore, OS_STK_GROWTH is set to 1. Four assembly language functions need to be written in OS_CPU_A.ASM: OS_TASK_SW(), OS_IntCtxSw(), OSStartHighRdy(), and OSTickISR(). The OSStartHighRdy() function code is as follows: LDR r4, addr_OSTCBCur ; Get the current task TCB address LDR r5, addr_OSTCBHighRdy ; Get the highest priority task TCB address ... ; Restore CPU working mode LDMFD sp! , {r4} MSR SPSR_cxsf, r4 LDMFD sp! , {r4} MSR CPSR_cxsf, r4 LDMFD sp!, {r0-r12, lr, pc} The OS_TASK_SW() function assembly code is as follows: STMFD sp! , {lr} ; Save pc STMFD sp!, {lr} ; Save lr STMFD sp!, {r0~r12} ; Save registers and return address…… ; Get the current task TCB address LDR r4, addr_OSTCBCur LDR r5, [r4] STR sp, [r5] ; Save sp in the TCB of the preempted task ; Get the TCB address of the highest priority task LDR r6, addr_OSTCBHighRdy LDR r6, [r6] LDR sp, [r6] ; Get the new task stack pointer; OSTCBCur = OSTCBHighRdy STR r6, [r4] ; Set the new current task TCB address…… The assembly code of the OSIntCtxSw() function is as follows: LDR sp, = IRQ_STACK SUB r7, sp, #4 ; Switch the processor to management mode MRS r1, SPSR ORR r1, r1, #0xC0 MSR CPSR_cxsf, r1 ; Complete mode switching... STMFD sp!, {r4} ; Save program status register... OS_CPU_C.C requires six operating system-related functions written in C: OSTaskStkInt(), OStaskCreateHook(), OStaskDelHook(), OStaskSwHook(), OStaskStatHook(), OSTimeTickHook(). OSTaskStkInt() is mandatory; the other five functions must be declared but can be omitted. void *OSTaskStkInit(void(*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt) { OS_STK *stk; opt = opt // Prevent compilation errors stk = ptos; // Load stack pointer... *--stk = (USER_USING_MODE|0x00); // SPSR, enable IRQ, FIQ interrupts *--stk = (); // Disable interrupt counter OsEnterSum return (stk); } The next step is to port LwIP to μC/OS-II, which means separating the hardware, OS, and compiler-related parts and placing them in the /src/arch directory. The implementation of LwIP on μC/OS-II involves modifying the files in this directory; other files are generally not modified. First, files related to the CPU or compiler need to be modified, such as data length and word order, to ensure consistency with the data length parameters defined by the user during the μC/OS-II porting process. Next, operating system-related functions and data structures need to be modified. Finally, library functions need to be implemented, such as `u16_t htons()`, `u16_t ntohs()`, `u32_t htonl()`, `u32_t ntohl()`, `int strlen()`, `int strncmp()`, `void bcopy()`, and `void bzero()`. The first four functions are implemented by the user, while the latter four are already included in the ADS compiler library. Users should decide on the implementation based on their compiler when implementing these functions on other CPUs. After porting LwIP to μC/OS-II, the remaining work involves writing the application program. The system is divided into several tasks, each corresponding to an independent infinite loop main program that performs a specific function. The priority of system tasks is determined by their importance, while also considering system security factors. To simplify the design, the application program uses static priorities, meaning the priority of each task remains unchanged during application execution. Once the system's software architecture is built, writing the various tasks in C becomes much easier. The key code in the main program is as follows: #define TASK_STK_SIZE 64 ; Declare the task stack OS_STK TaskStartStk[TASK_STK_SIZE] ; Start the task stack OS_STK TaskWatchStk[TASK_STK_SIZE] ; Monitor the task stack... void TaskWatch(void *data) ; Declare the function prototype for monitoring the task... void main(void) { OSInit() /* Initialize μC/OS-Ⅱ */ OSTaskCreate(TaskStart, (void *)0, &TaskStartStk[TASK_STK_SIZE-1], 0); OSStart(); /* Start multitasking */ } void TaskStart(void *data) { data=data; /* Prevent compiler errors */ ……} Place the main program and the system files in μC/OS-Ⅱ in the same project and compile. To improve execution efficiency, some commonly used code in μC/OS-II can be modified according to actual applications, and even some unnecessary code can be cut off. 4. Conclusion The design scheme based on embedded real-time operating system and network components is simple and reliable in hardware; the software has good maintainability and scalability, which is conducive to subsequent system development and reduces the complexity of system design. With the deepening of embedded product research, the research on network interface chips will also develop rapidly, making the design of intelligent products simpler, more standardized, and more mature. It can be seen that embedded real-time operating systems and networks will see greater development and wider application.
Read next

CATDOLL Oksana Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22