Steps to write a Linux driver
1th Step: Build Linux driver skeleton (load and unload Linux drivers)
2nd step: Registering and unregistering device files
3rd Step: Specify driver-related information
4th step: Specify the callback function
5th step: Writing Business logic
6th step: Writing the Makefile file
7th step: Compiling Linux drivers
8th step: Install and uninstall Linux drivers
Install Linux drivers:
# Insmod Word_count.ko
To see if Word_count installed successfully:
# Lsmod | grep word_count
Uninstalling the L Inux Drive:
# Rmmod Word_count
To view log information from Linux-driven output:
# DMESG | grep Word_count | Tail–n 2
Compiling the driver into the Linux kernel for testing (using the Word_count driver example)
1th step: Put the word_count.c file into the Linux kernel source code
2nd Step: Modify the Kconfig file
3rd Step: Modify the Makefile file
4th step: Set the. config file
5th step: Compiling the Linux kernel
To add the Word_count directory to the Linux kernel source tree
1th Step: Create a new Kcinfig file
2nd Step: Modify the Makefile file
3rd Step: Modify the Kconfig file of the upper directory
4th Step: Modify the Makefile file of the upper directory
Developing and testing Linux drivers using eclipse
1th Step: Build C Project
2nd step: Establish C source code file link
3rd Step: Set the Include path
4th step: Compiling Linux drivers
Testing Linux drivers in eclipse
1th Step: Import the Test_word_count.c file
2nd step: Set the Include path
3rd Step: Set Target
4th Step: Build Project
5th step: Run the test program
After reading this chapter, this chapter has done some simple summary of the Linux driver compiling process, this chapter introduces the complete development process of Linux driver with Word_count driver as an example, this chapter not only introduces an example, but also describes how to test Linux driver using different methods. There are other ways, for example, to test Linux drivers directly using Ubuntu Linux, and there are many drivers that can be installed directly on the Android emulator, Development Board, or even the phone to test the Linux drive as soon as they are compiled again with the appropriate Linux kernel.
Android Deep Explore (Vol. 1) Hal with Driver development Sixth Chapter reading notes