注册 登录
LUPA开源社区 返回首页

xiang002的个人空间 http://www.lupaworld.com/?328269 [收藏] [复制] [分享] [RSS]

我的博客

在Linux内核中增加自己的驱动代码

已有 1034 次阅读2011-8-23 12:03 |系统分类:IT技术

  在内核中增加驱动代码,本质上就是修改kconfig和makefile两个文件。

  先熟悉下kconfig的语法

  1.menu menuname

  2.configure myconfigurename

  3. bool configurenametoshow

  4. depends on anotherconfigurename

  5. default y

  6. help

  7. some words you are freedom to explain

  8.endmenu

  第一行,菜单名

  第二行,配置项名称,代表整个配置项

  第三行,配置类型,包括bool,tristate,string,hex和int.

  第四行,领带项,如果anotherconfigurename存在,则显示。

  第五行,默认

  第六,七行,帮助信息。

  实例介绍:

  要求drivers目录下,增加一个文件夹yonganadded,此文件下入自己的驱动,如globalvar,等。

  Drivers目录的makefile追加: obj-y += yonganadded/

  Drivers目录的Kconfig中endmenu前追加: source "drivers/yonganadded/Kconfig"

  1.Yonganadded目录中

  Makefile内容: obj-y +=globalvar/

  Kconfig内容:

  menuconfig YONGAN

  tristate "drivers added by yongan"

  ---help---

  it depends on what you write

  if YONGAN

  source "drivers/yonganadded/globalvar/Kconfig"

  endif

  2.在globalvar目录中

  Makefile:obj-$(GLOBALVAR) += /globalvar.o

  Kconfig: config GLOBALVAR

  bool "globalvar"

  ---help---

  Provide a test of read and write

  最终结果:  

在Linux内核中增加自己的驱动代码

 

在Linux内核中增加自己的驱动代码

 已同步至 xiang002的微博

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册
验证问答 换一个 验证码 换一个

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部