Project: Read, Collect & Decode SD Card CID Register Data

Buying flash memory from poorly reputed places, such as Chinese computer markets, and online auction sites is an often known way to collect BAD flash memory cards that fall short on performance, longevity and data security. SD cards, along with their “counterparts” mini and microSD cards, all contain manufacturer defined information in a set of registers. One is known as the CID, short for Card Identification Register. There is also another called the CSD or Card Specific Data Register. These can only be accessed directly via hardware and not via most card readers. I am aware that it was possible to do this via the SD Card Shield and Arduino, but since I have a Chromebook, things got really easy. Under the Chromebook, the SD reader slot on the side is directly connected to the SD bus of the ARM CPU and is not a USB based reader. By running Chrubuntu, getting the CID or CSD data from a card is as simple as:

cat /sys/block/mmcblk1/device/cid
cat /sys/block/mmcblk1/device/csd

Et voila! You will be rewarded with a hexadecimal string with the data in it. By comparing some cards that you own with the known signatures, you can have some reassurance whether your cards are similar, or genuine. Unfortunately, I haven’t seen a large CID database online, nor have I seen a CID decoder that will decode the hex string into the component parts (some BCD, some ASCII, others Unsigned Int or best as Hex), so I went on a journey to code one up for CID. I used this reference by Sandisk for the data field lengths and types. The CIDs for the cards I have in my possession that are in reach are as follows:

45010053454d31364790e03506aebf4d CHROMEBOOK INTERNAL EMMC
1b534d3030303030100337410200d13b RASPBMC SDHC CARD
1b534d3030303030107d11463800c199 SAMSUNG 32Gb CLASS 10 SDHC
8903034e43617264000000667000b285 TEAM 32Gb CLASS 10
41343253443132383002b800b600da6f KINGSTON 128Gb SDXC CLASS 10
02544d534430324728ad78243300793d KINGSTON 2Gb SDSC
035344534430324780019acc7600844b SANDISK 2Gb Blue SDSC
275048534433324730b018bd6700abe5 PATRIOT 32Gb CLASS 10 SDHC
035344535533324780718848c800b7fb SANDISK 32Gb CLASS 4 MicroSDHC
035344535530314780401c751300637d SANDISK ULTRA II 1Gb MicroSDSC
0353445355363447801013d98600d6d3 SANDISK ULTRA 64Gb UHS-I MicroSDXC
1234564d532020201000004c6300c853 UNBRANDED 2Gb MicroSDSC
8803023132333220100000cea40071b9 PRETEC 2Gb MicroSDSC

Please note, while the code below works using the Javascript of your browser, I have no prior Javascript coding until today, with much help from Google searches and W3schools. I won’t warrant the below decoder as being bug free, but it’s free so give it a whirl! If you want a full-screen one, so you can use it side-by-side and compare two separate CIDs, try this “framed” wrapper here. Hope you find this useful! Maybe I’ll get around to coding one for the CSD in the future.

About lui_gough

I'm a bit of a nut for electronics, computing, photography, radio, satellite and other technical hobbies. Click for more about me!
This entry was posted in Computing, Electronics, Flash Memory and tagged , , . Bookmark the permalink.

9 Responses to Project: Read, Collect & Decode SD Card CID Register Data

  1. Hi, thanks for the online CID decoder, very useful.
    Additionally thanks for linking to my blog post about reading the SD card serial number from CID, very appreciated.

    • lui_gough says:

      Dear Mike,

      Thanks for the comment – always nice to receive some comments in return. I will always link to the resources I find helpful during my experiments and discoveries, and while I can’t link to everything, I definitely only link to those pages which are truly helpful and valuable. The pleasure is all mine :).

      – Gough

  2. Ken Fisher says:

    There’s an android app, SD Insight, that can read and decode CID from a slotted Micro SD. I think it references an internal database.

    I suspect the reason that information on the internal workings is so limited is because the DRM relies on the information for decryption authentication.

    I’ve read that in system programming to update the firmware / configuration that runs on the SD cards controller is possible, and that a few vendors will custom manufacture a card to clone an existing cards signature. In theory that 100% breaks the DRM allowing cloned cards to access the media as if it was the original license holding card..

    Personally I’m more interesting in hacking the controllers Flash Translation Layer. I suspect the cheap cards are actually good cards de-tuned for slower performance. I already do this with USB Flash drives, and the results are impressive. A $5 USB drive that writes 17 MBPS when it’s only rated at 4.

  3. Rishabh sharma says:

    I’m trying to find where my sd card is from. Can I use the serial number to find the batch country ?

    • lui_gough says:

      Not that I know of, no. It’s not like a UPC barcode that uses the first three digits to denote country. The serial is essentially random and defined by the manufacturer. The vendor code (two digits) is the closest to knowing your SD card manufacturer, and even then, only the SD Association has the official two-digit to manufacturer mapping and they don’t release this publicly. There is information that seems to suggest that CSD and CID of some cards may be altered after manufacturing, with some limitations (e.g. change of bits from 1 to 0 only, or only some fields alterable), so even this information alone may not be enough to guarantee authenticity.

      – Gough

  4. ginbot86 says:

    After doing some of my own investigation, the CID for the Chromebook’s internal eMMC corresponds to the SanDisk SDIN8DE2-16G.

    There’s even a full datasheet if you look up the chip by its internal MMC name (SEM16G – MMC uses a 6-byte long name string):

    eMMC’s been a bit of a hobby thing for me lately; if you’d like more entries on your list, I have a few CIDs and CSDs of various eMMC devices I can provide.

  5. Matthijs van Duin says:

    Note that (e)MMC and SD have different CID structures and different manufacturer ID registries! So when cataloguing CIDs be sure to include the device type (found in sysfs attribute ‘type’). Also, the year code of the MMC CID is only 4-bit (specifically (year-1997) mod 16), so to interpret it correctly you need to know which version of the standard is used (obtained from ext_csd). See eMMC spec for details, you can download it from JEDEC after free registration.

    A list of some manufacturer IDs can be found here:
    The CID decoding there however seems to be broken, I’m getting garbage out of it.

    Some eMMC CIDs I have:
    fe014e4d4d43303447424f02f8bf61b3 (Micron MTFC4GLDEA-0M WT, eMMC 4.41)
    fe014e4d4d433034474200e52c8251b9 (Micron MTFC4GLDEA-0M WT, eMMC 4.41)
    fe014e503158585858122ecf986a9207 (Micron MTFC4GACAAAM-1M WT, eMMC 4.5)
    7001004d4d43303447581b9e35db9151 (Kingston KE4CN2H5A, eMMC 4.5)
    7001005331303030340858c9a6f9c2cf (Kingston EMMC04G-S100, eMMC 4.5/5.0)

    The last one claims 5.0 in the docs I found (a 1-page brief), but its ext_csd says 4.5. Based on dumping other fields it seems to partially implement 5.0.

  6. Gerhard says:

    Hi, i just stumbled over the calculator – very practical 😉

    A few remarks, though…
    – Product revision are afaik actually hex, not BCD, for Major/Minor revision.
    – Manufacturing date is definitely hex – my latest card with CID 1b534d303030303010402d55d8010900 is from 09/2016, which doesn’t work with the current decoder formula…

    changing the “manufdate” decoder output from
    >[Hex: “+h2d(txt[27])+””+h2d(txt[28])+” / “+h2d(txt[29])+”][Hex: “+h2d(txt[27]+txt[28])+” / “+h2d(txt[29])+”][Hex: 20″+h2d(txt[27]+txt[28])+” / “+h2d(txt[29])+”]< shows the correct dates…

    • Gerhard says:

      i seem to have mangled the javascript…

      original was [Hex: “+h2d(txt[27])+””+h2d(txt[28])+” / “+h2d(txt[29])+”]

      replacement is [Hex: “+h2d(txt[27]+txt[28])+” / “+h2d(txt[29])+”]

      or nicer [Hex: 20″+h2d(txt[27]+txt[28])+” / “+h2d(txt[29])+”]

Error: Comment is Missing!