0 Preface
In order to adapt to different applications, while taking into account the flexibility, scalability and tailorability of the computer system, an embedded operating system that is application-centric, computer-based, and software and hardware tailorable was born. This kind of embedded system can be suitable for application systems with strict requirements on function, reliability, cost, volume, and power consumption. Among many embedded operating systems, Linux has been widely adopted because of its small size, reduced size, fast running speed, excellent network performance, and open source code. Especially the 2.6 kernel version of Linux has been greatly improved in real-time performance, so it has received more and more attention and applications in industrial control occasions.
In this context, this article builds an embedded system development based on the Linux2.6.16 kernel for the S3C2410-based embedded platform (expanded a variety of peripheral devices, including: LCD, A/D, network chips, etc.) Platform to meet the needs of wind power monitoring system development.
1 system architecture
The hardware platform of this system is based on the 32-bit high-performance embedded processor S3C2410A as the system's CPU, with a maximum operating frequency of 203MHz and powerful processing capabilities. In addition, there are a variety of peripheral devices, such as: 260,000-color TFT LCD with a resolution of 640×480, serial ports, USB ports, network ports, 64MBFlash, 64MBSDRAM, and so on. It can fully meet the needs of wind power generation monitoring system development.
The software architecture of this hardware platform is mainly divided into the following parts: BSP layer, operating system layer and application layer. Figure 1 shows the software architecture diagram. The hardware platform of this system is composed of embedded microprocessor and its peripheral equipment. The hardware abstraction layer (BSP) is a hardware driver that is stored on the hardware platform ROM or Flash and is responsible for communicating with the underlying hardware. It is mainly responsible for initializing the system and passing the collected hardware information to the operating system kernel that will run next. . The operating system kernel manages system hardware resources through the BSP, and provides services such as process scheduling, memory management, file system, and device drivers for upper-level software. The application layer is mainly responsible for communicating with users.
After completing the architecture design of the system, the hardware platform can be specifically constructed. Its work mainly includes the following parts: BootLoader transplantation, kernel transplantation and file system establishment, etc. The kernel transplantation includes network equipment, LCD and USB Wait-driven transplantation. In this paper, the transplantation of related programs is given for the design of this system.
2BootLoader porting
BootLoader (boot loader) is the first piece of code that runs after the system is powered on. This small program is used to initialize hardware devices and establish a map of memory space, so as to bring the system's software and hardware environment to a suitable state, so as to prepare the correct environment for the final call of the operating system kernel.
At present, the more popular BootLoader mainly include U-boot and Vivi. This design is mainly based on the hardware platform of S3C2410 as the controller, so Vivi with network function can be selected as the BootLoader of the system. As a boot program, Vivi is generally divided into two parts, stage1 and stage2. Stage1 is mainly based on the CPU architecture for device initialization and other tasks. It is usually implemented in short and succinct assembly language, while stage2 is usually implemented in C language. This can achieve more complex functions and the code will have better performance. Readability and portability. In order to make Vivi more suitable for the hardware platform of this system, it needs to be partially modified during design.
(1) Modify the compiler
First, point the relevant compilation options of the Makefile in Vivi to the installed 3.4.1 version of the cross-compilation tool chain, and set the Linux folder "UNUX-INCLUDE-DIR=" to the folder where the cross-compiler is located. LINUX-INCLUDE-DIR=/usr/local/arm/3.4.1/include", and modify the "CROSS-COMPILE=" item to "CROSS-COMPILE=/usr/local/arm/3.4.1/bin/arm -linux-".
(2) Modify startup parameters
Then according to the actual situation of the hardware platform, the Flash partitioning in Vivi should be modified. This system divides Flash into four parts: the first part is used to store the Vivi of the system; the second part is used to store the startup parameters of Vivi and the Linux operating system; the third part is used to store the embedded Linux operating system; the last part is used to store the embedded Linux operating system Store the file system. The specific address and block size allocation are listed in Table 1.
After modifying the above two items, you can compile Vivi, and then burn the generated binary code to the first part of Flash through JTAG, which completes the transplantation of Vivi.
3 kernel porting
Kernel transplantation and BootLoader transplantation should be carried out according to the designed hardware platform. According to the design of the hardware platform of this embedded system, it is necessary to modify the kernel Makefile, set the Flash partition, configure and compile the kernel, etc., and complete the porting of network devices, LCD and USB drivers. The following briefly introduces the related porting for this hardware platform jobs.
(1) Kernel compilation and transplantation
Before cross-compiling the kernel, you must first configure the compilation options. Execute the "makemenuconfig" command, enter the SyetemType option, select the support for the S3C2410 system board, and then configure the FileSystem and Blockdevice, then use the "makedep" command to set the dependency, and then use the "makezImage" command to compile. The cross-compilation time for compiling the kernel is relatively long. Finally, a file zImage will be generated, which is the ARMLinux kernel file after successful compilation. Write the compiled kernel image file into Flash, which completes the transplantation of the kernel.
(2) Network equipment migration
The system adopts CS8900A as a network chip and supports a transmission rate of up to 10Mb/s. It uses nGCS3 of S3C2410 as a chip selection line and IRQ_EINT9 as an external interrupt signal line. The driver transplantation method is as follows:
1) Add the chip's driver file cs8900 in the linux/driver/net/arm directory. h and cs8900. c:
2) Complete the corresponding register settings in the SMDk2410_init function; set the S3C2410 network control register in the cs8900_probe() function: add _raw_writel (0x221ldll0, S3C2410_BWSCON); and _raw_writel (0x1f7c, S3C2410_BANKCON3); two statements;
3) Map the physical address (0x19000000) of the network card to the virtual address pointed to by vSMDK2410_ETH_IO, that is, in /arch/arm/mach-s3c2410/mach-smdk2410. Add the following content to the smdk2410_iodesc[] structure array in the c file: {vSMDK2410_ETH_IO, 0x19000000, SZ_1M, MTl_DEVICE};
4) Configure the Makefile and Kconfig files of the network device driver, and make some modifications to the header files.
(3) LCD transplantation
The LCD driver of S3C2410 has been included in the 2.6.16 kernel. Therefore, the main task of transplantation is to initialize the driver and the actual situation of the LCD screen. S3C2410 comes with 5 LCD controllers, each of which has different functions. It is necessary to set the parameters of each controller to start the LCD smoothly. These parameters include: LCD screen type (TFT screen or CSTN screen) , Color digits, verticality, levelness, polarity of control signal lines and resolution of LCD screen, etc.
This system uses a SHARP8.0 inch TFT LCD screen. Refer to the LCD screen manual and set the parameters of each register according to the actual situation as listed in Table 2.
After setting the parameters of the LCD screen, start the LCD screen in the platform initialization function smdk2410_devicesï¼»]_initdata. Finally, modify the Kconfig in the drivers/video directory and the Makefile in the drivers/video directory.
4 file system establishment
Each operating system has its own file system, such as: Windows generally uses FAT32 or NTFS file system format, Linux uses EXT2 or EXT3 file system format, and the embedded Linux operating system is built on a type called YAFFS2 (YAFF file The improved version of the system) based on the file system for embedded Linux. Therefore, it can be designed according to the hardware platform of the system and the adopted Linux kernel. Build the YAfTS2 file system, the steps are as follows:
(1) Create the YAFFS2 directory fs/yaffs2 in the kernel, and copy the downloaded YAFFS2 code (the source code of the open source YAFFS2 can be downloaded from the Internet) to this directory;
(2) Modify Kconfig and Makefile to configure YAFFS2;
(3) Generate Makefile and Kconfig files in YAFFS2 directory;
(4) Modify the NAND partition in the kernel according to Table 1;
(5) When configuring the kernel, MTD support and YAFFS2 support should be selected;
(6) Compile the kernel and download it to the Flash of the development board;
(7) Make the root file system and download it to the designated address of Flash (the address is shown in Table 1).
So far, the software and hardware platform required for the development of wind power monitoring system has been built. Figure 2 shows a screenshot of a wind power monitoring system based on a built platform and using Qt/Embeded.
5 concluding remarks
According to a specific target platform, this article introduces how to build an embedded development platform based on Linux2.6.16, introduces the main technology and the whole process of transplantation, and develops wind power monitoring software under Qt/Embedd. Mastering these transplantation and development technologies is very important for the development of embedded Linux application systems, and also has certain reference significance for the development of other types of embedded systems.
Thermal Printer,Thermal Receipt Printer,Minithermal Printer,Thermal Printer For Shipping Labels
Guangzhou Winson Information Technology Co., Ltd. , https://www.winsonintelligent.com