关于用ubuntu中内核模块的编译及设备驱动中的问题

编译打包和其他
回复
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

关于用ubuntu中内核模块的编译及设备驱动中的问题

#1

帖子 duckling813 » 2006-10-13 23:19

在学习编写设备驱动程序
初步照着linux device driver 3rd 编了个起步的hello.c
编译时发现/usr/src 下没有内容
于是用apt-get install linux-headers-2.6.15-27-686
于是在编译时用了 gcc -DMODULE -D__KERNEL__ -O2 -Wall -c -I/usr/src/linux-headers.2.6.15-27-686/include hello.c
可以生成一个hello.o可是2.6的中应该是.ko阿
所以没办法解决
有没有牛人能够详细的给出解决办法阿
我是新手
对一些命令不是很熟悉
谢谢
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#2

帖子 nobrain » 2006-10-14 0:02

ldd 3rd不是这样编译kernel module的啊,是用Makefile.里面就没说过用这样的方法编译啊。
爱喝真猪奶茶的夜鸣猪
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

#3

帖子 duckling813 » 2006-10-17 10:52

用Makefile编译后出现
make -C /lib/modules/2.6.13-15-default/build M=/home/fanny/Documents/programme modules
make[1]: Entering directory `/usr/src/linux-2.6.13-15-obj/i386/default'
make[1]: *** 没有规则可以创建目标“modules”。 停止。
make[1]: Leaving directory `/usr/src/linux-2.6.13-15-obj/i386/default'
make: *** [default] 错误 2
这是为什么阿?
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#4

帖子 nobrain » 2006-10-18 14:55

没有modules目标,我不知道你的 /lib/modules/$(shell uname -r)/build 指向是否正确,我是直接从源上下的linux-headers,我的 build 指向 build -> /usr/src/linux-headers-2.6.15-27-686,目录结构和你的不一样。
爱喝真猪奶茶的夜鸣猪
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

#5

帖子 duckling813 » 2006-10-20 21:17

建立链接后,build指向headers...
再次运行后出现:
make -C /lib/modules/2.6.15-23-386/build SUBDIRS=/home/fanny/hello modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.15-23'

WARNING: Symbol version dump /usr/src/linux-headers-2.6.15-23/Module.symvers
is missing; modules will have no dependencies and modversions.

CC [M] /home/fanny/hello/hello.o
Building modules, stage 2.
MODPOST
/bin/sh: scripts/mod/modpost: No such file or directory
make[2]: *** [__modpost] 错误 127
make[1]: *** [modules] 错误 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.15-23'
make: *** [default] 错误 2
会不会是kbuid的问题?
能不能有大虾详细的讲解下用ubuntu6.06做内核模块要作那些准备,下载哪些工具?
再次谢过!!
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#6

帖子 nobrain » 2006-10-21 13:23

我准备编译内核模块环境的方法:

代码: 全选

sudo apt-get install module-assistant
sudo m-a update
sudo m-a prepare
之后,就按照ldd3里面的方法编译内核模块就可以了。
爱喝真猪奶茶的夜鸣猪
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

#7

帖子 duckling813 » 2006-10-23 21:36

谢谢了
没在哪本书上看见要装这样的环境,也没有明白为什么要装
但是结果是真的就需要这个 。
再次谢了
看了一下你回复的时间 ,那个时候我在南京的一个叫珍珠泉的景点差点溺水而亡
世界真的很奇妙
thank you
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

#8

帖子 duckling813 » 2006-10-23 21:38

对了 ,你有关于linux内核方面的比较好的书介绍么?
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#9

帖子 nobrain » 2006-10-24 18:35

我就看过ldd3,但是还没看完,因为现在没有时间了。在学校的bbs上看了一个贴,发现做技术似乎工作的时候会很累,呜呜。早知道就学别的了。 :cry:
我不会游泳,估计发大水的时候我很可能会溺水身亡……
bless me~~
爱喝真猪奶茶的夜鸣猪
duckling813
帖子: 11
注册时间: 2006-09-03 15:57
来自: nju

#10

帖子 duckling813 » 2006-11-02 22:09

呵呵
好几天没有上论坛了
你是科大哪个系的?
cs or ee?
可以qq联系么?我的号是389931550
头像
fallleaf
帖子: 694
注册时间: 2006-12-29 20:13

#11

帖子 fallleaf » 2007-01-13 20:10

同是ustcer!俺是个新手。不知道老兄在瀚海上的ID是什么?
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#12

帖子 nobrain » 2007-01-14 23:13

duckling813 写了:呵呵
好几天没有上论坛了
你是科大哪个系的?
cs or ee?
可以qq联系么?我的号是389931550
好久没看这个贴了,偶是科大物理系的,这方面最近几个月一直没看,有其他的课要上阿。可惜一登录腾讯就说qq版本太低,damn it.
爱喝真猪奶茶的夜鸣猪
头像
nobrain
帖子: 808
注册时间: 2005-08-25 13:58
来自: ustc
联系:

#13

帖子 nobrain » 2007-01-14 23:15

fallleaf 写了:同是ustcer!俺是个新手。不知道老兄在瀚海上的ID是什么?
我也比较菜,id就不说了吧,免得丢人 :oops:
驱动这方面好像瀚海上的xhacker比较强,好像他工作就是干这个的。
Linux版经常能看到他。
爱喝真猪奶茶的夜鸣猪
回复