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