2015-02-09 185 views
0

我寫了一個程序,它在裝載的USB設備上創建一個文件。這可以通過RS232連接使用基於文本的UI完成。然而,似乎有些事情是關閉的。在5次1,寫入USB設備的全過程失敗,我得到如下: enter image description hereLinux USB恐怖

顯然發生I/O錯誤和內核決定卸載設備,並重新檢測它。任何想法可能是什麼問題? 此錯誤不依賴於正在使用的USB設備,因爲我能夠使用多個不同的USB設備重現此錯誤。

P.S .:我不確定這個問題是否屬於stackoverflow。如果沒有,請隨時移動它。

編輯:有問題的設備上運行Linux 2.6.24.6

編輯:

我剛剛發現一個非常有趣的現象。我連接USB棒的設備和創建使用命令大型目錄的焦油:

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 

我要創建一個新的線程這個問題!

+0

有沒有可能在那裏更新內核? – 0andriy 2015-02-09 13:19:58

+0

@AndyShevchenko我讀過某個地方,這個特定的內核版本可能與USB設備有問題。我不確定我們是否能夠更新它 – 2015-02-09 13:22:43

+0

@AndyShevchenko更新整個內核是不可能的。但我們可以更新一些驅動程序。 – 2015-02-09 13:28:56

回答

0

顯然發生I/O錯誤,內核決定卸載設備並再次檢測。

它可能是另一種方式:該設備被刪除(由USB子系統),並導致錯誤,因爲它仍然安裝。

這看起來像是一個硬件問題 - AFAIK設備檢測和刪除是在主機控制器或集線器的硬件中完成的。檢查電纜和連接,包括焊接連接。使用示波器觀察USB上的+5伏也是很有價值的 - 電壓可能會超出規格幾ms,從而導致USB復位。

+0

正確。在調查了電路板上的佈局之後,我發現2根電線彼此非常接近。其中一個連接到USB端口,另一個連接到SD卡。所以寫入USB時顯然會出現串擾。在這些電線之間添加接地層後,問題得到解決! – 2015-09-15 15:18:47

0

I/O錯誤和目錄麪包消息在損壞的文件系統上很常見,通常可以使用fsck工具修復。 修復文件系統後,我建議您檢查連接在寫操作過程中是否中斷。由於您的問題可以在多個USB設備上重現,因此我會首先檢查RS232/USB接口。

+0

該問題發生在4個不同的USB設備上。 'fsck'說一切都很乾淨。我甚至慢格式化USB設備(覆蓋零),但無濟於事。 – 2015-02-09 12:36:11