linux内核外部驱动模块编译报错ERROR—drivers/*.ko] undefined

http://www.programgo.com/article/5954542773/

http://stackoverflow.com/questions/7812418/kernel-driver-external-modules-not-building-completely

我往linux内核里添加一个驱动模块,根据《linux设备驱动》第三版,修改Makefile如下:


点击(此处)折叠或打开

  1. obj-m := GobiNet.o
  2. GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
但是出现了如下错误:

点击(此处)折叠或打开

  1. /home/sylvain/Projects/android_gingerbread_realv210_ver_1_0/kernel
  2.    CHK include/linux/version.h
  3.    CHK include/generated/utsrelease.h
  4. make[1]: `include/generated/mach-types.h' is up to date.
  5.    CALL scripts/checksyscalls.sh
  6.    CHK include/generated/compile.h
  7.    LD drivers/cell/OptionGobiNet/built-in.o
  8.    CC [M] drivers/cell/OptionGobiNet/GobiUSBNet.o
  9.    CC [M] drivers/cell/OptionGobiNet/QMIDevice.o
  10.    CC [M] drivers/cell/OptionGobiNet/QMI.o
  11.    LD [M] drivers/cell/OptionGobiNet/GobiNet.o
  12.    Kernel: arch/arm/boot/Image is ready
  13.    SHIPPED arch/arm/boot/compressed/lib1funcs.S
  14.    AS arch/arm/boot/compressed/lib1funcs.o
  15.    LD arch/arm/boot/compressed/vmlinux
  16.    OBJCOPY arch/arm/boot/zImage
  17.    Kernel: arch/arm/boot/zImage is ready
  18.    Building modules, stage 2.
  19.    MODPOST 5 modules
  20. ERROR: "usbnet_suspend" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
  21. ERROR: "usbnet_resume" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
  22. ERROR: "usbnet_disconnect" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
  23. ERROR: "usbnet_probe" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
  24. make[1]: *** [__modpost] Error 1
  25. make: *** [modules] Error 2
编译过程中生成了"GobiNet.mod.c"和"GobiNet.o",但是并没有生成GobiNet.ko文件。
经历一番折腾之后,我发现问题的原因了。

我误解了错误信息,没有清楚ko生成过程。编译模块在链接过程中查找外部符号表,但并没有找到,因为该外部符号表并没有编译。

根据以上分析,我查看了外部符号在drivers/net/usb/usbnet.c文件,这就需要配置.config文件中设置CONFIG_USBNET=y。

希望对大家有所帮助。


英文地址:http://stackoverflow.com/questions/7812418/kernel-driver-external-modules-not-building-completely




<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(162) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-02-01 00:00  张同光  阅读(931)  评论(0编辑  收藏  举报