Android Driver Development 5-7 Summary

Source: Internet
Author: User

AndroidDeep Exploration5-7Chapter Summary

This paper introduces the function of s3c6410 Development Board, the difference of Development Board is mainly in the way of burning embedded system, and how to install Android on this board. Learn about how to test Linux drivers in a variety of ways on multiple platforms. The given example is the number of statistical words, but the key to implement the algorithm is the Linux driver. This example gives me an insight into the complete development of Linux drivers.

Linux drives work and access is one of the highlights of Linux, and the Linux system maps each driver into a single file. These files, called device files or drive files, are stored in the/dev directory, and since most Linux drivers have their corresponding device files, exchanging data with Linux drives becomes a data exchange with the device files.

The driver is compiled into the Linux kernel for testing, and the dynamic load driver module does not automatically mount as the Android system starts, so the Android system must be loaded with the Insmod or modprobe command to load the Linux drive module each time it starts. The Word_count driver can be added to the Linux kernel source tree using the following steps. Put the word_count.c file into the Linux kernel source code, put the word_count.c file in the <linux kernel directory >/drivers/char directory, modify the Kconfig file, modify the makefile file, open/ Root/kernel/goldfish/drivers/char/makefile file, set the. config file,

The. config file can be configured by hand or by using the make Menuconfig command in the menu, compiling the Linux kernel, entering the/root/kernel/goldfish directory, and executing the following command to compile the Linux kernel, Create a new Kconfig file and create a kconfig file in the Word_count directory.

The next step is to control the LEDs to demonstrate how to develop a complete Linux drive. This driver is used to control 4 LED lights. This means that the LEDs can be controlled by sending data to the Linux driver. The LED driver contains all the necessary parts of the Linux drive. A complete Linux driver consists of two parts: internal processing and hardware interaction. As long as the internal processing refers to the Linux driver loading, unloading and device file-related action processing including read and write device files, send I/O commands to the device file and other actions and business logic.

Create a device file, use the Cdev_init function to initialize the CDEC, most of the member variables do not require our own initialization, call the Cdev-init function. Describe the device file requires a CDEV structure, specify the device number, specify the master/slave number separately, so you need to MKDEV the macro

int Dev_number=mkdev (major,minor); Use the Cdev_add function to add a character device to the character device data in the kernel, call the Cdev_add function to specify the device file pointer (p), the device number (dev), The number of device files (count) also calls an important function kobj_map, which uses Class_create macros to create a Struct class,struct class contains some variables related to device files and some callback function pointer variables.

Uninstall the LED-driven device file and call the Decive_destory, Class_destory, unregister_chrdev_region methods in turn. The Led_destory_device function is used to unload the LED-driven device file, and the Leds_exit function is the LED-driven unload function that completes the operation of uninstalling the LED driver file by calling the Led_destory_device function.

Set the status of the LED, set the register and initialize the LED driver, set the register value to set the status of the LED pin and control its light off. Then to control the LEDs, you can pass strings and I/O commands. Use the string to File_operations.write function, use the I/O command to File_operations.ioctl, from the user space like the kernel to write data to the function Copy_from_user.

Interaction with hardware mainly refers to the data interaction with the registers in the hardware through the functions of iowrite32, IOREAD32 and so on. The porting of Linux drivers on different platforms also includes these two parts. Porting between different Linux kernel versions, the main porting is the internal processing of Linux drivers. , the Linux kernel API can be very different when the general kernel is different, but the second part is the main porting on different hardware platforms. Of course, in some cases, Linux-driven porting is basically equivalent to rewriting one side of the Linux driver, which requires a step-by-step learning process to better understand the advanced technology of Linux drivers.

http://www.cnblogs.com/xxyue/

Android Driver Development 5-7 Summary

Related Article

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.