Software Design UK


Home Page
Contact Us
About Us

Web 2.0
Sound Cards for Linux
Spam Filters
Linux FlashReader
Scripting in Linux
A SQL Tutorial

Clients
Client Login
Autoresponder
 
Linux FlashReader
Home Page > Training > Tutorials > Linux FlashReader


This is a Linux article covering Flash Readers for Digital Cameras. It explains what is a Flash Reader, the circumstances in which its use is advantageous, the IT requirements for use and how to install the hardware and software under Linux.

Contents
Downloading directly
Downloading from removable memory
What is a Flash Reader
IT Requirements
Installing the UnoMas

Downloading directly from a camera
A digital camera stores its images somewhere in the digital camera. In the old days, all images were stored on a fixed internal memory. Now, just about all cameras come with the memory being removable, very much along the lines of a floppy disk for personal computers. For a camera that has fixed memory, the only way to transfer the image from the camera to a computer is by plugging a lead from the camera to the computer and relying on software on the PC to "talk" to software on the camera. In Linux, the key software which talks to the very large majority - but not all - cameras is "gphoto2" (download and instructions from www.gphoto.org.uk).

The "gphoto" route works very well for cameras that are supported. There is an excellent training manual for using the command line instructions to see what is in the camera, transferring files and deleting files that you have transferred.

(Back to contents)


Downloading from memory removed from the camera
The alternate to direct communications that are camera specific is to remove the relatively standard removable memory media, slot it into a "Reader" that is not far off a floppy disk drive, "mount" the Reader to the Linux system, and use conventional Linux commands to see what is on the drive, copy files across and clear the files when finished. The conventional commands include "cp" to copy, "ls" to list and "rm" to remove.

For removable memory, there are currently six main physical formats on which the images are stored. The formats are Compact Flash (CF), IBM's MicroDrive (a hard disk built in the form factor of CF), Smart Media (SM), Secure Digital (SD), MultiMedia Card (MMC), and Sony's memory stick (MS).

We went down the "Reader" route because gphoto support for the Nikon D100 was patchy, and we could not get the software to link with the camera. Without going into detail, there are many Readers that do not seem to give universal satisfaction on Linux. The Reader we tried out successfully was the UnoMas reader from OmniFlash (details on www.omniflashproducts.com). We opted for the UnoMas after having searched the web extensively for reliable Readers. This was the only one we could find (as at Dec. 2002) that had only positive commentary from Linux users.

(Back to contents)


What is a FlashReader?
The FlashReader has four slots, each of a slightly different size and thickness, each accepting one of the six formats above. The format is removed from the camera and physically plugged in to the Reader. The Reader has a lead which plugs into the PC. Typically, the lead will stay in the PC, making the Reader instantly available at all times.

(Back to contents)


What are the requirements to use the UnoMas FlashReader?
In the UnoMas, the Reader's lead plugs into the USB port. If you do not have a USB port or USB support, you will not be able to use the UnoMas. On the OmniFlash web site, the stated software requirements are Linux Kernel 2.4.1 and later (which includes Red Hat V7.1 or later and Suse Linux 7.2 or later, for example).

(Back to contents)


Installing the UnoMas
There are instructions on the OmniFlash web site for installing the UnoMas on Linux. We had difficulty understanding the concepts involved, which this article is designed to resolve. This is not a substitute for the excellent instructions on the web site, which can be found on www.omniflashproducts.com/downloads/OmniFlash/Linux/LinuxMountingInstructions.PDF

STEP 1 (Checking for USB support)

Firstly, you need to check that the USB support is working. You can check by typing the command:
admin@softwaredesign.co.uk> ls /proc/scsi/scsi

If your USB is properly installed and working, you will get a response:
admin@softwaredesign.co.uk> /proc/scsi/scsi

If your USB is not properly installed you will get a different response. In this case, you may need to install USB support. We are novices with USB. If you, like us, don't really know where to start, a good place is the excellent www.gphoto.org where there is a great introduction to installing a USB system from scratch.

If your USB is working, you may want to check out what is in it before you go to step 2, just to know what is in it before you "plug in" the Reader.

We have a CD burner on the scsi bus, which was picked up and reported as follows:

Type:
admin@softwaredesign.co.uk> cat /proc/scsi/scsi

Response:

Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: PLEXTOR  Model: CD-R   PX-W8432T Rev: 1.04
  Type:   CD-ROM                           ANSI SCSI revision: 02


When we played around in blissful ignorance, one command that we entered was:

admin@softwaredesign.co.uk> /sbin/modprobe \*

There is a possibility that the above device was not picked up prior to this command.


STEP 2 (Getting the Lun numbers)

When you know that your USB is working, plug in your UnoMas to the USB port at the back of the computer. If everything is working as it should, you will hear a "sort of click" and the lights on the front of the UnoMas will light up. This "sort of click" seems to coincide with Linux detecting the new device having been plugged in.

Miraculously, the UnoMas was picked up (although our fingers were very crossed at this point and it is possible that the crossing was what made it work rather than divine intervention). The proof of success was this:

Type again:
admin@softwaredesign.co.uk> cat /proc/scsi/scsi

This time, the response:

Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: PLEXTOR  Model: CD-R   PX-W8432T Rev: 1.04
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: OEI-USB  Model: MMC/SD           Rev: 5.09
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 01
  Vendor: OEI-USB  Model: SmartMedia       Rev: 5.09
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 02
  Vendor: OEI-USB  Model: CompactFlash     Rev: 5.09
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 03
  Vendor: OEI-USB  Model: Memory Stick     Rev: 5.09
  Type:   Direct-Access                    ANSI SCSI revision: 02



For step 3, please note the following:
The top left slot on the UnoMas seems to accommodate the MMC/SD format - note in particular the Lun of 00. Top right is SmartMedia (Lun 01), Bottom left is for CompactFlash (Lun 02) and Bottom right is for Memory Stick (Lun 03).


STEP 3 (Updating the /etc/fstab settings)

Once you have the UnoMas "scsi" recognition, you can set up the fstab settings. These are required to allow you to "mount" the device, which will then allow you to access the device as if it were a simple directory. Within the fstab settings, you will be identifying the "file structure" so that Linux knows how to handle the device.

In the fstab file (you need to be "root" or "su" for this) add the following two lines if they are not already there.
proc	/proc	   	proc    	defaults 0 0
usbdevfs /proc/bus/usb usbdevfs noauto 0 0


Then, still in the fstab file add the following line which should not already be there, subject to the following comments.

/dev/sdc1       /home/directory/CompactFlashReader   auto    noauto,user 0 0


The first part of this line is "/dev/sdc1". The letter "c" in the statement comes from the Lun number, where "a" corresponds with "Lun 00", "b" corresponds with "Lun 01" and so on. In other words, depending on the format you want to read, you will need a different letter correspondingly.

The second part of this line is "/home/directory/CompactFlashReader". You want to set up a directory to "contain" the photo files. (As normal, you can use any directory you want - the one given is just illustrative). Set up (using the command "mkdir"), which will appear to be the directory that contains the files. If you want anyone to have access, change its rights to 777 (using the command "chmod"). Alternatively, use more restrictive rights if you want more privacy. The commands in this paragraph would look something like:
admin@softwaredesign.co.uk> mkdir /home/download/CompactFlashReader
admin@softwaredesign.co.uk> chmod 777 /home/download/CompactFlashReader

The third final parts are just system instructions that I used faithfully.


STEP 4 (Mounting the directory)

Once you have the /etc/fstab file set up properly, you only need to "mount" the device. This is the Linux way of allowing you to pretend that the Reader is just a directory, and the contents of the memory are just normal files.

Type (you need to be "root" or "su" for this):
admin@softwaredesign.co.uk> mount /home/directory/CompactFlashReader

If everything worked properly, you now have a working system. You can check all is in order by firstly plugging in the memory to the Reader, and then typing the command:
admin@softwaredesign.co.uk> ls /home/directory/CompactFlashReader

A (wonderful) response would be something like:

admin@softwaredesign.co.uk> dcim nikon001.dsc


A (somewhat) less satisfying response would be something like:
admin@softwaredesign.co.uk> mount: I could not determine the filesystem type, and none was specified

This would result where you have forgotten to plug the memory card into the Reader, for example.


STEP 5 (Downloading etc)

Once you have mounted the file, you are ready to download. Here are some simple suggestions:

See what files are available:
admin@softwaredesign.co.uk> ls /home/directory/CompactFlashReader

In the Nikon 100, this lists the jpg files taken by the camera:
admin@softwaredesign.co.uk> ls /home/directory/CompactFlashReader/dcim/100nd100

Copy the files to another directory (all directories are illustrative - use your own source and destination directories as per usual):
admin@softwaredesign.co.uk> cp /home/directory/CompactFlashReader/dcim/100nd100/* /home/directory/MyPhotoAlbum

Delete the files from the Memory Card:
admin@softwaredesign.co.uk> rm /home/directory/CompactFlashReader/dcim/100nd100/*


Remember to unmount the device before you "quit", with the command:
admin@softwaredesign.co.uk> umount /home/directory/CompactFlashReader


OPTIONAL STEP 6 (Automating the download process)

Being very impatient, we have set up a simple script that allows us a "one click" command to mount the device, then copy all files to a standard directory, then unmount the device. We have a second script that mounts the device, deletes all photos from the memory card and unmounts the device afterwards.

To execute the commands, simple execute:
admin@softwaredesign.co.uk> ./MountCamera
or
admin@softwaredesign.co.uk> ./ClearCamera

In case you want a similar functionality, here it is. To run the commands, simple execute ./MountCamera or ./ClearCamera:


File : MountCamera (with executable rights 777):
mount /home/download/CompactFlashReader

SourceDirectory='/home/download/CompactFlashReader/dcim/100nd100'
DestinationDirectory='/home/directory/PhotoAlbum'
PhotoExtension='jpg'
DateStamp=`date +"%y%m%d.%H%M"`

for photoName in $SourceDirectory/*.$PhotoExtension; do

  NewName=`echo ${photoName#$SourceDirectory/}`
  NewPhotoName=`echo $NewName | sed s/$NewName/$DateStamp.$NewName/g`
  echo "$NewPhotoName"
  cp $photoName $DestinationDirectory/$NewPhotoName

done

umount /home/nigel/general/photos/CompactFlashReader


In case of interest, one gaff we made was the automatic overwriting of files in the PhotoAlbum. The Nikon camera, by defaults, resets the numbering system of photos to "1" each time the memory is cleared. This means we initially downloaded (with huge delight) a wonderful set of pictures, numbered from 1 to 125 as it happens, to the PhotoAlbum directory. The next automated download transferred pictures, 1 to 73 as it happens, overwriting the original 1 to 73 without a care in the world. The solution in the script above is to rename each jpg file by adding a fixed date and time string before saving it. We have never again overwritten a jpg file.


File : ClearCamera (with executable rights 777):

mount /home/download/CompactFlashReader
rm /home/download/CompactFlashReader/dcim/100nd100/*.jpg
umount /home/download/CompactFlashReader

(Back to contents)