我往linux内核里添加一个驱动模块,根据《linux设备驱动》第三版,修改Makefile如下:
-
obj-m := GobiNet.o
-
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
但是出现了如下错误:
-
/home/sylvain/Projects/android_gingerbread_realv210_ver_1_0/kernel
-
CHK include/linux/version.h
-
CHK include/generated/utsrelease.h
-
make[1]: `include/generated/mach-types.h' is up to date.
-
CALL scripts/checksyscalls.sh
-
CHK include/generated/compile.h
-
LD drivers/cell/OptionGobiNet/built-in.o
-
CC [M] drivers/cell/OptionGobiNet/GobiUSBNet.o
-
CC [M] drivers/cell/OptionGobiNet/QMIDevice.o
-
CC [M] drivers/cell/OptionGobiNet/QMI.o
-
LD [M] drivers/cell/OptionGobiNet/GobiNet.o
-
Kernel: arch/arm/boot/Image is ready
-
SHIPPED arch/arm/boot/compressed/lib1funcs.S
-
AS arch/arm/boot/compressed/lib1funcs.o
-
LD arch/arm/boot/compressed/vmlinux
-
OBJCOPY arch/arm/boot/zImage
-
Kernel: arch/arm/boot/zImage is ready
-
Building modules, stage 2.
-
MODPOST 5 modules
-
ERROR: "usbnet_suspend" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
-
ERROR: "usbnet_resume" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
-
ERROR: "usbnet_disconnect" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
-
ERROR: "usbnet_probe" [drivers/cell/OptionGobiNet/GobiNet.ko] undefined!
-
make[1]: *** [__modpost] Error 1
-
make: *** [modules] Error 2
编译过程中生成了"GobiNet.mod.c"和"GobiNet.o",但是并没有生成GobiNet.ko文件。
经历一番折腾之后,我发现问题的原因了。
我误解了错误信息,没有清楚ko生成过程。编译模块在链接过程中查找外部符号表,但并没有找到,因为该外部符号表并没有编译。
根据以上分析,我查看了外部符号在drivers/net/usb/usbnet.c文件,这就需要配置.config文件中设置CONFIG_USBNET=y。
希望对大家有所帮助。
英文地址:
阅读(3008) | 评论(0) | 转发(0) |