Third time monthly exam

Source: Internet
Author: User

The eighth chapter makes the Development Board sound: Buzzer driver

One, Linux code-driven code reuse: Linux-driven code reuse there are many ways, such as the C program, the code will be reused in other files but to be declared in the header file. Another way to use dynamic reuse is to have a Linux driver using another driver's content, such as a function. Compilation is a Linux driver consisting of multiple files, and if the Linux driver is complex, it requires multiple Linux files to hold different functions, which facilitates classification and management.

Second, forcibly uninstall the Linux driver: if the written Linux driver is logically correct, then it can be loaded and unloaded normally, in some cases it will not load and unload normally, the Linux driver can not unload the situation:

Scenario One: initialization function crashes P

Scenario Two: The Unload function is blocked

Three, buzzer (PWM) driver: Buzzer and LED is the same as the development Board comes with a simple hardware, if you open the buzzer Development Board will emit the same sounds like beep, close will stop screaming. The principle of buzzer actuation: The basic principle of PWM is to control the buzzer opening and closing by Pulse.

Test buzzer driver: The PWM_FUN.C contains two functions to open and stop the PWM, as can be seen from the makefile, the compiler first compiles pwm.c and pwm_fun.c files into PWM.O and PWM_FUN.O, and then connects two. o files into a pwm_ DRIVER.O, finally generates the Pwm_driver.ko, then executes the build.sh script file and then compiles it successfully.

Enter the following command:

./ioctl/dev/pwm_dev 1 0

./ioctl/dev/pwm_dev 0 0

Since the command must require the input I/o command parameters, and the PWM driver does not use I/o command parameters, the last command line of the IOCTL can enter parameters arbitrarily. If the following message is displayed and the buzzer screams, the test is successful!

Nineth Hardware Abstraction Layer: HAL

HAL (Handerware abstraction layers, Hardware abstraction layer) is a set of libraries built on Linux programs that are not part of the kernel, but that belong to the application layer on top of the kernel.

First, why join Hal in Android: In Linux drivers there are generally two types of code: Access to hardware register code and business logic code. There is no secret to the code that accesses the hardware registers, which are standard operations that call the standard functions of the Linux kernel. Google joins HAL for Android Its main purpose is:

The calling interface of unified hardware;

Fixed the issue of GPL copyright; '

for some special requirements;

Second, andriod HAL Architecture

Use libraries in the ANDRIOD system, strip Linux drivers located in kernel space, and then andriod the application.

The basic principle of HAL is to use the library to invoke kernel space Linux drivers in the Android system.

Add HAL to the LED: porting all business logic from the LED driver to the HAL module, while the LED driver module only retains the engineering performance of the read and write registers. Joining HAL makes the entire library of Linux drivers more independent and easier to maintain. To write a Linux program driver that supports HAL: 1.Linux driver; 2. Write the HAL Library;3. Write the service Library. To write the HAL module: 1. Define structures and macros; 2. Write the open function of the HAL module; 3. Define hw_module_methods_t structure variables; 4. Define HAL_MODULE_INFO_SYM variables ; 5. Write the close function of the HAL module; 6. Write a function that controls the LEDs.

Tenth Chapter debugging technology of embedded Linux

For complex Linux drivers and libraries such as HAL, you need to debug them in a variety of ways

First, print kernel debug information: The PRINTK:PRINTK function is similar to the printf function, except that the PrintK function runs in kernel space and the printf function runs in user space. This means that Linux kernel programs like Linux drivers can only output debugging information using the PRINTK function.

Second, prevent the PRINTK function to reduce the Linux drive performance: Although the PRINTK function can be very convenient to write messages to the log file or console, large that is a large number of PRINTK functions to manipulate the log file or console device files can seriously affect the drive performance of Linux. As long as the PRINTK function is used only during the development phase, PRINTK functions that may affect performance are removed when the Linux driver is formally released.

Third, the data interaction through the virtual file system (/PROC): In the Linux file system,/proc is often used as a tool for data interaction as user space and kernel space. The/proc file system behaves in a similar manner to the device system (/dev).

Four, Debugging Tools: Gdb,gdbservice, and Kgdb.

Third time monthly exam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.