编译内核模块常见问题
2013-02-15 19:19
274 查看
在x86上做出来了,但是在ARM上却出现了很多问题,有内核代码准备的问题,有模块代码问题,也有Makefile的问题。看似不起眼的角色,出了问题也很纠结。
第一种:内核代码没有准备好
其实看实质就是找不到auto.conf,这个其实已经有了,就是.config,但是如果不想手动来拷贝可以假装make zImage(如下),这里就可以了,完整的编译一个内核只为了这个一个配置文件,也太浪费了。
注意看hello.ko就出来了。
第二种错误:模块代码有异常
这大多是模块代码的错误,里边有中文相关的一些东西了,一些符号。代码是在博客上拷贝的或者是在win下用ue编辑的,直接拷贝到Linux中就会有这种问题。唯一的办法就是重新打一编代码了。目前还没有找到合适的方法。(语法问题就不提了)
第三种:模块Makefile语法错误
第一种:内核代码没有准备好
[root@localhost module]# make make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2' ERROR: Kernel configuration is invalid. include/linux/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it. WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers is missing; modules will have no dependencies and modversions. Building modules, stage 2. /opt/kangear/kernel/linux-2.6.32.2/scripts/Makefile.modpost:42: include/config/auto.conf: 没有那个文件或目录 make[2]: *** 没有规则可以创建目标“include/config/auto.conf”。 停止。 make[1]: *** [modules] 错误 2 make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2' make: *** [all] 错误 2 [root@localhost module]#这种是下载的很干净的内核,配置都没有配置;或是配置了,有.config但是没有make zImage。编译一下,不为用这个zImage,只是为了更好的编译内核模块。
其实看实质就是找不到auto.conf,这个其实已经有了,就是.config,但是如果不想手动来拷贝可以假装make zImage(如下),这里就可以了,完整的编译一个内核只为了这个一个配置文件,也太浪费了。
[root@localhost linux-2.6.32.2]# make zImage HOSTLD scripts/kconfig/conf scripts/kconfig/conf -s arch/arm/Kconfig CHK include/linux/version.h UPD include/linux/version.h Generating include/asm-arm/mach-types.h CHK include/linux/utsrelease.h UPD include/linux/utsrelease.h SYMLINK include/asm -> include/asm-arm CC kernel/bounds.s GEN include/linux/bounds.h CC arch/arm/kernel/asm-offsets.s GEN include/asm/asm-offsets.h CALL scripts/checksyscalls.sh CC scripts/mod/empty.o HOSTCC scripts/mod/mk_elfconfig MKELF scripts/mod/elfconfig.h HOSTCC scripts/mod/file2alias.o HOSTCC scripts/mod/modpost.o HOSTCC scripts/mod/sumversion.o HOSTLD scripts/mod/modpost HOSTCC scripts/kallsyms HOSTCC scripts/pnmtologo HOSTCC scripts/conmakehash CC init/main.o CHK include/linux/compile.h UPD include/linux/compile.h CC init/version.o ^Cmake[1]: *** wait: 没有子进程。 停止。 make[1]: *** 正在等待未完成的任务.... make[1]: *** wait: 没有子进程。 停止。 make: *** wait: 没有子进程。 停止。 make: *** 正在等待未完成的任务.... make: *** wait: 没有子进程。 停止。 [root@localhost linux-2.6.32.2]#这里再来make一下:
[root@localhost module]# make make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2' WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers is missing; modules will have no dependencies and modversions. CC [M] /root/桌面/kangear/module/hello.o Building modules, stage 2. MODPOST 1 modules WARNING: modpost: missing MODULE_LICENSE() in /root/桌面/kangear/module/hello.o see include/linux/module.h for more information CC /root/桌面/kangear/module/hello.mod.o LD [M] /root/桌面/kangear/module/hello.ko make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2' [root@localhost module]# ls hello.c hello.mod.c hello.o modules.order param hello.ko hello.mod.o Makefile Module.symvers symbol [root@localhost module]#
注意看hello.ko就出来了。
第二种错误:模块代码有异常
[root@localhost hello]# make make -C /opt/kangear/kernel/linux-2.6.32.2 M=/opt/kangear/hello modules make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2' WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers is missing; modules will have no dependencies and modversions. CC [M] /opt/kangear/hello/hello.o /opt/kangear/hello/hello.c:3: error: expected declaration specifiers or '...' before string constant /opt/kangear/hello/hello.c:3: warning: data definition has no type or storage class /opt/kangear/hello/hello.c:3: warning: type defaults to 'int' in declaration of 'MODULE_LECENSE' /opt/kangear/hello/hello.c:3: warning: function declaration isn't a prototype /opt/kangear/hello/hello.c:17: error: redefinition of '__inittest' /opt/kangear/hello/hello.c:16: note: previous definition of '__inittest' was here /opt/kangear/hello/hello.c: In function '__inittest': /opt/kangear/hello/hello.c:17: warning: return from incompatible pointer type /opt/kangear/hello/hello.c: At top level: /opt/kangear/hello/hello.c:17: error: redefinition of 'init_module' /opt/kangear/hello/hello.c:16: note: previous definition of 'init_module' was here make[2]: *** [/opt/kangear/hello/hello.o] 错误 1 make[1]: *** [_module_/opt/kangear/hello] 错误 2 make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2' make: *** [default] 错误 2 [root@localhost hello]# make
这大多是模块代码的错误,里边有中文相关的一些东西了,一些符号。代码是在博客上拷贝的或者是在win下用ue编辑的,直接拷贝到Linux中就会有这种问题。唯一的办法就是重新打一编代码了。目前还没有找到合适的方法。(语法问题就不提了)
第三种:模块Makefile语法错误
[root@localhost hello]# make make: Nothing to be done for `default'. [root@localhost hello]#对应的makefile是命令为:
default: make -C $(KERNELDIR) M=$(PWD) modulesmake前边应该有一个tab键。或者是make前边是空格而不是tab。
相关文章推荐
- 解决编译内核模块helloworld.c:1: 错误:代码模式‘kernel’在 32 位模式下不受支持问题,未编译对64位的支持
- DM6446 内核编译常见问题解决方法
- 内核模块编译时出现的问题解决
- linux 内核编译:内核配置原理与常见配置问题的解决方法&&内核版本控制解析
- linux 编译内核几个常见问题解决方法
- linux 内核编译:内核配置原理与常见配置问题的解决方法&&内核版本控制解析
- 编译2.6内核模块出问题了,尚未解决.............
- openwrt 编译内核模块中的配置问题
- linux 编译内核几个常见问题解决方法
- linux kernel 编译内核模块代码,插入内核模块遇到的问题和解决
- 内核学习方法,编译、调试等常见问题【转】
- 编译内核模块问题
- 内核模块编译加载问题
- vivi以及内核编译过程以及其中遇到的一些问题
- Linux内核和驱动编译常见问题
- Linux:编译生成内核模块(来自国嵌的视频教学)
- linux 内核编译——修改版本号的一些问题
- Linux 下内核模块的开发方式的记录 及问题解决(入门的Helloworld)
- 内核模块编译、加载&卸载及查看运行结果 -- linux内核
- linux设备驱动程序_hello word 模块编译各种问题集锦