Search:  
Gentoo Wiki

Digital_Camera

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

Connecting an Olympus D-40 ZOOM digital camera is much simpler than one would expect. This particular model uses USB 1.1, so everyone owning this product should be able to easily use this camera with any linux system using a 2.6 series kernel.

Aside from this HOWTO being specific to the D-40 ZOOM digital camera, this HOWTO should be able to be used for any digital camera.

USB mass storage mode?

If your camera does NOT support USB mass storage mode, this HOWTO won't help you! In this case you probably could use gphoto2 ([1]). But if your camera DOES support mass storage mode, gphoto won't help you! You should use the HOWTO in this case.

(List of cameras supported by gphoto: [2])

Synopsis

What this HOWTO will do

1. Install an Olympus D-40 ZOOM digital camera with UDEV

Required packages

sys-fs/udev
sys-apps/hotplug

Step by Step

1. Install packages
2. Configure UDEV

You will need root access.

Gentoo environment

System environment

This Olympus D-40 ZOOM digital camera was configured on a stable x86 platform using kernel 2.6.10. CFLAGS and CHOST used are as follows:

CFLAGS

-march=athlon-xp -fomit-frame-pointer -pipe -O2

CHOST

i686-pc-linux-gnu

Kernel version

2.6.11-ck1

It is assumed, if you wish to implement this HOWTO, that you have a fully functioning Gentoo Linux system and some basic knowledge of device installation.

The Linux Kernel

In order to use the Olympus D-40 ZOOM digital camera, the kernel must be configured to support USB, SCSI and vfat filesystems. Please note that if you enable USB support first, this will also enable SCSI support. However, we must still veryify all drivers that will be installed.

First, you will need to verify whether you will need OHCI OR UHCI support. Because my board has the VIA chipset, I need UHCI support. To verify, you'll need to run the following command:

Code: Run Command
# lspci
0000:00:02.0 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)
0000:00:02.1 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)
0000:00:02.2 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)

If your output is as generic as mine is, you will need to verify which USB driver to use by visiting your USB controllers website. (NOTE: Try lspci -v first as it provides much more information)

Next, you will need to add proper USB, SCSI and file system support to your kernel. This digital camera supports USB 1.1 so you do not need to worry about having USB 2.0 support unless you have other devices that can take advantage of the 2.0 technology. In this example, OHCI is used because this is what my USB controller requires.

I prefer compiling support into my kernel as opposed to making modules. The choice is yours.

Code: Required Kernel options

For USB support

Device Drivers -> USB Support
<*> Support for Host-side USB
[*]   USB device filesystem
<*> EHCI HCD (USB 2.0) support
<*> OHCI HCD support
<*> USB Mass Storage support

For SCSI support

Device Drivers -> SCSI device support
[*]   legacy /proc/scsi/ support
<*>   SCSI disk support
<*>   SCSI generic support

For vfat file system support

File systems -> DOS/FAT/NT Filesystems
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support

Remove devfs support

File systems -> Pseudo filesystems
[ ] /dev file system support (OBSOLETE)

It may be necessary to add:

File systems -> Partition types
[*] PC BIOS (MSDOS partition tables) support

for your system to understand MSDOS partition table from your camera (this trick is mandatory for a mac).

Lastly, you will need to make sure your system boots using udev and not devfs. In the first example, the boot loader grub is used. A lilo example is available below that.

File: grub.conf
mount /boot
nano /boot/grub/grub.conf

At the end of kernel line, add gentoo=nodevfs:

kernel (hd0,0)/boot/2.6.10-ck5 ro root=/dev/hda3 gentoo=nodevfs vga=792

Do not forget to unmout your /boot partition before rebooting, if needed.

And for the lilo users among us.

File: lilo.conf
nano /etc/lilo.conf

Between label and read-only statments, add:

append = "gentoo=nodevfs"

Make sure to update lilo.

When you're done recompiling your kernel you will need to reboot unless you built all of the above as modules AND are already running UDEV. In which case, hotplug should load the modules when you plug the camera in. In case it does not load all the modules, you'll need to load the modules yourself:

Code: Load Module
# modprobe msdos
# modprobe vfat
# modprobe sd_mod
# modprobe sg
# modprobe usbcore
# modprobe ehci-hcd (for USB 2 support, if needed for something else)
# modprobe ohci-hcd OR # modprobe uhci-hcd (depending on what your USB controller requires)

NOTE: Because this device is a USB device and a file system, SCSI support must be installed. All filesystems connected to a linux node use a "virtual" SCSI interface to provide access to the drive. Why? I really don't know.

Verify Camera's Presence

After you've rebooted, or loaded the needed modules, connect your camera to a USB port. You also have to switch on your camera. This should create the device /dev/sgX, where X is the number of your device. To verify your camera is recognized, take a look at dmesg output:

Code: View dmesg output
# dmesg
usb 3-2: new full speed USB device using ohci_hcd and address 10
scsi2 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 10
usb-storage: waiting for device to settle before scanning
 Vendor: OLYMPUS   Model: C-40Z/D-40Z       Rev: 1.00
 Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sdb: 256000 512-byte hdwr sectors (131 MB)
sdb: assuming Write Enabled
sdb: assuming drive cache: write through
SCSI device sdb: 256000 512-byte hdwr sectors (131 MB)
sdb: assuming Write Enabled
sdb: assuming drive cache: write through
sdb: sdb1
Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi2, channel 0, id 0, lun 0,  type 0
usb-storage: device scan complete

Or another example...

Code: View dmesg output
# dmesg
usb 5-2: new full speed USB device using uhci_hcd and address 2

If you see the above message, or similar, you're good to go. Otherwise, you'll need to double check your kernel options OR you will need to troubleshoot at the hardware level. With some cameras you can install gtkam to get the photos, since you can't mount them as you can with most of the cameras.

Install Packages

This is probably the easiest step. It is good practice to always do a pretend/verbose before installing any package. This way you know what is going to be installed (focusing on dependencies, if any). UDEV is a very small package and takes under a minute to install (maybe a bit longer on slower systems).

Code: Install UDEV
# su
Password:
# emerge --sync
# emerge udev hotplug -av

Configure UDEV

Now you will need to write a udev rule. We'll need to get the sys device information from the device. First we will need to find out what the device's sys path is:

Code: udevinfo
# udevinfo -q path -n /dev/sg0
/class/scsi_generic/sg0

Now, with the above output, we can now obtain the sys device serial number that will be needed for the udev rule. You will need to append /sys to the beginning of the statement:

# udevinfo -a -p /sys/class/scsi_generic/sg0
BUS="usb"
ID="3-2"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="  0mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="c0"
SYSFS{detach_state}="0"
SYSFS{devnum}="10"
SYSFS{idProduct}="0105"
SYSFS{idVendor}="07b4"
SYSFS{manufacturer}="OLYMPUS"
SYSFS{maxchild}="0"
SYSFS{product}="C-40Z/D-40Z"
SYSFS{serial}="000202125180"
SYSFS{speed}="12"
SYSFS{version}=" 1.10"

The bold face information above is what you will need for the rule, so copy it to your favourite text editor for the next step.

If udevinfo -a -p does not specify your product's SYSFS{serial} number you may be able to find it using the lsusb -v command.

Now, using your favourite text editor, open the /etc/udev/rules.d/10-local.rules file (go ahead and create a new one if it doesn't exist) and add the following line:

BUS=="usb", SYSFS{serial}=="000202125180", KERNEL=="sd?1", NAME="%k", SYMLINK="olympus"

The bold face text above represents the information needed from the previous step. I added the line under the USB devices section for obvious reasons.

After you have made these changes, it is necessary to unplug your device, and plug it back in, before the changes can take effect.

note: the 10 in the above mentioned 10-local.rules may differ. On my system there was a "50-local.rules" file. I created a new file with the 10-local.rules name, and it works.

Final Steps

At this point, your camera should still be plugged in. It would be a good idea to unplug it briefly and reconnect it so hotplug can do it's thing. Then, after editing fstab, the last step, you will need to power up your camera. Make sure the batteries have enough juice or you have an AC adapter connected to it. I suggest getting an AC adapter as transferring the images to your hard drive consumes batteries like a Hummer does petrol. As an alternative, invest in rechargable batteries.

The last step of this HOWTO involves editing your fstab so that your system knows where to mount the device when it need to be mounted.

File: fstab
#<fs>                <mountpoint>   <type>    <opts>                 <dump/pass>
/dev/olympus    /media/camera   vfat         noauto,user,exec     0 0

Then create the directory to which you want your camera mounted to. In my example, I created /media/camera. Create your directory anywhere you want, with respective changes to /etc/fstab.

The fs column will be /dev/olympus in this example as this is the udev rule created. From /etc/udev/rules/50-udev.rules, if you changed the value of (the bold faced text)

BUS=="usb", SYSFS{serial}=="000202125180", KERNEL=="sd?1", NAME="%k", SYMLINK="olympus"

you will need to change the value of your fs to /dev/olympus. Don't forget to execute udevstart afterwards; else udev won't be updated to use the new settings.


Post-edit fstab

I personally use KDE. As a user, I just launch konqueror and open up /media/camera and KDE mounts the mountpoint for me. I believe this is because I have enabled Kernel automounter version 4 support in my kernel but I am not 100% sure.

If you find that you cannot access your camera, you will most likely have to mount it yourself.

Code: mount camera
# su
Password:
# mount /media/camera
# exit

Camera mounted and ready to be used.


Things to remember

1. Plug the camera in
2. Make sure your camera has adequate power, ie: charged batteries or AC adapter.
3. Turn the camera on
4. Reboot if you recompiled drivers into the kernel

Automatic Picture Import in GNOME

Note that GNOME can auto-mount a digital camera when it is connected. This functionality requires the gnome-base/gnome-volume-manager package emerged and can be adjusted by running gnome-volume-properties. For more info on that see gnome-volume-manager.

For cameras, the default command calls up gthumb (media-gfx/gthumb) in the import pictures mode, but this will only work for cameras that are supported by media-gfx/gphoto2. For those using the mass storage driver (like the one above), the camera recognition will fail. (See also above: #USB mass storage mode?)

Instead, get this script by David Zeuthen which will open gthumb with your camera pictures directory. The command line that needs to be executed by gnome-volume-manager is: /path/to/gvm-gthumb-wrapper %h (provided that's what you called the script).

Now when you connect the camera, gnome-volume-manager should ask whether you want to import the pictures, and if so, will open gthumb with the picture directory from the camera.

A simpler option is to use F-Spot to import your photos. The command line that needs to be executed by gnome-volume-manager is: /usr/bin/f-spot-import %h It will automatically determine if the device uses USB Mass Storage or requires gphoto2 and import them into your photo library.

Kodak CX* camera's

libgphoto2 2.1.6 is broken with Kodak CX* camera's so you'll need to downgrade to 2.1.5 to get Digikam or gphoto2 working.

Notes

Hotplug is responsible for acknowledging that a new device was connected while the machine is on. udev is responsible for device naming.

For more information on udev, please review the udev man page.

Support

Gentoo Forums
Contact the author
An alternative HOWTO


This article is in major need of an overhaul by an expert. The information is out of date, incomplete, and possibly inaccurate.

Retrieved from "http://www.gentoo-wiki.info/Digital_Camera"

Last modified: Wed, 27 Aug 2008 04:44:00 +0000 Hits: 40,569