当前位置:首页 > 嵌入式 > 嵌入式软件
[导读]Scull在2.6.35-30内核中的编译解决方案

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 reported only once /media/orientation/driver/ldd3/examples/scull/pipe.c:131: error: for each function it appears in.)

/media/orientation/driver/ldd3/examples/scull/pipe.c:131: error: implicit declaration of function ‘signal_pending’/media/orientation/driver/ldd3/examples/scull/pipe.c:131: error: implicit declaration of function ‘schedule’/media/orientation/driver/ldd3/examples/scull/pipe.c: In function ‘scull_getwritespace’:/media/orientation/driver/ldd3/examples/scull/pipe.c:168: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/pipe.c: In function ‘scull_p_write’:/media/orientation/driver/ldd3/examples/scull/pipe.c:219: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/pipe.c:223: error: ‘SIGIO’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/pipe.c:223: error: ‘POLL_IN’ undeclared (first use in this function)

make[2]: *** [/media/orientation/driver/ldd3/examples/scull/pipe.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 6、根据提示,TASK_INTERRUPTIBLE没有声明,我们在源码里面搜索,发现该宏定义在<linux/sched.h>中,故在pipe.c中加入该头文件,接着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.35-30-generic' CC [M] /media/orientation/driver/ldd3/examples/scull/pipe.o CC [M] /media/orientation/driver/ldd3/examples/scull/access.o /media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_u_open’:/media/orientation/driver/ldd3/examples/scull/access.c:106: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c:107: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_w_available’:/media/orientation/driver/ldd3/examples/scull/access.c:165: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c:166: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_w_open’:/media/orientation/driver/ldd3/examples/scull/access.c:179: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/access.c:179: error: (Each undeclared identifier is reported only once /media/orientation/driver/ldd3/examples/scull/access.c:179: error: for each function it appears in.)

/media/orientation/driver/ldd3/examples/scull/access.c:179: error: implicit declaration offunction ‘signal_pending’/media/orientation/driver/ldd3/examples/scull/access.c:179: error: implicit declaration offunction ‘schedule’/media/orientation/driver/ldd3/examples/scull/access.c:184: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_w_release’:/media/orientation/driver/ldd3/examples/scull/access.c:205: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)

/media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_c_open’:/media/orientation/driver/ldd3/examples/scull/access.c:277: error: dereferencing pointer to incomplete type /media/orientation/driver/ldd3/examples/scull/access.c:281: error: dereferencing pointer to incomplete type make[2]: *** [/media/orientation/driver/ldd3/examples/scull/access.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 7、根据提示,同上所述,我们需要在access.c中加入头文件<sched.h>,接着编译:

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/access.o /media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_u_open’:/media/orientation/driver/ldd3/examples/scull/access.c:106: error: ‘struct task_struct’ has no member named ‘uid’/media/orientation/driver/ldd3/examples/scull/access.c:107: error: ‘struct task_struct’ has no member named ‘euid’/media/orientation/driver/ldd3/examples/scull/access.c:114: error: ‘struct task_struct’ has no member named ‘uid’/media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_w_available’:/media/orientation/driver/ldd3/examples/scull/access.c:165: error: ‘struct task_struct’ has no member named ‘uid’/media/orientation/driver/ldd3/examples/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘euid’/media/orientation/driver/ldd3/examples/scull/access.c: In function ‘scull_w_open’:/media/orientation/driver/ldd3/examples/scull/access.c:184: error: ‘struct task_struct’ has no member named ‘uid’make[2]: *** [/media/orientation/driver/ldd3/examples/scull/access.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 8、根据提示,错误在于task_struct结构体没有uid,euid成员变量,查看源码发现struct task_struct定义在include/linux/sched.h中,确实没有这两个成员,逐个成员分析发现,这两个成员在2.6.35内核中放在const struct cred *cred成员中了,所以,我们尝试将所有出现错误的地方做如下改动:

current->uid 修改为 current->cred->uid current->euid 修改为 current->cred->euid 9、接着make,发现成功编译

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

在这篇文章中,小编将为大家带来Linux内核的相关报道。如果你对本文即将要讲解的内容存在一定兴趣,不妨继续往下阅读哦。

关键字: 嵌入式 Linux 内核

以下内容中,小编将对嵌入式linux内核移植实现方案的相关内容进行着重介绍和阐述,希望本文能帮您增进对嵌入式的了解,和小编一起来看看吧。

关键字: 嵌入式 Linux 内核

KeilμVision4是Keil软件公司为8051系列微控制器及其兼容产品设计的集成式软件开发环境。μVision4集成了C51编译器和A51汇编器,其界面类似于Microsoft VS,支持C语言和汇编语言程序的编写...

关键字: 程序 编译 链接

上海2022年11月29日 /美通社/ -- 2022年11月4日至6日,具有国际影响力的金融科技经纪商ATFX参加且赞助了2023年“爱丁堡公爵杯”预选赛。此次预选赛是在墨西哥金塔纳罗奥州坎昆月亮宫酒店球场(Hotel...

关键字: 内核 进程 TE SE

据业内信息报道,近日半导体封测大厂日月光已从高通公司获得Oryon芯片的封测大单。

关键字: 高通 内核 Oryon 封测 日月光

据业内消息,在近日举办的Snapdragon技术峰会中,高通公司公布了新一代定制ARM内核Oryon。

关键字: 高通公司 ARM 内核 Oryon

北京2022年11月15日 /美通社/ -- "双十一"当天,思享无限正式推出拾遗计划,聚焦非遗文化的传播与传承,将传统文化与直播新的媒介语境相融合,让非遗传承者、非遗爱好者在直播平台上共同参与、共同...

关键字: 互联网 内核 数字化

第五届中国国际进口博览会,丹纳赫集团携手中国健康传媒集团,在创新技术在疫苗、细胞治疗药物、中药研发以及质量控制中的应用等领域签署战略合作。同时,双方将共同编译并出版《生物制药工艺》等书籍,以支持相关领域国际前沿技术工具在...

关键字: 编译 质量控制

高德智感推出PT系列红外热像仪新品,内核搭载1280x1024非制冷氧化钒红外探测器,率先拥有百万像素的红外热像仪产品。同时测温精度高达正负1摄氏度,热灵敏度NETD不超过55mK,可辨识微小的热差异,并自动追踪全屏最高...

关键字: 红外热像仪 NET NFC 内核

2022北京马拉松于11月6日开跑。本次北马采用集“数字化注册”、“人脸识别核验”、“AI测温”以及“北京健康宝健康码状态、全程新冠疫苗接种和24小时内核酸检测阴性证明”多验合一的物联网智能终端——声智科技IDA数字哨点...

关键字: 人脸识别 内核 数字化 智能终端
关闭
关闭