Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 

HP Photosmart 120 on Fedora Core

by Pawel Szopinski on Feb 20, 2004

1. Introduction
This document describes how to use HP Photosmart 120, a digital camera on Fedora Core. This document should be useful for other Linux distributions users too. We will use Disk Device mode in the camera, which means no special drivers are necessary, we will use a special storage protocol. If you have another digital camera and it can work in a Disk Device mode, then you should read this carefully too, because this is a really clean and flexible method and the information in this document will be helpful to you as well.

1.1 HP Photosmart 120
HP Photosmart 120 is a cheap digital camera from an HP Photosmart family. The camera has 1 MP resolution, 2x digital zoom and uses a USB 2.0 interface. This model has 4MB internal memory and a CF expansion slot. We can access stored images and movies via an internal protocol, which requires special drivers for an operating system or we can use the camera as a portable storage device, which means we can use the USB Mass Storage protocol.

1.2 USB Mass Storage
USB Mass Storage is a protocol used by portable storage devices and operating systems to access the device memory. We can define it as SCSI over USB. It's a popular and well working standard on various operating systems, including the latest versions of Linux and *BSD kernels.

1.3 fstab
fstab is a configuration file, one of the most important and necessary files on your system. It stores all the information about your hard disks, storage devices, swap memory and their mount points.

2. Requiments
Of course you need an HP Photosmart 120 digital camera, a USB port and a USB cable which should be included in the camera. Actual Fedora Core with a default kernel and a hotplug package. Probably you can use the kernel built by yourself, but information about which modules or what should be compiled will not be provided in this document. Also you need 10-15 minutes free, your preferred text editor and a basic knowledge of Linux.

3. Configuration
Now it's time for a configuration and it's easy, I will tell everything that is necessary.

3.1 Hardware
First you have to go to Setup on your digital camera, then look for a USB Configuration and change the mode from Digital Camera to Disk Drive. Now you only need to connect your camera to the computer and start the Software section of this document.

3.2 Software
To finish this section, you need to have root privileges. You can login as root or use su:

[pawel@pawel pawel]$ su
Password:
[root@pawel pawel]#
Now you have to create a folder, this will be your mount point:
[root@pawel pawel]# mkdir /mnt/digicam
If there are no problems, you should see nothing, but you can check to be sure:
[root@pawel pawel]# ls -la /mnt/|grep digicam
drwxr-xr-x    2 root     root         4096 Feb 19 17:53 digicam
Fine. Now it's time to see how your camera was recognised and which device you will use. You can do this simply by using the 'dmesg' command, which gives your last kernel messages. You will see a lot of lines, but only the last lines are important:
[root@pawel pawel]# dmesg
You should see at the end something like this:
hub.c: new USB device 00:1d.0-1, assigned address 15
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 15
SCSI device sda: 31360 512-byte hdwr sectors (16 MB)
sda: Write Protect is off
 sda: sda1
As you can see, my kernel found a new USB device with 16MB memory - my CF disk inside. All necessary modules were loaded, including USB Mass Storage. The most interesting lines for you are now:
sda: Write Protect is off
 sda: sda1
This means the kernel gives this device the name 'sda1' for your digital camera. You should note this down right now. To keep your system clear and elegant, you can make a simple symbolic link to this device:
[root@pawel pawel]# ln -s /dev/sda1 /dev/digicam
[root@pawel pawel]# ls -la /dev/digicam
lrwxrwxrwx    1 root     root            9 Feb 19 18:11 /dev/digicam -> /dev/sda1
Now you have to edit an fstab file and try to be careful, don't edit other lines in the file if you don't know what you are doing! All changes can make your system inaccessible. You have to add this line to the end of the file:
/dev/digicam            /mnt/digicam            auto    noauto,rw 0 0
To give access to mount/umount/write for other users than root, you have to add 'users' as an option to this line, it has to look like this:
/dev/digicam            /mnt/digicam            auto    noauto,rw,users 0 0
For all not-sure-users in editing configuration files, you can add these lines without manually editing the fstab file:
[root@pawel pawel]# echo '/dev/digicam            /mnt/digicam            auto    noauto,rw 0 0' >> /etc/fstab
And the line with permission for users:
[root@pawel pawel]# echo '/dev/digicam            /mnt/digicam            auto    noauto,rw,users 0 0' >> /etc/fstab
Warning! Remember to use two '>>' signs; if you only put one '>' sign, you will not be able to access to your system!

3.3 Testing and accessing data
Now if you would like to access your data on the camera, you need to do a simple mount operation:

[root@pawel pawel]# mount /mnt/digicam/
And that's all! All your camera memory is now in '/mnt/digicam'. You don't need to mount and umount the camera every time you disconnect it, only when rebooting your computer. Later you can simply put back the cable and access the files by just going to the folder. Look at what is inside:
[root@pawel root]# ls -la /mnt/digicam/
total 22
drwxr-xr-x    4 root     root        16384 Feb 19 21:59 .
drwxr-xr-x    6 root     root         4096 Feb 19 17:53 ..
drwxr-xr-x    4 root     root         1024 Apr 30  2000 dcim
drwxr-xr-x    2 root     root         1024 Apr 30  2000 misc
[root@pawel root]#
Your pictures and movies should be here in the dcim folder:
[root@pawel root]# ls -la /mnt/digicam/dcim/
total 19
drwxr-xr-x    4 root     root         1024 Apr 30  2000 .
drwxr-xr-x    4 root     root        16384 Feb 19 21:59 ..
drwxr-xr-x    2 root     root         1024 Apr 30  2000 100hp120
drwxr-xr-x    2 root     root         1024 Apr 30  2000 101hp120
Yes there are other folders inside, not exactly pictures. The first directory '100hp120' is internal memory, the second folder '101hp120' is external memory - my CF card. Look now:
[root@pawel root]# ls -la /mnt/digicam/dcim/101hp120/
total 7396
drwxr-xr-x    2 root     root         1024 Apr 30  2000 .
drwxr-xr-x    4 root     root         1024 Apr 30  2000 ..
-rwxr-xr-x    1 root     root       264124 Apr 30  2000 im000443.jpg
-rwxr-xr-x    1 root     root       384034 Apr 30  2000 im000445.jpg
-rwxr-xr-x    1 root     root       261016 Jan  1  2000 im000446.jpg
-rwxr-xr-x    1 root     root      1865396 Jan  1  2000 im000447.avi
I know, too many folders, too many names, look what I'm doing, I've got a symbolic link to this folder, with a CF data to my home directory, it's easy and I've got pictures directly from my camera inside my home directory:
[root@pawel root]# exit
exit
Now I'm a normal user again.
[pawel@pawel pawel]$ ln -s /mnt/digicam/dcim/101hp120/ ~/digicam
[pawel@pawel pawel]$ ls -la digicam/
total 7396
drwxr-xr-x    2 root     root         1024 Apr 30  2000 .
drwxr-xr-x    4 root     root         1024 Apr 30  2000 ..
-rwxr-xr-x    1 root     root       264124 Apr 30  2000 im000443.jpg
-rwxr-xr-x    1 root     root       384034 Apr 30  2000 im000445.jpg
-rwxr-xr-x    1 root     root       261016 Jan  1  2000 im000446.jpg
-rwxr-xr-x    1 root     root      1865396 Jan  1  2000 im000447.avi
Enjoy your files! But it's not everything. Did you have any problems keeping your CV on you at all times? Now look:
[pawel@pawel pawel]$ cp documents/pawel_szopinski_cv2.pdf /mnt/digicam/
[pawel@pawel pawel]$ ls -la /mnt/digicam/
total 28
drwxr-xr-x    4 pawel    pawel       16384 Feb 19 22:13 .
drwxr-xr-x    6 root     root         4096 Feb 19 17:53 ..
drwxr-xr-x    4 pawel    pawel        1024 Apr 30  2000 dcim
drwxr-xr-x    2 pawel    pawel        1024 Apr 30  2000 misc
-rwxr-xr-x    1 pawel    pawel        5237 Feb 19 22:13 pawel_szopinski_cv2.pdf
Nice huh? Did you think about the CF reader/writer? No worries, you won't need one. Now you can put the files directly into the memory inside your camera.

4. Summary
It's a fast and easy method to manage data stored on your camera. Also you can store other files, and use your camera like a disk, feel free to store documents; take a cable with you and you can enjoy this facility at all times. I hope you enjoyed this document and you now know something more about how Linux works, what the USB Mass Storage protocol is, how it works, how to deal with fstab, mount and read basic kernel messages.

5. Resources
http://www.teaser.fr/~hfiguiere/linux/digicam.html - Digital Camera Support for UNIX, Linux and BSD
http://www.linux-usb.org/USB-guide/x498.html - The Linux USB sub-system Howto, Mass Storage Devices section
fstab(5), mount (8) - Manual pages

6. Greetings
Special thanks to David Llewellyn Smith and Thanh Banh for corrections and motivation.