[已解决]字符设备驱动 scull

内核编译和嵌入式产品的设计与开发
回复
头像
infinite180
帖子: 207
注册时间: 2007-05-31 20:17
来自: DUT
联系:

[已解决]字符设备驱动 scull

#1

帖子 infinite180 » 2009-03-12 20:57

<<linux设备驱动程序>>第三章 scull给的原代码我make的时候出现error,不知道需要改哪里,我的内核是2.6.28的,发行版本UBUNTU8.10。

提示:CFLAGS was changed in ******. Fix it to use EXTRA_CFLAGS.
这句是什么意思呢? 在网上搜到说在Makefile里面把DEBFLAGS注释掉就好了,我注释掉之后这步的确过了,但是又有新问题了
说:linux/config.h no such file....

驱动路漫漫啊~

Makefile文件如下:
# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y

# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif

CFLAGS += $(DEBFLAGS)
CFLAGS += -I$(LDDINC)

ifneq ($(KERNELRELEASE),)
# call from kernel build system

scull-objs := main.o pipe.o access.o
obj-m := scull.o

else

KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modules
endif

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
上次由 infinite180 在 2009-03-16 17:47,总共编辑 1 次。
头像
infinite180
帖子: 207
注册时间: 2007-05-31 20:17
来自: DUT
联系:

Re: 字符设备驱动 scull

#2

帖子 infinite180 » 2009-03-16 17:46

问题解决了,
我的内核是2.6.28,里面的linux/config.h已经没有了。
只要:
sudo touch /usr/src/XXX/include/linux/config.h
就可以了,然后make的时候会出现编译错误,这个时候需要在access.c
里面加上下面两个头文件:
#include<linux/capability.h>
#include<linux/sched.h>
回复