我正在使用ftdi_sio驱动程序v1.4.3中的gentoo-2.6.30中的ftdichip调制解调器处理短信相关程序。但是现在我遇到了一个奇怪的情况:当OS启动时,我的程序将尝试无限制地打开/ dev / ttyUSB0,直到它成功(由于编码时没有考虑到正确),然后插入我的USB串口调制解调器,一个错误消息将立即显示与dmesg,如果我拔掉调制解调器,系统将没有响应。
BUG消息是:
[ 43.769794] BUG: unable to handle kernel NULL pointer dereference at 00000074
[ 43.775687] IP: [<405829ba>] _spin_lock_irqsave+0x8/0x1a
[ 43.775687] *pdpt = 000000009ad51001 <6>usb 2-2: Detected FT232BM
[ 43.785760] usb 2-2: FTDI USB Serial Device converter now attached to ttyUSB0
[ 43.785840] drivers/usb/core/inode.c: creating file '002'
[ 43.785686] *pde = 0000000000000000
[ 43.785686] Oops: 0002 [#1] SMP
[ 43.785686] last sysfs file:
[ 43.785686] Modules linked in: ixgbe igb dca e1000e e1000
[ 43.785686]
[ 43.785686] Pid: 1059, comm: smssp.orig Not tainted (2.6.30-gentoo-r8 #24) AM5400B
[ 43.785686] EIP: 0060:[<405829ba>] EFLAGS: 00010046 CPU: 1
[ 43.785686] EIP is at _spin_lock_irqsave+0x8/0x1a
[ 43.785686] EAX: 00000074 EBX: 00000074 ECX: 00000246 EDX: 00000100
[ 43.785686] ESI: dade8400 EDI: 00000000 EBP: d903ba00 ESP: da43be28
[ 43.785686] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 43.785686] Process smssp.orig (pid: 1059, ti=da43a000 task=dad6f710 task.ti=da43a000)
[ 43.785686] Stack:
[ 43.785686] 4047d5c8 da5f3000 4045bbb5 4073d460 d903ba00 d9001340 dade8400 404799fd
[ 43.785686] d88bfb40 d9001378 d903bad0 d903ba58 d903ba04 da652300 dade8400 d88bfb40
[ 43.785686] dade8400 4035d144 da8e48a8 00000000 00000902 00000100 0bc00000 00000000
[ 43.785686] Call Trace:
[ 43.785686] [<4047d5c8>] ? ftdi_open+0x42/0x1a1
[ 43.785686] [<4045bbb5>] ? usb_autopm_do_interface+0x9a/0xa1
[ 43.785686] [<404799fd>] ? serial_open+0x112/0x189
[ 43.785686] [<4035d144>] ? tty_open+0x27b/0x3a9
[ 43.785686] [<40293524>] ? chrdev_open+0x128/0x152
[ 43.785686] [<402a198c>] ? mntput_no_expire+0x12/0xe0
[ 43.785686] [<402933fc>] ? chrdev_open+0x0/0x152
[ 43.785686] [<4028f5dd>] ? __dentry_open+0x113/0x1e9
[ 43.785686] [<40290413>] ? nameidata_to_filp+0x29/0x3c
[ 43.785686] [<40299ac4>] ? do_filp_open+0x3ab/0x689
[ 43.785686] [<4025d5bb>] ? __rcu_process_callbacks+0x57/0x159
[ 43.785686] [<40236d6a>] ? autoremove_wake_function+0x0/0x2d
[ 43.785686] [<402a05ff>] ? alloc_fd+0x5e/0xd0
[ 43.785686] [<4028f3ea>] ? do_sys_open+0x44/0xb4
[ 43.785686] [<4028f49e>] ? sys_open+0x1e/0x23
[ 43.785686] [<40202964>] ? sysenter_do_call+0x12/0x22
[ 43.785686] Code: 74 05 e8 3e fe ff ff c3 fa f0 83 28 01 79 05 e8 4d fe ff ff c3 f0 81 00 00 00 00 01 fb c3 f0 ff 00 fb c3 9c 59 fa ba 00 01 00 00 <f0> 66 0f c1 10 38 f2 74 06 f3 90 8a 10 eb f6 89 c8 c3 9c 5a fa
[ 43.785686] EIP: [<405829ba>] _spin_lock_irqsave+0x8/0x1a SS:ESP 0068:da43be28
[ 43.785686] CR2: 0000000000000074
[ 43.785686] ---[ end trace b68e6189f2a3d267 ]---
[ 45.882827] hub 1-0:1.0: hub_suspend
[ 45.886552] usb usb1: bus auto-suspend
[ 45.890434] ehci_hcd 0000:00:1d.7: suspend root hub
这是我的等效重现测试程序:
/*
* =====================================================================================
* compile:
* gcc -g usb.c -o usb_sleep.exe -DSLEEP -D_GNU_SOURCE
* gcc -g usb.c -o usb.exe -D_GNU_SOURCE
*
* =====================================================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
int
main()
{
char *dev = "/dev/ttyUSB0";
//int fd = open(dev, O_RDONLY|O_LARGEFILE/* O_RDWR | O_NOCTTY | O_NONBLOCK */);
//int fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK);
int fd = open(dev, O_RDWR | O_NOCTTY | O_NDELAY);
while(fd < 0)
{
//fd = open(dev, O_RDONLY|O_LARGEFILE/* O_RDWR | O_NOCTTY | O_NONBLOCK */);
//fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK);
fd = open(dev, O_RDWR | O_NOCTTY | O_NDELAY);
#ifdef SLEEP
sleep(1);
#endif
}
printf("open tty ok!\n");
char buf[1024];
printf(buf, "at");
int ret = write(fd, buf, strlen(buf));
if(ret < 0){
printf("write error:%s\n", strerror(errno));
}
ret = read(fd, buf, sizeof(buf) - 1);
if(ret < 0){
printf("read error:%s\n", strerror(errno));
}
close(fd);
}
重现程序:1.insmod usbserial.ko ftdi_sio.ko 2.#。/ usb.exe运行我的测试程序3.plug USB调制解调器和dmesg关于ftdi_sio堆栈信息上面显示
奇怪的是,如果我使用其他usb_sleep.exe进行测试,堆栈信息不会发生,并打开ttyUSB0罚款
我已经在内核2.4.30的另一个盒子中进行了测试,它有ftdi_sio版本1.3.5,没有什么奇怪的事情发生。
我用Google搜索并试图找出它几天,没有找到任何有价值的东西。这是我在谷歌群组中找到的链接:http://groups.google.com/group/linux.kernel/browse_thread/thread/2c0c32a649006cf5/de263399cb0c38c9?show_docid=de263399cb0c38c9#,标题为“USB:ftdi_sio:修复回归2.6 .31并清理“,但我真的不知道它是否有帮助,因为我绝对是新的内核或驱动程序。
顺便说一句,我尝试用内核2.6.32.58中的较新版本1.5.0替换ftdi_sio驱动程序,但无法编译,错误消息列出如下:
drivers/usb/serial/ftdi_sio.o
drivers/usb/serial/ftdi_sio.c:931: warning: initialization from incompatible pointer type
drivers/usb/serial/ftdi_sio.c:932: warning: initialization from incompatible pointer type
drivers/usb/serial/ftdi_sio.c:933: error: unknown field ‘dtr_rts’ specified in initializer
drivers/usb/serial/ftdi_sio.c:933: warning: initialization from incompatible pointer type
drivers/usb/serial/ftdi_sio.c: In function ‘ftdi_process_packet’:
drivers/usb/serial/ftdi_sio.c:2219: error: implicit declaration of function ‘usb_serial_handle_break’
drivers/usb/serial/ftdi_sio.c:2235: error: ‘struct usb_serial_port’ has no member named ‘sysrq’
drivers/usb/serial/ftdi_sio.c:2239: error: implicit declaration of function ‘usb_serial_handle_sysrq_char’
make[3]: *** [drivers/usb/serial/ftdi_sio.o] Error 1
make[2]: *** [drivers/usb/serial] Error 2
make[1]: *** [drivers/usb] Error 2
make: *** [drivers] Error 2
我真的很沮丧,有没有其他人遇到过这个问题?是不是司机有问题?
任何有用的答复将不胜感激。
PSi在linux.kernel谷歌群组中发布了这个帖子,但我发布后没有找到我的帖子,所以我再次发布在这里。:(真诚的肯