Linux kernel 源码添加可选项


闲来无事,顺便记录一篇在Linux kernel make menuconfig 内添加一个可选项。
说不定将来就要用到这个东西呢。 linux kernel 的配置系统由以下三个部分组成。
Makefile: 分布在Linux 内核源代码中,定义Linux kernel的编译规则。
配置文件:(kconfig) 给用户提供配置选择的功能。
配置工具:包括配置命令解析器和配置用户界面。这些配置工具使用的都是脚本语言,如Perl。
最常使用的,我们一般使用make menuconfig 进行配置我们自己想要的。
这里面我们看到很多可以选择的选项,那么如果我们自己要增加自己的选项该怎么办呢。
网上有很多教程都是在drivers里面添加,我这里讲一种就是直接如果自己想建一个目录,然后添加里面的模块该怎么做。



###过程:
我首先在顶层目录建一个目录chentest

cd $KERNEL_DIR
mkdir chentest
vim chentest.c
chentest.c:
#include <linux/init.h>
#include <linux/module.h> int __init chen_init(void)
{
printk("start\n");
return 0;
}
module_init(chen_init); void __exit chen_exit(void)
{
printk("end\n");
} module_exit(chen_exit); MODULE_AUTHOR("chenfl");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("This is test modules");
MODULE_VERSION("V1.0");


vim Makefile
Makefile:
obj-$(CONFIG_CHENTEST) += chen_test.o


vim Kconfig
Kconfig:
menu "chentest" config CHEN_TEST
tristate "This is a test"
default y
help
Say Y here if you have any input device (mouse, keyboard, tablet,
joystick, steering wheel ...) connected to your system and want
it to be available to applications. This includes standard PS/2
keyboard and mouse. Say N here if you have a headless (no monitor, no keyboard) system. More information is available: <file:Documentation/input/input.txt> If unsure, say Y. To compile this driver as a module, choose M here: the
module will be called input. if CHEN_TEST config CONFIG_CHENTEST
tristate "chentest"
help
Say Y here if you have memoryless force-feedback input device
such as Logitech WingMan Force 3D, ThrustMaster FireStorm Dual
Power 2, or similar. You will also need to enable hardware-specific
driver. If unsure, say N. To compile this driver as a module, choose M here: the
module will be called ff-memless.
endif endmenu

好了大概到了这一步,准备工作差不多做好了,然后你的arm架构的话,需要在arm/arch/Kconfig

里面添加一句话。

大概在 这个位置添加:sourch "chentest/Kconfig"
2167 source "drivers/Kconfig"
2168
2169 source "chentest/Kconfig"
2170
2171 source "drivers/firmware/Kconfig
make ARCH=arm menuconfig
看 Device Drivers 下面是不是多了个选项 chentest

Linux kernel4.4.12 添加make menuconfig 可选项的更多相关文章

  1. [Linux] Ubuntu Server 12.04 LTS 平台上搭建WordPress(Nginx+MySql+PHP) Part II

    接着上一节继续搭建我们的LNMP平台,接下来我们安装PHP相关的服务 sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5- ...

  2. Linux 用户名、主机添加背景色

    文章参考:PS1应用之——修改linux终端命令行各字体颜色 Linux 用户名.主机添加背景色,用于生产环境,这样可以减少人为的误操作. [root@zhang ~]# tail /etc/bash ...

  3. Linux平台Oracle 12.1.0.2 单实例安装部署

    主题:Linux平台Oracle 12.1.0.2 单实例安装部署 环境:RHEL 6.5 + Oracle 12.1.0.2 需求:安装部署OEM 13.2需要Oracle 12.1.0.2版本作为 ...

  4. ASP .Net Core系统部署到SUSE Linux Enterprise Server 12 SP3 64 具体方案

    .Net Core 部署到 SUSE Linux Enterprise Server 12 SP3 64 位中的步骤 1.安装工具 1.apache 2..Net Core(dotnet-sdk-2. ...

  5. ASP .Net Core系统部署到SUSE 16 Linux Enterprise Server 12 SP2 64 具体方案

    .Net Core 部署到 SUSE 16 Linux Enterprise Server 12 SP2 64 位中的步骤 1.安装工具 1.apache 2..Net Core(dotnet-sdk ...

  6. ASP.NET Core 2.0 MVC 发布部署--------- SUSE 16 Linux Enterprise Server 12 SP2 X64 具体操作

    .Net Core 部署到 SUSE 16 Linux Enterprise Server 12 SP2 64 位中的步骤 1.安装工具 1.apache 2..Net Core(dotnet-sdk ...

  7. SUSE Linux Enterprise Serve 12 试用体验

    SUSE Linux Enterprise Serve 12 试用体验 大家都知道德国出产的奔驰.宝马.等车型以精美.可靠.耐用而著称.而相同出自德国人之手的Suse Linux .即使是被收购也是一 ...

  8. Lab1:Linux内核编译及添加系统调用(详细版)

    实验一:Linux内核编译及添加系统调用(HDU) 花了一上午的时间来写这个,良心制作,发现自己刚学的时候没有找到很详细的,就是泛泛的说了下细节地方也没有,于是自己写了这个,有点长,如果你认真的看完了 ...

  9. linux下查看和添加PATH环境变量

    linux下查看和添加PATH环境变量 $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PA ...

随机推荐

  1. [LeetCode] Find the Celebrity 寻找名人

    Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist o ...

  2. MSSQLSERVER

    create database test--创建数据库zh use test --打开数据库 go--执行 create table tab--创建表 ( UserName ),--创建字符串类型的字 ...

  3. C/C++ 标准输入输出重定向

    转载自:http://www.cnblogs.com/hjslovewcl/archive/2011/01/10/2314356.html 这个对经常在OJ上做题的童鞋们很有用.OJ基本都是用标准输入 ...

  4. logback logback.xml常用配置详解 <filter>

    <filter>: 过滤器,执行一个过滤器会有返回个枚举值,即DENY,NEUTRAL,ACCEPT其中之一.返回DENY,日志将立即被抛弃不再经过其他过滤器:返回NEUTRAL,有序列表 ...

  5. windows多线程编程

    进程共同实现某个任务或者共享计算机资源, 它们之间存在两种关系: 1.同步关系, 指为了完成任务的进程之间, 因为需要在某些位置协调它们的执行顺序而等待, 传递消息产生的制约关系. 2.互斥关系, 进 ...

  6. Maven命令

    1. mvn help:describe 你是否因为记不清某个插件有哪些goal而痛苦过,你是否因为想不起某个goal有哪些参数而苦恼,那就试试这个命令吧,它会告诉你一切的. 参数: 1. -Dplu ...

  7. PHPstorm同步文件时与ftp断开连接

    一用PHPstorm同步对比服务器端和本地文件的差异时,一会就断开ftp再也连不上了,弄了好久终于找到原因了,好像这个同步会频繁请求建立连接,服务器本地安全策略屏蔽了ip,还是下载后再做修改或者直接在 ...

  8. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  9. UVa 524 Prime Ring Problem(回溯法)

    传送门 Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbe ...

  10. maven引入多个spring jar包中存在同名文件的问题

    项目打包后执行报错:Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespaceht ...