Linux USB恐怖

时间:2015-02-09 08:24:36

标签: linux linux-kernel usb

我编写了一个程序,它在已安装的USB设备上创建了一个文件。这可以通过RS232连接使用基于文本的UI来完成。然而,似乎有些事情发生了。 1次5次,写入USB设备的整个过程失败,我得到以下内容: enter image description here

显然发生了I / O错误,内核决定卸载设备并再次检测到它。知道问题可能是什么? 此错误不依赖于正在使用的USB设备,因为我可以使用多个不同的USB设备重现此错误。

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

编辑:有问题的设备正在运行Linux 2.6.24.6

编辑:

我刚刚发现了一个非常有趣的行为。我将USB记忆棒连接到设备,并使用以下命令创建了一个大目录的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

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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

  

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

它可能反过来了:设备被移除(通过USB子系统)并导致错误,因为它仍然被挂载。

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

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