Currently, Linux software engineers can be divided into two levels:
(1) Application Software Engineer ):
Mainly uses C library functions and Linux APIs to write application software;
For development in this area, you need to learn about the following APIs and system calls that comply with the POSIX standard of Linux: multi-process, multi-thread, inter-process communication, synchronization and mutex among multiple tasks, embedded database learning, UI programming: QT, MiniGUI, etc.
(2) firmware engineer ):
This module is mainly used to transplant Bootloader and Linux and design the drivers of Linux devices.
Generally, the requirements of firmware engineers are higher than those of application software engineers. The Linux device driver programming is a complicated part in Linux programming, it mainly includes the following aspects:
1) the device driver is part of the Linux kernel. Writing a Linux Device Driver requires a certain kernel Foundation of the Linux operating system. You need to understand the working mechanism and system composition of some linux kernels.
2) Writing Linux device drivers requires a good understanding of the hardware principles. In most cases, we write drivers for a specific embedded hardware platform, for example, for a specific host platform: it may be Samsung's 2410, 2440, Atmel, or flying Karl.
3) Linux device drivers are widely involved in multi-process concurrency synchronization and mutex control, and prone to bugs. Because Linux is a multi-task working environment, it is inevitable that concurrent operations will occur on the same device at the same time.
4) as part of the kernel, debugging for Linux device drivers is also quite complex. Linux device drivers do not have a good IDE environment for single-step, variable viewing, and other debugging auxiliary tools. Linux drivers and linux kernels work at the same level, it is easy to cause the overall crash of the kernel.
In this series of articles, we will introduce some problems and learning methods in Linux Device Driver Programming step by step and in a simple way, and hope to help you learn about Linux device drivers.
In any computer system, large to servers, PCs, small to mobile phones, MP3/MP4 players, whether it is a complex large server system or a simple single-chip microcomputer system of the streaming lamp, drivers are inseparable. software without hardware is a castle in the air. Hardware without software is just a pile of scrap iron. hardware is the underlying foundation and a platform for all software to run, the code is finally implemented in the logical combination of hardware.
However, there is a argument between hardware and software: In order to quickly and efficiently complete software functional design, application engineers do not want to care about hardware, however, it is difficult for hardware engineers to process some applications in software development. For example, when a software engineer calls printf, the software engineer does not need to care about what kind of processing the information and the paths through which the information is displayed, after a 4*4 keyboard driver is written, the hardware engineer does not have to worry about what processing and operations the application performs after obtaining the key value.
That is to say, the software engineer needs to see a pure software world without hardware, and the hardware must be provided to him transparently. Who will implement this task? The answer is the driver, which is literally "Driving hardware device action ". The driver directly deals with the hardware. According to the specific form of the hardware device, the driver registers the device to complete device polling, interrupt processing, DMA Communication, and finally allow the communication device to send and receive data, enables the display device to display text and images, allowing the audio device to store and play sound.
It can be seen that the device driver acts as a hub between hardware and software, so the driver may be represented by some standard, pre-agreed API functions, the driver engineer only needs to fill in the corresponding function, and the Application Engineer only needs to call the corresponding interface to complete the corresponding function. No matter whether there is an operating system or not, the driver has its own value. However, in bare metal scenarios, the working environment is relatively simple and the work done is relatively simple, and the functions completed by the driver are relatively simple, at the same time, the interface only needs to comply with unified standards in a small scope. However, in the case of operating systems, this problem will be magnified: hardware comes from different companies and is ever-changing. A large number of new chips are produced every day in the world, A large number of circuit boards are designed. If there is no good unified standard to standardize this program, the operating system will be designed to be very redundant and the efficiency will be very low.
Therefore, any operating system will develop a standard architecture to manage these drivers: Linux, as a model of embedded operating systems, has a high degree of standardization and convergence, not only does different hardware devices have different categories and integrated management, but also unified abstraction of the commonalities of different hardware to minimize the hardware relevance, greatly simplifying the preparation of the driver program, it has formed a driving organizational structure with its own characteristics.
Reflects the relationship between applications, linux kernels, drivers, and hardware.
Linux kernels are divided into five parts: multi-task management, memory management, file system management, device management, and network management;
Each part has the ability to fulfill the requirements. It provides APIs for application development engineers to use;
Blocks different hardware components from the driver to complete hardware operations.