Dynamic Linux driver modules

Source: Internet
Author: User

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:

 
 
  1. obj-m := test.o  
  2. KERNELDIR := /root/test/YLP2440  
  3. PWD := $(shell pwd)  
  4. modules:  
  5. $(MAKE) -C $(KERNELDIR) M=$(PWD) modules  
  6. modules_install:  
  7. $(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:

 
 
  1. obj-m := test.o  
  2. KERNELDIR := /root/test/YLP2440  
  3. PWD := $(shell pwd)  
  4. default:  
  5. $(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.

  1. Linux UNIX system learning experience
  2. Simple Theory Linux ReiserFS system analysis features and results
  3. Introduction to Linux software installation
  4. Hands-on manual: Restore Linux passwords
  5. Learn how to check whether the email system is successfully installed in Linux

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.