This is something that's been bugging me for quite some time now. I have a Canon Powershot S400 (Digital Elph), which uses Compact Flash (CF) cards as the storage medium. In addition to that, I bought a Lexar Jumpshot CF reader dongle thingy that allows me to just read images off the CF card without having to turn on the camera. But to use this under linux was a copmlete pain in the ass. I had to login as root, load some modules, yada, yada, yada.
I figured there just had to be a better way. And besides, this procedure will probably work for lots of other USB devices besides the Jumpshot Card Reader.
Before you get too far, and for the following instructions to actually work, you will have to configure/rebuild your linux kernel so that it pretty closely meets the following requirements (I chose to build nearly all of these as modules):
- Code maturity level options: Prompt for development drivers
- Loadable Module Support: Enable loadable module support
- Loadable Module Support: Set version information on all module symbols
- Loadable Module Support: Kernel module loader
- IDE, ATA and ATAPI Block devices: SCSI emulation support
- SCSI support: SCSI disk support
- SCSI Support: SCSI generic support
- File Systems: DOS FAT fs support
- File Systems: VFAT (Windows-95) fs support
- File Systems: /dev file system support (EXPERIMENTAL)
- File Systems: /dev file system: Automatically mount at boot
- USB Support: Preliminary USB device filesystem
- USB Support: EHCI HCD (USB 2.0) support
- USB Support: UHCI Alternate Driver
- USB Support: OHCI
- USB Support: USB Mass Storage Support
- USB Support: USB Mass Storage Support: Lexar Jumpshot CF Reader
You will then have to do go through the usual steps of building and installing the new kernel and modules. Configure your boot loader for the new kernel version, reboot, and proceed to the next step
The next thing you'll need to do is make sure you have the Linux Hotplug utilities installed on your machine. If you're using Gentoo Linux, this would look like:
> emerge hotplugOnce the installation is complete, you should have a shiny new /etc/hotplug directory. Make sure that the hotplug startup script has been started (/etc/init.d/hotplug) and configured to execute the next time you restart your machine. We're going to hack one of the installed shell scripts temporarily to help us figure out what vendor and model device the kernel thinks we have. If you are configuring a Jumpshot Compact Flash card reader, make sure the card reader (without the card) is plugged into one of the USB ports on your machine before proceeding.
> cd /etc/hotplug > vim usb.agentInside this file, find this passage, near line 128:
# than a float: e.g. 1.0 become 0100 PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+" -e "s/\.$/00/" \And change to read as follows:
# than a float: e.g. 1.0 become 0100 echo "PROD: $PRODUCT" >> /root/hotplug PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+" -e "s/\.$/00/" \You should now plug-in your USB device (or put the Compact Flash card into the card reader). Blinky lights should blink for a few seconds. Once they've stopped, do the following:
> cat /root/hotplug PROD: 5dc/1/1The output you see here is the product identifier that the USB modules in the kernel have assigned to your device. Write that down. Oh, and you can remove the 'echo' line from the usb.agent file now too. The '5dc/1/1' means the Vendor ID is '5dc', the Product ID is '1', and the Device ID is '1'.
Next, we're going to tell the hotplug scripts that each time it sees that device being plugged in, it should run a script of our choosing. This configuration happens in the /etc/hotplug/usb.usermap file. So edit that file, and insert the following on one line:
jumpshot 0x03 0x05dc 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000Here is what all of that means:
- Each time I insert the device, execute the script /etc/hotplug/usb/jumpshot
- Ensure it is the correct device by matching the Vendor and Product ID (0x03)
- The Vendor ID to look for is 5dc (0x05dc)
- The Product ID to look for is 1 (0x0001)
- The remaining 0x00... entries are ignored because we are only matching by Vendor and Product ID
So what does this 'jumpshot' script need to do? That is up to you. Mine does the following:
- Makes sure all of the required kernel modules are loaded.
- Mounts the Compact Flash card under the /mnt/jumpshot mountpoint.
- Generates a small removal script that will unmount /mnt/jumpshot when someone removes the CF card from the card reader
You can download a copy of my 'jumpshot' scripts (they're written in perl) if you like. Place the 'jumpshot' script into /etc/hotplug/usb directory, and make sure that the file is owned and executable by root. Make sure you open and read through the file before you use it. It needs to be customized for your environment. You might also want to modify and use my unmounter script, which I install in /usr/local/bin.
What comes next? Well, the last thing I wanted was a quick script that would copy all images off of the CF card into a directory named according to date (/home/pics/2003-03-22), then launch a graphics viewer like kuickshow. My copy images script is included in the tar archive above.
And that should be all it takes to get you up and running. Comments and improvements to jason@buberel.org.