Apr 102006
Card reader for FreeBSD
When I first heard of a card reader, I thought of business cards. I imagined a device that took business cards and digitized them so you could save contact information. Yes, such tools exist, but the card reader in question is actually a memory card reader. A very common use of this tool is to take a memory card from a digital camera and read it into your computer. I have two such devices. One I’ve had for year or so, and the other one is a recent acquistion. I bought a second card reader just recently in order to get the pictures off the kids’ camera. Their cameras take an XD meory chip. My original card reader was a USB 2.0 7-in-1 device. It can handle the following types of cards:- CF
- MD
- SD
- MMC
- MS
- MSpro
- SM
- Memory Stick Duo
- Mmeory Stick PRO
- Mmeory Stick PRO Duo
- Compact Flash I
- Compact Flash II
- SD
- miniSD
- MultilMediaCard
- MMCplus
- MMCmobile
- RS-MMC
- RSMMC Dual Voltage
- SmartMedia
- xD
- xD Type M



/var/log/messages
when the card reader is
connected and it contains an xD memory card. The device that represents the memory card
is in bold.
To access the memory card, you need to mount the device. To FreeBSD, this memory card appears as a SCSI device.umass0: SanDisk ImageMate 14 in 1 Reader/Writer, rev 2.00/93.21, addr 2 da0 at umass-sim0 bus 0 target 0 lun 0 da0:Removable Direct Access SCSI-0 device da0: 40.000MB/s transfers da0: 15MB (32000 512 byte sectors: 64H 32S/T 15C) (da0:umass-sim0:0:0:0): READ CAPACITY. CDB: 25 0 0 0 0 0 0 0 0 0 (da0:umass-sim0:0:0:0): CAM Status: SCSI Status Error (da0:umass-sim0:0:0:0): SCSI Status: Check Condition (da0:umass-sim0:0:0:0): NOT READY asc:3a,0 (da0:umass-sim0:0:0:0): Medium not present (da0:umass-sim0:0:0:0): Unretryable error Opened disk da0 -> 6 (da0:umass-sim0:0:0:0): READ CAPACITY. CDB: 25 0 0 0 0 0 0 0 0 0 (da0:umass-sim0:0:0:0): CAM Status: SCSI Status Error (da0:umass-sim0:0:0:0): SCSI Status: Check Condition (da0:umass-sim0:0:0:0): NOT READY asc:3a,0 (da0:umass-sim0:0:0:0): Medium not present (da0:umass-sim0:0:0:0): Unretryable error Opened disk da0 -> 6 (da0:umass-sim0:0:0:0): READ CAPACITY. CDB: 25 0 0 0 0 0 0 0 0 0 (da0:umass-sim0:0:0:0): CAM Status: SCSI Status Error (da0:umass-sim0:0:0:0): SCSI Status: Check Condition (da0:umass-sim0:0:0:0): NOT READY asc:3a,0 (da0:umass-sim0:0:0:0): Medium not present (da0:umass-sim0:0:0:0): Unretryable error Opened disk da0 -> 6 da1 at umass-sim0 bus 0 target 0 lun 1 da1: Removable Direct Access SCSI-0 device da1: 40.000MB/s transfers da1: 15MB (32000 512 byte sectors: 64H 32S/T 15C) da2 at umass-sim0 bus 0 target 0 lun 2 da2:Removable Direct Access SCSI-0 device da2: 40.000MB/s transfers da2: Attempt to query device size failed: NOT READY, Medium not present da3 at umass-sim0 bus 0 target 0 lun 3 da3: Removable Direct Access SCSI-0 device da3: 40.000MB/s transfers da3: Attempt to query device size failed: NOT READY, Medium not present (da2:umass-sim0:0:0:2): READ CAPACITY. CDB: 25 40 0 0 0 0 0 0 0 0 (da2:umass-sim0:0:0:2): CAM Status: SCSI Status Error (da2:umass-sim0:0:0:2): SCSI Status: Check Condition (da2:umass-sim0:0:0:2): NOT READY asc:3a,0 (da2:umass-sim0:0:0:2): Medium not present (da2:umass-sim0:0:0:2): Unretryable error Opened disk da2 -> 6 (da2:umass-sim0:0:0:2): READ CAPACITY. CDB: 25 40 0 0 0 0 0 0 0 0 (da2:umass-sim0:0:0:2): CAM Status: SCSI Status Error (da2:umass-sim0:0:0:2): SCSI Status: Check Condition (da2:umass-sim0:0:0:2): NOT READY asc:3a,0 (da2:umass-sim0:0:0:2): Medium not present (da2:umass-sim0:0:0:2): Unretryable error Opened disk da2 -> 6 (da2:umass-sim0:0:0:2): READ CAPACITY. CDB: 25 40 0 0 0 0 0 0 0 0 (da2:umass-sim0:0:0:2): CAM Status: SCSI Status Error (da2:umass-sim0:0:0:2): SCSI Status: Check Condition (da2:umass-sim0:0:0:2): NOT READY asc:3a,0 (da2:umass-sim0:0:0:2): Medium not present (da2:umass-sim0:0:0:2): Unretryable error Opened disk da2 -> 6 (da3:umass-sim0:0:0:3): READ CAPACITY. CDB: 25 60 0 0 0 0 0 0 0 0 (da3:umass-sim0:0:0:3): CAM Status: SCSI Status Error (da3:umass-sim0:0:0:3): SCSI Status: Check Condition (da3:umass-sim0:0:0:3): NOT READY asc:3a,0 (da3:umass-sim0:0:0:3): Medium not present (da3:umass-sim0:0:0:3): Unretryable error Opened disk da3 -> 6 (da3:umass-sim0:0:0:3): READ CAPACITY. CDB: 25 60 0 0 0 0 0 0 0 0 (da3:umass-sim0:0:0:3): CAM Status: SCSI Status Error (da3:umass-sim0:0:0:3): SCSI Status: Check Condition (da3:umass-sim0:0:0:3): NOT READY asc:3a,0 (da3:umass-sim0:0:0:3): Medium not present (da3:umass-sim0:0:0:3): Unretryable error Opened disk da3 -> 6 (da3:umass-sim0:0:0:3): READ CAPACITY. CDB: 25 60 0 0 0 0 0 0 0 0 (da3:umass-sim0:0:0:3): CAM Status: SCSI Status Error (da3:umass-sim0:0:0:3): SCSI Status: Check Condition (da3:umass-sim0:0:0:3): NOT READY asc:3a,0 (da3:umass-sim0:0:0:3): Medium not present (da3:umass-sim0:0:0:3): Unretryable error Opened disk da3 -> 6
Make sure that /mnt exists before you issue this command. Most cameras use a FAT file system, and that is why I used# mount_msdosfs /dev/da1s1 /mnt
mount_msdosfs
above.
The memory stick is now just another filesystem according to your FreeBSD system:
# df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2a 507630 102034 364986 22% / devfs 1 1 0 100% /dev /dev/ad0s2e 507630 72 466948 0% /tmp /dev/ad0s2f 15709014 6505554 7946740 45% /usr /dev/ad0s2d 1254862 282386 872088 24% /var /dev/da1s1 16000 15744 256 98% /mnt
Here’s a look around that memory stick:
Now you can copy files around, just as you would on any other disk:# cd /mnt # ls dcim # cd dcim # ls 100_fuji # cd 100_fuji # ls dscf0001.jpg dscf0048.avi dscf0091.jpg dscf0002.jpg dscf0049.avi dscf0092.jpg dscf0003.jpg dscf0081.jpg dscf0093.jpg dscf0030.jpg dscf0082.jpg dscf0117.jpg dscf0046.jpg dscf0086.jpg dscf0118.avi #
Always remember to unmount the filesystem before you disconnect the USB device, or remove the memory stick from the card reader. Failure to do this may result in a corrupted filesystem.# mkdir ~/my-photos # cd ~/my-photos # cp /mnt/dcim/100_fuji/* . # ls dscf0001.jpg dscf0048.avi dscf0091.jpg dscf0002.jpg dscf0049.avi dscf0092.jpg dscf0003.jpg dscf0081.jpg dscf0093.jpg dscf0030.jpg dscf0082.jpg dscf0117.jpg dscf0046.jpg dscf0086.jpg dscf0118.avi #
# umount /mnt
The link in the article for the card reader dock is broken. The link currently points to:
http://www.freebsddiary.org/images/card-reader.san.disk.in.dock.jpg
[%sig%]
Fixed. Thanks. Sorry.
—
The Man Behind The Curtain