# 13.1-RELEASE fails to detect SD card reader



## rawthey (May 31, 2022)

I have an Akasa AK-ICR-01B card reader connected to a USB header on the motherboard

With previous versions of FreeBSD the reader was detected at boot time and device nodes
are created for da0, da1, da2 and da3. Since upgrading from 13.0 to 13.1-RELEASE this
device is no longer detected.

Here's what I think is the relevant sections from dmesg with 13.0 when booting with no cards in the
reader:

```
ugen1.1: <Intel EHCI root HUB> at usbus1
uhub0 on usbus1
ugen2.1: <Intel EHCI root HUB> at usbus2
uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen0.1: <0x8086 XHCI root HUB> at usbus0
uhub1 on usbus2
uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2
uhub2 on usbus0
uhub2: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0


uhub1: 2 ports with 2 removable, self powered
uhub0: 2 ports with 2 removable, self powered
uhub2: 21 ports with 21 removable, self powered
ugen1.2: <vendor 0x8087 product 0x8009> at usbus1
uhub3 on uhub0
uhub3: <vendor 0x8087 product 0x8009, class 9/0, rev 2.00/0.00, addr 2> on usbus1
ugen2.2: <vendor 0x8087 product 0x8001> at usbus2
uhub4 on uhub1
uhub4: <vendor 0x8087 product 0x8001, class 9/0, rev 2.00/0.00, addr 2> on usbus2
ugen0.2: <Generic USB2.0-CRW> at usbus0
umass0 on uhub2
umass0: <Bulk-In, Bulk-Out, Interface> on usbus0
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:6:0: Attached to scbus6
uhub3: 6 ports with 6 removable, self powered
da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
da0: <Generic- Compact Flash 1.00> Removable Direct Access SCSI device
da0: Serial Number 20060413092100000
da0: 40.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present
da0: quirks=0x2<NO_6_BYTE>
da1 at umass-sim0 bus 0 scbus6 target 0 lun 1
da1: <Generic- SM/xD-Picture 1.00> Removable Direct Access SCSI device
da1: Serial Number 20060413092100000
da1: 40.000MB/s transfers
da1: Attempt to query device size failed: NOT READY, Medium not present
da1: quirks=0x2<NO_6_BYTE>
uhub4: 8 ports with 8 removable, self powered
da2 at umass-sim0 bus 0 scbus6 target 0 lun 2
da2: <Generic- SD/MMC 1.00> Removable Direct Access SCSI device
da2: Serial Number 20060413092100000
da2: 40.000MB/s transfers
da2: Attempt to query device size failed: NOT READY, Medium not present
da2: quirks=0x2<NO_6_BYTE>
da3 at umass-sim0 bus 0 scbus6 target 0 lun 3
da3: <Generic- MS/MS-Pro 1.00> Removable Direct Access SCSI device
da3: Serial Number 20060413092100000
da3: 40.000MB/s transfers
da3: Attempt to query device size failed: NOT READY, Medium not present
da3: quirks=0x2<NO_6_BYTE>
```

But with 13.1 I only get this:

```
ugen0.1: <Intel XHCI root HUB> at usbus0
ugen1.1: <Intel EHCI root HUB> at usbus1
uhub0 on usbus0
uhub0: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
uhub1 on usbus1
uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen2.1: <Intel EHCI root HUB> at usbus2
uhub2 on usbus2
uhub2: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2


uhub2: 2 ports with 2 removable, self powered
uhub1: 2 ports with 2 removable, self powered
uhub0: 21 ports with 21 removable, self powered
ugen1.2: <vendor 0x8087 product 0x8009> at usbus1
uhub3 on uhub1
uhub3: <vendor 0x8087 product 0x8009, class 9/0, rev 2.00/0.00, addr 2> on usbus1
ugen2.2: <vendor 0x8087 product 0x8001> at usbus2
uhub4 on uhub2
uhub4: <vendor 0x8087 product 0x8001, class 9/0, rev 2.00/0.00, addr 2> on usbus2
uhub3: 6 ports with 6 removable, self powered
uhub4: 8 ports with 8 removable, self powered
usb_alloc_device: set address 2 failed (USB_ERR_TIMEOUT, ignored)
ugen0.2: <Generic USB2.0-CRW> at usbus0
umass0 on uhub0
umass0: <Bulk-In, Bulk-Out, Interface> on usbus0
umass0:  SCSI over Bulk-Only; quirks = 0x4000
umass0:6:0: Attached to scbus6
```


----------



## cy@ (Jun 1, 2022)

This is your SD card reader:

da2 at umass-sim0 bus 0 scbus6 target 0 lun 2
da2: <Generic- SD/MMC 1.00> Removable Direct Access SCSI device
da2: Serial Number 20060413092100000
da2: 40.000MB/s transfers
da2: Attempt to query device size failed: NOT READY, Medium not present
da2: quirks=0x2<NO_6_BYTE>

When you insert an SD card you should see a message to the console like this,

mmc0: <MMC/SD bus> on sdhci_pci0
mmc0: CMD8 failed, RESULT: 1
mmcsd0: 253MB <SD SD256 5.5 SN 6008C0C4 MFG 11/2003 by 3 SD> at mmc0 25.0MHz/4bit/65535-block

If you're using a desktop environment like gnome, kde, or whatever else, you can run xconsole or simply run dmesg in an xterm to see these messages.

Your SD card will be at /dev/mmcsd0.

If you install sysutils/automount, your SD card will automatically be mounted at /med/mmcsd0s1, or whatever slice its filesystem is on. (The secret sauce is in /usr/local/etc/devd/automount_devd.conf.)


----------



## rawthey (Jun 1, 2022)

cy@ said:


> This is your SD card reader:
> 
> da2 at umass-sim0 bus 0 scbus6 target 0 lun 2
> da2: <Generic- SD/MMC 1.00> Removable Direct Access SCSI device
> ...


Firstly, my apologies for the confusion caused by my careless typo in the title which originally incorrectly referred to 13.0 instead of 13.1 and which I've now corrected. The text of the post is however correct in that 13.1 RELEASE fails to detect the card reader wherase it was detected with 13.0-RELEASE.

Your reference to the card reader being at da2 is in correct with 13.0 except that /dev/mmcsd0 is not created, but this is no problem because I can mount it as /dev/da2s1. The problem is that the reader is not detected with 13.1 and there is no sign of it in the console messages


----------



## tingo (Jun 3, 2022)

Have you verified that the card reader still works under FreeBSD 13.0-release? Sometimes hardware dies on you.


----------



## rawthey (Jun 3, 2022)

tingo said:


> Have you verified that the card reader still works under FreeBSD 13.0-release? Sometimes hardware dies on you.


Yes, it consistently works fine if I reboot into a 13.0 boot environment but is never detected when running 13.1


----------



## rawthey (Jun 5, 2022)

I've done a bit more digging and made some progress. I've found that if there is a card in at least one slot of the card reader at boot time then it is detected and /dev/da* devices are created for all the slots but if all the slots are empty then no da* devices are created after the device is detected and there is a series of console messages like these:

```
umass0:6:0: Attached to scbus6
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
```
I've opened up the case of the card reader and found a Realtek RTS5130 chip which suggests that it might depend on the rtsx(4) driver which is built into the GENERIC kernel, although the RTS5130 isn't listed among the verified chips in rtsx(4) .

Since this reader without any card inserted works with 13.0 It's looking like this could be a bug which has crept in with 13.1.


----------



## sidetone (Jun 5, 2022)

Is devd on? To see, type: `service -e | grep dev`

Either way, try `service devd restart`, then `service devfs restart`, in that order. This will restart it, and perhaps fix it without requiring a reboot.


----------



## rawthey (Jun 5, 2022)

Yes, devd is running. I tried inserting a card and restarting devd and devfs but that had no effect.


> ```
> curlew:/root# service -e | grep dev
> /etc/rc.d/devmatch
> /etc/rc.d/devd
> ...


----------



## sidetone (Jun 5, 2022)

What shows up in dmesg after you remove and insert an SD card into your reader?


cy@ said:


> Your SD card will be at /dev/mmcsd0.


Either it's a hardware failure of the drive [driver, bug, configuration], or the device of the card has changed from da. Is it anything like or prefixed with mmcsd?


cy@ said:


> If you install sysutils/automount, your SD card will automatically be mounted at /med/mmcsd0s1, or whatever slice its filesystem is on. (The secret sauce is in /usr/local/etc/devd/automount_devd.conf.)











						Chapter 19. Storage
					

This chapter covers the use of disks and storage media in FreeBSD. This includes SCSI and IDE disks, CD and DVD media, memory-backed disks, and USB storage devices.




					docs.freebsd.org
				



The applications and configuration files shown there are in the base system of FreeBSD 13.1.


----------



## rawthey (Jun 6, 2022)

> sidetone said:
> 
> 
> > What shows up in dmesg after you remove and insert an SD card into your reader?


Nothing appears in dmesg or the system console when cards are inserted or removed.  I've been using this card reader for 12 years and this has always been the case. Device files /dev/da[0-3] have always been created at boot time for all previous versions of FreeBSD from 8.x through to 13.0 and device files such as /dev/da2s1 have been silently created and removed for the partitions as cards are inserted and removed.

The problem is that with 13.1 no device files are created for the slots unless there is a card already in the reader at boot time. Here's details of devices when booting into 13.1 with no card in any slot:

```
curlew:/home/mike% camcontrol devlist
<WDC WDS100T2B0A-00SM50 401020WD>  at scbus0 target 0 lun 0 (pass0,ada0)
<ST3500418AS CC38>                 at scbus1 target 0 lun 0 (pass1,ada1)
<WDC WDS100T2B0A-00SM50 401020WD>  at scbus2 target 0 lun 0 (pass2,ada2)
<ST3500418AS CC38>                 at scbus3 target 0 lun 0 (pass3,ada3)
<HL-DT-ST DVDRAM GH24NSD0 LH00>    at scbus4 target 0 lun 0 (cd0,pass4)
<AHCI SGPIO Enclosure 2.00 0001>   at scbus5 target 0 lun 0 (pass5,ses0)
```
Here's an example with FreeBSD 13.0 where devices are created for the individual slots in the reader even when they are all empty:

```
curlew:/home/mike% camcontrol devlist
<WDC WDS100T2B0A-00SM50 401020WD>  at scbus0 target 0 lun 0 (ada0,pass0)
<ST3500418AS CC38>                 at scbus1 target 0 lun 0 (ada1,pass1)
<WDC WDS100T2B0A-00SM50 401020WD>  at scbus2 target 0 lun 0 (ada2,pass2)
<ST3500418AS CC38>                 at scbus3 target 0 lun 0 (ada3,pass3)
<HL-DT-ST DVDRAM GH24NSD0 LH00>    at scbus4 target 0 lun 0 (cd0,pass4)
<AHCI SGPIO Enclosure 2.00 0001>   at scbus5 target 0 lun 0 (ses0,pass5)
<Generic- Compact Flash 1.00>      at scbus6 target 0 lun 0 (da0,pass6)
<Generic- SM/xD-Picture 1.00>      at scbus6 target 0 lun 1 (da1,pass7)
<Generic- SD/MMC 1.00>             at scbus6 target 0 lun 2 (da2,pass8)
<Generic- MS/MS-Pro 1.00>          at scbus6 target 0 lun 3 (da3,pass9)
```
Another significant thing is that under 13.1 with no card in the reader there's a number of error messages at boot time:

```
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 2 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 1 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Retrying command, 0 more tries remain
(probe0:umass-sim0:0:0:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(probe0:umass-sim0:0:0:0): Error 5, Retries exhausted
```



> sidetone said:
> 
> 
> > Either it's a hardware failure of the drive, or the device of the card has changed from da. Is it anything like or prefixed with mmcsd?


I think we can rule out hardware issues. There are consistently no problems when I boot into a 13.0 boot environment and device files are created for each slot but if I boot into a 13.1 environment the device files are not created uless I already have a card in the reader.

There are no devices matching /dev/mm* and to the best of my knowledge there never has been in the past.

I don't use, or even need, automounter and since the problem here is that device files for the card slots are not being created I don't expect there's anything to be gained from using it in connection with this problem.


----------



## sidetone (Jun 6, 2022)

I meant a failure of the software driver for the hardware, and less likely the hardware too. They give messages of hardware failures, even though it's the driver, configuration setting or a bug.


----------



## grahamperrin@ (Jun 15, 2022)

FreeBSD bug 264670 – 13.1-RELEASE fails to detect card slots in SD card reader


----------

