Linux device node for sd card as mmcblk to access CSD register

8.6k Views Asked by At

I am trying to access the CSD (Card Specific Data) register on a SD card. The only way I know to do this is by having the linux system recognize it as a mmc device (Multi Media Card?) (eg. /dev/mmcblk0). Right now the device is being shown as a scsi disk (eg. /dev/sda).

Is there any way I can access the CSD Register (Card Specific Data) when is is mounted as a scsi disk?

Is there any way I can get the kernel to recognize the device as a mmc?

Thanks.

3

There are 3 best solutions below

4
RaFD On

At least some of CSD information you should get in /sys/block/diskX directory.

Example: My sd card connected to USB stick is discovered by system as /dev/sdc.

ls -l /sys/block/sdc/queue/
total 0
-rw-r--r-- 1 root root 4096 Oct  7 22:25 add_random
-r--r--r-- 1 root root 4096 Oct  7 22:25 discard_granularity
-r--r--r-- 1 root root 4096 Oct  7 22:25 discard_max_bytes
-r--r--r-- 1 root root 4096 Oct  7 22:25 discard_zeroes_data
-r--r--r-- 1 root root 4096 Oct  7 22:25 hw_sector_size
drwxr-xr-x 2 root root    0 Oct  7 22:24 iosched
-rw-r--r-- 1 root root 4096 Oct  7 22:24 iostats
-r--r--r-- 1 root root 4096 Oct  7 22:25 logical_block_size
-r--r--r-- 1 root root 4096 Oct  7 22:24 max_hw_sectors_kb
-r--r--r-- 1 root root 4096 Oct  7 22:24 max_integrity_segments
-rw-r--r-- 1 root root 4096 Oct  7 22:24 max_sectors_kb
-r--r--r-- 1 root root 4096 Oct  7 22:24 max_segment_size
-r--r--r-- 1 root root 4096 Oct  7 22:24 max_segments
-r--r--r-- 1 root root 4096 Oct  7 22:24 minimum_io_size
-rw-r--r-- 1 root root 4096 Oct  7 22:25 nomerges
-rw-r--r-- 1 root root 4096 Oct  7 22:25 nr_requests
-r--r--r-- 1 root root 4096 Oct  7 22:25 optimal_io_size
-r--r--r-- 1 root root 4096 Oct  7 22:23 physical_block_size
-rw-r--r-- 1 root root 4096 Oct  7 22:25 read_ahead_kb
-rw-r--r-- 1 root root 4096 Oct  7 22:25 rotational
-rw-r--r-- 1 root root 4096 Oct  7 22:25 rq_affinity
-rw-r--r-- 1 root root 4096 Oct  7 22:25 scheduler
0
0x2207 On

Looking into the Linux kernel sources, you may find that there are rare cases when USB device provide mmcblk device. Realtek chips RTS5129, RTS5139, RTS5179 and RTS5170 provide MMC interface. I have found RTS5129 as integrated part of my laptop, and checked that it correctly handles vendor custom CMD56. Unfortunately, I don't know is it possible to buy external USB SD card reader based on mentioned chips.

0
Maksym On

I can confirm that RTS5179-based card reader recognize MMC as /dev/mmcblk0. I bought laptop used card-reader part, and connected it via USB with replaced connector. This is the only way, as I never seen usual USB card readers that recognizes MMC as /dev/mmcblk0.

In this mode started working TRIM functionality for my MMC.