Recently

Saturday, September 14, 2013

ANDROID TERMINAL DISPLAYS CID


How to read CID from android Term
Read SD Card Serial Number from CID

I tried to read the serial number from an SD Card 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 the Card Identification Register (CID) which is read by ‘Command 10′ as stated in the SD Simplified Specifications. One point by doing so is that it is not possible to read the CID if the card is plugged into a USB adapter — you need to have the card plugged into a ‘direct’ SD interface. Our own 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?

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 real path yourself.

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



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 Term/Sdk (rooting is not necessary):
adb shell # cat /sys/block/mmcblk0/../../cid



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


cat /sys/block/mmcblk0/device/cid

No comments: