简体   繁体   English

我可以读取与 USB 卡读写器连接的 SD 卡序列号作为挂载的 sda 吗?

[英]Can I read SD card serial number connected with USB card reader/writer as mounted sda?

On Raspberry pi, I can read the serial number of SD card mounted on the built-in SD card drive from cid file under /sys/block/mmcblk0/device folder.在树莓派上,我可以从 /sys/block/mmcblk0/device 文件夹下的cid文件中读取安装在内置 SD 卡驱动器上的 SD 卡的序列号。

pi@raspberrypi:~ $ ls /sys/block/mmcblk0/device
block  driver      hwrev   oemid                 scr        type
cid    dsr         manfid  power                 serial     uevent
csd    erase_size  name    preferred_erase_size  ssr
date   fwrev       ocr     rca                   subsystem

But, about the SD card connected with USB SD card reader/writer mounted on the device of sda, I can't see the cid file.但是,关于与安装在sda设备上的USB SD卡读写器连接的SD卡,我看不到cid文件。

pi@raspberrypi:~ $ ls /sys/block/sda/device
blacklist                           evt_soft_threshold_reached  rescan
block                               generic                     rev
bsg                                 inquiry                     scsi_device
delete                              iocounterbits               scsi_disk
device_blocked                      iodone_cnt                  scsi_generic
device_busy                         ioerr_cnt                   scsi_level
driver                              iorequest_cnt               state
eh_timeout                          max_sectors                 subsystem
evt_capacity_change_reported        modalias                    timeout
evt_inquiry_change_reported         model                       type
evt_lun_change_reported             power                       uevent
evt_media_change                    queue_depth                 vendor
evt_mode_parameter_change_reported  queue_type                  wwid

Is there any way to read SD card serial number mounted as sda ?有没有办法读取安装为sda的 SD 卡序列号? Any suggestions are welcome!欢迎任何建议!

I ran into this problem just the other day (and stumbled across this question in my search), and it looks like the answer is that it's not really possible .前几天我遇到了这个问题(并且在我的搜索中偶然发现了这个问题),看起来答案是这不太可能

The CID information is stored on a register on the SD card, and you can only access it through SPI (usually). CID 信息存储在 SD 卡上的一个寄存器中,您只能通过 SPI 访问它(通常)。 The driver has to send specific commands to the SD card to read these registers.驱动程序必须向 SD 卡发送特定命令才能读取这些寄存器。

When you use a USB SD Card reader on the other hand, it uses the generic "USB mass storage device" interface -- so when your PC is talking to the USB card reader, it [your PC] doesn't even really know it's talking to an SD card specifically, it just treats it like its another generic USB storage device (like a flash drive or something).另一方面,当您使用 USB SD 读卡器时,它使用通用的“USB 大容量存储设备”接口——所以当您的 PC 与 USB 读卡器通信时,它 [您的 PC] 甚至都不知道它是特别是与 SD 卡交谈时,它只是将其视为另一个通用 USB 存储设备(如 flash 驱动器或其他东西)。

The only way this kind of thing would remotely be possible if your USB SD card reader had a mode that let you communicate with it directly by-hand (eg send a custom command to it over USB), but AFAIK this kind of thing doesn't exist.如果您的 USB SD 读卡器有一种模式可以让您直接手动与它通信(例如通过 USB 向它发送自定义命令),那么这种事情就远程成为可能的唯一方法,但是 AFAIK 这种事情没有不存在。

If you're deadset on getting the CID info and don't mind using additional hardware (~ $10), you could buy an SD card breakout board and connect it to an Arduino or whatever, then you'll have access to the pins and you can write your own code to read the CID data.如果您对获取 CID 信息不感兴趣并且不介意使用额外的硬件(约 10 美元),您可以购买 SD 卡分线板并将其连接到 Arduino 或其他任何东西,然后您将可以访问引脚和您可以编写自己的代码来读取 CID 数据。

Credits to this answer, which is what my answer is based off: https://stackoverflow.com/a/50999034/1576548归功于这个答案,这是我的答案所依据的: https://stackoverflow.com/a/50999034/1576548

If you're interested, you can check out the SD Card Association's specification (the 'Physical Layer') here https://www.sdcard.org/downloads/pls/ for more info on how the CID information is gathered.如果您有兴趣,可以在此处查看 SD 卡协会的规范(“物理层”) https://www.sdcard.org/downloads/pls/以获取有关如何收集 CID 信息的更多信息。

And the Linux kernel's SD card driver: https://github.com/torvalds/linux/blob/master/drivers/mmc/core/sd.c和Linux内核的SD卡驱动: https://github.com/torvalds/linux/blob/master/drivers/mmc/core/sd.Z4A8A08F09D37B73795649034F

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何列出在USB大容量存储模式下通过电话连接到Linux的SD卡的内容? - How can I list the contents of an SD card connected to Linux via a phone in USB Mass Storage Mode? 我需要找到如何区分USB已连接和读卡器也已连接到Linux中的目标 - I need to find how to differentiate between usb is connected and card reader is also connected to target in linux 在Linux下读取连接到USB-SD读取器的SD卡的CID - Read CID of SDcard connected to USB-SD Reader under Linux 如何在SD卡上设置写/读保护? - how can I put write/read protection on the sd card? 在Linux下检索SD卡序列号和制造商 - Retrieve SD Card Serial Number and Manufacturer under Linux 如何使用Spidev控制SD卡读卡器 - How do I control an sd card reader using spidev 如何将音频文件播放到任何已连接的USB音频卡? - How I can play any audiofile to any connected usb audio card? 如何在安装前检查SD卡大小并且不需要root用户 - how to check the SD card size before mounted and do not require root 获取安装到 /dev 文件夹的 USB 设备的唯一序列号 - Get unique serial number of USB device mounted to /dev folder 在Linux上通过Java程序检测PCSC时出现问题,读卡器已连接 - Issue detecting PCSCvia java program on linux, the card reader is connected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM