hackorama
hackorama

USB Device Drives on Linux

Some notes on using USB devices on Linux. Like using the usb-storage module for a Digital camera which supports it. Using usb-video module for webcam support. As usual all my usb devices came with Windows only drivers. Thanks to the open source USB developers on Linux all USB devices works great on my 2.4.x kernel machines.

linux-usb general site for USB support on linux.
SPCA50X USB support for SPCA50X chip based webcams

My main resource in understanding USB drivers was the O'Reiily book Linux Device Drivers. Helped me to get an idea of how the device drivers work on linux, understanding kernel modules and using insmod lsmod. modprobe.

I have tested these on 2.4.8 and 2.4.18 kernels.

The USB devices on my machine are

1. Multimedia keyboard ( this acts as a USB hub with two usb portes )
2. USB mouse - connected to one of the ports on the keyboatd
3. USB 4 port hub
4. USB Webcam
5. USB Digital Camera

The kernel modules loaded to support these USB devices

$ lsmod | grep -i usb
usb-storage  52236   0  (unused)
scsi_mod     92488   3  [usb-storage sr_mod ide-scsi]
usbmouse      1984   0  (unused)
usbkbd        3136   0  (unused)
input         3616   0  [usbmouse keybdev mousedev hid usbkbd]
usb-uhci     21668   0  (unused)
usbcore      59072   1  [usb-storage usbmouse hid usbkbd usb-uhci]
$

USB Digital Camera Nikon Coolpix on Linux

The usb-storage module is for the Digital Camera that works like USB mass storage device.

$ lsmod | grep -i scsi
ide-scsi                8032   1
scsi_mod               92488   3  [usb-storage sr_mod ide-scsi]
$

You will see these system messages when a USB mass storage device is plugged in.


$dmesg 
hub.c: USB new device connect on bus1/1/3, assigned device number 5
usb.c: USB device 5 (vend/prod 0x4b0/0x104) 
       is not claimed by any active driver.
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
scsi1 : SCSI emulation for USB Mass Storage devices
  Vendor: NIKON     Model: NIKON DSC E995    Rev: 1.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 5
USB Mass Storage support registered.
usb.c: USB disconnect on device 5
hub.c: USB new device connect on bus1/1/3, assigned device number 6
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 6
$
So usb-storage module will show the Digital Camera as a SCSI storage device on your system.

$cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: MITSUMI  Model: CR-4804TE        Rev: 2.4C
Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: SAMSUNG  Model: DVD-ROM SD-608   Rev: 1.1
Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NIKON    Model: NIKON DSC E995   Rev: 1.00
Type:   Direct-Access
$

Mount it and use it as any other file drive.


$vi /etc/fstab

# this is for nikon coolpix 995 usb mass storage
/dev/sda1 /mnt/camera  vfat rw,suid,dev,noexec,noauto,user,async 1 2

$
$mkdir /mnt/camera
$mount sda1 
$cd /mnt/camera
$ls 
dcim/  nikon001.dsc*
$cd dcim
$ls
100nikon/
$ cd 100nikon
$ls -l
total 2248
-rwxr-xr-x    1 root     root       719339 Dec 31  2000 dscn0001.jpg*
-rwxr-xr-x    1 root     root       785226 Dec 31  2000 dscn0002.jpg*
-rwxr-xr-x    1 root     root       791558 Dec 31  2000 dscn0003.jpg*
$
See man mount for the options used in mounting the device.

$man mount
defaults
Use default options: rw, suid, dev, exec, auto, nouser, and async.
$

And the usbview utiity will show the digital camera as follows.

Config Number: 1
Number of Interfaces: 1
Attributes: c0
MaxPower Needed:   0mA

Interface Number: 0
	Name: usb-storage
	Alternate Number: 0
	Class: 08(stor.) 
	Sub Class: 6
	Protocol: 50
	Number of Endpoints: 2

		Endpoint Address: 04
		Direction: out
		Attribute: 2
		Type: Bulk
		Max Packet Size: 64
		Interval:   0ms

		Endpoint Address: 83
		Direction: in
		Attribute: 2
		Type: Bulk
		Max Packet Size: 64
		Interval:   0ms
NIKON DSC E995
Manufacturer: NIKON
Serial Number: 000003582834
Speed: 12Mb/s (full)
USB Version:  1.10
Device Class: 00(>ifc )
Device Subclass: 00
Device Protocol: 00
Maximum Default Endpoint Size: 8
Number of Configurations: 1
Vendor Id: 04b0
Product Id: 0104
Revision Number:  1.00

USB Webcam on Linux

The modules loaded for the webcam ( ViewQuest VQ110 with SPCA508 chipset )
usb-uhci               21232   0  (unused)
usbcore                50752   1  [spca50x usb-uhci]
videodev                5056   2  [spca50x]

This is the small script that loads the modules and starts the video streaming server camserv

#!/bin/sh
modprobe videodev
insmod spca50x.o bright=90
camserv /home/kishan/.camserv 2>/dev/null 1>/tmp/camerror.txt &

More details on the webcam can be found here.



Thursday, 15-Apr-2004 19:55:23 PDT kishan at hackorama dot com