Mise à jour Debian : 10.9 / Buster
Les cartes SD (Secure Digital) sont des périphériques blocs de type mémoires amovibles de stockage de données, disposant d'une interface SPI (Serial Peripheral Interface).
Elles peuvent être connectées sur le PC
Dans ce qui suit, on s’intéresse aux cartes SD raccordées via un lecteur de carte SPI
Sommaire
$ sudo dmesg
...
mmc0: cannot verify signal voltage switch
mmc0: new ultra high speed SDR104 SDHC card at address aaaa
mmcblk0: mmc0:aaaa SC32G 29.7 GiB
Dans cet exemple, l'identifiant de la carte est /dev/mmcblk0
$ lsblk -f /dev/mmcblk0
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
mmcblk0
│
├─mmcblk0p1
│ vfat ESP3 6BB1-6D60
└─mmcblk0p2
ext4 buster3
7caa02f6-96d9-496a-9c8d-d7dceb100078
$ sudo blkid /dev/mmcblk*
/dev/mmcblk0: PTUUID="a8c365d4-5756-4f6b-bbcc-c17339afdc38" PTTYPE="gpt"
/dev/mmcblk0p1: LABEL_FATBOOT="ESP3" LABEL="ESP3" UUID="6BB1-6D60" TYPE="vfat" PARTLABEL="ESP3" PARTUUID="25818892-3ec6-4f07-9bf8-e41fa1a6a123"
/dev/mmcblk0p2: LABEL="buster3" UUID="7caa02f6-96d9-496a-9c8d-d7dceb100078" TYPE="ext4" PARTLABEL="buster3" PARTUUID="6db2f9f6-954d-41db-bd4e-d646648bae90"
$ sudo dmesg
...
mmc0: cannot verify signal voltage switch
mmc0: new ultra high speed SDR104 SDHC card at address aaaa
mmcblk0: mmc0:aaaa SC32G 29.7 GiB
Dans cet exemple, la carte est sur le bus mmc0 à l'adresse aaaa
$ udevadm monitor -k -s block
KERNEL[52388.478848] add /devices/pci0000:00/0000:00:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0 (block)
KERNEL[52388.478935] add /devices/pci0000:00/0000:00:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0/mmcblk0p1 (block)
ou en supprimant la première partie des lignes jusqu'à 0000:00 pour des raisons de lisibilité
$ udevadm monitor -k -s block |sed 's/^.*0000:00//'
...
:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0 (block)
:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0/mmcblk0p1 (block)
On en déduit que le lecteur de la carte /dev/mmcblk0 a pour adresse sur le bus pci 02:00.0
$ lspci -k -s 2:00.0
02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)
Subsystem: Intel Corporation RTS522A PCI Express Card Reader
Kernel driver in use: rtsx_pci
Kernel modules: rtsx_pci
Liste des cartes et partitions
$ ls /sys/class/block/ |grep mmcblk
mmcblk0
mmcblk0p1
$ ls -l /sys/class/block/mmcblk*
lrwxrwxrwx 1 root root 0 juin 4 00:31 /sys/class/block/mmcblk0 -> ../../devices/pci0000:00/0000:00:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0
lrwxrwxrwx 1 root root 0 juin 4 00:31 /sys/class/block/mmcblk0p1 -> ../../devices/pci0000:00/0000:00:1d.6/0000:02:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:212d/block/mmcblk0/mmcblk0p1
Propriétés de la carte
$ ls /sys/class/block/mmcblk0
alignment_offset discard_alignment force_ro mmcblk0p1 removable subsystem
bdi events hidden mq ro trace
capability events_async holders power size uevent
dev events_poll_msecs inflight queue slaves
device ext_range integrity range stat
$ sudo aptitude install mmc-utils
$ aptitude versions mmc-utils
i 0+git20180327.b4fe0c8c-1 stable 500
p 0+git20180327.b4fe0c8c-1+b1 testing 10
$ sudo mmc extcsd read /dev/mmcblk0 ioctl: Connection timed out
Could not read EXT_CSD from /dev/mmcblk0
$ ls /sys/bus/mmc/devices/
mmc0:212d
$ ls /sys/bus/mmc/devices/mmc0\:aaaa
block date erase_size manfid oemid rca ssr uevent
cid driver fwrev name power scr subsystem
csd dsr hwrev ocr preferred_erase_size serial type
Utilisation de mmc cid
$ sudo mmc cid read /sys/bus/mmc/devices/mmc0\:aaaa
type: 'SD'
manufacturer: 'SanDisk' 'SD'
product: 'SD128' 8.0
serial: 0x18809300
manfacturing date: 2019 jul
# Equivalent à
$ sudo mmc cid read /sys/bus/mmc/devices/mmc0:*
$ sudo mmc csd read /sys/bus/mmc/devices/mmc0:*
type: 'SD'
card classes: 9 I/O mode, 8 application specific, 4 block write, 2 block read, 1 reserved, 0 basic,
capacity: 99.00Gbyte (106301489152 bytes, 207620096 sectors, 512 bytes each
Utilisation de mmc scd
$ sudo mmc scr read /sys/class/mmc_host/mmc0/mmc0:*
type: 'SD'
version: SD 3.0x
bus widths: 4bit, 1bit,
Capacité 128 GB
Débit théorique max lecture séquentielle 160 Mo/s
Débit théorique max écriture séquentielle 90 Mo/s
Bus mémoire UHS-I (max 104 Mo/s)
Classe U3 : débit minimum écriture 30 Mo/s
Vitesse de transfert minimum : A2
$ sync ; sudo dd if=/dev/mmcblk0 bs=1M count=1024 iflag=direct of=/dev/null
....
1073741824 octets (1,1 GB, 1,0 GiB) copiés, 13,5447 s, 79,3 MB/s
$ sudo mount /dev/mmcblk0 /mnt; sync; sudo dd if=/dev/zero of=/mnt/test bs=1MiB count=1000 oflag=direct
....
1048576000 octets (1,0 GB, 1000 MiB) copiés, 23,2805 s, 45,0 MB/s
$ sudo parted /dev/mmcblk0 unit GB print
Model: SD SN128 (sd/mmc)
Disk /dev/mmcblk0: 128GB
$ sudo dmesg
....
[ 1961.354321] usb 1-2: new high-speed USB device number 5 using xhci_hcd
[ 1961.504834] usb 1-2: New USB device found, idVendor=14cd, idProduct=1212, bcdDevice= 1.00
[ 1961.504839] usb 1-2: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[ 1961.504842] usb 1-2: Product: Mass Storage Device
[ 1961.504844] usb 1-2: Manufacturer: Generic
[ 1961.504846] usb 1-2: SerialNumber: 121220160204
[ 1961.505981] usb-storage 1-2:1.0: USB Mass Storage device detected
[ 1961.506599] scsi host3: usb-storage 1-2:1.0
[ 1961.533719] usbcore: registered new interface driver uas
[ 1962.527377] scsi 3:0:0:0: Direct-Access Mass Storage Device 1.00 PQ: 0 ANSI: 0 CCS
[ 1962.527901] sd 3:0:0:0: Attached scsi generic sg1 type 0
[ 1962.810157] sd 3:0:0:0: [sdb] 249737216 512-byte logical blocks: (128 GB/119 GiB)
[ 1962.810644] sd 3:0:0:0: [sdb] Write Protect is off
[ 1962.810649] sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 1962.811036] sd 3:0:0:0: [sdb] No Caching mode page found
[ 1962.811044] sd 3:0:0:0: [sdb] Assuming drive cache: write through
[ 1962.833025] sdb: sdb1
[ 1962.834907] sd 3:0:0:0: [sdb] Attached SCSI removable disk
[ 2141.949662] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
$ sync ; sudo dd if=/dev/sdb bs=1M count=1024 iflag=direct of=/dev/null
....
1073741824 octets (1,1 GB, 1,0 GiB) copiés, 72,2722 s, 14,9 MB/s
1073741824 octets (1,1 GB, 1,0 GiB) copiés, 59,6877 s, 18,0 MB/s
$ sudo mount /dev/sdb1 /mnt; sync; sudo dd if=/dev/zero of=/mnt/test bs=1MiB count=1000 oflag=direct
....
1048576000 octets (1,0 GB, 1000 MiB) copiés, 99,7896 s, 10,5 MB/s
1048576000 octets (1,0 GB, 1000 MiB) copiés, 69,4552 s, 15,1 MB/s
$ sudo rm /mnt/test; sync
Capacité 16 Go
Classe C 10 : débit minimum écriture 10 Mo/s
$ sync ; sudo dd if=/dev/mmcblk0 bs=1M count=1024 iflag=direct of=/dev/null
....
1073741824 octets (1,1 GB, 1,0 GiB) copiés, 46,3159 s, 23,2 MB/s
1 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 46,3159 s, 23,2 MB/s
2 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 46,1657 s, 23,3 MB/s
3 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 45,8216 s, 23,4 MB/s
4 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 60,8896 s, 17,6 MB/s
5 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 47,055 s, 22,8 MB/s
6 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 65,443 s, 16,4 MB/s
7 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 47,0333 s, 22,8 MB/s
8 - 1073741824 octets (1,1 GB, 1,0 GiB) copiés, 45,6887 s, 23,5 MB/s
$ sudo mount /dev/mmcblk0p1 /mnt; sync; sudo dd if=/dev/zero of=/mnt/test bs=1MiB count=1000 oflag=direct
.....
1048576000 octets (1,0 GB, 1000 MiB) copiés, 85,2957 s, 12,3 MB/s
1 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 85,2957 s, 12,3 MB/s
2 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 115,502 s, 9,1 MB/s
3 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 81,7841 s, 12,8 MB/s
4 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 80,042 s, 13,1 MB/s
5 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 88,1661 s, 11,9 MB/s
6 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 93,5574 s, 11,2 MB/s
7 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 83,6851 s, 12,5 MB/s
8 - 1048576000 octets (1,0 GB, 1000 MiB) copiés, 78,6434 s, 13,3 MB/s
$ sudo parted /dev/mmcblk0 unit GB print
Model: SD APPSD (sd/mmc)
Disk /dev/mmcblk0: 15,7GB
....
1 - Disk /dev/mmcblk0: 15,7GB
2 - Disk /dev/mmcblk0: 15,9GB
3 - Disk /dev/mmcblk0: 15,7GB
4 - Disk /dev/mmcblk0: 16,1GB
5 - Disk /dev/mmcblk0: 15,7GB
6 - Disk /dev/mmcblk0: 16,1GB
7 - Disk /dev/mmcblk0: 15,7GB
8 - Disk /dev/mmcblk0: 15,7GB
$ sync ; sudo dd if=/dev/mmcblk0 bs=1M count=1024 iflag=direct of=/dev/null
...
1073741824 octets (1,1 GB, 1,0 GiB) copiés, 13,0602 s, 82,2 MB/s
$ sudo mount /dev/mmcblk0p1 /mnt;sync; sudo dd if=/dev/zero of=/mnt/test bs=1MiB count=1000 oflag=direct
....
1048576000 octets (1,0 GB, 1000 MiB) copiés, 59,1638 s, 17,7 MB/s
$ sudo parted /dev/mmcblk0 unit GB print
Model: SD SC32G (sd/mmc)
Disk /dev/mmcblk0: 31,9GB
....