usb驱动与网络故障

110 篇文章 8 订阅

2007-06-19 15:23
自从我上周五开始调试usb,我的网络开始变得很糟糕,今天才发现网络故障与usb的关系:
我的系统里面开启了usb的功能,然后插上U盘之后,我的PC机就不能ping通局域网络上面任何一台机器了.

为了查清楚到底是因为我一插上U盘,网络就会坏掉,还是因为我插上U盘,运行的程序引起的网络变坏,我就将Linux中的usb功能禁止掉,编译,运行,这个时候插上U盘,观察网络良好,( 刚刚写良好,网络就变坏,:<),现在只能说网络变坏的时间需要很长;

后来干脆就不插usb盘,程序运行一定时间网络一样变坏

然后我就只上电,只有bootloader在跑,看看情况如何?(待观察),结果是网络一直很好,是不是现在麻烦了,估计是系统其他地方引起的网络问题,

如果Linux中开启usb功能,一插入U盘,网络会马上变坏,所以我认为应该马上查查看插上U盘之后,程序做了什么动作?

此时插入U盘,出现:
# usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
ub(1.2): Error at GetMaxLUN (-2)

然后拔出U盘,出现
# usb 1-1: USB disconnect, address 2
再次插入U盘,提示:
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
ub(1.3): Error at GetMaxLUN (-2)

这个错误出在drivers/usb/core/message.c

在修改FAT文件系统的字符集之后(由 (437) Default codepage for FAT   437->936),提示是:
usb 1-1: new full speed USB device using adm5120-hcd and address 2
adm5120-hcd adm5120-hcd: Unlink after no-IRQ? Controller is probably using the wrong IRQ.
usb 1-1: device descriptor read/64, error -145
usb 1-1: device descriptor read/64, error -145

# usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: device descriptor read/64, error -145

# usb 1-1: device descriptor read/64, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 4
这个错误出在./drivers/usb/core/hub.c: 文件中

将字符集437,iso8859-1,等编译进内核,然后插入usb,出现如下信息:
usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: can't set config #1, error -145

将选项Device Drivers ---> Block device-> < > Low Performance USB Block driver 去掉,出现
restore exit: isCheckpointed 0
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: device firmware changed
usb 1-1: USB disconnect, address 2
usb-storage: device scan complete
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
Vendor: Generic   Model: Flash Disk        Rev: %z!Y
Type:   Direct-Access                      ANSI SCSI revision: 02
1:0:0:0: Attached scsi generic sg0 type 0
usb-storage: device scan complete
VFS: Mounted root (yaffs2 filesystem).
Freeing unused kernel memory: 128k freed

加入usb filesystem的支持,变成这样了:
adm5120-hcd adm5120-hcd: adm5120-hcd
adm5120-hcd adm5120-hcd: new USB bus registered, assigned bus number 1
adm5120-hcd adm5120-hcd: irq 3, io base 0x11200000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
restore entry: isCheckpointed 0
found no more checkpt blocks
checkpoint byte count 0
restore exit: isCheckpointed 0
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: device firmware changed
usb 1-1: USB disconnect, address 2
usb-storage: device scan complete
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: string descriptor 0 read error: -22
usb 1-1: string descriptor 0 read error: -22
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
usb 1-1: reset full speed USB device using adm5120-hcd and address 3
Vendor: Generic   Model: Flash Disk        Rev: %z!Y
Type:   Direct-Access                      ANSI SCSI revision: 02
1:0:0:0: Attached scsi generic sg0 type 0
usb-storage: device scan complete

2007/06/18:
今天早上来,重新启动机器,插入我的U盘显示:
# usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
Vendor: Netac     Model: OnlyDisk          Rev: 1.00
Type:   Direct-Access                      ANSI SCSI revision: 02
0:0:0:0: Attached scsi generic sg0 type 0
usb-storage: device scan complete

然后,到目录:/proc/usb_storage/0
# cat 0
   Host scsi0: usb-storage
       Vendor: Netac
      Product: USB Flash Disk
Serial Number: B615CA7D52BD2E4C
     Protocol: Transparent SCSI
    Transport: Bulk
       Quirks:
规律总结:
插入U盘,系统开始识别U盘:
usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usb 1-1: reset full speed USB device using adm5120-hcd and address 2
usb 1-1: device firmware changed
usb 1-1: USB disconnect, address 2
usb-storage: device scan complete
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage:  waiting for device to settle before scanning    (anna:这个不成功会一直找,直到成功扫描)
usb 1-1: reset full speed USB device using adm5120-hcd and address 3
Vendor: Netac     Model: OnlyDisk          Rev: 1.00
Type:   Direct-Access                      ANSI SCSI revision: 02
1:0:0:0: Attached scsi generic sg0 type 0
usb-storage: device scan complete
直到成功,然后
现在将usb文件系统挂载上来
mount -t usbfs none /proc/bus/usb
cd /proc/bus/usb
# ls
001      devices
# cat devices

T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.17.11-adm5120 adm5120-hcd
S: Product=adm5120-hcd
S: SerialNumber=adm5120-hcd
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0dd8 ProdID=0c00 Rev= 1.00
S: Manufacturer=Netac
S: Product=USB Flash Disk
S: SerialNumber=B615CA7D52BD2E4C
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
#
这些表明系统已经识别了usb信息了,感觉应该可以挂载usb设备了,可是在/dev下面挂载sda,sda1,等不起作用,再自己建一个设备节点:
mknod /dev/ub0 b 180 0
mknod /dev/ub1 b 181 1
再次挂载还是不行;郁闷;

加入scsi disk support支持,加上

hub 1-0:1.0: state 7 ports 2 chg 0000 evt 0002
hub 1-0:1.0: port 1, status 0101, change 0001, 12 Mb/s
hub 1-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x101
usb 1-1: new full speed USB device using adm5120-hcd and address 2
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: Unlink after no-IRQ? Controller is probably using the wrong IRQ.
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
usb 1-1: device descriptor read/64, error -145
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
usb 1-1: device descriptor read/64, error -145
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: ed: A2B72700, ed->ep: 823D1034, ep: 823D1034
adm5120-hcd adm5120-hcd: Freeing ED: A2B72700
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: Hosthead empty!
usb 1-1: new full speed USB device using adm5120-hcd and address 3
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
usb 1-1: device descriptor read/64, error -145
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A1C00F80, data_len: 64
adm5120-hcd adm5120-hcd: 3 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 81C00F80
usb 1-1: khubd timed out on ep0in len=0/64
usb 1-1: device descriptor read/64, error -145
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: ed: A2B72400, ed->ep: 823D1034, ep: 823D1034
adm5120-hcd adm5120-hcd: Freeing ED: A2B72400
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: Hosthead empty!
usb 1-1: new full speed USB device using adm5120-hcd and address 4
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A0000000, data_len: 0
adm5120-hcd adm5120-hcd: 2 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 0
usb 1-1: khubd timed out on ep0out len=0/0
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A0000000, data_len: 0
adm5120-hcd adm5120-hcd: 2 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 0
usb 1-1: khubd timed out on ep0out len=0/0
usb 1-1: device not accepting address 4, error -145
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: ed: A2B72A00, ed->ep: 823D1034, ep: 823D1034
adm5120-hcd adm5120-hcd: Freeing ED: A2B72A00
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: Hosthead empty!
usb 1-1: new full speed USB device using adm5120-hcd and address 5
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A0000000, data_len: 0
adm5120-hcd adm5120-hcd: 2 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 0
usb 1-1: khubd timed out on ep0out len=0/0
adm5120-hcd adm5120-hcd: urb_enqueue: 0
adm5120-hcd adm5120-hcd: data pointer: A0000000, data_len: 0
adm5120-hcd adm5120-hcd: 2 control TDs filled
adm5120-hcd adm5120-hcd: urb_dequeue: data 0
usb 1-1: khubd timed out on ep0out len=0/0
usb 1-1: device not accepting address 5, error -145
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: ed: A2B72300, ed->ep: 823D1034, ep: 823D1034
adm5120-hcd adm5120-hcd: Freeing ED: A2B72300
adm5120-hcd adm5120-hcd: endpoint_disable: 0
adm5120-hcd adm5120-hcd: Hosthead empty!
hub 1-0:1.0: state 7 ports 2 chg 0000 evt 0002
hub 1-0:1.0: port 1 enable change, status 000001

以上信息是打开了输出debug信息。

再次试着将我的系统里的/dev/sda,sda1... ; /dev/sdb,sdb1...; /dev/sdc,sdc1...等,然后再次插入我的U盘,然后查看/proc/patitions下面,居然看见有
90 0/mtdblock0
90 2/mtdblock1
90 4/mtdblock2
8 0/sda
8 1/sda1
这个进步可不小,发现这里面的主设备号却是8,我之前一直以为是180,
于是我在/dev下面建立usb的设备节点
mknod /dev/sda b 8 0
mknod /dev/sda1 b 8 1
现在可以mount了,
mount -t vfat -o iocharset=cp936 /dev/sda1 /mnt
挂载成功,进入/mnt可以看到U盘里面的内容了!

现在比较郁闷的问题是,并不是每一次我的U盘插上去可以正确识别:
且经常出现这种问题:
现象一:
usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: unable to read config index 0 descriptor/all
usb 1-1: can't read configurations, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: device descriptor read/64, error -145
usb 1-1: device descriptor read/64, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 4
usb 1-1: device not accepting address 4, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 5
usb 1-1: device not accepting address 5, error -145
拔出,无显示,再次插入:
usb 1-1: new full speed USB device using adm5120-hcd and address 6
usb 1-1: unable to read config index 0 descriptor/start
usb 1-1: can't read configurations, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 7
usb 1-1: device descriptor read/64, error -145
usb 1-1: device descriptor read/64, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 8
usb 1-1: device not accepting address 8, error -145
usb 1-1: new full speed USB device using adm5120-hcd and address 9
usb 1-1: device not accepting address 9, error -145
现象二:
# usb 1-1: new full speed USB device using adm5120-hcd and address 2
usb 1-1: string descriptor 0 read error: -145
usb 1-1: string descriptor 0 read error: -145
usb 1-1: string descriptor 0 read error: -145
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: can't set config #1, error -145
拔出,显示:
usb 1-1: USB disconnect, address 2
再次插入:
usb 1-1: USB disconnect, address 2
usb 1-1: new full speed USB device using adm5120-hcd and address 3
usb 1-1: string descriptor 0 read error: -145
usb 1-1: string descriptor 0 read error: -145
usb 1-1: string descriptor 0 read error: -145
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: can't set config #1, error -145

查找错误类型:以上错误有2种类型,第一为-22,第二为-145,
在include/asm-generic/errno-base.h中定义
#define EINVAL          22      /* Invalid argument */
在include/asm-mips/errno.h中定义
#define ETIMEDOUT       145     /* Connection timed out */

先看看第一中错误:
在./drivers/usb/core/message.c: 中找到 "string descriptor 0 read error: %d\n",

int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
...
            "string descriptor 0 read error: %d\n",
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值