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. IE6读取不到样式文件bug

    早年的东东,贴出来充一下数吧~ 问题描述 在一个弹层优化需求中,完成了修改后,刷一下其他(除IE6外)浏览器,很给力,展现都一个样: 再刷下IE6,傻眼了: 初步分析 IE6问题多我知道,不过像这样的 ...

  2. [LeetCode] Best Meeting Point 最佳开会地点

    A group of two or more people wants to meet and minimize the total travel distance. You are given a ...

  3. [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  4. [LeetCode] Search in Rotated Sorted Array 在旋转有序数组中搜索

    Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...

  5. hihocoder-1453-Rikka with Tree

    #Hihocoder 1453 : Rikka with Tree 时间限制:10000ms 单点时限:1000ms 内存限制:256MB   source: https://hihocoder.co ...

  6. maven+springmvc+dubbo+zookeeper

        为什么要用dubbo?   还是让官方来解释吧: http://dubbo.io/User+Guide-zh.htm   http://dubbo.io/   一般 nginx+tomcat ...

  7. Redis五种数据结构简介

    Redis五种结构 1.String 可以是字符串,整数或者浮点数,对整个字符串或者字符串中的一部分执行操作,对整个整数或者浮点执行自增(increment)或者自减(decrement)操作. 字符 ...

  8. MVC POST在ACTION上进行多个模型的数据绑定

    首先声明,接下来的东西并不符合本人认同的严谨的MVC模式. 用MVC做项目的过程中,越来越多的用到不严谨的MVC编程. 比如,在"cshtml"文件中写: @Html.Raw(DB ...

  9. zabbix监控Java 8080端口

    linux下端口和服务是对应的,Java进程启动时默认监听8080端口,如果服务挂掉则8080端口就没有了. lsof -i:8080 端口,如果没有任何的输出,说明该端口不在工作. 想在zabbix ...

  10. 237. Delete Node in a Linked List

    在链接列表中删除节点. 编写一个函数来删除单链表中的一个节点(除了尾部),只提供对该节点的访问..假设链表是1 - > 2 - > 3 > 4,并给出了具有值为3的节点, 链表应该成 ...