[ home | photos | gallery | scheme | notes | blog | facebook | twitter | youtube | last.fm | myspace | del.icio.us | EverythingHerePlus ]
Various notes and how to information for PC Cards with OpenBSD, recorded so I can refer back to them if necessary. Some items may help others. Since there isn't a great deal of data on the Internet for PC Cards under OpenBSD, I hope that this may be a starting point for others.
The Athlon OpenBSD 3.3 box at work has a two slot Cardbus capable reader utilizing the Ricoh R5C486 bridge chip. The reader is almost always used for new product testing under the new OS from Redmond, and occasionally with SuSE. However, the system is usually booted under the best of the three installed OSs -- OpenBSD. Being a researcher for a PC Card company, it really bothered me that I could never figure out how to get cards to work with my x86 operating system of choice. Off and on I have been unsuccessfully researching and trying to get consumer memory cards to mount for months. Now that I have sorted things out, I hope that it will serve others. These techniques should work with laptop based slots as well, I just don't have an x86 laptop to verify if they do. I now have another reader installed in a home OpenBSD server, the information for that configuration is also at the end of this document.
Remember, just about everything here needs to be executed as root, or better yet, sudo. The system logs all PC Card insertions and removals. To observe this behavior, insert a card and look at the system log.
california# tail -f /var/log/messages Sep 17 15:12:53 california /bsd: wdc2 at pcmcia0 function 0 "STI, Flash 6.1.0" port 0xc000/16 Sep 17 15:12:53 california /bsd: wd1 at wdc2 channel 0 drive 0 Sep 17 15:12:53 california /bsd: : <STI Flash 6.1.0> Sep 17 15:12:53 california /bsd: wd1: 1-sector PIO, LBA, 488MB, 1059 cyl, 15 head, 63 sec, 1000755 sectors Sep 17 15:12:53 california /bsd: wd1(wdc2:0:0): using BIOS timings
The second line holds the device name we are looking for. Since ATA Flash and consumer cards based on it (CF, SmartMedia, etc.) are essentially IDE devices, OpenBSD assigns the typical IDE Drive device name 'wd*' to it. In this case, the first item
wd1 is what we will use. Now to determine the full device name by calling disklabel on the card.
california# disklabel wd1 disklabel: warning, DOS partition table with no valid OpenBSD partition # /dev/rwd1c: type: ST506 disk: ST506/MFM/RLL label: ST506 flags: bytes/sector: 512 sectors/track: 17 tracks/cylinder: 8 sectors/cylinder: 136 cylinders: 1024 total sectors: 1000755 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg] c: 1000755 0 unused 0 0 # (Cyl. 0 - 7358*) i: 999873 63 MSDOS # (Cyl. 0*- 7352*)
Unless intentionally formated otherwise all PC Card media is FAT-16. So we want the DOS partition since that is where every thing is and goes. This makes the full device name
wd1i, which we can now mount.
california# mount_msdos /dev/wd1i /mnt/pccardtwo/
We can now access data on the card or even write to it. I have two mount points (one for each slot) in mnt. Since I use tcsh, I name them so that I can use auto complete to avoid a lot of typing. I type /mnt/pc tab and auto complete expands to /mnt/pccard, then I can type o or t tab and auto complete finishes the path. Unmounting the card is just as simple. Make sure that you cd out of the directory first (cd ~) if you were cwd in the mount point. I type mount here first just to remember which path to unmount.
california# mount /dev/wd0a on / type ffs (local, softdep) /dev/wd1i on /mnt/pccardtwo/ type msdos (local, uid=1000, gid=0) california# umount /mnt/pccardtwo/
The card can now be ejected safely. The system logs the card removal.
california# tail -f /var/log/messages Sep 17 15:14:29 california /bsd: wd1 detached Sep 17 15:14:29 california /bsd: wdc2 detached
That's all there is to it. The same methodology works for all ATA Flash based media cards in adapters as well. This includes CompactFlash, SmartMedia, .
Thanks to the Daemon News article 'Mounting Compact Flash under FreeBSD' for moving me in the right direction. Special thanks to the Usenet message post comp.unix.bsd.openbsd.misc for causing me to attempt calling disklabel. Even though the post discussed USB readers instead or PC Card slots it, was the key to identifying the correct partition on the card.
Everything tested under OpenBSD 3.3-Stable. I will either update, or create a new list once I have 3.4 installed. Hardware notes and link to compressed dmesg output listing below. Yes, they are links to my day job's site. Since they allow me to test all these products for free, I figure a little promotion isn't all that bad. Anyway, these items are known to work.
To help demonstrate how the kernel lists the reader, here is the dmesg output. The installed card reader is a two slot Cardbus capable reader utilizing the Ricoh R5C486 bridge chip. Our part number for the device is the PCM-CR-PC2IC3, OEM Ratoc Systems International, Inc.
My home PIII system is dual boot OpenBSD 3.4-stable and 3.5-beta, here is the dmesg output. The installed card reader is a two slot Cardbus capable reader utilizing the eNe PCI-1420 (TI Compatible) bridge chip. Our part number for the device is the PCM-CR-PC2IF2, OEM Elan Digital Systems, Ltd.