Linux USB恐怖

Linux USB恐怖,linux,linux-kernel,usb,Linux,Linux Kernel,Usb,我已经写了一个程序,它在安装的USB设备上创建一个文件。这可以通过RS232连接使用基于文本的UI来完成。然而,似乎有什么不对劲。1/5次,写入USB设备的整个过程失败,我得到以下结果: 显然发生了I/O错误,内核决定卸载设备并再次检测它。知道问题出在哪里吗? 此错误不取决于正在使用的USB设备,因为我能够使用多个不同的USB设备重现此错误 我不确定这个问题是否属于stackoverflow。如果没有,请随意移动它 编辑:该设备正在运行Linux 2.6.24.6 编辑: 我刚刚发现了一个非常

我已经写了一个程序,它在安装的USB设备上创建一个文件。这可以通过RS232连接使用基于文本的UI来完成。然而,似乎有什么不对劲。1/5次,写入USB设备的整个过程失败,我得到以下结果:

显然发生了I/O错误,内核决定卸载设备并再次检测它。知道问题出在哪里吗? 此错误不取决于正在使用的USB设备,因为我能够使用多个不同的USB设备重现此错误

我不确定这个问题是否属于stackoverflow。如果没有,请随意移动它

编辑:该设备正在运行Linux 2.6.24.6

编辑:

我刚刚发现了一个非常有趣的行为。我将U盘连接到设备,并使用以下命令创建了一个大目录的tar:

tar -cvf test.tar ./test_directory
目录位于sd卡上,即位于完全不同的文件系统上。但是,在创建存档时,会发生多个USB断开和USB连接事件:

--> start creating archive



/tmp # 
[74901.704258] usb 2-1: new high speed USB device using fsl-ehci and address 18
[74901.914427] usb 2-1: configuration #1 chosen from 1 choice
[74902.020174] scsi18 : SCSI emulation for USB Mass Storage devices
[74904.147779] usb 2-1: USB disconnect, address 18
[74904.573424] usb 2-1: new high speed USB device using fsl-ehci and address 19
[74904.785303] usb 2-1: configuration #1 chosen from 1 choice
[74904.891860] scsi19 : SCSI emulation for USB Mass Storage devices
[74907.748285] usb 2-1: USB disconnect, address 19
[74908.063438] usb 2-1: new high speed USB device using fsl-ehci and address 20
[74908.264751] usb 2-1: configuration #1 chosen from 1 choice
[74908.311019] scsi20 : SCSI emulation for USB Mass Storage devices
[74909.470917] usb 2-1: USB disconnect, address 20
[74909.783331] usb 2-1: new high speed USB device using fsl-ehci and address 21
[74909.983410] usb 2-1: configuration #1 chosen from 1 choice
[74910.031500] scsi21 : SCSI emulation for USB Mass Storage devices
[74915.106340] scsi 21:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[74915.184964] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.235993] sd 21:0:0:0: [sda] Write Protect is off
[74915.275597] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.330972] sd 21:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74915.379568] sd 21:0:0:0: [sda] Write Protect is off
[74915.411428] sd 21:0:0:0: [sda] Assuming drive cache: write through
[74915.457712]  sda: sda1
[74915.771348] sd 21:0:0:0: [sda] Attached SCSI removable disk
[74915.805114] sd 21:0:0:0: Attached scsi generic sg0 type 0
[74923.462332] usb 2-1: USB disconnect, address 21
[74924.484001] usb 2-1: new high speed USB device using fsl-ehci and address 22
[74924.702678] usb 2-1: configuration #1 chosen from 1 choice
[74924.798064] scsi22 : SCSI emulation for USB Mass Storage devices
[74929.855161] scsi 22:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[74929.951158] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.001646] sd 22:0:0:0: [sda] Write Protect is off
[74930.034424] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.077218] sd 22:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74930.131909] sd 22:0:0:0: [sda] Write Protect is off
[74930.166881] sd 22:0:0:0: [sda] Assuming drive cache: write through
[74930.208044]  sda: sda1
[74930.260520] sd 22:0:0:0: [sda] Attached SCSI removable disk
[74930.303588] sd 22:0:0:0: Attached scsi generic sg0 type 0
[74931.951336] usb 2-1: USB disconnect, address 22
[74932.272609] usb 2-1: new high speed USB device using fsl-ehci and address 23
[74932.483821] usb 2-1: configuration #1 chosen from 1 choice
[74932.569866] scsi23 : SCSI emulation for USB Mass Storage devices
[74936.434380] usb 2-1: USB disconnect, address 23
[74936.754210] usb 2-1: new high speed USB device using fsl-ehci and address 24
[74937.751966] usb 2-1: configuration #1 chosen from 1 choice
[74937.820607] scsi24 : SCSI emulation for USB Mass Storage devices
[74942.887336] scsi 24:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[74942.958666] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.004909] sd 24:0:0:0: [sda] Write Protect is off
[74943.044027] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.101958] sd 24:0:0:0: [sda] 7884800 512-byte hardware sectors (4037 MB)
[74943.147503] sd 24:0:0:0: [sda] Write Protect is off
[74943.190786] sd 24:0:0:0: [sda] Assuming drive cache: write through
[74943.230368]  sda: sda1
[74943.258203] sd 24:0:0:0: [sda] Attached SCSI removable disk
[74943.314301] sd 24:0:0:0: Attached scsi generic sg0 type 0

我要为这个问题创建一个新的线程

I/O错误和目录面包消息在损坏的文件系统上是典型的,通常可以用fsck工具修复。 在修复文件系统之后,我建议您检查在写入操作中间没有中断连接。由于您的问题可以在多个USB设备上重现,我将首先检查RS232/USB接口

显然发生了I/O错误,内核决定卸载设备并再次检测它

很可能是另一种情况:设备被USB子系统移除,并且由于设备仍在安装中而导致错误

这看起来像是硬件问题—AFAIK设备检测和删除是在主机控制器或集线器的硬件中完成的。检查电缆和连接,包括焊接连接


用示波器查看USB上的+5伏电压也很有价值-电压可能在几毫秒内超出规格,导致USB复位。

该问题发生在4个不同的USB设备上。fsck说一切都很干净。我甚至用零缓慢格式化了一个USB设备覆盖,但没有用。有可能在那里更新内核吗?@AndyShevchenko我在某处读到,这个特定的内核版本可能与USB设备有问题。我不确定我们是否能够更新它though@AndyShevchenko无法更新整个内核。但是我们可以更新一些驱动程序。我怀疑你可能会在不更新内核的情况下更新USB子系统。对不起,在你的情况下帮不上忙。正确。在调查了电路板上的布局后,我发现两条导线彼此非常接近。其中一个连接到USB端口,另一个连接到SD卡。所以很明显,在向USB写入数据时会发生串扰。在这些导线之间添加接地层后,问题得到解决!