Forums

How to read the 'Card Information Structure' from a CompactFlash card

Started by irotas April 14, 2009
I'm trying to find out how to read the manufacturer and product name
from the 'Card Information Structure' on a CompactFlash card.

Here's the details:
 - Linux 2.4 kernel
 - BusyBox v1.00-rc3
 - Need to be able to read the CIS from userland
 - Need to be able to read the CIS from an embedded C++ application
(in other words, not by viewing 'dmesg')
 - Linux is running from the CompactFlash card that I need to read
 - The card reader is attached directly to the board - i.e., it is not
over USB or anything like that
 - Would prefer a solution that does not involve recompiling the
kernel
 - An indirect solution like reading some special file in '/proc'
would be acceptable

Essentially what I'd like to do is modify my embedded application so
it can respond to a network query asking what the CF manufacturer/
product name is.

I've been looking around on the web but haven't found anything
terrible useful. Any advice?

Thanks,
Adam
On Apr 14, 1:40=A0pm, irotas <goo...@irotas.net> wrote:

> Essentially what I'd like to do is modify my embedded application so > it can respond to a network query asking what the CF manufacturer/ > product name is.
You probably can't. It is very rare to find a CF card slot implemented as anything other than a hardwired True-IDE device. AFAICR you can't access the CIS unless the slot is wired as a PCMCIA-type implementation. There's no reason to look at the CIS for a flash disk card; it's only useful for I/O type cards. You can however use the ATA Identify command to get some vendor information about the card. Look at hdparm -I (or -Istdout for the raw data) to see what this will give you.
On Apr 14, 2:11=A0pm, zwsdot...@gmail.com wrote:
> You can however use the ATA Identify command to get some vendor > information about the card. Look at hdparm -I (or -Istdout for the raw > data) to see what this will give you.
Nice, hdparm is able to read the manufacturer/product name from the card. The only trouble is that our deployed systems don't have 'hdparm' installed. Do you know of any comparable libraries that I could use to access the information? Otherwise I may have to strip out the necessary functionality from 'hdparm' manually and create a library myself. Thanks again, Adam
On Apr 14, 2:38=A0pm, irotas <goo...@irotas.net> wrote:

> The only trouble is that our deployed systems don't have 'hdparm' > installed.
Did you try reading the documentation for Busybox? <http://www.busybox.net/downloads/BusyBox.html>
> Do you know of any comparable libraries that I could
If busybox's implementation isn't enough, it really depends on why you care. Does /proc/sg/device_strs tell you enough for whatever you are trying to do?
On Apr 14, 3:01=A0pm, zwsdot...@gmail.com wrote:
> Did you try reading the documentation for Busybox? > > <http://www.busybox.net/downloads/BusyBox.html>
Yeah, either 'hdparm' was added to BusyBox after the version we deployed, or we stripped it out. (I wasn't around when all this took place originally). In any case, it's not available.
> If busybox's implementation isn't enough, it really depends on why you > care. Does /proc/sg/device_strs tell you enough for whatever you are > trying to do?
Basically we're replacing one brand of CompactFlash cards with another, and I was hoping to find a nice way to auto-detect which devices have been swapped out and which haven't. This is essentially an automated replacement for a manual spreadsheet. Unfortunately /proc/sg doesn't exist - I think that's only installed if you have the 'sg' module loaded. Thanks again, Adam
On Apr 14, 3:08=A0pm, irotas <goo...@irotas.net> wrote:

> Yeah, either 'hdparm' was added to BusyBox after the version we > deployed, or we stripped it out. (I wasn't around when all this
Recompiling busybox is the work of a few minutes. Your call if it is more or less effort than duplicating that functionality from scratch.
> Basically we're replacing one brand of CompactFlash cards with > another, and I was hoping to find a nice way to auto-detect which > devices have been swapped out and which haven't. This is
Again - why does your software care? If it's a space issue, then check free space, no? In other words, is this some audit issue, or is there an actual performance difference that needs to be taken into account by your software - if so, can you measure the desired parameter directly rather than guessing from the vendor name? If you don't have scsi-generic, do you have /proc/ide/hda/identify ?
Actually I just found a way:

~ # cat /proc/ide/ide0/hda/model
SanDisk SDCFH-512

Hooray!
On Apr 14, 3:14=A0pm, zwsdot...@gmail.com wrote:
> Again - why does your software care? If it's a space issue, then check > free space, no? In other words, is this some audit issue, or is there > an actual performance difference that needs to be taken into account > by your software - if so, can you measure the desired parameter > directly rather than guessing from the vendor name?
For technical reasons we need to transition to a different CompactFlash vendor - I won't get into the specifics. All I really need to know is the manufacturer name, which is available directly from '/proc/ide/ide0/hda/model', so I'm happy! Thanks again, Adam
In article <9fac201e-084b-4afc-a864-56f84d0ac594@
21g2000vbk.googlegroups.com>, zwsdotcom@gmail.com says...
> On Apr 14, 3:08=A0pm, irotas <goo...@irotas.net> wrote: >=20 > > Yeah, either 'hdparm' was added to BusyBox after the version we > > deployed, or we stripped it out. (I wasn't around when all this >=20 > Recompiling busybox is the work of a few minutes. Your call if it is > more or less effort than duplicating that functionality from scratch. >=20 > > Basically we're replacing one brand of CompactFlash cards with > > another, and I was hoping to find a nice way to auto-detect which > > devices have been swapped out and which haven't. This is >=20 > Again - why does your software care? If it's a space issue, then check > free space, no? In other words, is this some audit issue, or is there > an actual performance difference that needs to be taken into account > by your software - if so, can you measure the desired parameter > directly rather than guessing from the vendor name? >=20 > If you don't have scsi-generic, do you have /proc/ide/hda/identify ? >=20 >=20
How about just writing an ID file on the new cards. If it's there it is a new card. If missing, it's an old card. Mark Borgerson
On Apr 14, 4:12=A0pm, Mark Borgerson <mborger...@comcast.net> wrote:


> > If you don't have scsi-generic, do you have /proc/ide/hda/identify ? > > How about just writing an ID file on the new cards. If it's there > it is a new card. =A0If missing, it's an old card.
It was on the tip of my tongue to suggest this, but rereading the OP it seems that some units in the field have already been upgraded.