USB Digital Camera HOWTO

Dave Kelly

April 2002

Revision History
Revision 2.02002-06-02Revised by: tab
Converted to Docbook XML 4.1.2
Revision 1.02002-04-13Revised by: dek
Initial release

Table of Contents
1. License
1.1. Copyright
1.2. Intent
1.3. Scope of Devices
1.4. Reading Material
2. Assumptions
3. Preliminary Setup
4. The Script Files
4.1. If You Login as User
4.2. If You Login as Superuser
4.3. Make it Executable
4.4. What is Happening while the script is running
5. Exploring and Fine Tuning
5.1. DON'T PANIC
6. Troubleshooting or PANIC!
7. Last Things Last
A. Appendix A
A.1. PART 1
A.2. PART 2
B. Appendix B
C. Appendix C
D. Gnu Free Documentation License
D.1. PREAMBLE
D.2. APPLICABILITY AND DEFINITIONS
D.3. VERBATIM COPYING
D.4. COPYING IN QUANTITY
D.5. MODIFICATIONS
D.6. COMBINING DOCUMENTS
D.7. COLLECTIONS OF DOCUMENTS
D.8. AGGREGATION WITH INDEPENDENT WORKS
D.9. TRANSLATION
D.10. TERMINATION
D.11. FUTURE REVISIONS OF THIS LICENSE
D.12. How to use this License for your documents

Chapter 1. License


1.3. Scope of Devices

This procedure works with the Linux kernel version 2.4.8, and I tested it with a Sony P-50 Cybershot with a 4 MB and 64 MB memory stick, and a USB smart card reader for an Olympus camera. I have read that the procedure will also work on kernel versions back to 2.2.19, but there are no guarantees. I know the procedure does not work on my old kernel version of 2.2.15.

The information in this document is how I solved my problems. There are other way to do this but it may require recompiling the kernel, which I did not want to do. This document should give you the necessary information to make USB mass storage active at boot time.

Also, Linux is an evolving technology, a hands on technology, and while this document may not give you the answers to your specific question, it should give you a place to start exploring for those answers. Plus the serendipity of discovering new thing along the way.

The following excerpt from the "gphoto2 README" might give you some insight to other cameras that will work with this procedure. I don't know who to give credit for this, as I could not find a name.) Check the "gphoto" link for updated information: http://www.gphoto.org

Then, there are cameras supporting the so-called USB Mass Storage protocol. This is a protocol that has been published and lets you access any storage device, be it a camera or a disk connected via USB to your computer. As there are already drivers for this protocol out there, you don't need an additional program like gphoto2.

As of now, the following cameras seem to support the USB Mass Storage protocol:

  • Casio QV [2x00,3x00,8000]

  • Fuji FinePix S1 Pro, [1400,2400,4700]Zoom, 1300, 4500

  • HP PhotoSmart 315, 618, 912

  • Leica Digilux 4.3

  • Konica KD300Z

  • Kyocera Finecam s3

  • Minolta Dimage 7

  • Nikon Coolpix 995

  • Olympus C-100, C-200Z, C-700, C-860L, C-2040, C-3020Z, C-3040Z, C-4040Zoom, D-510, E-10

  • Pentax Optio 330

  • Sony DSC-F505(V), DSC P5, DSC-F707

Again, those cameras cannot be accessed through gphoto2.

Other cameras support a protocol called PTP or USB Imaging Devices that has been developed by Kodak and other. gphoto2 does not support PTP yet, but jPhoto does. Here is a short list of cameras that use this protocol:

  • Kodak DC-4800, DX-3215, DX-3500, DX-3600, DX-3700, DX-3900, MC3 and all the cameras that use Kodak Easy Share™ system.

  • Sony DSC-P5, DSC-F707 (both need user configuration of the camera)

These cameras won't be supported until gphoto2 implements PTP.


Chapter 2. Assumptions

My system is a Athlon 900 with a 40 gig hard drive. I have no SCSI or USB devices. My kernel was compiled without any of the SCSI or USB drivers. I compiled the SCSI and USB drivers as modules. I have version 2.4.8_26mdk of the Linux kernel with Mandrake 8.1. Since we are working on the kernel level, this document should be applicable to any distro.

I also make the following assumptions in this document:


Chapter 3. Preliminary Setup

At this point you need to make some decisions. You will need to create a directory for a mount point, and you will need a name for this directory. I use camera and place it in /mnt. The name of the directory (camera in my case) can be any word of your choice. The command for creating this directory is:


[bash]$ mkdir -m 777 /mnt/camera

I prefer for all my pictures to be in one directory with subdirectories by subject matter, so I also created a directory named picture, and placed it in my home directory. The name of the directory (picture in my case) can be any word of your choice. The command for creating this directory is:


[bash]$ mkdir -m 777 ~/picture

See Section A.1, listed at the end of this document.

The big decision! Are you going to do this as "user" or "superuser/root"?


Chapter 4. The Script Files

The following script file is the result of reading several of the Linux newsgroups and a lot of HOWTOs and manuals. I take no credit for originality but confess that this is a compilation of what those more experienced have told me. A very big thank you to all those in the newsgroups who responded to my questions and the ones posted by others who were seeking this information.

To get started, using your favorite text editor select a name for the file and, type in the following script for a user or superuser.


4.1. If You Login as User

Type in the following script file:


echo "Please enter a directory name for the pictures."
read DIRPATH
mkdir ~/picture/$DIRPATH
su -c "/sbin/modprobe usb-storage; mount -t vfat /dev/sda1 /mnt/camera;
/etc/rc.d/init.d/usb start;
mv /mnt/camera/dcim/100msdcf/*.jpg ~/picture/$DIRPATH;
umount /mnt/camera;
chown -R your_login_name ~/picture/$DIRPATH"

4.2. If You Login as Superuser

If you are not creating this script for use as superuser, go to Section 4.3.

Type in the following script file.


echo "Please enter a directory name for the pictures."
read DIRPATH
mkdir picture/$DIRPATH
/sbin/modprobe usb-storage
mount -t vfat /dev/sda1 /mnt/camera
/etc/rc.d/init.d/usb start
mv /mnt/camera/dcim/100msdcf/*.jpg picture/$DIRPATH;
umount /mnt/camera
chown -R your_login_name picture/$DIRPATH

4.3. Make it Executable

Now make the script file executable. The command for that is:

As user:


[bash]$ su -c "chmod a=r+w+x your_script_file_name"

As superuser:


[bash#] chmod a=r+w+x your_script_file_name

4.4. What is Happening while the script is running

When you run the script, it will create a subject matter directory. DIRPATH should describe the pictures and is entered at the prompt. If your_script_file_name = getcamJ,(J for getting the pictures with .jpg extensions) the command sequence would look like this:


[bash]$ getcamJ
Please enter a directory name for the pictures.
bash]$ something
Password: 
[bash]$ your root password

If you run this script file in superuser mode the rest of this paragraph does not apply. You have to be superuser to run this. Consequently, the 'su' command. The -c flag will let you execute one command and return to your present working directory. The quotation marks allow you to enter more that one command. And the semicolon allows one command to execute right after the last.

/sbin/modprobe usb-storage: modprobe will install the USB mass storage module along with any other modules or drivers needed. Mainly the SCSI driver. Make sure that you have in your /dev directory the following entries. sda0, sda1, sda2, sda3, sda4, sdb0, sdb1, sdb2, sdb3, sdb4. Set sda1 to the appropriate device if you have other SCSI devices mounted, probably sdb1.

Mount your SCSI driver: mount -t vfat /dev/sda1 /mnt/camera

Start your USB: /etc/rc.d/init.d/usb start

Move your pictures from your camera to your hard drive. mv will also remove your pictures from your camera: mv /mnt/camera/dcim/100msdcf/*.jpg picture/$DIRPATH;

Unmount your SCSI driver: umount /mnt/camera

Then: chown -R your_login_name picture/$DIRPATH. When you do something as superuser (su) or root, root owns those files/pictures. Some of the things you may want to do to these files/pictures may give you a permission denied error. This allows the user to work without those errors. Read the manual for more information.

My system is set up with no USB or SCSI compiled into the kernel. All this was compiled as modules. This script file assumes your system is the same. If not, you will have to make some modifications. Please read the manuals and HOWTOs. Or ask on one of the Linux newsgroups.


Chapter 5. Exploring and Fine Tuning

OK, you should be set up and ready to do some exploring. Go take some trash pictures with your camera in all the different formats. Mine will take in 4 formats, TIFF, GIF, JPEG, and MPEG, and it also provides a thumbnail of each picture. In my Sony P-50 these will be stored on the memory media in 4 different sub-folders, 100msdcf, imcif100, thm, and moml0001. These are in 2 folders, dcim, and mssony. You need to find how your camera names the directories. You can do this in the following manner:


Chapter 6. Troubleshooting or PANIC!

If nothing has gone right, let's do some troubleshooting. Use your camera and see if you still have pictures on it. If you do, skip the rest of this paragraph. If you don't, they should be someplace, check again. If not, and you can not find them, go take some more. Turn your camera off and plug it in and boot up again.

Check to see if the mount point unlinked by mv,/mnt/camera is there. If it's gone create it again. Sometimes the mount point disappears in modified mode. Also, I have notice on my system that sometimes the SCSI device in /dev (sda1) gets removed. Check that also and replace if needed.

Clean up all the extra directories you got from the script you ran that produced the errors and run your new script with the directories and see if it works. To make it easier to clean up all the directories and files you may have to su - if you're in user mode. Be sure to change back when you get through. See Appendix C at the end of this document.

Type:


[bash]$ dmesg

and you should see this somewhere:


hub.c: USB new device connect on bus1/1, assigned device number 2
usb.c: USB device 2 (vend/prod 0x54c/0x10) is not claimed by any active driver. (The 
0x54c/0x10 will be different for different vendors.)

If you see this, your USB mass storage device in recognized.

Now turn your camera on and run the script file (the modified one) and you should see something like this when you run dmesg again:


[bash]$ dmesg

SCSI subsystem driver Revision: 1.00
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: Sony Model: Sony DSC Rev: 3.22
Type: Direct-Access ANSI SCSI revision: 02
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 2
USB Mass Storage support registered.
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 126848 512-byte hdwr sectors (65 MB)
sda: Write Protect is off
/dev/scsi/host0/bus0/target0/lun0: p1
usb-uhci.c: interrupt, status 3, frame# 1628

Now run this command and read Appendix B.


[bash]$ lsmod

If the information from running lsmod appears as in Appendix B,and your dmesg shows the information listed above, and there are no pictures, I don't know what is wrong. Unfortunately, the only thing I know to do is go thru the whole process again. Only this time use the re-direction option >filename to capture the results. Post this to one of these 2 newsgroups:

telling what you've done and ask for help. Include everything you can think of, the more information the better, and e-mail me at the same time. My address is: daveekelly@earthlink.net.


Chapter 7. Last Things Last

After you have got everything working correctly and working just the way you want it to, this is something you can do if you want to. Not required. You can continue to run the executable script file from the directory you wrote it in with the dot slash option preceding the name (./) or you can install it in one of the directories that hold other executable applications. I would recommend /usr/sbin. The command for that is:


[bash]$ install file_name /usr/sbin

Appendix A. Appendix A

A.1. PART 1

This is the way I want my picture directory to be set up. A primary directory picture and a sub-directory describing the content smkbot.


picture/smkbot:
dsc00117.jpg dsc00120.jpg dsc00123.jpg dsc00126.jpg dsc00129.jpg 
dsc00118.jpg dsc00121.jpg dsc00124.jpg dsc00127.jpg dsc00130.jpg 
dsc00119.jpg dsc00122.jpg dsc00125.jpg dsc00128.jpg dsc00131.jpg

A.2. PART 2

With the modified version of the script file you have the pictures scattered over several directories. But right now, this is what we want.


picture/trash:
camera

picture/trash/camera:
dcim mssony

picture/trash/camera/dcim:
100msdcf

picture/trash/camera/dcim/100msdcf:
dsc00357.jpg dsc00360.jpg dsc00363.jpg txt00365.gif
dsc00358.jpg dsc00361.jpg dsc00364.jpg txt00365.thm
dsc00359.jpg dsc00362.jpg dsc00366.jpg

picture/trash/camera/mssony:
imcif100

picture/trash/camera/mssony/imcif100:
dsc00364.jpg dsc00366.tif

Appendix B. Appendix B

What we want to see here is the word usb-storage under the Used by column:


Module       Size      Used by
nls_iso8859-12880  0   (autoclean)
nls_cp437 4400  0   (autoclean)
sd_mod11792  0   (autoclean)
vfat 9968  0   (autoclean)
fat 32192  0  (autoclean) [vfat]
usb-storage 52528 0
scsi_mod 91072 2 [sd_mod usb-storage]
ppp_deflate 42208 0  (autoclean)
bsd_comp  4576  0  (autoclean)
ppp_async 6672  0  (autoclean)
ppp_generic 19616  0  (autoclean) [ppp_deflate bsd_comp ppp_async]
slhc 5136  0  (autoclean) [ppp_generic]
parport_pc  20240 1  (autoclean)
lp 5808  0  (autoclean)
parport  24768  1 (autoclean) [parport_pc lp]
es1371 26768  1
soundcore 4208  4 [es1371]
ac97_codec  9312  0  [es1371]
gameport  1856  0  [es1371]
af_packet  12560  0 (autoclean)
ip_vs 62000  0  (autoclean)
usb-uhci  21232  0  (unused)
usbcore  50752  1 [usb-storage usb-uhci]
rtc 5600  0  (autoclean)

Appendix C. Appendix C

When you go to clean up all those test directories, use the following command. BUT BE VERY VERY CAREFUL:


[bash]$ rm -Rf picture/test_directory

You could lose more than you bargin for, test_directory should be what you entered for $DIRPATH in the scripts above. (It never hurts for first time user to slip over somewhere else and create a directory tree, copy file to it, and test this command line before using it on something irreplacable.) Again read the manual.


Appendix D. Gnu Free Documentation License

Version 1.1, March 2000

Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.


D.2. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".

A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.

The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.

A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.


D.4. COPYING IN QUANTITY

If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.


D.5. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

  1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.

  2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).

  3. State on the Title page the name of the publisher of the Modified Version, as the publisher.

  4. Preserve all the copyright notices of the Document.

  5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.

  6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.

  7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.

  8. Include an unaltered copy of this License.

  9. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.

  10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.

  11. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.

  12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.

  13. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.

  14. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.


D.11. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.