微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > Scull在2.6.35-30内核中的编译解决方案

Scull在2.6.35-30内核中的编译解决方案

时间:04-12 来源:互联网 点击:

LDD3作为从事驱动开发工作人员的必要参考资料,认真研究书中的附带源码具有很高的参考价值,但由于代码基于2.6.10内核,部分内核API较老,导致在2.6.35-30等较新内核上编译不能通过,由于工作需要,特花了一段时间进行整理,本篇文章对示例源码中的第一个驱动程序SCULL进行整理,供各位同仁参考:

1、修改Makefile的第24行:

如果是基于PC,则KERNELDIR ?= /lib/modules/$(shell uname -r)/build(我的PC中linux内核是2.6.35版本)

如果是基于arm,则改变为:

KERNELDIR ?= ……/……/……/……/linux/linux-2.6.35-30(arm开发板上所需内核的源码目录)

2、进入scull目录,执行make,有如下错误:

make -C /lib/modules/2.6.35-30-generic/build M=/media/orientation/driver/ldd3/examples/scull LDDINC=/media/orientation/driver/ldd3/examples/scull/……/include modules make[1]: Entering directory `/usr/src/linux-headers-2.6.32-28-generic' scripts/Makefile.build:49: *** CFLAGS was changed in /media/orientation/driver/ldd3/examples/scull/Makefile. Fix it to use EXTRA_CFLAGS. Stop. make[1]: *** [_module_/media/orientation/driver/ldd3/examples/scull] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-28-generic' make: *** [modules] Error 2 3、根据错误提示,修改Makefile中12、13行代码如下:

EXTRA_CFLAGS += $(DEBFLAGS)

EXTRA_CFLAGS += -I$(LDDINC)

4、接着make,错误如下:

make -C /lib/modules/2.6.35-30-generic/build M=/media/orientation/driver/ldd3/examples/scull LDDINC=/media/orientation/driver/ldd3/examples/scull/……/include modules make[1]: Entering directory `/usr/src/linux-headers-2.6.32-28-generic' CC [M] /media/orientation/driver/ldd3/examples/scull/main.o /media/orientation/driver/ldd3/examples/scull/main.c:17:26: error: linux/config.h: No such file or directory make[2]: *** [/media/orientation/driver/ldd3/examples/scull/main.o] Error 1 make[1]: *** [_module_/media/orientation/driver/ldd3/examples/scull] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-28-generic' make: *** [modules] Error 2 root@ubuntu:/media/orientation/driver/ldd3/examples/scull# vim Makefile root@ubuntu:/media/orientation/driver/ldd3/examples/scull# make make -C /lib/modules/2.6.32-28-generic/build M=/media/orientation/driver/ldd3/examples/scull LDDINC=/media/orientation/driver/ldd3/examples/scull/……/include modules make[1]: Entering directory `/usr/src/linux-headers-2.6.32-28-generic' CC [M] /media/orientation/driver/ldd3/examples/scull/main.o /media/orientation/driver/ldd3/examples/scull/main.c:17:26: error: linux/config.h: No such file or directory make[2]: *** [/media/orientation/driver/ldd3/examples/scull/main.o] Error 1 make[1]: *** [_module_/media/orientation/driver/ldd3/examples/scull] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-28-generic 5、根据提示,查看2.6.35.30源码发现linux/config.h文件不存在,直接在main.c里将他屏蔽,接着编译,仍有错误:

make -C /lib/modules/2.6.35-30-generic/build M=/media/orientation/driver/ldd3/examples/scull LDDINC=/media/orientation/driver/ldd3/examples/scull/……/include modules make[1]: Entering directory `/usr/src/linux-headers-2.6.32-28-generic' CC [M] /media/orientation/driver/ldd3/examples/scull/main.o CC [M] /media/orientation/driver/ldd3/examples/scull/pipe.o /media/orientation/driver/ldd3/examples/scull/pipe.c: In function ‘scull_p_read’:/media/orientation/driver/ldd3/examples/scull/pipe.c:131: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/pipe.c:131: error: (Each undeclared identifier is

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top