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

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

Reply to
irotas
Loading thread data ...

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.

Reply to
zwsdotcom

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

Reply to
irotas

Did you try reading the documentation for Busybox?

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?

Reply to
zwsdotcom

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.

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

Reply to
irotas

Recompiling busybox is the work of a few minutes. Your call if it is more or less effort than duplicating that functionality from scratch.

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 ?

Reply to
zwsdotcom

Actually I just found a way:

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

Hooray!

Reply to
irotas

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

Reply to
irotas

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

Reply to
Mark Borgerson

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.

Reply to
zwsdotcom

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.