0 Introduction
32-bit ARM embedded processors have the characteristics of high performance, low power consumption and high cost performance, and have been widely used in consumer electronics, wireless communications, control and network communications. uCLinux is an embedded operating system designed specifically for MMU-less processors and supports ARM, Motorola and other microprocessors. Currently, it is very common to use ARM + uCLinux as a development model for embedded systems.
A complete embedded system based on uCLinux consists of three parts, namely the system bootloader, the uCLinux operating system kernel and the file system. The boot technology of embedded systems is a difficult point in embedded system development. The success of system boot determines whether the operating environment of the application can be correctly established. The successful system boot is the prerequisite for the correct operation of the application. The boot process of the uCLinux kernel is also an important part of it. Analyzing the boot process of uCLinux can speed up the system boot speed and correctly establish the application environment. This article will study the boot process of the uCLinux operating system kernel.
1 System Introduction
This system uses the S3C4510B processor with the Arm7TDMI core of SamSung, and mainly uses its powerful network function to communicate with the PC. The main function of this system is to use the serial port to monitor a smart meter, transmit the obtained data to the PC through the Internet, and the PC will further process it and present the final result to the user.
The hardware platform includes a processor with ARM as the core, 2MB Flash and 16MB SDRAM as the memory, and an Ethernet interface in addition to the serial port for communication to support the network function of S3C4510B. The software platform consists of the following parts: system bootloader, embedded operating system kernel, and file system.
Depending on whether the kernel is compressed and whether the kernel is executed locally, uCLinux usually has two startup methods: flash local execution and compressed kernel loading. This system uses the second startup method, that is, the kernel's compressed image is fixed to the flash, decompressed in the memory when the system starts, and then executed in the memory. This startup method runs faster than the first method.
2 Implementation of uCLinux kernel startup process
The boot process of the ARM + uCLinux system can be summarized into the following stages: (1) PC points to the reset address entry, that is, the Bootloader code at 0x0H. The Bootloader completes some basic initialization and brings the system's hardware and software environment to a suitable state; (2) After the Bootloader hands over control to the boot program of the operating system kernel, it starts loading the uCLinux kernel; (3) After the uCLinux kernel is loaded and booted, the init process is started, completing the system boot process.
The boot program of this system uses the boot program that comes with uCLinux to load the kernel. During the kernel boot process, the following files are mainly called: head.S (in the \\linux-2.4.x\\arch\\armnommu\\boot\\compressed\\ directory), main.c (in the \\linux-2.4.x\\init\\init\\ directory), and simpleinit.c (in the \\user\\init\\ directory) [1]. In actual applications, the relevant files should be modified according to the hardware platform and system functions to correctly boot the system.
When the Bootloader hands over control to the kernel's boot program, the first program executed is head.S, which completes most of the work of loading the kernel; misc.c provides the subroutines required to load the kernel, among which the subroutine for decompressing the kernel is an important program called by head.S. In addition, the kernel loading also requires the knowledge of the system's hardware information, which is defined in hardware.h and referenced by head.S. The kernel startup process in this system is shown in Figure 1.
[page]
In this system, head.S first configures the system register SYSCFG of S3C4510B, initializes the system's Flash, SDRAM and bus control registers, and sets the address ranges of Flash and SDRAM to 0x0-0x1fffff and 0x1000000-0x1ffffff respectively; according to the functional characteristics of this system, the interrupt priority and I/O port configuration are redefined; in order to improve the running speed of the kernel, the 2M kernel image file is copied from Flash to SDRAM; by operating some system registers, the system's memory is remapped, and the address ranges of Flash and SDRAM are remapped to 0x1000000-0x11ff respectively fff and 0x0-0xffffff; then initialize the system stack; then call the function decompress_kernel in misc.c to decompress the kernel image file copied to SDRAM; finally jump to execute the kernel function call_kernel. Calling the call_kernel function actually executes the start_kernel function in main.c. The functions completed by this function include initialization of the processor structure, initialization of interrupts, initialization of timers, initialization of processes, and initialization of memory; finally, the kernel creates an init thread, calls the init process in this thread, and completes the system startup [1][2].
It is worth noting again that during the kernel boot process, the hardware-related information defined in the file hardware.h is called. The boot of Linux-based embedded systems is heavily dependent on the hardware platform. Before the kernel boots, necessary files must be modified according to the hardware platform and system functions [2]. In this system, the flash and SDRAM control registers ROMCON0, DRAMCON0, and SYSCFG in hardware.h are modified.
When uCLinux starts, it runs a program called init, which is a user-level process started by the operating system. It starts the following tasks, including multi-user environment and network. The behavior of the init process is defined in the function simpleinit.c, so the behavior of the init process can be customized according to the system's functions. For example, a serial port control program is added to this system, and the printk function can be used to print out necessary debugging information. When the init process starts, it reads a run control file rc and a configuration file inittab. In embedded applications, it is generally necessary to run user-specific programs immediately after the operating system is running. For this purpose, these two files can be modified. In this system, the inittab file and rc file are appropriately modified so that some specific processes can be run immediately after the system starts. The inittab file is modified in the program inittab.c, and then the SIGHUP signal is sent to the init process, that is, kill(1,SIGHUP), so that the init process re-reads the configuration file inittab[3].
Some of the code in the inittab.c file is as follows:
FILE *pFile;
if((pFile=fopen("/etc/inittab","w"))!=NULL){
fprintf(pFile,"pollmeter:unknown:/bin/pollmeter ");
fprintf(pFile,"netcomm:unknown:/bin/netcomm ");
…
}
......
kill(1,SIGHUP); //The ID of the init process is equal to 1
…
There is also an important link script file in the startup process, which specifies the entry address of the kernel.
In short, the startup process of uCLinux is also relatively complicated, and many files need to be called. In order to correctly start the uCLinux operating system, the relevant source code files must be modified according to the hardware platform and system functions.
3 Conclusion
This paper analyzes the kernel boot process, modifies the boot code and necessary related files according to the characteristics of the application system, and completes the correct boot of the uCLinux kernel. Practical application shows that the boot design of this system is correct and reliable. The analysis and design method of this paper has great reference value for the development of embedded Linux. I believe that the application of Linux in embedded systems will become more and more extensive.
References:
[1]. Arm7TDMI datasheet http://www.dzsc.com/datasheet/Arm7TDMI_139812.html.
[2]. S3C4510B datasheet http://www.dzsc.com/datasheet/S3C4510B_589.html.
Previous article:Debugging and diagnosis method based on embedded system
Next article:Design and Analysis of Embedded Ethernet Based on S3C44B0X+μcLinux
Recommended ReadingLatest update time:2024-11-16 14:42
- Popular Resources
- Popular amplifiers
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 5G in 60: An introduction to 5G
- Battery system state of charge calculation algorithm problem
- I'm a newbie in your place, please take care of me, thank you!
- Choosing Machine Learning Processors at the Edge
- EEWORLD University Hall----MATLAB Applications Complete Book Video
- All-inclusive OLED
- c0000 28335 Program automatic upgrade problem
- TMS320C62x Boot Mode
- Any port generates a square wave with half duty cycle
- 【MicroPython】Using MCO as a clock