为Android内核添加新驱动
转载地址:http://blog.chinaunix.net/uid-16759545-id-4892379.html
1. 在drives目录下添加hello目录,内含hello.c Kconfig Makefile
hello.c内容:
#include <stdio.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT"Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Kconfig内容:
config HELLO
tristate "Hello Driver added by Farsight"
default n
help
test for adding driver to menuconfig.
MakeFile内容:
obj-$(CONFIG_HELLO) += hello.o
2. 上面的Kconfig文件再加上下面的两个配置,可使hello项出现在配置菜单中。
在arch/arm/Kconfig menu "Device Drivers" endmenu之间添加:
source "drivers/hello/Kconfig"
在drivers/Kconfig menu "Device Drivers" endmenu之间添加:
source "drivers/hello/Kconfig"
3.修改Drivers目录下的Makefile文件,添加如下行:
obj-$(CONFIG_HELLO) += hello/
当CONFIG_HELLO为y或m时,使系统能找到hello驱动的makefile。
linux-2.6.35目录下make menuconfig,在Device Drivers菜单下选中Hello Driver added by Farsight项比如M,作为module。然后保存配置,执行make命令,
就可以看到 CC [M] drivers/hello/hello.o 的log了,hello目录里生成了hello.o hello.ko的等文件。
最新文章
- .NET导入Excel到SQL数据库
- maven工程下 读取resource下配置文件
- ACM: A Simple Problem with Integers 解题报告-线段树
- Silverlight项目笔记4:初识Prism以及IoC
- (二)学习JavaScript之setInterval和clearInterval方法
- DHTMLX 前端框架 建立你的一个应用程序教程(四)--添加一个工具条toolbar
- 重温 Win32 API ----- 截屏指定窗体并打印
- 联系人数据库设计之AbstractContactsProvider
- 利用NPOI将EXCEL转换成HTML的C#实现
- PHP 是什么
- 通过 Azure Pipelines 实现持续集成之docker容器化及自动化部署
- CAN总线学习记录之四:位定时与同步
- 【深入理解Java集合框架】红黑树讲解(上)
- SQL Server 链接服务器连接 SQLite数据库文件
- 3D Slicer 4.7.0 VS 2010 Compile 编译
- 变态跳台阶(python)
- 【转】jQuery.validate 用法
- php扩展yaf 按照配置
- ubuntu16.04下安装Eigen
- asp.net web api 2 host in a windows service推荐阅读
热门文章
- org.springframework.beans.factory.BeanDefinitionStoreException异常
- linux系统使用python监测网络接口获取网络的输入输出
- shiro使用教程
- XJOI练习2神奇的供水系统
- 玩转SSH(五):Struts + Spring + MyBatis(注解版)
- UTF-8 GBK UTF8 GB2312 之间的区别和关系
- 你不得不知的逻辑或(||)与(&;&;)非(!)
- 最近公共祖先LCA(Tarjan算法)的思考和算法实现
- file_get_contents HTTP request failed! Internal Server Error
- 战斗逻辑 - demo