Add a driver to the Linux Kernel

Source: Internet
Author: User
Add a driver to the Linux kernel-general Linux technology-Linux programming and kernel information. The following is a detailed description. The Linux Kernel provides a lot of device driver code, but each project always needs to add our own driver. For example, we need to add an infrared remote control driver. We can write and debug this driver independently. After maturity, we should put it in the kernel directory tree and use the make modules command for unified compilation. In addition, you can use the make menuconfig command to configure the compilation or not. The steps are relatively simple, but some people may not be clear about them and are writing them as a reference.

I. Kernel configuration method:

Generally, use make config and make menuconfig to configure the kernel. They use the scripts/Configure and scripts/Menuconfig script interpretation tools to execute the scripts respectively. In the 2.4 kernel, the script is Config. in all levels of directories, and in the 2.6 kernel, it is changed to Kconfig. After the configuration is complete, the. config file is generated with the corresponding macro definition.

To display our driver items to the configuration options, you must modify the corresponding Kconfig file (taking the 2.6 kernel as an example). This file has certain syntax rules and is relatively simple, here is not much description.


Ii. Procedure

The following describes how to add an oloir IR driver:

1: first select a location where the driver code is placed: drivers/olo_ir, and put the code in this directory.

2: add the Kconfig file in drivers/olo_ir. The content is as follows:

Menu "OLO ir support"

Config OLOIR

Tristate "OLO ir support"

--- Help ---

Olo ir use gpio as ir input.

If you want olo ir support, you shoshould say Y here and also to

Specific driver for your bus adapter (s) below.

This olo ir support can be built as a module.

Endmenu

3: Write makefile. The content is very simple:

Obj-$ (CONFIG_OLOIR) + = oloir. o

4. Modify Makefile and Kconfig of the previous level.

Add: obj-$ (CONFIG_OLOIR) + = olo_ir/to Makefile/

Add source "drivers/olo_ir/Kconfig" to Kconfig"

5: add it to Kconfig of arch/arm

Source "drivers/olo_ir/Kconfig"

This location depends on the architecture of your platform.
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.