找回密码
 注册
关于网站域名变更的通知
查看: 513|回复: 1
打印 上一主题 下一主题

瞅过来~~~编译LDD3的scull驱动问题总结来了

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-8-14 10:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
由于Linux内核版本更新的原因,LDD3(v2.6.10)提供的源码无法直接使用,下面是本人编译scull源码时出现的一些问题及解决方法。
8 B% V% n+ D: \& n4 T2 n编译环境:CentOS 6.3(kernel version 2.6.32)4 ]+ W% U8 M. n- J

8 K0 h$ D* v4 }) @编译错误:
6 J" v+ U! ?" O) @/ O( smake -C /lib/modules/2.6.32-279.14.1.el6.i686/build M=/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull LDDINC=/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/../include modules
2 S$ A8 m6 x& `. H* _0 h: Amake[1]: Entering directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686': [7 |; T5 a+ o  I
scripts/Makefile.build:49: *** CFLAGS was changed in "/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/Makefile". Fix it to use EXTRA_CFLAGS.  Stop.
6 P$ V5 ^1 Q8 S; n1 K+ S* Imake[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2
" C0 c7 R# }. i5 b9 Y7 s* ~8 F$ x- K( ?make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'
3 o1 U; {0 G! D7 x+ Q" O! _6 [make: *** [modules] Error 2
; V3 t* `# [( A; h4 k$ [解决方案:$ @! u" Q8 \/ y. R
CFLAGS与Makefile.build中的CFLAGS冲突,错误提示要求将CFLAG换成EXTRA_CFLAGS重新编译即可;
! ^0 J" P& m# P0 ?. ?6 l& k! x: ?$ c
编译错误:
! o0 j6 R- Q* ^& D3 Eerror: linux/config.h: No such file or directory% a2 {3 {& {5 U+ Q" d
解决方案:
: y9 [9 u' J$ H* H5 P从linux-2.6.20起,config.h就已经被移除了.6 E* R! X3 @8 [/ {
将#include <linux/config.h>修改成如下——>
4 D6 A. d& v- G- ^; x8 A' |#include <linux/version.h>+ F5 I6 j% D% P  S# ^
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
2 B" n* E7 a: U+ |# _5 a+ j7 e1 r#include <linux/config.h>
( y+ A4 U% D3 K" c2 _# S- n& d#endif* v1 {! m5 U$ a
* k! E1 f3 I' T; J6 @. b) B$ Z
编译错误:
) i0 H2 G6 |6 d  v. R; q/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_p_read’:, R9 Q6 `& C. }* i% u* k( ?
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
  A1 O* f& c& U) b, K/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: (Each undeclared identifier is reported only once
/ h* d& J6 h6 M2 s# u4 l2 O" F/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: for each function it appears in.)
6 D  C! T  e" d( q. U/ l7 {( G/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: implicit declaration of function ‘signal_pending’  E+ ^  \5 c; T4 @; b. d
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: implicit declaration of function ‘schedule’7 z  x% t6 D3 E- \, A  p' @
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_getwritespace’:
, S- Y& S0 [4 D0 U. ?) }/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:168: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)5 Z/ f7 N7 O! Y! |6 {
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_p_write’:
. P7 t3 \! j* ?/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:219: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)6 A4 n1 `1 n/ k" g6 D7 V4 p
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:223: error: ‘SIGIO’ undeclared (first use in this function)
2 z5 m  C) S" B3 H! m! @4 ~( x/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:223: error: ‘POLL_IN’ undeclared (first use in this function)
, r* d' D! B# e) J  l0 Wmake[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.o] Error 15 I8 J4 }) z4 F! x0 {. B: A
make[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2& Z" l- K  u! w4 n
解决方案:
& _/ U  A- A% j, N头文件变动原因,在pipe.c中添加
) k4 c3 a4 w, {  @: F#include <linux/sched.h> 0 P2 {* n5 d: q0 x. }. A! C

9 u! z: ^/ }5 ~' q+ _编译错误:6 M: C' S. f% a& M. w
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_u_open’:. p% c3 H5 [3 U# W
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:106: error: dereferencing pointer to incomplete type
+ I% }/ G, y) Q8 Y9 {' K' C/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:107: error: dereferencing pointer to incomplete type
* B. q& `- z. x  J# B/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type
1 i) H6 w" ?9 q$ `& p/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_available’:
( o: W% i, C' [! V: g6 F/ r6 L- R/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:165: error: dereferencing pointer to incomplete type
% L1 ?7 O' j. n' ^3 G  Y5 L9 w/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:166: error: dereferencing pointer to incomplete type. C4 ?9 q* w& g3 R, ^- M3 ~
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_open’:
5 c* S0 i5 N  ^  X) J/ A/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)1 H) P2 e  X7 q# G
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: (Each undeclared identifier is reported only once
  A* w9 Z$ N4 A% ?) z6 d4 b8 q; D/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: for each function it appears in.)
( G+ f, N1 r" ~  P" P' ^5 g8 }/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: implicit declaration of function ‘signal_pending’
; N3 Y, S' m7 @/ z$ I* {/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: implicit declaration of function ‘schedule’& o4 B$ d: o. \( j: H5 K
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:184: error: dereferencing pointer to incomplete type
+ p) q2 e# G1 y( Z% @1 K/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_release’:
0 }, W$ t5 _% T2 @5 L/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:205: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function). B/ {4 T- ]/ d3 ?$ M* L" L9 ]5 k
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_c_open’:2 v" v' s5 A6 z; K- q2 `( a
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:277: error: dereferencing pointer to incomplete type
4 c7 p) n/ J' |4 O$ f6 [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:281: error: dereferencing pointer to incomplete type
7 {6 J+ I/ H8 N8 A: i. Umake[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.o] Error 14 F8 B8 N# H+ x9 o
make[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2
5 `" e8 u' G5 y& k2 s* Nmake[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'3 Q& [% x& l8 ]
make: *** [modules] Error 2
9 Y. v5 ?+ J$ a: G9 t. j) j; i解决方案:
' I' ^5 R: z0 d! g头文件变动原因,在access.c中添加
3 X9 B- x# ]* z8 _; m  B#include <linux/sched.h>   
. M3 L4 H$ b& e1 o
) @0 P; I6 I  S; p: u( V编译错误:+ {' X' C8 [! P+ x5 e0 a
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_u_open’:
7 Q8 M- I3 D& Z, |( F9 w/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:107: error: ‘struct task_struct’ has no member named ‘uid’
3 G% i4 j% d+ c3 w) ~& j/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘euid’9 n9 L  r2 b  s7 ]
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:115: error: ‘struct task_struct’ has no member named ‘uid’
) N& z2 \5 ]: ?" H# U. r+ P/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_available’:
' a! y1 _3 B) j* N. e9 V* d' G* i/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘uid’
& [: W; ?# P) _1 ^/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘euid’
( P- l$ A+ c( d& b/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_open’:1 o7 n8 u, V, D9 N/ Y+ \; ^$ R
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:185: error: ‘struct task_struct’ has no member named ‘uid’
* n% |5 \& p* q! `  M0 Z* B3 Gmake[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.o] Error 1! E4 a1 k' ]9 m0 }4 c4 S( y
make[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2. `$ O! J! v: c# `* O
make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'3 i# ?' T2 m. h+ `
make: *** [modules] Error 2
7 {1 s! M1 I4 y解决方案:
+ n5 C! R7 R8 V6 y8 o. B/ ^因为内核版本的升级,struct task_struct发生了变动,uid和euid放到了cred域下., `  r0 F, A& G1 C, q
修改,做如下替换1 [6 W+ P/ h6 ]9 x4 ?, k
current->uid 替换成current->cred->uid$ b& F" x$ K( u
current->euid替换成current->cred->euid2 E' ~: [* X( a( h
4 t+ `4 R/ ^0 |- x/ V
重新编译,成功!
( v. p0 }% Y. \0 k& m: v6 z( _0 u" Q# H0 b1 P9 b
+ }( ^5 N2 W$ o8 U8 M- c+ ^
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-24 22:22 , Processed in 0.156250 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表