Research on ARM-based embedded Linux Application Development
[Date:] |
Source: China Power Grid Author: Dong Ling, Zhu Hong, Yang zhongxiao |
[Font:Large Medium Small] |
0
In today's society, embedded systems have penetrated into all fields of people's work and life. embedded processors account for 94% of the market share of distributed processors. The development of embedded Linux not only inherits the advantages of open source Linux, stable and efficient kernel, and rich software, it also supports a wide range of processor structures and hardware platforms, small footprint, low costs, and compact structures.
1 ARM processor and Development Board
In the field of embedded technology, ARM has achieved great success and created the myth of commercialization and marketization of IP core. According to statistics, 103 giant IT companies around the world are using ARM technology, 20 of them are the largest semiconductors, and 19 of them are ARM users. ARM chips have been widely used in mobile, handheld computers, and a variety of embedded application fields, making them the world's largest 32-bit microprocessor. ARM has become an industry standard for the use of the chip.
ARM series Processors are used in different fields according to their respective characteristics. From the application perspective, the general principles of ARM chip selection are MMU, processor speed, built-in memory capacity, USB interface, GPIO quantity, interrupt controller, and IIS (integrate interface ofsound) audio interface; nWAIT signal; RTC (real timeclock); LCD controller; PWM output and other indicators.
This article uses ARM9. its performance is far higher than that of arm7. The Development Board uses the Development Board of Guangzhou Sidao Information Technology Co., Ltd., and the core processor is Samsung's S3C2410. ARM9. it has the following features: 5-level pipelines; Harvard structure; introduction of high-speed cache and write cache; Support for MMU.
2. Embedded Linux System
The embedded operating system is the foundation and development platform of embedded application software. It has solved the difficulties of the embedded software development standardization. Embedded systems have the most basic functions of the operating system. Currently, mainstream embedded systems include Linux, VxWorks, QNX, Windows CE, and Palm OS.
The embedded Linux operating system has some unique advantages: the hierarchical structure and kernel are fully open, powerful network support functions, a complete tool chain, and a wide range of hardware support features.
There are many types of Embedded Linux systems. This document uses the red hat9 operating system.
On a PC with both Windows and Linux systems installed, the grub of Linux is used as the boot loader to start the two. In this case, if you delete the LINUX partition directly, the system cannot start Windows or you need to run a command to start Windows. You can first use a virtual machine to install the Linux system, practice, familiarize yourself with it, And then install it on the PC.
3. Application Development
General Embedded Development Process 1 is shown.
The preceding three steps are omitted here, starting with application development.
3.1 cross-Development Environment Establishment
For an embedded system, only necessary resources are required. This also determines that the development environment of embedded applications cannot be an embedded system with limited resources. It can only be developed on a PC with rich resources, create a cross-development platform.
Cross-compiler is the main software tool for cross-platform development. It is a compiler that runs on a processor architecture, but can generate the target code that runs on a different processor architecture. To establish a cross-development environment, the main tools are GCC, glib, binutils, and GDB. Generally, the Development Board provides these tools. If you are not using the Development Board, you can download all the software packages online. Install them on the PC in sequence.
Linux software installation method is different from windows. Linux uses different commands for installation based on different compression and packaging methods. During the installation process, due to the dependency between software packages, the system may warn which software packages are not installed and ignore these warnings.
3.2 U-boot
Before U-boot (universalbootloader), we will first introduce bootloader. To put it simply, bootloader is a boot program before the operating system kernel runs, similar to the BIOS in the PC. With this function, you can initialize the corresponding hardware device and create a memory space ing graph to prepare for the final call of the system kernel.
U-Boot is an open source project that complies with the GPL terms. It not only supports embedded Linux system guidance, in U-Boot, the definition of Universal is that U-Boot supports multiple embedded operating systems. At present, U-Boot provides the most complete support for Linux. Another layer is that U-Boot supports a variety of commonly used series of processors.
U-Boot supports the following main functions: System Boot; Basic auxiliary functions (operating system interface functions; flexible settings and transmission of multiple key parameters to the operating system; support for multiple storage methods of the target board; CRC32 check); device driver; power-on self-check function; special features (XIP kernel boot ).
U-Boot porting involves two steps: Configuring the motherboard and configuring Flash and SDRAM timing.
3.3 embedded Linux kernel compilation and Transplantation
The compilation of the embedded Linux kernel is implemented by using different make commands, which are generally divided into three steps: (1) Kernel configuration. It is mainly used by users to select the processor architecture option for the target board. The kernel supports four methods of configuration. Although the interface is different, the functions are the same. make menuconfig is the most widely used. (2) establish dependency. When the first compilation occurs, generate the ". de-pend" file and run "make dep". (3) create the kernel. Here we create a compressed kernel image, using "make zIm-age" or "make bzImage ". This completes the compilation and can be downloaded to the Development Board.
Generally, there are three ways to communicate with the Development Board: Network download (tftp, ftp, etc.), serial download and USB download. To download data using tftp, You need to configure the tftp service in Linux, and then connect the PC to the Development Board directly (non-network cable). to download data using a serial port, You need to configure the Linux serial-day communication tool Minicom. The configuration mainly involves some important parameters, such as the baud rate.
However, only the system kernel is not enough. To enable the system to start normally, you also need to load the file system, so you need to create a file system. It can be manually created, but the workload is too large. It is generally to load the existing file system to the target board, including creating a file system image and loading a file system with NFS.
The embedded system kernel image, file system, and the U-Boot mentioned above have been installed on the Development Board. After mastering the writing method, you can download it by yourself.
3.4 source program acquisition, compilation and debugging
Since Linux is an open-source software, the application software running under it is also an open-source software. No matter which type of software is used, the source code is obtained for free. You can directly modify the existing source code to obtain the required code. The existing source code is used in this paper, as shown in figure 2.
Linux supports compilation, C, C ++, basic, Fortran, Pascal, Java, PHP, and other programming languages. The text editor is VI and Emacs, both of which have powerful editing functions. The graphic interface programming uses QT or MiniGUI. The above software is written in the same way as windows and other operating systems.
The process of writing software is no different from that of other systems, and compilation and debugging are different. In embedded systems, this is called cross-compilation and cross-debugging.
Cross-compilation is to compile the source code compiled on the PC and generate code that can run on the embedded system through links, as shown in figure 2.
In cross-debugging, the debugger and the program to be debugged are in the PC system and embedded system, which is different from general debugging. Cross-debugging is generally divided into software debugging and hardware debugging.
Software Debugging is performed by inserting the debugging pile. A typical gdb debugger is divided into gdbserver and gdbclient. The former is installed as a debugging Pile in an ARM embedded system, and the latter is located in a local PC, the two can communicate through the serial port, network port, and parallel port.
Generally, hardware debugging uses simulators, such as rommonitor, romemulator, In-circuitemulator, and in-circuitdebugger. The hardware debugging function is more powerful and the performance is better, but some of them are expensive and additional devices increase the cost. The JTAG port of arm can be debugged inside the CPU, and commands and messages are sent and received through the port.
The main technology used by JTAG is boundary scanning. The basic idea of JTAG is to add a shift register unit on the input and output pins close to the chip. When the chip is in the debugging status, these boundary scan registers can isolate the chip from the peripheral input and output. Through these boundary scanning Register units, we can observe and control the input and output signals of chips. It provides a convenient way to observe and control the chips to be debugged. Through the JTAG interface, you can easily test the target system and implement flash programming. This is a very popular debugging method.
4 Conclusion
The host downloads mp3 songs from the network and transmits them to the Development Board via serial port (or tftp). It uses the debugged player and the power amplifier developed by the Teaching and Research Section, the audio playback function is well implemented.
On this basis, you can further develop the video playback function. In addition to the player application software, you can also add other applications based on the memory size.