Embedded system HAL principle and BSP implementation method

Spot Remarks 2017+
L0504-Murata muRata common mode inductor 90Ω 150mA

With the rapid development of computer hardware and software technology, more and more portable devices and smart devices have emerged. These devices usually contain a control CPU and a corresponding operating system; such special computer systems are called embedded real-time systems. Embedded real-time systems are widely used in computers, communications, etc. due to their simplicity and efficiency.

Due to the particularity of the embedded real-time system application environment, there are many special problems in the design and implementation process. Among them, the interface between the operating system and other system software modules and hardware is the main feature of the embedded real-time system and the necessary links in the system design process, and is also a key issue affecting the application prospect of the embedded system. After the development of the past few years, with the maturity of the general embedded operating system technology and the continuous expansion of applications, a unified interface form has been widely recognized and applied. This is commonly known as the board support package, namely BSP. .

1 Principle of embedded system hardware abstraction layer

1.1 Introduction of the hardware abstraction layer

嵌入式系统HAL原理与BSP的实现方法 0

As a special type of computer system, the embedded real-time system consists of three parts from the bottom up, as shown in Figure 1.

(1) Hardware environment: It is the hardware platform for the entire embedded real-time operating system and real-time application running; different applications usually have different hardware environments; the diversity of hardware platforms is a main feature of embedded systems.

(2) Embedded real-time operating system————RTOS: Complete core functions such as task scheduling and control of embedded real-time applications. It has the characteristics of streamlined, configurable, and closely related to high-level applications. Embedded operating systems are relatively invariant.

(3) Embedded real-time application: Runs on the operating system and uses the real-time mechanism provided by the operating system to complete embedded functions with specific functions. Different systems need to design different embedded real-time applications.

Due to the large difference in hardware environment of embedded system applications, how to apply embedded systems to various application environments in a simple and effective manner is a key issue that must be solved in the development of embedded systems.

After continuous development, the three-layer structure of the original embedded system gradually evolved into a four-layer structure. This newly added intermediate level is between the operating system and the hardware and contains most of the hardware-related features of the system. The specific upper layer interface interacts with the operating system to provide the underlying hardware information to the operating system; and the direct operation of the hardware is completed according to the requirements of the operating system. Since an intermediate level is introduced to shield the diversity of the underlying hardware, the operating system no longer directly faces the specific hardware environment. It is oriented towards the logical hardware environment represented by this intermediate level. Therefore, this intermediate level is called Hardware Abstraction Layer (HAL). In the current embedded field, the HAL is usually called the Board Support Package (BSP). Figure 2 shows the embedded system architecture after the introduction of HAL. The introduction of BSP has greatly promoted the generalization of embedded real-time operating systems, thus providing a wide range of applications for embedded systems.

嵌入式系统HAL原理与BSP的实现方法 1

1.2 Features and functions of BSP

HAL/BSP is proposed to enable general-purpose embedded operating systems and high-level embedded applications to run effectively on specific, application-related hardware environments, enabling operating systems and applications to control and operate specific hardware devices. Specific features. Therefore, in most embedded systems, BSP is an indispensable level.

Due to its special location in the system, the BSP has the following main features:

(1) Hardware correlation

Because the hardware environment of the embedded real-time system has application relevance, as an interface between high-level software and hardware, the BSP must provide a way for the operating system to operate and control specific hardware.

(2) Operating system relevance

Different operating systems have their own software hierarchy, so different operating systems have specific hardware interface forms.

In terms of implementation, BSP is a software layer between the operating system and the underlying hardware, including most of the hardware-related software modules in the system. There are two parts in the function: system initialization and hardware-related device drivers.

2 BSP design and implementation

In order to achieve the above two functions, designing a complete BSP requires two parts:

(1) Design the initialization process to complete the initialization of the embedded system;

(2) Design hardware-related device drivers to complete the operation of the operating system and application programs on specific hardware.

2.1 Embedded System Initialization and BSP Functions

The initialization process of the embedded system is a process that includes both hardware initialization and software (mainly operating system and system software modules) initialization; and the initialization operation before the operating system starts is one of the main functions of the BSP. Since the embedded system not only has the diversity of the hardware environment, but also has the configurability of the software, the content involved in the initialization of different embedded systems is different, and the complexity is not the same. However, the initialization process can always be abstracted into three main links, in order of bottom-up, hardware-to-software: slice-level initialization, board-level initialization, and system-level initialization.

(1) Chip-level initialization: Mainly complete the initialization of the CPU, including setting the core register and control register of the CPU, the CPU core working mode, and the local bus mode of the CPU. Chip-level initialization sets the CPU from the default state at power-on to the working state required by the system. This is a pure hardware initialization process.

(2) Board level initialization: Initialize the hardware devices other than the CPU. In addition to this, the data structure and parameters of some software are set to establish a hardware and software environment for subsequent system level initialization and application operation. This is an initialization process that includes both hardware and software.

(3) System level initialization: This is a process based on software initialization, mainly for operating system initialization. The BSP transfers control to the operating system, and the rest of the initialization operations are performed by the operating system. This includes loading and initializing hardware-independent device drivers, building system memory regions, loading and initializing other system software modules, such as network systems, file systems, etc. Finally, the operating system creates an application environment and passes control to the application's portal. .

After the above three levels of operation, the hardware and software environment required for the operation of the embedded system has been correctly set up. From here on, the high-level real-time application can be run.

Need to point out: System level initialization is not the job of BSP. However, the key to the success of system-level initialization is the correct setting of software and hardware during the first two initializations of the BSP, and system-level initialization is also initiated by the BSP. Therefore, the focus of the design of the BSP initialization function is mainly concentrated in the first two links. Figure 3 shows the initialization process for an embedded system.

Education Projector

Educational projectors are mainly aimed at classroom teaching by school teachers; traditional projectors are not easy to carry. Due to the naughty students in school classrooms, projectors are not safe to place in classrooms and are easily damaged by students. The portability of educational micro-projectors makes up for teaching Vacancy, it is convenient for teachers to give lectures and only need to store the materials in the projector and show them to students for teaching, saving the trouble of textbooks and handwriting with pens and chalks. Its general weight will not exceed 0.2Kg, and some do not even need fan cooling or ultra-small silent fan cooling.

Educational projectors need to have:

1. Clear handwriting Educational projectors most often display text and images, at least a resolution of 1024*768 or more, and a contrast ratio of more than 3000 lumens, so that students in the back row can see the projection clearly

2. Short-focus large screen;

3. Accurate color;

4. Easy operation;

5. Features such as multiple connection methods.

education projector,education use projector,smart education projector,best education projectors,projector for education

Shenzhen Happybate Trading Co.,LTD , https://www.happybateprojector.com