In the era of network technology, computers have become essential things in our lives. We use computers, but do we know how computers work? An operating system is essential to a computer. Now many people use the Linux operating system. Here we will introduce the knowledge of Linux, so that you can learn how to apply the Linux system well. Today I will talk about how to add a driver module to Linux. I hope you will remember how to add a driver module to Linux.
Note: The original test keyboard driver is used as the experiment material and must be dynamically loaded into the system through insmod. Think: to dynamically load, you must first put test in the file system. ko file ,. how to generate ko files when they are loaded by a dedicated module. what about ko files? The method is generated during compilation. Of course, you cannot compile the test file in the arm-linux-gcc-o test. ko test. c syntax. What should you do? The analysis is as follows:
1. set test. c files are stored in the root directory of YLP2440, which is the same as the kernel version used in the board). YLP2440 is the file directory in this kernel and then in the PC. 2. modify the Makefile file in the root directory of YLP2440 and add the following code in the header:
- obj-m := test.o
- KERNELDIR := /root/test/YLP2440
- PWD := $(shell pwd)
- modules:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
- modules_install:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
3. make 4. generate test. ko file, and then put it in the file system, create a new cramfs file system, download to the Board 5. start the board, and then in test. input: insmod test. ko 6. complete
In the above code, I do not know why modules and modules_install should be named. Another code is written like this:
- obj-m := test.o
- KERNELDIR := /root/test/YLP2440
- PWD := $(shell pwd)
- default:
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
This statement does not prompt that the modulles is overwritten.
After completing the preceding steps, the driver module is added to Linux.
- Linux UNIX system learning experience
- Simple Theory Linux ReiserFS system analysis features and results
- Introduction to Linux software installation
- Hands-on manual: Restore Linux passwords
- Learn how to check whether the email system is successfully installed in Linux