急急急,在虚拟机Ubuntu上编译驱动模块,在开发板上加载驱动错误

Frog1228 2015-08-17 04:45:37
因为我需要在开发板上连接一个USB转串口的设备,而内核中没有编译进相关驱动,所以无法识别出该设备,usb转串口线的芯片是pl2303,因此需要编译加载它的驱动。
以模块方式编译,加载过程如下:
在内核所在目录,键入:
make menuconfig
打开内核配置菜单项,在usb support项中配置USB Serial Converter Surpport相关的选项。USB Serial Converter Surpport这个配置成M,usb generic serial driver选中,usb prolific 2303 single port serial driver配成M。保存退出。
然后在内核所在目录,编译:
make -C /home/tl/omapl138/linux-3.3 M=drivers/usb/serial/  modules

生成:

make: Entering directory `/home/tl/omapl138/linux-3.3'
CC [M] drivers/usb/serial/usb-serial.o
CC [M] drivers/usb/serial/generic.o
CC [M] drivers/usb/serial/bus.o
LD [M] drivers/usb/serial/usbserial.o
CC [M] drivers/usb/serial/option.o
CC [M] drivers/usb/serial/pl2303.o
CC [M] drivers/usb/serial/usb_wwan.o
Building modules, stage 2.
MODPOST 4 modules
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_suspend' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_release' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_startup' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_close' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_open' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_chars_in_buffer' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_write_room' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_write' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_ioctl' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_tiocmset' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_tiocmget' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_set_termios' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_dtr_rts' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_deregister' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_register' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_suspend' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_probe' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_port_softint' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_dcd_change' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_break' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_sysrq_char' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_unthrottle' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_throttle' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_write_bulk_callback' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_read_bulk_callback' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_process_read_urb' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_submit_read_urbs' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_write' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_close' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_open' exported twice. Previous export was in vmlinux
WARNING: "find_first_bit" [drivers/usb/serial/usbserial.ko] undefined!
WARNING: "_copy_from_user" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "copy_to_user" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "current_task" [drivers/usb/serial/pl2303.ko] undefined!
WARNING: "copy_to_user" [drivers/usb/serial/pl2303.ko] undefined!
WARNING: "find_next_bit" [drivers/usb/serial/option.ko] undefined!
WARNING: "find_first_bit" [drivers/usb/serial/option.ko] undefined!
CC drivers/usb/serial/option.mod.o
LD [M] drivers/usb/serial/option.ko
CC drivers/usb/serial/pl2303.mod.o
LD [M] drivers/usb/serial/pl2303.ko
CC drivers/usb/serial/usb_wwan.mod.o
LD [M] drivers/usb/serial/usb_wwan.ko
CC drivers/usb/serial/usbserial.mod.o
LD [M] drivers/usb/serial/usbserial.ko
make: Leaving directory `/home/tl/omapl138/linux-3.3'

在/home/tl/omapl138/linux-3.3/drivers/usb/serial/ 目录下将usbserial.ko和pl2303.ko拷贝到开发板任意目录下,用modprobe或者insmod加载驱动,提示:
Error: could not insert module /lib/modules/usbserial.ko: Invalid module format
我在网上查过,大多是说编译记载版本号的字符串和当前正在运行的内核模块的不一样,他们都能从系统文件日志里(通过 cat /var/log/messages | tail 或者 dmesg | )找到对应的提示信息,但是我的根本没有和刚才加载驱动有关的任何信息。还有一点比较奇怪的是我查看了一下pl2303.ko模块依赖,竟然是空的,应该是依赖于usbserial.ko。
本人是新新新新新新手,刚接触Linux,嵌入式系统,MakeFile我也不是很熟悉,我有几个问题想请问一下:
1. 我在Ubuntu上编译Linux3.3内核的驱动,用的应该是内核自己提供的makefile,网上找到的资料都是自己编写的驱动模块,makefile都是自己写的,而且都是直接在PC上编译,不是用作嵌入式系统上用,那是不是makefile有问题,要修改一下?
2. 如何在Ubuntu上查看Linux3.3内核的具体版本信息,用uname之类查到的都是Ubuntu的版本信息。
这是以模块的方式加载驱动,不需要重新编译内核,如果实在不行的话,我再把驱动编译进内核,但是我觉得这样太烦。
搞了几天,查了很多资料都没有解决,这里也无人可问,短期内要解决实在没办法。
...全文
1068 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
只看不动手 2017-07-15
请问最后那个重定义的问题解决了吗?
回复
zhxianbin 2015-08-20
是 arm 的,首先还是应该把那些 undefined 解决了
回复
Frog1228 2015-08-20
引用 9 楼 linglongqiongge 的回复:
[quote=引用 7 楼 mjjackey 的回复:] [quote=引用 6 楼 linglongqiongge 的回复:] 你的开发板用的什么的版本的内核 你编译的驱动和你开发板的内核版本是一致的吗
是Linux3.3,编译的驱动也是用Linux3.3的内核编译的。[/quote] file 一下你编译出来的驱动文件,看看信息,然后把makefile的关键部分都粘贴出来看看[/quote] file过的驱动信息。

tl@tl-desktop:~/omapl138/rootfs$ file /mnt/hgfs/shareVM/pl2303.ko
/mnt/hgfs/shareVM/pl2303.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
tl@tl-desktop:~/omapl138/rootfs$ file /mnt/hgfs/shareVM/usbserial.ko
/mnt/hgfs/shareVM/usbserial.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
回复
zhxianbin 2015-08-20
file pl2303.ko
回复
Frog1228 2015-08-20
引用 13 楼 zhxianbin 的回复:
是 arm 的,首先还是应该把那些 undefined 解决了
就是不知道那些Warning是什么意思。
回复
Frog1228 2015-08-19
引用 9 楼 linglongqiongge 的回复:
[quote=引用 7 楼 mjjackey 的回复:] [quote=引用 6 楼 linglongqiongge 的回复:] 你的开发板用的什么的版本的内核 你编译的驱动和你开发板的内核版本是一致的吗
是Linux3.3,编译的驱动也是用Linux3.3的内核编译的。[/quote] file 一下你编译出来的驱动文件,看看信息,然后把makefile的关键部分都粘贴出来看看[/quote] 就是用的Linux3.3顶层目录下自带的makefile,只不多参数设置成交叉编译,你说的file是什么意思?
回复
Frog1228 2015-08-18
引用 4 楼 zhxianbin 的回复:
http://book.2cto.com/201309/33431.html
已经看过,按提示进行了修改,Linux3.3内核顶层目录下的makefile,修改参数:
ARCH		?= arm
CROSS_COMPILE	?= arm-none-linux-gnueabi-
编译

tl@tl-desktop:~/omapl138/linux-3.3$ make M=drivers/usb/serial modules
结果

 Building modules, stage 2.
  MODPOST 4 modules
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_open' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_close' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_dtr_rts' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_suspend' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_write_room' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_startup' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_chars_in_buffer' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_tiocmset' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_ioctl' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_tiocmget' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_write' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_release' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usb_wwan: 'usb_wwan_set_termios' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_deregister' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_probe' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_port_softint' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_suspend' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_register' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_write_bulk_callback' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_sysrq_char' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_dcd_change' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_disconnect' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_read_bulk_callback' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_unthrottle' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_throttle' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_open' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_submit_read_urbs' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_resume' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_write' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_process_read_urb' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_generic_close' exported twice. Previous export was in vmlinux
WARNING: drivers/usb/serial/usbserial: 'usb_serial_handle_break' exported twice. Previous export was in vmlinux
WARNING: "__aeabi_unwind_cpp_pr1" [drivers/usb/serial/usbserial.ko] undefined!
WARNING: "__aeabi_unwind_cpp_pr0" [drivers/usb/serial/usbserial.ko] undefined!
WARNING: "__aeabi_unwind_cpp_pr1" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "__aeabi_unwind_cpp_pr0" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "__aeabi_unwind_cpp_pr0" [drivers/usb/serial/pl2303.ko] undefined!
WARNING: "__aeabi_unwind_cpp_pr0" [drivers/usb/serial/option.ko] undefined!
  CC      drivers/usb/serial/option.mod.o
  LD [M]  drivers/usb/serial/option.ko
  CC      drivers/usb/serial/pl2303.mod.o
  LD [M]  drivers/usb/serial/pl2303.ko
  CC      drivers/usb/serial/usb_wwan.mod.o
  LD [M]  drivers/usb/serial/usb_wwan.ko
  CC      drivers/usb/serial/usbserial.mod.o
  LD [M]  drivers/usb/serial/usbserial.ko
再把驱动拷到开发板上加载,结果和之前是完全一样的,pl2303.ko的depends还是空的,照理说应该是usbserial.ko,我查过Ubuntu下的pl2303.ko就是依赖于usbserial.ko的,请问还有什么地方有问题的?高手,帮帮忙。
回复
sung_june 2015-08-18
引用 7 楼 mjjackey 的回复:
[quote=引用 6 楼 linglongqiongge 的回复:] 你的开发板用的什么的版本的内核 你编译的驱动和你开发板的内核版本是一致的吗
是Linux3.3,编译的驱动也是用Linux3.3的内核编译的。[/quote] file 一下你编译出来的驱动文件,看看信息,然后把makefile的关键部分都粘贴出来看看
回复
zhxianbin 2015-08-18
你这里面有错误啊
WARNING: "find_first_bit" [drivers/usb/serial/usbserial.ko] undefined!
WARNING: "_copy_from_user" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "copy_to_user" [drivers/usb/serial/usb_wwan.ko] undefined!
WARNING: "current_task" [drivers/usb/serial/pl2303.ko] undefined!
WARNING: "copy_to_user" [drivers/usb/serial/pl2303.ko] undefined!
WARNING: "find_next_bit" [drivers/usb/serial/option.ko] undefined!
WARNING: "find_first_bit" [drivers/usb/serial/option.ko] undefined!
驱动其实我也不熟
回复
Frog1228 2015-08-18
引用 6 楼 linglongqiongge 的回复:
你的开发板用的什么的版本的内核 你编译的驱动和你开发板的内核版本是一致的吗
是Linux3.3,编译的驱动也是用Linux3.3的内核编译的。
回复
sung_june 2015-08-18
你的开发板用的什么的版本的内核 你编译的驱动和你开发板的内核版本是一致的吗
回复
zhxianbin 2015-08-17
引用 2 楼 mjjackey 的回复:
[quote=引用 1 楼 zhxianbin 的回复:] 你在板子上用,自然要交叉编译,修改 makefile 的 CROSS_COMPILE
默认用的是内核代码顶层自带的makefile,是把这句交叉编译加到这个makefile里,还是自己再重新弄个?谢谢![/quote] 修改 makefile 里的 CROSS_COMPILE 变量,自己先看下就明白说什么了, 网上关于交叉编译的资料太多了
回复
Frog1228 2015-08-17
引用 1 楼 zhxianbin 的回复:
你在板子上用,自然要交叉编译,修改 makefile 的 CROSS_COMPILE
默认用的是内核代码顶层自带的makefile,是把这句交叉编译加到这个makefile里,还是自己再重新弄个?谢谢!
回复
zhxianbin 2015-08-17
你在板子上用,自然要交叉编译,修改 makefile 的 CROSS_COMPILE
回复
相关推荐
发帖
Linux_Kernel
创建于2007-08-27

4148

社区成员

Linux/Unix社区 内核源代码研究区
申请成为版主
帖子事件
创建了帖子
2015-08-17 04:45
社区公告
暂无公告