Android Driver Development (vi)----FIRST Linux driver: Count the number of words

Source: Internet
Author: User

In the sixth chapter, the author describes the process of driving development with an example. First of all, there are eight basic steps to drive development: first to build a driver skeleton, namely Module_init and Module_exit, register and unregister device files, develop information related to drive information, formulate callback functions, write business logic, write makefile files, Compile Linux drivers, install and uninstall Linux drivers.

The above eight steps are the basic steps to drive the development, of course, in the actual development is not one step, like the book to write a complete code. At this point we can write a step-by-step, first write a simple Linux driver skeleton. Next write the registration and logoff driver, here Add the callback function, and then write the business logic, that is, to drive the function to complete. Finally, the above three elements are integrated into one. (Of course, at the end of the driver, the driver-related information should be added)

To be able to run the written driver, you also need to write a makefile file. The makefile file is primarily used to define the compilation rules for the Linux kernel source code. With makefile, you can compile the driver you wrote.

Also, it should be noted that there are two ways to compile. One is obj-m, one is obj-y. The former indicates that the Linux driver is compiled as a module. ko file, while the latter compiles Linux drivers into the Linux kernel.

The driver is loaded and unloaded at the end. There are two ways of loading, namely Insmod and modprobe. The difference is that the latter can check the dependency of the driver module. (You need to use the DEPMOD command to detect the dependencies of the Linux driver module before using the modprobe command to load the driver module)

Android Driver Development (vi)----FIRST Linux driver: Count the number of words

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.