How to dynamically add driver modules

Source: Internet
Author: User
Article Title: How to dynamically add driver modules. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

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. put the c file in the root directory of YLP2440 (the same kernel version as the kernel used in the board). YLP2440 is the file directory 2 in the PC after the kernel. 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.

Related Article

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.