增加驱动模块到内核树
来源:互联网 发布:手机分贝测试软件 编辑:程序博客网 时间:2024/05/16 19:31
现在要把下面的驱动模块添加到内核树中:
/* module_param.ko num.c*/#include <linux/module.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/moduleparam.h>static int num = 0;static char* string="this is a test";static int array[3]={0};static amount=3;module_param(num, int, S_IRUGO|S_IWUSR);module_param(string, charp, S_IRUGO|S_IWUSR);module_param_array(array, int, &amount, S_IRUGO|S_IWUSR);MODULE_PARM_DESC(num,"it's a test num");MODULE_PARM_DESC(string, "it's a test string");MODULE_PARM_DESC(array, "it's a test array");static int __init module_param_init(void){printk(KERN_INFO"num=%d\n",num);printk(KERN_INFO"string=%s\n", string);printk(KERN_INFO"array=%d,%d,%d\n", array[0], array[1], array[2]);return 0;}static void __exit module_param_exit(void){printk(KERN_INFO"module param exit!\n");}module_init(module_param_init);module_exit(module_param_exit);MODULE_LICENSE("GPL");MODULE_AUTHOR("BANG");MODULE_DESCRIPTION("module study");MODULE_SUPPORTED_DEVICE("none");步骤:
1、进入内核目录把module_param.c放到drivers/module_param/目录下
mkdir drivers/module_param
cp module_param.c drivers/module_param/
2、修改drivers目录下的Kconfig和Makefile文件
vim Kconfig ---------》增加 source "drivers/module_param/Kconfig"
vim Makefile ---------》增加 obj-$(CONFIG_MODULE_PARAM) += module_param/
3、进入module_param 目录,增加Makefile、Kconfig文件
Kconfig内容:
config MODULE_PARAM --------------------------(注意,这里不是写CONFIG_MODULE_PARAM)
tristate "module param" ---------------(标签的命名是module param可以有三种选择)
default y
---help---
this is my test
Makefile内容:
obj-$(CONFIG_MODULE_PARAM) +=module_param.o
5、make menuconfig 选择编译方式
如果是选择built-in 方式, 在make uImage时驱动会添加到uImage 镜像中
如果是选择modules的方式, make modules会在module_param目录生成.ko文件
- 增加驱动模块到内核树
- 在内核树内增加驱动模块
- 驱动文件增加到内核
- 驱动模块静态编译到 Linux 内核
- linux下增加新源码到 linux内核或 模块
- 17 增加驱动源码到Linux内核里
- 增加usb转串口驱动到内核中
- 将LED驱动模块编译到Linux3.10.17内核
- linux-2.6.29 添加驱动模块到内核
- Linux内核驱动模块
- Linux内核驱动模块
- Linux内核驱动模块
- Linux内核驱动模块
- Linux内核驱动模块
- Linux内核驱动模块
- Linux内核驱动模块
- 遍历内核驱动模块
- 为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程
- Linux驱动框架之——Input子系统
- 手游《奔跑吧?骚年!》技术分享(四):矩形碰撞检测
- [leetcode] Reverse Linked List II
- hdu 1800 Flying to the Mars
- POJ3422 费用流
- 增加驱动模块到内核树
- 算法面试题:求最小的k个束/求数组中最小的k个数
- IOS CoreText.framework --- 段落样子CTParagraphStyle
- Android开发系列之SQLite
- 对象引用前加const 报错
- 【Android开发-6】了解内情,我们需要一些调试和测试手段
- root用户和普通用户的切换
- 妙记jsp的九个内置对象
- cocos2dx基础类型学习