Linux - 19 - Flash card reader
This guide assumes you are using a 2.6 kernel with udevfs and sysfs.
Kernel requirements
| MSDOS_FS, MSDOS_PARTITION, VFAT_FS, NLS_CODEPAGE_437 | For the FAT filesystem that is commonly used on flash cards |
| USB, USB_STORAGE | The actual support for your card reader |
| SCSI, SCSI_MULTI_LUN, CHAR_DEV_SG, BLK_DEV_SD | The USB storage support emulates the device as a SCSI disk. |
udev rule
The following rule maps the card reader to a device node in /dev/. Rules are stored in /etc/udev/rules.d/udev.rules on slackware 10.0, this may differ in your distribution.
BUS="scsi", SYSFS{vendor}="04DA*", SYSFS{model}="1B00*", NAME="sdcardreader%n"
/etc/fstab
The following line is needed to map the mount mount to the device.
/dev/sdcardreader1 /mnt/sdcardreader vfat defaults,user 1 1
Testing / debugging
Plug in your device, ensuring there is a card in the slot! Type dmesg, you should see something like the following.
scsi2 : SCSI emulation for USB Mass Storage devices
Vendor: 04DA Model: 1B00 Rev: 0010
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi2, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi2, channel 0, id 0, lun 0, type 0
USB Mass Storage device found at 4
SCSI device sda: 124160 512-byte hdwr sectors (64 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
sda: sda1
Check /var/log/messages and you should see udevd create the device node in /dev/
udev[7932]: configured rule in '/etc/udev/rules.d/udev.rules'
at line 128 applied, 'sda1' becomes 'sdcardreader%n'
Access the card by mounting it mount /mnt/sdcardreader. No errors should be returned. Check dmesg if there are. If you get "bad block or wrong fs type" then check you included the FAT filesystem in your kernel, especially codepage 437 support.
You can check basic access to the device with fdisk /dev/sdcardreader. Then type P for print partition table.