Узнать cid sd карты linux

Узнать cid sd карты linux

Camera Memory Speed
Memory Card Comparison & Performance Tests for Digital Cameras

Internal SD Card Information

Information about an SD card is encoded in its internal card registries. One of these is the Card Identification (CID) Register, a 16 byte code that contains information that uniquely identifies the SD card, including the card serial number (PSN), manufacturer ID number (MID) and manufacture date (MDT). The CID register is set when the card is manufactured and cannot be changed after it is set. (According to SD card specification the information is only to be written once, however if a card does not conform to the specification this information could be changed!)

How to read the CID from an SD card

One way to read the CID is to use a laptop with an SD card slot. Card readers in laptops are usually connected directly through the PCI bus (or IDE bus). This will not work through a USB card reader because the command to retrieve the card information is intercepted and not understood by card readers. Not all computers with built-in card slots will work, some internal card readers are connected through a USB bus.

Assuming you have the proper hardware, there are several methods you can use to get the card information. With Linux, reading the internal SD card information is simple. Insert the card and look under /sys/block/mmcblk0/device/ (this location may change depending on your platform, it may be mmcblk1 or in a different location). Under this location you will see several attributes available that include the CID and CSD registers and the information inside it.

To view the CID, the command is cat /sys/block/mmcblk0/device/cid (the exact location may be different)

What information is in the CID?

The following information is stored in the CID:

Name Field Linux attribute* Description
Manufacturer ID MID manfid Assigned by SD-3C, LLC.
OEM/Application ID OID oemid Identifies the card OEM and/or the card contents. Assigned by SD-3C, LLC.
Product Name PNM name 5 characters long (ASCII)
Product Revision PRV hwrev, fwrev Two binary coded decimal (BCD) digits. Each is four bits. The PRV is in the form x.y. The PRV can also be found by using the hwrev and fwrev, where x=hwrev and y=fwrev
Serial Number PSN serial This 32 bit field is intended to be read as an unsigned integer
Manufacture Date Code MDT date Manufacture date is stored in the form yym (offset from 2000)
CRC7 checksum CRC 7 bit code used for checking errors in the card register

* these are the attribute titles used for the card in Linux

List of Common Manufacturer ID (MID)

Manufacturer ID (MID) are assigned by the SD Assoication (SD-3C LLC). They consider this information confidential so an official list is not published.

Читайте также:  Service linux посмотреть все

The following list was compiled by reading the CID on numerous SD cards. Many card brands are produced by OEM suppliers, and the MID and OEMID may reflect this, or in some cases they appear to show the producer of the card controller. For example, PNY cards have been found with 0x000028 and BE (Lexar) or 0x000027 and PH (Phison).

Company MID OEMID Card brands found with this MID/OEMID
Panasonic 0x000001 PA Panasonic
Toshiba 0x000002 TM Toshiba
SanDisk 0x000003 SD (some PT) SanDisk
Samsung 0x00001b SM ProGrade, Samsung
AData 0x00001d AD AData
Phison 0x000027 PH AgfaPhoto, Delkin, Integral, Lexar, Patriot, PNY, Polaroid, Sony, Verbatim
Lexar 0x000028 BE Lexar, PNY, ProGrade
Silicon Power 0x000031 SP Silicon Power
Kingston 0x000041 42 Kingston
Transcend 0x000074 JE or J` Transcend
Patriot(?) 0x000076 �� Patriot
Sony(?) 0x000082 JT Gobe, Sony
0x00009c SO Angelbird (V60), Hoodman
0x00009c BE Angelbird (V90)

How can I use the information from the CID?

The CID information can be helpful in identifying counterfeit memory cards. We include the CID data in our SD card reviews so you may compare it with your cards.

©2023 CameraMemorySpeed.com. All Rights Reserved. No part of this web site may be reproduced without permission.

Источник

Уникальный идентификатор устройства хранения

Это приводит меня к выводу, что есть способ получить уникальный идентификатор CF-карты. Как можно добиться этого в Linux?

PS: я намеренно пропустил какие-либо подробности о самом продукте, так как мне интересно больше в общих чертах, как такая система может создать уникальный идентификатор CF-карты.

2 ответа 2

Как прокомментировали другие, это может быть связано с тем, как была удалена CF-карта, но более вероятно, что программное обеспечение идентифицирует CF-карту на основе встроенного программного обеспечения в карте —

Эта информация обычно читается с использованием «udevinfo» — например, если CF-карта /dev /sdb udevinfo -a -p $(udevinfo -q путь -n /dev /sdb) — это, скорее всего, будет содержать достаточно информации для однозначно идентифицировать карту.

Примечание : в дистрибутивах на основе udevadm info udevadm заменяет udevinfo :

udevadm info -a -p $( udevadm info -q path -n /dev/sdb )

На карте будет много информации, зарегистрированной только для чтения.

Внутренняя информация SD-карты

Информация о SD-карте закодирована в ее внутренних реестрах. Одним из них является регистр идентификации карты (CID) , 16-байтовый код, который содержит информацию, которая однозначно идентифицирует SD-карту, включая серийный номер карты (PSN), идентификационный номер производителя (MID) и дату изготовления (MDT). Регистр CID устанавливается при изготовлении карты и не может быть изменен после ее установки. (Согласно спецификации SD-карты информация должна быть записана только один раз, однако, если карта не соответствует спецификации, эта информация может быть изменена!)

Как прочитать CID с SD-карты

Один из способов прочитать CID — использовать ноутбук с гнездом для SD-карты. Кард-ридеры в ноутбуках обычно подключаются напрямую через шину PCI (или шину IDE). Это не будет работать через устройство чтения карт USB, потому что команда для получения информации о карте перехвачена и не понята устройствами чтения карт. Не все компьютеры со встроенными слотами для карт памяти будут работать, некоторые внутренние устройства чтения карт подключены через шину USB.

Предполагая, что у вас есть подходящее оборудование, есть несколько методов, которые вы можете использовать для получения информации о карте. В Linux считывание информации с внутренней SD-карты просто. Вставьте карту и посмотрите в /sys/block/mmcblk0/device/ (это расположение может меняться в зависимости от вашего устройства). Вы увидите несколько доступных атрибутов, которые включают в себя регистр CID и информацию внутри него.

Читайте также:  Дата создания файловой системы linux

Источник

Read CID of SDcard connected to USB-SD Reader under Linux

But when I connect same card to USB-SDCard reader, I couldn’t find any interface to read it in sysfs. Is there such interface in Linux? Or, is there any other way to read from registers of SDcard over USB in Userspace, without modifying Linux Kernel ? Many thanks.

Are you asking about lsusb and lsusb -v to return that information (and detail) for all USB ID’s on the system?

No I am not asking that. CID is a 16byte long number stored in registers of SDcards. I am asking, if there is a way to read registers of SDcards which are connected to USB-SD Converters.

1 Answer 1

But when I connect same card to USB-SDCard reader, I couldn’t find any interface to read it in sysfs.

That would be because it’s not available.

USB SD card readers use the USB Mass Storage device class. This interface is media-agnostic — it’s essentially a simplified version of SCSI. It doesn’t provide any standard way of accessing SD-specific information, like the CID register, and most SD readers don’t implement anything of the sort.

Unlikely. The SD registers aren’t part of USBMS — there’s no standard way of accessing them over USB.

After many years, this is the right answer. SD card readers has a chip inside. That chip is kind of a bridge, where one side is a USB device ( connected to your PC via USB cable ) and the other side is SDcard interface ( Where you insert your uSDcard into slot ). Most SD cardreaders in the market doesn’t provide any standard or non-standard way of accessing registers of Sdcard Controllers. Some manufacturers ( cough GenesysLogic cough ) can provide some proprietary way of accessing this data , or some SDcard manufacturers ( cough swissbit cough ) provide a proprietary tool ( SBLTM) for it

Источник

Read SD Card Serial Number from CID

For my current project, I tried to read the SD Card serial number because the number is factory stamped and unchangeable, so it easily could be used to protect embedded firmware from being copied.

The serial number is stored in the Card Identification Register (CID) which is read by \’Command 10\’ as stated in the SD Simplified Specifications. Unfortunately, it is not possible to read the CID of the card with a USB adapter — you need a \’direct\’ SD interface. My iMX233 based development board has 2 of them, so it was an easy task to improve our firmware to read the CID and extract the serial number, but how do I check if I get the correct information?

Reading SD-Card SID

Luckily the Linux kernel provides the CID via the SD and MMC Block Device Attributes so you may use a Linux device containing a direct SD interface like your Android phone or an embedded Linux board. Unfortunately, you cannot know the real path of the SD card in the /sys file system so I can only give some examples and you have to try out the actual path yourself.

Читайте также:  Переместить файл linux сервер

For example, on my Samsung Galaxy Note running Gingerbread, there is a /sys/block/mmcblk0 soft link pointing to:

mmcblk0 -> ../devices/platform/s3c-mshci.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0 mmcblk1 -> ../devices/platform/s3c-sdhci.2/mmc_host/mmc1/mmc1:b368/block/mmcblk1

So I check the CID using the adb tool from the Android SDK (rooting is not necessary):

adb shell # cat /sys/block/mmcblk0/../../cid

On my Olimex iMX233 OLinuXino embedded Linux board I call the following (directly on the board):

cat /sys/block/mmcblk0/device/cid

The resulting hexadecimal number contains the following information:

 Name Field Width CID-bits ------------------------------------------------ Manufacturer ID MID 7 [127:120] OEM/Application ID OID 15 [119:104] Product Name PNM 39 [103:64] Product Revision PRV 7 [63:56] Product Serial Number PSN 31 [55:24] reserved -- 3 [23:20] Manufacturing Date MDT 11 [19:8] CRC6 Checksum CRC 7 [7:1] not used, always 0 -- 1 [0:0] 

To convert the hexadecimal number to a binary one, please have a look at my multiplatform Binary/Decimal/Hexadecimal Converter.

Based on an iMX233 CPU Board it may be easy to build an intelligent USB card-reader, supporting, for example, CID / CSD information and autonomic card tests.

Update:

I got a few emails pointing out that using the CID as copy protection is not a good idea because there are some cards on the market which are not compliant with the standard. These cards don’t prohibit CMD26 in SPI mode and therefore allow writing the CID. However, I\’ve never seen such a card.

Update 2:

You can find an online CID decoder here: Decode SD Card CID Register Data

Mike Bergmann

Technical software developer loving low level, bit peeking, embedded development as well as GUI, OO, and X-platform development.

Источник

Finding a unique identifier for SD cards

FYI: You’re not really expected to reply to each answer. Though voting up/down on them and, if one solves your problem, picking it as your accepted answer are definitely appreciated.

2 Answers 2

Based on @humanityAndpeace comment, Looking for CID could be a solution, but it seems that you cannot get it from all sd cards. At least it is the case for one I tested. See more documentation here.

The idea is to get infos from /sys/block//device/cid

Note: you can read from sudo dmesg after plug in

blkid(8) is probably what you’re looking for. It will give the UUID of each device.

For vfat, can set UUID using mtools application mlabel(1).

For ext2, ext3, and ext4, e2label(8) can be used to set the UUID.

So if you reformat from time to time, just set the UUID to the same as it was before if needed.

Can’t speak for other card readers, but the ones I’ve used via a USB port pass through the UUID of the SD card.

whatever blkid returns will change whenever the data stored on the SD-card changes. This is much different to the CID or serial number. If you made a dd if=/dev/sdcard1 of=/dev/sdcard2 count=2 , changes are very hight that blkid /dev/sdcard1 will be identical to blkid /dev/sdcard2 . Also the final remark of the answer is misleading: the UUID is derived from the data stored on the SD card, and not the card, clearly most every USB reader will let you read the content of th SD-card. What is still not possible is to access the CID .

Источник

Оцените статью
Adblock
detector