Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USB SDHC Card Reader works, but only if mounted first in VM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
paulbiz
Guru
Guru


Joined: 01 Feb 2004
Posts: 506
Location: St. Louis, Missouri, USA

PostPosted: Wed Jul 28, 2010 8:05 pm    Post subject: USB SDHC Card Reader works, but only if mounted first in VM Reply with quote

Hi,

I have a USB SDHC card reader whose partition table is not read, and device node not created, when plugged into my Gentoo Linux computer. I posted about this a year or two ago but was never able to get it working, until I recently made an accidental discovery:

If I let a VMWare WinXP take control of the USB device, on the same physical linux machine as above, the card reader mounts normally in the virtual WinXP. Then, if I release the USB device from VMware, Linux takes control of the device back and can read the partition table and creates the device node normally. After that everything works fine, I can copy files to/from etc. and everything seems normal.

I hope some usb/udev/something guru here can give me a pointer on where to begin tracking down the cause of this. Thanks. :) I have other card readers that work fine on this same computer, just this one reader is a pain. I've tried it on a couple other Gentoo machines and it behaves the same on all of them.

When I plug in the card reader, dmesg tells me this:
Code:
[1637793.709415] usb 2-4: new high speed USB device using ehci_hcd and address 22
[1637793.826139] usb 2-4: New USB device found, idVendor=090c, idProduct=6000
[1637793.826142] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1637793.826145] usb 2-4: Product: SM331AB CARD-READER
[1637793.826146] usb 2-4: Manufacturer: Silicon Motion,Inc.
[1637793.826148] usb 2-4: SerialNumber: 12345678901234567890
[1637793.826356] scsi38 : usb-storage 2-4:1.0
[1637799.870068] scsi 38:0:0:0: Direct-Access     6000 PQ: 0 ANSI: 0 CCS
[1637799.870187] sd 38:0:0:0: Attached scsi generic sg8 type 0
[1637799.871735] sd 38:0:0:0: [sdg] 62748672 512-byte logical blocks:
(32.1 GB/29.9 GiB)
[1637799.872307] sd 38:0:0:0: [sdg] Write Protect is off
[1637799.872309] sd 38:0:0:0: [sdg] Mode Sense: 4b 00 00 08
[1637799.872310] sd 38:0:0:0: [sdg] Assuming drive cache: write through
[1637799.874301] sd 38:0:0:0: [sdg] Assuming drive cache: write through
[1637799.874303]  sdg:
[1637800.005993] sd 38:0:0:0: [sdg] Result: hostbyte=0x00 driverbyte=0x08
[1637800.005996] sd 38:0:0:0: [sdg] Sense Key : 0x5 [current]
[1637800.005998] sd 38:0:0:0: [sdg] ASC=0x21 ASCQ=0x0
[1637800.006000] sd 38:0:0:0: [sdg] CDB: cdb[0]=0x28: 28 00 00 00 00 00 00 00 08 00
[1637800.006004] end_request: I/O error, dev sdg, sector 0
[1637800.006006] Buffer I/O error on device sdg, logical block 0
[1637800.006881] ldm_validate_partition_table(): Disk read failed.
[1637800.006883]  unable to read partition table
[1637800.008115] sd 38:0:0:0: [sdg] Assuming drive cache: write through
[1637800.008117] sd 38:0:0:0: [sdg] Attached SCSI removable disk


Despite dmesg saying unable to read partition table, fdisk -l /dev/sdg shows me the partition anyway (it is a 32GB SDHC card):
Code:
Disk /dev/sdg: 32.1 GB, 32127320064 bytes
236 heads, 42 sectors/track, 6330 cylinders, total 62748672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            8192    62748671    31370240    c  W95 FAT32 (LBA)



When I let VMware Workstation virtual WinXP session claim the USB device, it shows me this in dmesg when I plug it in:
Code:
[1639461.856033] usb 2-4: new high speed USB device using ehci_hcd and address 23
[1639461.972673] usb 2-4: New USB device found, idVendor=090c, idProduct=6000
[1639461.972676] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1639461.972679] usb 2-4: Product: SM331AB CARD-READER
[1639461.972680] usb 2-4: Manufacturer: Silicon Motion,Inc.
[1639461.972682] usb 2-4: SerialNumber: 12345678901234567890
[1639461.972956] scsi39 : usb-storage 2-4:1.0
[1639462.343346] usb 2-4: reset high speed USB device using ehci_hcd and address 23
[1639462.459687] scsi40 : usb-storage 2-4:1.0
[1639462.607973] usb 2-4: reset high speed USB device using ehci_hcd and address 23
[1639462.826673] usb 2-4: usbfs: interface 0 claimed by usb-storage while 'vmware-vmx' sets config #1
[1639462.826721] usb 2-4: usbfs: interface 0 claimed by usb-storage while 'vmware-vmx' sets config #1


And when I release the USB device from VMWare back to Linux, dmesg shows this:
Code:
[1639859.353550] scsi41 : usb-storage 2-4:1.0
[1639864.347499] scsi 41:0:0:0: Direct-Access      6000 PQ: 0 ANSI: 0 CCS
[1639864.347616] sd 41:0:0:0: Attached scsi generic sg8 type 0
[1639864.348239] sd 41:0:0:0: [sdg] 62748672 512-byte logical blocks: (32.1 GB/29.9 GiB)
[1639864.348757] sd 41:0:0:0: [sdg] Write Protect is off
[1639864.348759] sd 41:0:0:0: [sdg] Mode Sense: 4b 00 00 08
[1639864.348761] sd 41:0:0:0: [sdg] Assuming drive cache: write through
[1639864.350737] sd 41:0:0:0: [sdg] Assuming drive cache: write through
[1639864.350740]  sdg: sdg1
[1639864.354864] sd 41:0:0:0: [sdg] Assuming drive cache: write through
[1639864.354866] sd 41:0:0:0: [sdg] Attached SCSI removable disk


From this point the card reader works normally in Linux until I unplug it. Every time I plug it in I must use the above stated virtual WinXP workaround in order to use it.


The lsusb -v of this device:
Code:
Bus 002 Device 023: ID 090c:6000 Feiya Technology Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x090c Feiya Technology Corp.
  idProduct          0x6000
  bcdDevice            1.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk (Zip)
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255


From /proc/bus/usb/devices:
Code:
T:  Bus=02 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 23 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=090c ProdID=6000 Rev= 1.00
S:  Manufacturer=Silicon Motion,Inc.
S:  Product=SM331AB CARD-READER
S:  SerialNumber=12345678901234567890
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=31875us
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2381
Location: Wisconsin (USA)

PostPosted: Wed Jul 28, 2010 9:02 pm    Post subject: Reply with quote

As a workaround, use hdparm -z to re-read the partition table. Since you can read the device fine with fdisk, then probably either the device takes too long to be ready, or the first read just always fails due to a hardware or driver quirk.
Back to top
View user's profile Send private message
paulbiz
Guru
Guru


Joined: 01 Feb 2004
Posts: 506
Location: St. Louis, Missouri, USA

PostPosted: Wed Jul 28, 2010 9:10 pm    Post subject: Reply with quote

BradN wrote:
As a workaround, use hdparm -z to re-read the partition table. Since you can read the device fine with fdisk, then probably either the device takes too long to be ready, or the first read just always fails due to a hardware or driver quirk.


Thanks for the tip! I will try it when I get home from work tonight.
Back to top
View user's profile Send private message
paulbiz
Guru
Guru


Joined: 01 Feb 2004
Posts: 506
Location: St. Louis, Missouri, USA

PostPosted: Fri Jul 30, 2010 11:30 pm    Post subject: Reply with quote

hdparm -z did the trick, that's much easier than using a VM and really helps to narrow down the causes. Thanks!

Now I'll try to figure out the next step as far as patching the driver or something like this...
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2381
Location: Wisconsin (USA)

PostPosted: Fri Jul 30, 2010 11:43 pm    Post subject: Reply with quote

I did something similar to deal with a cd drive that caused errors ripping audio cd's that made linux drop to single frame DMA mode and also a promise IDE card that experienced DMA lockups making it shut off DMA after the 5th or so occurrence. It wasn't particularly hard, but it was a pain to keep patching each new kernel and the problems didn't bother me that much so I just gave up on it.
Back to top
View user's profile Send private message
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 461
Location: Sweden

PostPosted: Wed Dec 15, 2010 9:44 am    Post subject: Reply with quote

I just bought a new card reader for SD and SDHC cards that connects to my MOBO USB. I also have problems getting the SD and SDHC cards to be detected. The same card reader has a CF card slot and CF cards gets detected alright. So the card reader itself seems to work properly.

Do I need a special module in the kernel for reading SDHC cards?


My kernel:

Code:
# uname -a
Linux phils_pc 2.6.27-gentoo-r8 #3 SMP PREEMPT Sat Dec 5 17:05:24 CET 2009 i686 AMD Phenom(tm) 9550 Quad-Core Processor AuthenticAMD GNU/Linux

_________________
/Phil
Back to top
View user's profile Send private message
jblake20
n00b
n00b


Joined: 04 May 2006
Posts: 22

PostPosted: Tue Jan 11, 2011 4:24 am    Post subject: usb 2.0 card reader and SDHC Reply with quote

I am trying to my usb card reader to read an sdhc card

It sees the card reader and works fine with CF.

Want kernel options are needed to get the SDHC to work?

Thanks
Back to top
View user's profile Send private message
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 461
Location: Sweden

PostPosted: Thu Jan 27, 2011 3:22 pm    Post subject: Reply with quote

First make sure that your card reader is capable of reading SDHC cards. Older readers, reading SD cards only, do not have this capability.
I had to buy a new card reader to get my SDHC cards detected.
_________________
/Phil
Back to top
View user's profile Send private message
PeGa!
n00b
n00b


Joined: 13 May 2005
Posts: 62
Location: Capital Federal, Buenos Aires, Argentina

PostPosted: Wed Oct 03, 2012 4:54 am    Post subject: Reply with quote

Hi all,

I've been in a nightmare all day, because of this card reader. I've recently bought a Kingston MobileLite G2

Code:
usb 1-7: new high-speed USB device number 4 using ehci_hcd
usb 1-7: New USB device found, idVendor=090c, idProduct=6300
usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-7: Product: Kingston  Reader
usb 1-7: Manufacturer: Kingston  Reader
usb 1-7: SerialNumber: AA00000000320990
scsi7 : usb-storage 1-7:1.0
scsi 7:0:0:0: Direct-Access     Kingston Reader     SD/MS 0200 PQ: 0 ANSI: 0 CCS
sd 7:0:0:0: Attached scsi generic sg3 type 0


// AT WORK

lsusb sees it as Silicon Motion (Formerly Fenya Corp.).

I'm an experienced Gentoo user with a custom kernel. When I noticed that my kernel was able to detect the reader but not the card (it shows up as /dev/sdX, but never appears a partition and whatever interaction with that device returns "no medium found" or something like that) I begun searching the kernel looking for forgotten modules and settings. Well, after several reboots I ended activating every single module in the SD/MMC section of the kernel.

Nothing happened.

Humilliated :p but in despair I went to an Ubuntu box in order to see what ubuntu load when it detects the reader and the card, and thus replicate the scenario in my box. Ubuntu not only mounted immediately the microsd and showed it to me with Nautilus, but didn't load any visible module. So I felt myself a little lost.


// AT HOME

I've got three gentoo boxes; all of them showed the same behaviour: the card didn't show up. At last, not sure even of my sanity, I begun switching memories (NOTE: The memory always worked, besides, remember what did Ubuntu) to see if there was a little change.

Here is what's really crazy: A SD card (not microSD, but SD) worked flawlessly. I grabbed a SD/microSD adapter and tested all my microSD cards -- all of them worked like a charm.

Conclusion: Gentoo (gentoo-sources?) is not able to see the microSD slot, but the SD slot of the card reader works flawlessly. Is that EVEN possible? I can't find an explanation or a solution. Although, at least I think it might help someone.

I'll be glad of any idea or hint or something that lead me to at least an explanation.
Thanks in advance.
_________________
If it moves, it has an ebuild.

Adopt an unanswered post.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum