linux驱动学习-----添加加一个模块hello
来源:互联网 发布:九州邮币卡软件下载 编辑:程序博客网 时间:2024/05/17 00:01
参考各个网站的教程编写一个HELLO MODULE,添加到menuconfig中。
主要是两个文件:Makefile和Kconfig。
首先进入驱动中lichee/linux-3.4/drivers/char/
这里面有很多c文件和文件夹,然后有一个Makefile和Kconfig。
先创建一个c文件,名字就叫hello.c。代码如下
#include <linux/kernel.h>#include <linux/module.h>static int __init mini2440_hello_module_init(void){printk("Hello, world !\n");return 0;}static void __exit mini2440_hello_module_cleanup(void){printk("Good-bye!\n");}module_init(mini2440_hello_module_init);module_exit(mini2440_hello_module_cleanup);MODULE_LICENSE("GPL");
然后修改Kconfig如图,添加这段代码。
这里主要是用config 定义一个变量,说明有一个这个模块。depend on指的是只有当ARM被有的时候,这个才显示。
然后修改Makefile,这个文件是用来通过config文件中的变量,判断相关的文件知否被编译生成一个KO文件。在makefile中添加下面一句。
注意这里的CONFIG_后面的字符一定要和Kconfig中定义的一致,要不会出错。
然后打开make menucofig,这里注意要在linux.xxxx目录下执行makemenucofig才行,如果直接make kernel_config会找不到我们添加的东西。
进入Device driver–>charactor driver–>
可以找到我们建的模块:
然后在linux的目录下生成.ko文件,直接将其拷入开发板insmod就可以啦
0 0
- linux驱动学习-----添加加一个模块hello
- linux驱动学习2:运行hello模块
- linux驱动学习1---Hello World模块
- 驱动学习,hello world模块
- Linux驱动学习(一)——简单的hello模块
- FL2440驱动添加(1):hello world 驱动模块添加
- linux设备驱动学习(二):Linux驱动模块的相关基础和hello world
- linux下hello world驱动模块
- Linux内核驱动模块编写(Hello,World)
- Linux内核驱动模块编写(Hello,World)
- Linux 2.6内核驱动之hello模块
- Linux驱动:动态加载hello world模块
- Linux驱动:动态加载hello world模块
- Linux设备驱动--Hello World模块
- Linux内核驱动模块测试 hello.ko
- linux内核驱动模块编程框架---(hello world模块)
- Linux设备驱动学习-Davinci开发板上运行的hello模块
- Linux设备驱动学习-Davinci开发板上 运行的hello-driver模块
- Linux每天一点ifconfig
- 第13章
- listview实现网格布局显示不全,不滑动
- CSS语法格式
- node-haystack Episode 11: node object of Volume
- linux驱动学习-----添加加一个模块hello
- Leetcode_7
- 【uva 1663】Purifying Machine 二分图匹配
- sublime text 3 快捷键大全以及配置编译环境
- oracle触发器实现表的实时同步(支持无主键表)
- 图像处理常用边缘检测算子
- 第13章
- HDU2602-Bone Collector
- 如何排序DataTable中的int型数据