Solved Is it possible to rescan SD Card devices?

I just installed FreeBSD 10.3-RELEASE on a little Intel NUC box. When I power it up without a SD Card, part of dmesg returns this:
Code:
sdhci_pci0: <Generic SD HCI> mem 0x8131c000-0x8131cfff irq 18 at device 18.0 on pci0
sdhci_pci0: 1 slot(s) allocated
mmc0: <MMC/SD bus> on sdhci_pci0
...
mmc0: No compatible cards found on bus
When I power it up with a SD Card, part of dmesg returns this:
Code:
sdhci_pci0: <Generic SD HCI> mem 0x8131c000-0x8131cfff irq 18 at device 18.0 on pci0
sdhci_pci0: 1 slot(s) allocated
mmc0: <MMC/SD bus> on sdhci_pci0
...
mmcsd0: 126GB <SDHC SD128 3.0 SN 012F74A2 MFG 01/2016 by 39 PH> at mmc0 50.0MHz/4bit/65535-block
After the boot with a SD Card, for example, /dev/mmcsd0 is available and /dev/mmcsd0s1 can be mounted and is perfectly usable. For completeness, pciconf -lv returns this:
Code:
sdhci_pci0@pci0:0:18:0: class=0x080501 card=0x20608086 chip=0x22968086 rev=0x21 hdr=0x00
vendor  = 'Intel Corporation'
class  = base peripheral
subclass  = SD host controller

The issue is that when the SD Card is physically removed (after an umount of course), the devices remain in the /dev tree. Even gpart list will list them. If I power up the box without a SD Card, then insert a SD Card, no device will be added in the /dev tree. No entry is added in dmesg either. I tried camcontrol rescan all and even added in /boot/loader.conf:
Code:
mmc_load="YES"
mmcsd_load="YES"
sdhci_load="YES"

Is there a way to tell mmc0 to scan/refresh its devices again? man pages of mmc, mmcsd and sdhci couldn't help at this time.

Thanks!
Dominique.
 
Force GEOM to retaste the device by opening it for a write but then not writing to it: true > /dev/mmcsd0
 
Sounds promissing! :) Note that if the box is booted without a SD Card, /dev/mmcsd0 is not created. However, the SD host controller is listed by pciconf -lv. So, running your suggested command, I get:
Code:
/dev/mmcsd0: Operation not supported.
PS: I ran it as root.

Dominique.
 
In the early days of FreeBSD a lot of device nodes had to be created by hand.
On modern FreeBSD the MAKEDEV script does no longer exist in /dev/ but I found a manpage that might help you:
mknod(8)
 
Here's a little experiment! I power up with the SD Card. /dev/mmcsd0 and /dev/mmcsd0s1 are present. I remove the SD Card, /dev/mmcsd0 and /dev/mmcsd0s1 are still present as mentioned before. I execute true > /dev/mmcsd0, /dev/mmcsd0 remains and /dev/mmcsd0s1 disappears. That's half of what one would expect. I insert the SD Card again, execute true > /dev/mmcsd0 again, no /dev/mmcsd0s1 added this time.
Is there some devd(8) interaction involved with the creation of the device?
I don't think so! I searched in /etc/devd.conf, and files in /etc/devd, and the only sd string I could find is FreeBSD.
In the early days of FreeBSD a lot of device nodes had to be created by hand.
Interesting! mknod does exist, but I don't see a parameter to specify which driver to use. I wrote an IRIX driver a long time ago, and I seem to recall a necessity to tie a node to its driver somehow… Besides, the GEOM trick doesn't seem to revive the SD Card partition device node, so something is still missing.

It would be nice to tell/call the driver to rescan its devices as what is performed on power up, but I don't know how to do that! In the mean time, I will just assume that (PCI)SD Cards are not hot-swapable.

Dominique.
 
devfs(8) is dynamic. The mknod(8) man page says "As of FreeBSD 6.0 device nodes may be created in regular file systems but such nodes cannot be used to access devices."

There are two things going on. One is the creation of the device so that /dev/mmcsd0 appears. The other is rescanning media in the device, which should be accomplished with true > /dev/mmcsd0.

The first one is the question. The second one might not work quite right, but is less of a problem.
 
I tried : NUC5CPYH, FreeBSD10.3

"mmc0: No compatible cards found on bus" situations;

# devctl disable -f mmc0
insert sd card to slot
# devctl enable mmc0

I found /dev/mmcsd0. my FAT formatted SD card,
# mount /dev/mmcsd0s1 /mnt
access OK.

"umount and physically removed card" situations;
# devctl disable -f mmc0
/dev/mmcsd0 removed automatically from devfs if exist.

It seems good.
 
Back
Top