# SD card issues

## Proinsias

I've been trying to get my desktop to work with my sd cards and am not getting anywhere fast. 

Not sure if the issue is in the uefi/bios, kernel, card reader or elsewhere.

At the moment I have a TDK 8G sd card inserted into a usb card reader. On plugging it in and out dmesg is reading:

```
36.564419] usb 3-12: new high-speed USB device number 4 using xhci_hcd

[   36.717421] usb 3-12: device descriptor read/64, error -71

[   36.971413] usb 3-12: device descriptor read/64, error -71

[ 1553.070851] usb 3-12: new high-speed USB device number 6 using xhci_hcd

[ 1553.223856] usb 3-12: device descriptor read/64, error -71

[ 1553.477850] usb 3-12: device descriptor read/64, error -71

```

Prior to this dmesg was reporting ehci pci on plugging in but it wasn't showing up in lsblk. So I looked in make menuconfig, found an ehci option, built it in the kernel and rebooted, now I'm getting the above error with xhci. My bios/uefi, Gigabyte Z87 HD3, has a few options for xhci support and related stuff, I tried flipping things on and off with no joy. 

lsusb -v output here: https://paste.pound-python.org/show/FRa6XFRS2pxtMGBfcbNf/

kernel config: https://paste.pound-python.org/show/zu1S4nwxQg5r5gtu3LPT/

I have another usb card reader and other sd cards but am not having much luck with any of them.

The current card is working just fine when it's in my Canon DSLR.

Any help is appreciated.

----------

## theotherjoe

Proinsias, please post your complete dmesg content.

I am pasting the messages from my USB cardreader 

from my machine for comparison

```
[    3.790583] usb 2-2: New USB device found, idVendor=058f, idProduct=6362

[    3.792030] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[    3.793463] usb 2-2: Product: Mass Storage Device

[    3.794901] usb 2-2: Manufacturer: Generic

[    3.796346] usb 2-2: SerialNumber: 058F312D81B1

[    3.798664] usb-storage 2-2:1.0: USB Mass Storage device detected

[    3.800271] scsi host4: usb-storage 2-2:1.0

....

[    4.805332] scsi 4:0:0:0: Direct-Access     Generic  USB SD Reader    1.00 PQ: 0 ANSI: 0

[    4.810692] scsi 4:0:0:1: Direct-Access     Generic  USB CF Reader    1.01 PQ: 0 ANSI: 0

[    4.816127] scsi 4:0:0:2: Direct-Access     Generic  USB SM Reader    1.02 PQ: 0 ANSI: 0

[    4.821454] scsi 4:0:0:3: Direct-Access     Generic  USB MS Reader    1.03 PQ: 0 ANSI: 0

[    4.826225] sd 4:0:0:0: Attached scsi generic sg4 type 0

[    4.827616] sd 4:0:0:0: [sdd] Attached SCSI removable disk

[    4.830440] sd 4:0:0:1: Attached scsi generic sg5 type 0

[    4.832261] sd 4:0:0:1: [sde] Attached SCSI removable disk

[    4.834595] sd 4:0:0:2: Attached scsi generic sg6 type 0

[    4.836273] sd 4:0:0:2: [sdf] Attached SCSI removable disk

[    4.836278] sd 4:0:0:3: Attached scsi generic sg7 type 0

[    4.846998] sd 4:0:0:3: [sdg] Attached SCSI removable disk

```

and the output of lsusb and lsusb -v

```
Bus 011 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Bus 010 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 005 Device 002: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 002: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer <== thats the device

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

...

Bus 002 Device 002: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer

Device Descriptor:

  bLength                18

  bDescriptorType         1

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  idVendor           0x058f Alcor Micro Corp.

  idProduct          0x6362 Flash Card Reader/Writer

  bcdDevice            1.00

  iManufacturer           1 Generic

  iProduct                2 Mass Storage Device

  iSerial                 3 058F312D81B1

  bNumConfigurations      1

  Configuration Descriptor:

    bLength                 9

    bDescriptorType         2

    wTotalLength           32

    bNumInterfaces          1

    bConfigurationValue     1

    iConfiguration          0 

    bmAttributes         0x80

      (Bus Powered)

    MaxPower              250mA

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass         8 Mass Storage

      bInterfaceSubClass      6 SCSI

      bInterfaceProtocol     80 Bulk-Only

      iInterface              0 

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x01  EP 1 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x82  EP 2 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

Device Qualifier (for other device speed):

  bLength                10

  bDescriptorType         6

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  bNumConfigurations      1

Device Status:     0x0000

  (Bus Powered)

```

----------

## NeddySeagoon

Proinsias,

Your dmesg says that your card reader in on 

```
usb 3
```

but I don't see a card reader at all in your

```
 lsusb -v 
```

output.

Plug in your card reader .. just one of them, make sure it appears in lsusb, then post the output of lsusb.

You do have USB 2 and USB 3 rood hubs but no USB1, so you don't need either the OHCI or UHCI drivers in the kernel.

Its not your problem though, so don't rebuild the kernel just yet.

----------

## Proinsias

Thanks guys,

Plugging in just one card reader, with no cards connected to it, full dmesg shows:

https://paste.pound-python.org/show/syMSptPz7nr2OTaybd9Y/

lsusb I don't think shows it:

https://paste.pound-python.org/show/4FJwrp6KQfswxu5ukI5A/

lsusb -v:

https://paste.pound-python.org/show/RsjFeHHb5PSOHuzi6RAh/

So I removed that card reader and went hunting in the drawer to find the one I gave up on a while back. It is at least showing up with lsusb:

lsusb -v

https://paste.pound-python.org/show/V6yue7MPY9fU7G2VpV5d/

dmesg:

https://paste.pound-python.org/show/g7KgqpxxlWF1pnmhpT7j/

----------

## NeddySeagoon

Proinsias,

```
[  484.890492] usb 3-9: new high-speed USB device number 4 using xhci_hcd

[  485.043507] usb 3-9: device descriptor read/64, error -71

[  485.297532] usb 3-9: device descriptor read/64, error -71
```

The kernel failed to read the USB device descriptor.

That's game over, as its what lsusb shows.

This email may offer a way forward.

----------

## Proinsias

Thanks Neddy,

The card reader was dirt cheap, a pound I think, so not really suprising it's got issues. I suspect the best option is to use another reader but I'm not sure where to go with the info in the email regarding kernel usb modules. I've grep'd the .config file and done some poking around and '/' searching in menuconfig for 'usbcore' & 'use_both_schemes' and not found anything. 

I was in a little panic for 20 mins or so as I've just upgraded my kernel and rebooted. The machine just bricked up, not even a display on the monitor, no bios/uefi or anything. After trying a few cold reboots I remembered I'd plugged in my other card reader and had an sd card in it, I unplugged it and breathed a sigh or relief as my machine came to life.

Apologies if this is me asking for fish but is the other card reader, the one that is showing up in lsusb at the bottom of my post which  just locked up my machine, worth pursuing? 

Trying to get my photos from my dlsr to my gentoo box is starting to hurt, I've got a load of memory cards, sd/cf and one or two Sony Duo's lying around I'd like to be able to access/use....is there a budget friendly multi card reader that will just work without gymnastics? I've switched my machine off and on again, sometimes not even on again, more over this issue than I have for anything else.

----------

## theotherjoe

```
[  484.890492] usb 3-9: new high-speed USB device number 4 using xhci_hcd

[  485.043507] usb 3-9: device descriptor read/64, error -71

[  485.297532] usb 3-9: device descriptor read/64, error -71

[ 1049.148620] usb 3-9: new high-speed USB device number 6 using xhci_hcd

[ 1049.314817] usb 3-9: New USB device found, idVendor=058f, idProduct=6362

[ 1049.314819] usb 3-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 1049.314821] usb 3-9: Product: Mass Storage Device

[ 1049.314822] usb 3-9: Manufacturer: Generic

[ 1049.314822] usb 3-9: SerialNumber: 058F312D81B

[ 1049.315232] usb-storage 3-9:1.0: USB Mass Storage device detected

[ 1049.315278] scsi host6: usb-storage 3-9:1.0

[ 1050.316213] scsi 6:0:0:0: Direct-Access     Generic  USB SD Reader    1.00 PQ: 0 ANSI: 0

[ 1050.316351] sd 6:0:0:0: Attached scsi generic sg4 type 0

[ 1050.317361] scsi 6:0:0:1: Direct-Access     Generic  USB CF Reader    1.01 PQ: 0 ANSI: 0

[ 1050.317468] sd 6:0:0:1: Attached scsi generic sg5 type 0

[ 1050.319235] scsi 6:0:0:2: Direct-Access     Generic  USB SM Reader    1.02 PQ: 0 ANSI: 0

[ 1050.319328] sd 6:0:0:2: Attached scsi generic sg6 type 0

[ 1050.321326] scsi 6:0:0:3: Direct-Access     Generic  USB MS Reader    1.03 PQ: 0 ANSI: 0

[ 1050.321410] sd 6:0:0:3: Attached scsi generic sg7 type 0

[ 1050.337802] sd 6:0:0:0: [sdd] Attached SCSI removable disk

[ 1050.339823] sd 6:0:0:1: [sde] Attached SCSI removable disk

[ 1050.340329] sd 6:0:0:2: [sdf] Attached SCSI removable disk

[ 1050.341322] sd 6:0:0:3: [sdg] Attached SCSI removable disk

```

no idea at the moment what triggers the descriptor errors from 485s

but everything else looks promising.

----------

## depontius

 *Proinsias wrote:*   

> I've grep'd the .config file and done some poking around and '/' searching in menuconfig for 'usbcore' & 'use_both_schemes' and not found anything. 
> 
> 

 

The "use_both_schemes" is a driver option in modprobe.conf or modprobe.d/<specific>.conf, not a kernel option.  If you're grepping for it, look in the source tree, not the config.

----------

## NeddySeagoon

Proinsias,

theotherjoe pasted some of your dmesg that showed your other card reader JustWorked

It has given you 

```
[ 1050.337802] sd 6:0:0:0: [sdd] Attached SCSI removable disk

[ 1050.339823] sd 6:0:0:1: [sde] Attached SCSI removable disk

[ 1050.340329] sd 6:0:0:2: [sdf] Attached SCSI removable disk

[ 1050.341322] sd 6:0:0:3: [sdg] Attached SCSI removable disk
```

four new devices.  This is typical of a multislot card reader.

Insert a card, look at dmesg for the partitions and mount one, (or more).

Don't forget umount before your remove the card.

Booting with a USB storage device connected that isn't usually connected, can upset the BIOS disk detection order and the kernel drive enumeration order.

Its harmless but can cause a degree of stress for a wee while.  You will do it again too.  :) 

USBcore is a module in the kernel.  You can choose <M> or <Y>.  If you choose < > USB wont' work.

Many modules take parameters at module load load time.

```
lsmod
```

will show the modules you have loaded.

```
modinfo <module_name>
```

will tell you about <module_name>, including the options it takes.

If you have usbcore made as a module you can do 

```
modprobe usbcore use_both_schemes=y
```

However, if  usbcore is already loaded, this will do nothing.  The module must be unloaded first.

That might be a really bad idea if you depend on a USB keyboard.

Module parameters can be passed to built in modules on the kernel command line. 

See the start of /usr/src/linux/Documentation/kernel-parameters.txt, which has a worked example with usbcore.

The down side to this, is that a reboot is required to change module parameters.

----------

## Proinsias

Thanks for the pointer on the kernel modules, I will have look into the usbcore when I have a little time.

The reader that JustWorked still doesn't seem to work. When empty it does show up as four removable devices in dmesg but upon plugging in an sd card I get this:

dmesg:

```

[    2.237948] scsi 6:0:0:0: Direct-Access     Generic  USB SD Reader    1.00 PQ: 0 ANSI: 0

[    2.238053] sd 6:0:0:0: Attached scsi generic sg4 type 0

[    2.239694] scsi 6:0:0:1: Direct-Access     Generic  USB CF Reader    1.01 PQ: 0 ANSI: 0

[    2.239781] sd 6:0:0:1: Attached scsi generic sg5 type 0

[    2.241935] scsi 6:0:0:2: Direct-Access     Generic  USB SM Reader    1.02 PQ: 0 ANSI: 0

[    2.242017] sd 6:0:0:2: Attached scsi generic sg6 type 0

[    2.244310] scsi 6:0:0:3: Direct-Access     Generic  USB MS Reader    1.03 PQ: 0 ANSI: 0

[    2.244393] sd 6:0:0:3: Attached scsi generic sg7 type 0

[    2.266811] sd 6:0:0:0: [sdd] Attached SCSI removable disk

[    2.269435] sd 6:0:0:1: [sde] Attached SCSI removable disk

[    2.271562] sd 6:0:0:2: [sdf] Attached SCSI removable disk

[    2.272811] sd 6:0:0:3: [sdg] Attached SCSI removable disk

[    2.298308] clocksource: Switched to clocksource tsc

[    2.453825] Adding 8388604k swap on /dev/sda3.  Priority:-1 extents:1 across:8388604k SS

[    2.635973] EXT4-fs (sda4): re-mounted. Opts: (null)

[    2.701976] EXT4-fs (sdc1): mounting ext2 file system using the ext4 subsystem

[    2.736252] EXT4-fs (sdc1): mounted filesystem without journal. Opts: (null)

[    2.831425] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)

[    3.304353] r8169 0000:02:00.0 enp2s0: link down

[    3.304354] r8169 0000:02:00.0 enp2s0: link down

[    3.304393] IPv6: ADDRCONF(NETDEV_UP): enp2s0: link is not ready

[    3.304437] ip (2531) used greatest stack depth: 11392 bytes left

[    3.398031] udevd[1653]: specified group 'adbusers' unknown

[    5.641626] r8169 0000:02:00.0 enp2s0: link up

[    5.641633] IPv6: ADDRCONF(NETDEV_CHANGE): enp2s0: link becomes ready

[   57.854768] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[   90.816892] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  123.843015] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  156.869120] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  189.895268] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  222.857386] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  255.819506] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  288.845628] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  321.871748] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  354.897879] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  387.859991] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  420.822124] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

[  453.848244] usb 2-1.5: reset high-speed USB device number 3 using ehci-pci

```

Which I think was the reason I had an issue a while back, gave up on it and started wresting with the second card reader.

----------

## NeddySeagoon

Proinsias,

Oh dear,  I was over confident.

The device that is causind USB bus resets is on usb bus 2, Your reader that showed up as 4 drive letters when empty was usb 3 device 9.

Its quite possible that they are the same device, its just that its now connected to a different USB port than in wan in a prior post.

It would hove been in dmesg, just above the snippet you posted.

Connect the device again, be sure it appears in lsusb then post 

```
lsusb -v
```

 That will enable us to check that your USB is not not overloaded.

Some USB chipsets do load shedding when all connected devices attempt to draw more power (combined) that the bus is supposed to supply.

Its a cyclic thing.

If you don't want to wait for the analysis. Try the card reader in all of your USB ports in turn.

That's what the fix will be anyway ... don't plug it in there.

----------

## Proinsias

Thanks Neddy,

The fix regarding which usb port it's plugged into I think goes someway to explain longterm issues and occasional success with the card reader using different set-ups and distros. Sometimes it has just worked, but rarely. I have been using different ports, I didn't realize it would have an impact. I had ventured it was connected to astrological alignment. 

Here's lsusb -v with the card reader showing up:

https://paste.pound-python.org/show/jNbjh4lCYzl4F7kNZhoi/

and dmesg, showing me plugging it into various usb ports: 

https://paste.pound-python.org/show/Xt9qhIB7xg2QB8rKlzsy/

I've been trying the ports over the course of today, I've tried all the ports and they all give the reset error eventually. The card appears as sdd for a while in dmesg, but no partitions or any note of it in lsblk, then it throws up the reset error.

----------

## NeddySeagoon

Proinsias,

From lsusb, the card reader is

```
Bus 001 Device 010: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer
```

And it wants

```
   MaxPower              100mA
```

What else in on Bus 001?

```
Bus 001 Device 004: ID 045e:0750 Microsoft Corp. Wired Keyboard 600   MaxPower              100mA

Bus 001 Device 003: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse    MaxPower              100mA

Bus 001 Device 002: ID 8087:8008 Intel Corp.      MaxPower                0mA

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub   bcdUSB               2.00     MaxPower                0mA
```

That tells that you have 300mA on a USB 2 root hub, that is specified to supply 500mA max.  That looks OK.

The keyboard and mouse are USB 1.1 devices. (bcdUSB               1.10) and the card reader is USB 2.

Not all USB2 root hubs play nicely with a mix of USB1 and USB2 devices attached.

Older root hubs fall back to USB1 speeds and expect USB2 devices to fall back too. It doesn't always work well.

Newer hubs do Transaction Translation, so that the two standards can be time division multiplexed. That needs kernel support for some root hubs.

Check your kernel

```
  │ │      <*>     EHCI HCD (USB 2.0) support                                          │ │  

  │ │      [*]       Root Hub Transaction Translators                                  │ │  

  │ │      [*]       Improved Transaction Translator scheduling 
```

If the various speed USB devices are kept on separate root hubs, thu speed problem does not arise.

Can you arrange all your USB devices like that?  

That includes any internal USB devices you may have.

USB has grown into a bit of a mess over the years, Rather like the PC itself.

----------

## Proinsias

Neddy,

I did not have Root Hub Transaction Translators set as '*' or 'M', I have set it '*' and rebooted. 

I have moved the usb devices around but am back where I started. Keyboard & mouse on bus one and the card reader on bus two. The issue persists:

https://paste.pound-python.org/show/FDUDDnIEl0s74NwQVFGD/

lsusb -v

https://paste.pound-python.org/show/Gwmvzu3JTGktguqakdDW/

*edit* I don't think I have any internal usb devices

*edit again* 

I set :

[*]       Root Hub Transaction Translators

then

make

then

make install

then reboot.......I did not update grub2 assuming make install is enough in this case of changing a single option to *

----------

## NeddySeagoon

Proinsias,

Look at the date/time in 

```
uname -a
```

That's the build time of the running kernel.

You don't mention 

```
mount /boot
```

before 

```
make install
```

That may or may not be a problem for you.

----------

## Proinsias

I solved this by buying one of these for £6. It JustWorks. I am happy.

Neddy, thanks for the knowledge regarding the murky world of usb workings. It is slightly less muddy for me now and good stuff to know as my usb usage is getting rather heavy.

----------

