How To: Read CID on SD cardMay 24, 2012, How To Read CID on SD cardIf you are looking to, or extract the CID off an SD card then you’ve find this article very helpful. Some also call this “reading the PSN off the SD card” or reading the product serial number off the SD card.Most phones and much of the software on phones will lock in to the CID number of a SD card. Free xbox games to download.
The CID number is a unique card identifier number that is unique to the card itself. The CID number is valuable because software developers and hardware developers can lock software to the unique number of the device thus eliminating the ability to pass along licensed software.Reading the CID number from an SD card is not an easy task. It requires specific access codes to the index table of the memory card, and unless you know how to use the SD chipset of your card reader, chances are you wont get the numberor least the correct and accurate number.What is the CID number of an SD card?The CID register is 16 bytes long and contains a unique card identification number. It is programmed during card manufacturing and cannot be changed by SD Card hosts. The CID number is a compilation of information about the card, such as manufacturer, date manufactured, checksum total, GB size and more. Below is a table outlining all the items which make up the SD CID number. So with all this said, how do you read the CID number from an SD card?
As we’ve mentioned it isn’t easy and it’s more or less hardware based. If you do enough searching on the internet you’ll find some home-brew code to read the CID numbers, but that’s only if you have the SD card or microSD card connected via an IDE bus to your host computer. This isn’t easy for everyone. There is clear evidence that using a USB to SD card reader will not get you the information you require, or at least accurate and correct information. Meaning most times the CID number generated is actually the serial number of the card reader itself, not the CID number of a specific SD card.In addition, what if you are required to read the CID number off SD media in bulk? A single, one-at-a-time solution is not practical.In my search to read the CID number from SD media, I cam across Nexcopy – a manufacturer of USB duplicator equipment and other flash memory equipment. Several models they carry are SD duplicators and microSD duplicators.
With the secure digital duplicators part of their feature set includes. The equipment can ready 20 cards at a time, 40 cards at a time, or 60 cards at a time, depending on the model.
The duplicators will read the CID number and exported to a.csv file for import into other business functions. This configuration makes it quick and easy to obtain the CID number. Granted, the equipment is not designed for single use operation, but rather reading the CID of SD media in bulk quantity. Here is a screenshot of Nexcopy’s software reading 20 CID numbers.
(Quick link to an executable, this might read the serial number on Windows XP/Vista/32/64 when you are not using a USB card reader (so when you have the card in a slot on the side of a laptop it should work - though it depends on the driver!)). Requires.Net Framework 3.5.I got an email about a about reading the serial number from an SD Card. People want to do this as the number is factory stamped and unchangeable, so it could be used to protect programs from being copied. Distribute your program on an SD Card, have it check the serial, and have it fail if the number doesn't match a hard-coded version. Maybe there's more to it than that. But anyway the thread went along the lines of:1) I want to read the serial2) Someone suggested: Well use DeviceIOControl to send IOCTLDISKGETSTORAGEID to the drive.At the time I'd just been playing with DeviceIOControl, and had spent ages working out how to use it from.Net.
There weren't any useful examples that I could find. I was working at trying to make a CD Burner, using COM Interop to talk to IMAPI on XP (before IMAPI2).
How To Get Sd Card Serial Number Location
I'd learnt about DeviceIOControl, and how it can be used to send messages straight to a device. I used it to find out things that IMAPI couldn't tell you - like the exact media in the drive, and whether the drive was ready. I eventually got a vb.net program that could burn MP3s to CD.
I never quite finished it though. I wasn't sure how to deal with all the possible errors during burning - there were so many!I quickly wrote some code that demonstrated sending the message. I didn't know if the number was really the hardware stamped serial or whether it was just something windows dreamt up (like the volume serial you get with dir c:).I was asked again this week about this, and pointed in the direction of the concise SD specification (you can only see the big one if you pay $$$$, as it isn't an open standard). It's call the.
This describes various commands that can be sent. Command 10 returns the CID. The CID is the bit we are interested in, the Card IDentification register:NameFieldWidthCID-sliceManufacturer IDMID8127:120OEM/Application IDOID16119:104Product NamePNM40103:64Product RevisionPRV863:56Product Serial NumberPSN3255:24reserved-423:20Manufacturing DateMDT1219:8CRC7 ChecksumCRC77:1not used, always 1-10:0There we have 128 bits used to identify the device. I was asked if the number that my earlier program grabbed was this number from the CID. I don't know.(edit - NO it isn't the same.
IOCTLDISKGETSTORAGEID is useless - it gets a serial that Windows invents when it formats a volume.)I decided to try and get this CID number out, and I've managed to, but there are provisos. My program (VB.Net) currently works only on Vista 64. Weirdly it only works when compiled for the x86 platform (the build target in visual studio).
When I tried it on Vista 32 I got invalid handle errors. The other biggy is that it only works when the SD Card is plugged into a reader that is attached directly to the pci bus.
If USB is involved in the chain, then the DeviceIOControl messages go to the USB host controller, and it doesn't understand them. It works on my laptop's reader, but not on a fan controller/card reading gadget plugged in to my desktop as its card reader is attached via a USB header on the mobo.Here are some pics of the CIDs.
They came out reversed, and the endianness of the serial number and manufacturer date were unhelpful. In the pics below, the 16 bytes are the ones I got in my buffer, but reversed order. They tally quite well with the above table.
But, the leftmost byte (0 in each case) shouldn't be there, and we are missing the CRC and final bit. So it goes - Unspecified byte, MID, OID, OID, PNM, PNM, PNM, PNM, PNM, PRV, PSN, reserved+MDT, MDT. And the CRC is missing.I bought the two Crucial 4GB cards at the same time, note the serial numbers are adrift by 2 - a good indication I'm not getting gobbledegook.
The Manufacture date is mm/yyyy. Also the numbers tally with the hardware IDs found in Windows Device Manager, which are, er WDK rather. I bought the Veho card two weeks ago, looks like it was made just last month.
It also looks like Vehos are made by Corsair - or maybe they are both made by some other company. Crucial don't fill in the product name or version, all the bytes were 0.The bit where is says 'This is an SD card', is because it also checks if the drive selected in the combobox is an SD card before attempting to get data.So, how's it done? Well, you send an IOCTL specifying an SD Command with DeviceIOControl. These are just user mode calls, so we aren't in the realms of writing a driver.
The main difficulties were trying to decipher the documentation, which appears to be plain wrong in places. This lead to many many errors being returned by DeviceIOControl.
Eventually I managed to send off command 0 without any complaint whatsoever, and figured I must be doing something right. I was using C code from and a bit of C Interop. I then got something back from cmd 10. I then went and did it in VB.Net instead as all this C was driving me mad. I can read it, but programming in it is a very laborious process for me.I used IOCTLSFFDISKQUERYDEVICEPROTOCOL to check if a mount point was an SD card. Then IOCTLSFFDISKDEVICECOMMAND to send cmd10. DeviceIOControl just takes the IOCTL code and a blob of memory - in.Net I used a byte array.
The byte array contains a SFFDISKDEVICECOMMANDDATA structure first, then the SDCMDDESCRIPTOR. Both of these structures were 20 bytes big on x64 vista when using c, so I made sure they were that size in.Net too. The Cmd field of SDCMDDESCRIPTOR is very nasty. The documentation says to fill it with a value from the SDCOMMANDCODE data type and lists two 'allowed values'. Well, both of those values give errors. Instead you should set the sd command code - i.e.
10 for command 10, 0 for command 0!!!!! After that structure I sent 16 bytes to receive the CID. And unfortunately I get 15 bytes of CID with a 00 in front and no CRC. Maybe I have some alignment problems with the structures. It might explain why my code isn't porting too.I'll iron out the bugs and try and get it running on my dilapidated axim 50v too with the compact framework.
I'm currently attempting to flash the rom on it to something newer. Best flight planning software australia. I nearly binned it last week in a grand tidy up.
I'll have to download the academic version of Visual Studio, which is Pro, to do the windows mobile stuff. I've only got Standard (which was a MS freebie from the launch). Code to follow.(note there are other, newer, posts on this on the blog, and some other code).
I can't seem to find a way to find the serial number of my SD card. I've looked in /dev/disk/by-uuid, but the same uuid is used across multiple Pis that I have. I've also used the blkid command, but I can only seem to get the size of the SD card. Any help would be appreciated.Edit: I managed to figure out where the 'serial number', aka CID, is found. For anyone who's interested, it's located in /sys/block/mmcblk0/device/cid. The CID contains info on when the card was manufactured, by whom and what its intended content is.
For more information on the SD card standard I plan on using the CID to encrypt the files on the SD card so no one can take my card out and simply copy what's on it.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |