开发内核模块过程中的问题总结

(1)

问题:交叉编译环境同板子上平台的大小端不一致,导致无法正常编译

原因:内核未正确配置成板子上的平台

解决方法:

cd linux2.6.x

cp arch/arm/configs/ixp4xx_defconfig .config

make zImage 

 

(2)

问题:当插入内核模块时,提示模块需要unloading属性

原因:内核配置时未选择Module Unloading

解决方法:

在Make menuconfig时选上Module Unloading,然后make zImage

 

(3)

CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h CC arch/arm/kernel/asm-offsets.s In file included from include/linux/irqflags.h:46, from include/asm/system.h:78, from include/asm/bitops.h:23, from include/linux/bitops.h:9, from include/linux/thread_info.h:20, from include/asm/current.h:4, from include/linux/capability.h:47, from include/linux/sched.h:49, from arch/arm/kernel/asm-offsets.c:13: include/asm/irqflags.h:11:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/asm/bitops.h:23, from include/linux/bitops.h:9, from include/linux/thread_info.h:20, from include/asm/current.h:4, from include/linux/capability.h:47, from include/linux/sched.h:49, from arch/arm/kernel/asm-offsets.c:13: include/asm/system.h:153:5: warning: "__LINUX_ARM_ARCH__" is not defined include/asm/system.h:159:5: warning: "__LINUX_ARM_ARCH__" is not defined include/asm/system.h:163:35: warning: "__LINUX_ARM_ARCH__" is not defined include/asm/system.h:283:5: warning: "__LINUX_ARM_ARCH__" is not defined include/asm/system.h:288:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/linux/bitops.h:9, from include/linux/thread_info.h:20, from include/asm/current.h:4, from include/linux/capability.h:47, from include/linux/sched.h:49, from arch/arm/kernel/asm-offsets.c:13: include/asm/bitops.h:233:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/asm/thread_info.h:16, from include/linux/thread_info.h:21, from include/asm/current.h:4, from include/linux/capability.h:47, from include/linux/sched.h:49, from arch/arm/kernel/asm-offsets.c:13: include/asm/fpstate.h:28:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/linux/prefetch.h:14, from include/linux/list.h:8, from include/linux/preempt.h:11, from include/linux/spinlock.h:49, from include/linux/seqlock.h:29, from include/linux/time.h:8, from include/linux/timex.h:57, from include/linux/sched.h:53, from arch/arm/kernel/asm-offsets.c:13: include/asm/processor.h:103:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/linux/spinlock.h:333, from include/linux/seqlock.h:29, from include/linux/time.h:8, from include/linux/timex.h:57, from include/linux/sched.h:53, from arch/arm/kernel/asm-offsets.c:13: include/asm/atomic.h:25:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/linux/jiffies.h:4, from include/linux/sched.h:54, from arch/arm/kernel/asm-offsets.c:13: include/linux/calc64.h: In function ‘do_div_llr’: include/linux/calc64.h:25: error: ‘__LINUX_ARM_ARCH__’ undeclared (first use in this function) include/linux/calc64.h:25: error: (Each undeclared identifier is reported only once include/linux/calc64.h:25: error: for each function it appears in.) In file included from include/asm/semaphore.h:10, from arch/arm/kernel/asm-offsets.c:13: include/linux/rwsem.h:24:65: error: asm/rwsem.h: No such file or directory In file included from include/asm/semaphore.h:13, from include/linux/sched.h:62, from arch/arm/kernel/asm-offsets.c:13: include/asm/locks.h:15:5: warning: "__LINUX_ARM_ARCH__" is not defined In file included from include/asm/page.h:32, from include/linux/sched.h:63, from arch/arm/kernel/asm-offsets.c:13: include/asm/glue.h:119:2: error: #error Unknown data abort handler type In file included from include/linux/sched.h:63, from arch/arm/kernel/asm-offsets.c:13: include/asm/page.h:116:2: error: #error Unknown user operations model In file included from include/linux/memory_hotplug.h:7, from include/linux/mmzone.h:493, from include/linux/gfp.h:4, from include/linux/slab.h:14, from include/linux/percpu.h:5, from include/linux/rcupdate.h:41, from include/linux/pid.h:4, from include/linux/sched.h:75, from arch/arm/kernel/asm-offsets.c:13: include/linux/notifier.h: At top level: include/linux/notifier.h:62: error: field ‘rwsem’ has incomplete type In file included from include/linux/sched.h:78, from arch/arm/kernel/asm-offsets.c:13: include/linux/seccomp.h:8:25: error: asm/seccomp.h: No such file or directory In file included from include/linux/sched.h:78, from arch/arm/kernel/asm-offsets.c:13: include/linux/seccomp.h: In function ‘secure_computing’: include/linux/seccomp.h:15: error: ‘TIF_SECCOMP’ undeclared (first use in this function) In file included from arch/arm/kernel/asm-offsets.c:13: include/linux/sched.h: At top level: include/linux/sched.h:385: error: field ‘mmap_sem’ has incomplete type make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1 make: *** [prepare0] Error 2

 

出现以上错误,说明在make menuconfig的时候未选择cpu类型为ixp4xx(system type->ixp4xx based),选上就好,注意此时如果不编辑Makefile,将ARCH=arm;CROSS_COMPILE=arm-linux- 打开,将找不到ixp4xx的选项。

 

(4)http://linux.chinaunix.net/bbs/thread-1162895-1-1.html

上面的帖子描述了出现下面问题时的解决办法:

opensuse-vm:/usr/src/linux-2.6.23 # make oldconfig
  HOSTCC  scripts/basic/fixdep
In file included from /usr/include/bits/posix1_lim.h:153,
                 from /usr/include/limits.h:145,
                 from /usr/lib/gcc/i586-suse-linux/4.3/include-fixed/limits.h:122,
                 from /usr/lib/gcc/i586-suse-linux/4.3/include-fixed/syslimits.h:7,
                 from /usr/lib/gcc/i586-suse-linux/4.3/include-fixed/limits.h:11,
                 from scripts/basic/fixdep.c:115:
/usr/include/bits/local_lim.h:39:26: error: linux/limits.h: No such file or directory
In file included from /usr/include/sys/socket.h:36,
                 from /usr/include/netinet/in.h:25,
                 from /usr/include/arpa/inet.h:23,
                 from scripts/basic/fixdep.c:117:
/usr/include/bits/socket.h:320:24: error: asm/socket.h: No such file or directory
scripts/basic/fixdep.c: In function ‘use_config’:
scripts/basic/fixdep.c:206: error: ‘PATH_MAX’ undeclared (first use in this function)
scripts/basic/fixdep.c:206: error: (Each undeclared identifier is reported only once
scripts/basic/fixdep.c:206: error: for each function it appears in.)
scripts/basic/fixdep.c:206: warning: unused variable ‘s’
scripts/basic/fixdep.c: In function ‘parse_dep_file’:
scripts/basic/fixdep.c:306: error: ‘PATH_MAX’ undeclared (first use in this function)
scripts/basic/fixdep.c:306: warning: unused variable ‘s’
make[1]: *** [scripts/basic/fixdep] Error 1
make: *** [scripts_basic] Error 2

 

解决方法:

更新/usr/include下面的asm,scsi和linux三个链接,执行:
ln -s /usr/src/linux-2.6.23/include/asm-i386 asm
ln -s /usr/src/linux-2.6.23/include/linux linux
ln -s /usr/src/linux-2.6.23/include/scsi scsi

你可能感兴趣的:(Linux)