gpt4 book ai didi

Linux USB 恐怖

转载 作者:太空宇宙 更新时间:2023-11-04 03:45:20 24 4
gpt4 key购买 nike

我编写了一个程序,它在已安装的 USB 设备上创建一个文件。这可以通过 RS232 连接使用基于文本的 UI 来完成。然而,似乎有些不对劲。 5 次中有 1 次,写入 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

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

最佳答案

Apparently an I/O error occurred and the kernel decided to unmount the device and detect it again.

很可能是相反的情况:设备被删除(由 USB 子系统)并导致错误,因为它仍然挂载。

对我来说,这看起来像是硬件问题 - 据我所知,设备检测和删除是在主机 Controller 或集线器的硬件中完成的。检查电缆和连接,包括焊接连接。

使用示波器查看 USB 上的 +5 伏电压也可能很有值(value) - 电压可能会超出规范几毫秒,从而导致 USB 重置。

关于Linux USB 恐怖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28405509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com