# unstable compact flash and SD

## Cypher0117

I'm hoping someone can shed some light on my situation i've been having for quite some time now.

I have an internal multimedia reader which works fin in windows but when i am running my gentoo install my SD and CF are unstable.  They unmount/mount themselves all the time.  Sometimes i can copy 10 files, and other times i can't even copy 1 file before it unmounts itself.  

I don't know what type of information you need to help out:

I'm running kernel 2.6.27

----------

## NeddySeagoon

Cypher0117,

If its a USB device, please post your /proc/bus/usb/devices.

if its a PCI device, post the output of lspci

Copy files until it fails then post the last 50 lines or so of dmesg.  

```
dmesg | tail -n 50
```

----------

## Cypher0117

```
dmesg | tail -n 50

[  501.171419] usb-storage: -- transfer complete

[  501.171423] usb-storage: Bulk data transfer result 0x0

[  501.171427] usb-storage: Attempting to get CSW...

[  501.171431] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[  501.171536] usb-storage: Status code 0; transferred 13/13

[  501.171540] usb-storage: -- transfer complete

[  501.171543] usb-storage: Bulk status result = 0

[  501.171548] usb-storage: Bulk Status S 0x53425355 T 0x146 R 0 Stat 0x0

[  501.171553] usb-storage: -- Result from auto-sense is 0

[  501.171557] usb-storage: -- code: 0xf0, key: 0x2, ASC: 0x3a, ASCQ: 0x0

[  501.171563] usb-storage: Not Ready: Medium not present

[  501.171568] usb-storage: scsi cmd done, result=0x2

[  501.171574] usb-storage: *** thread sleeping.

[  501.171587] usb-storage: queuecommand called

[  501.171595] usb-storage: *** thread awakened.

[  501.171599] usb-storage: Command TEST_UNIT_READY (6 bytes)

[  501.171602] usb-storage:  00 00 00 00 00 00

[  501.171612] usb-storage: Bulk Command S 0x43425355 T 0x147 L 0 F 0 Trg 0 LUN 0 CL 6

[  501.171617] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes

[  501.171662] usb-storage: Status code 0; transferred 31/31

[  501.171665] usb-storage: -- transfer complete

[  501.171669] usb-storage: Bulk command transfer result=0

[  501.171672] usb-storage: Attempting to get CSW...

[  501.171676] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[  501.171916] usb-storage: Status code 0; transferred 13/13

[  501.171920] usb-storage: -- transfer complete

[  501.171924] usb-storage: Bulk status result = 0

[  501.171928] usb-storage: Bulk Status S 0x53425355 T 0x147 R 0 Stat 0x1

[  501.171933] usb-storage: -- transport indicates command failure

[  501.171936] usb-storage: Issuing auto-REQUEST_SENSE

[  501.171942] usb-storage: Bulk Command S 0x43425355 T 0x148 L 18 F 128 Trg 0 LUN 0 CL 6

[  501.171947] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes

[  501.172042] usb-storage: Status code 0; transferred 31/31

[  501.172046] usb-storage: -- transfer complete

[  501.172049] usb-storage: Bulk command transfer result=0

[  501.172054] usb-storage: usb_stor_bulk_transfer_sglist: xfer 18 bytes, 1 entries

[  501.172173] usb-storage: Status code 0; transferred 18/18

[  501.172177] usb-storage: -- transfer complete

[  501.172181] usb-storage: Bulk data transfer result 0x0

[  501.172184] usb-storage: Attempting to get CSW...

[  501.172188] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[  501.172297] usb-storage: Status code 0; transferred 13/13

[  501.172300] usb-storage: -- transfer complete

[  501.172304] usb-storage: Bulk status result = 0

[  501.172309] usb-storage: Bulk Status S 0x53425355 T 0x148 R 0 Stat 0x0

[  501.172313] usb-storage: -- Result from auto-sense is 0

[  501.172318] usb-storage: -- code: 0xf0, key: 0x2, ASC: 0x3a, ASCQ: 0x0

[  501.172323] usb-storage: Not Ready: Medium not present

[  501.172328] usb-storage: scsi cmd done, result=0x2

[  501.172334] usb-storage: *** thread sleeping.

cat /proc/bus/usb/devices 

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh=10

B:  Alloc= 42/900 us ( 5%), #Int=  4, #Iso=  0

D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=1d6b ProdID=0001 Rev= 2.06

S:  Manufacturer=Linux 2.6.27-gentoo-r7 ohci_hcd

S:  Product=OHCI Host Controller

S:  SerialNumber=0000:00:02.0

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=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=1.5 MxCh= 0

D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1

P:  Vendor=0d62 ProdID=0171 Rev= 1.04

S:  Manufacturer=Generic

S:  Product=Wired USB Keyboard

C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid

E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=24ms

I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=48ms

T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  3 Spd=12  MxCh= 0

D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1

P:  Vendor=046d ProdID=c51a Rev=41.01

S:  Manufacturer=Logitech

S:  Product=USB Receiver

C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr= 98mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid

E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=1ms

I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=1ms

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh=10

B:  Alloc=  0/800 us ( 0%), #Int=  1, #Iso=  0

D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=1d6b ProdID=0002 Rev= 2.06

S:  Manufacturer=Linux 2.6.27-gentoo-r7 ehci_hcd

S:  Product=EHCI Host Controller

S:  SerialNumber=0000:00:02.1

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=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#=  4 Spd=480 MxCh= 0

D:  Ver= 2.00 Cls=ef(unk. ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1

P:  Vendor=046d ProdID=0992 Rev= 0.05

S:  SerialNumber=60CA0AE3

C:* #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA

A:  FirstIf#= 0 IfCount= 2 Cls=0e(video) Sub=03 Prot=00

A:  FirstIf#= 2 IfCount= 2 Cls=01(audio) Sub=02 Prot=00

I:* If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo

E:  Ad=87(I) Atr=03(Int.) MxPS=  16 Ivl=16ms

I:* If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

I:  If#= 1 Alt= 1 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 192 Ivl=125us

I:  If#= 1 Alt= 2 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 384 Ivl=125us

I:  If#= 1 Alt= 3 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 512 Ivl=125us

I:  If#= 1 Alt= 4 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 640 Ivl=125us

I:  If#= 1 Alt= 5 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 800 Ivl=125us

I:  If#= 1 Alt= 6 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS= 944 Ivl=125us

I:  If#= 1 Alt= 7 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS=1280 Ivl=125us

I:  If#= 1 Alt= 8 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS=1600 Ivl=125us

I:  If#= 1 Alt= 9 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS=1984 Ivl=125us

I:  If#= 1 Alt=10 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS=2688 Ivl=125us

I:  If#= 1 Alt=11 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

E:  Ad=81(I) Atr=05(Isoc) MxPS=3060 Ivl=125us

I:* If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio

I:* If#= 3 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio

I:  If#= 3 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio

E:  Ad=86(I) Atr=05(Isoc) MxPS=  68 Ivl=1ms

T:  Bus=01 Lev=01 Prnt=01 Port=06 Cnt=02 Dev#= 10 Spd=480 MxCh= 0

D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=058f ProdID=6362 Rev= 1.29

S:  Manufacturer=Generic

S:  Product=Mass Storage Device

S:  SerialNumber=058F312D81B

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=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

```

----------

## NeddySeagoon

Cypher0117,

You have some USB debugging on. 

```
[  501.171419] usb-storage: -- transfer complete

[  501.171423] usb-storage: Bulk data transfer result 0x0

[  501.171427] usb-storage: Attempting to get CSW...

[  501.171431] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

[  501.171536] usb-storage: Status code 0; transferred 13/13 
```

Some debug options interfere with proper device operation.

Rebuild you kernel with all the debug options off, unless you are doing kernel development. 

You have another USB problem too.  Each root hub can provide a maximum of 500mA for all connected devices.

Your webcam and USB drive are on the same root hub.

The webcam needs 500mA, so it needs a root hub to itself and your drive needs a further 100mA.

The over current trips are fairly good, so if you use your webcam and drive at the same time I would expect them both to cycle, as the overcurrent trip cycles. 

```
emerge usbview
```

to see the details.

You only have two USB root hubs and you must separate USB 1 and USB 2 devices or all devices run at USB 1 speeds.

Fix your kernel and connect either the webcam or the USB drive - not both at the same time, or invest in a *powered* USB hub, which will prove 500mA for all sockets, that overcomes the power issue.

----------

## Cypher0117

I unplugged my usb webcam and everything started to work.  I copied 1.6GB of pictures off of my CF card without a problem.  

One question I have now is, can I set my webcam to be on its own root usb hub and my keyboard, mouse, card reader on the other hub so i don't have to keep unplugging my webcam?

----------

## NeddySeagoon

Cypher0117,

The webcam needs to be on its own root hub to satisfy the 500mA requirement.

Your USB hard drive is USB 2 but your mouse and keyboard are USB 1 devices.

You can connect them all to the same root hub and satisfy the 500mA limit but your hard drive will fall back to USB 1 speed.

Thats 40x slower than USB 2. you won't like that.

As you only have two root hubs, the only way to plug in everything and maintain the speed is to use a powered USB2 hub.

This will draw little or no power from the computer and provide 500mA for the webcam and 100mA for the drive from its own PSU.

If you don't want an external USB2 hub, you can get a plug in USB PCI card to add more root hubs to your system. 

If you rebuild your kernel with the USB debugging off, data transfers will be faster. That won't help your power issues though.

----------

## Cypher0117

NeddySeagoon-

thanks for all your help.  I found a USB2.0 pci card in my box of old computer parts, plugged that in and plugged my webcam into it.  I can now use my multireader with everything plugged in.  

I was doing a few speed tests, and i was wondering if ~2MB/s is typical for a 4GB 45X CF card, ~4.5MB/s is typical for my usb flash drive, and ~3MB/s for my SD.  I disabled USB debugging in my kernel (unless there is more than one place i can select it [Device Drivers --> USB Support --> USB verbose debug messages]).  My firewire external hard drive runs at ~30MB/s and i thought that USB 2.0 was supposed to be close to that.

Thanks

----------

## NeddySeagoon

Cypher0117,

There is lots of USB debug options. Check your dmesg. It should be silent when USB is in use.

The speed of FLASH memory data transfers is not limited by USB2 data rates but I don't know how fast various cards go.

From the speeds you have, (over 1Mb) you are not mixing USB1 and USB2 devices on the same root hub.

Its as well to look with usbview.

EHCI Host Controllers should only have USB2 devices attached. The top device details will be 

```
Mass Storage Device

Manufacturer: Generic

Serial Number: 058F312D81B

Speed: 480Mb/s (high) *****

USB Version:  2.00 ***
```

 for each selected device.

Thats from my card reader.

----------

## Cypher0117

Thanks for all your help. 

I got all the dbug options out of my kernel for usb and it seems to be working great.

----------

