# Need some help with camera usb-mass-storage and scsi

## faz

Hi,

I'm having trouble getting my camera (a Sony DSC-P71 with a 128 MB memorystick) to work as a usb mass storage device.

I've read everything about it, both on the Net and on these forums, but I still can't get it to work.

I've rebuild my kernel with all the mentioned usb and scsi options build as modules:

```

CONFIG_USB

CONFIG_USB_DEVICEFS

CONFIG_USB_UHCI

CONFIG_USB_STORAGE

CONFIG_SCSI

CONFIG_BLK_DEV_SD

CONFIG_CHR_DEV_SG

```

note: SCSI emulation support for IDE is_not_ enabled

I have (among others) these modules loaded:

```

sd_mod                 10156   0  (unused)

hid                    12136   0  (unused)

usb-storage            21324   0  (unused)

scsi_mod               80292   1  [sd_mod usb-storage]

usb-uhci               20908   0  (unused)

usbcore                54816   1  [hid usb-storage usb-uhci]

```

No matter what I do, I don't get any devices in /dev/scsi. /proc/scsi/scsi gives "attached devices: none"

Iv'e seen some posts on this forum discussing entries in devfsd.conf for registering sd devices, but that's only for mapping those devices to /dev/scsi/... and that's keeps being empty on my box.

When I plug in the camera, i get this in the log:

```

Feb  7 13:04:16 [kernel] hub.c: USB new device connect on bus1/2, assigned device number 3

Feb  7 13:04:16 [kernel] usb.c: USB device 3 (vend/prod 0x54c/0x4e) is not claimed by any active driver.

Feb  7 13:04:19 [/etc/hotplug/usb.agent] Setup usbcam for USB product 54c/4e/120

Feb  7 13:04:19 [/etc/hotplug/usb.agent] Module setup usbcam for USB product 54c/4e/120

Feb  7 13:04:29 [kernel] Initializing USB Mass Storage driver...

Feb  7 13:05:03 [kernel] usb.c: USB disconnect on device 3

Feb  7 13:06:09 [kernel] usbdevfs: process 5261 (lsusb) did not claim interface 0 before use

Feb  7 13:06:14 [kernel] usbdevfs: process 5262 (lsusb) did not claim interface 0 before use

```

Obviously, i'm missing a essential step, but I can't figure out wich what.

----------

## Ian Goldby

I have this working with my Casio. My notes on how I managed this are a bit sketchy, but this may help:

Vaguely relevant kernal config:

```
CONFIG_HOTPLUG=y

CONFIG_BLK_DEV_IDESCSI=m

CONFIG_SCSI=y

CONFIG_BLK_DEV_SD=m

CONFIG_SD_EXTRA_DEVS=40

CONFIG_BLK_DEV_SR=m

CONFIG_BLK_DEV_SR_VENDOR=y

CONFIG_SR_EXTRA_DEVS=2

CONFIG_CHR_DEV_SG=m

CONFIG_SCSI_DEBUG_QUEUES=y

CONFIG_SCSI_CONSTANTS=y

CONFIG_FAT_FS=y

CONFIG_VFAT_FS=y

CONFIG_USB=y

CONFIG_USB_DEVICEFS=y

CONFIG_USB_UHCI_ALT=y

CONFIG_USB_STORAGE=m
```

Probably not all of those are necessary, and I'm not certain I've not missed anything, but if it helps, so much the better. There may be some entries needed in modules.conf, but I didn't have to change anything there. The IDE-SCSI might be for my CDRW and not needed for the camera. I'm pretty sure you need the FAT/VFAT bits though to read the DOS-format of the camera 'disk'.

----------

## taskara

I know this sounds stupid, but I read something about looking under /proc for usb devices...

at least you coudl 

```
cat /proc/usb/devices
```

 or something like that..

----------

## lsiden

Not stupid at all!  It's actually "cat /proc/bus/usb/devices", and on my sys it yields:

 *Quote:*   

> T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
> 
> B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
> 
> D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
> ...

  which isn't pleasant to read, I'll admit, but if you look closely, you'll see  *Quote:*   

> S:  Manufacturer=STMicroelectronics
> 
> S:  Product=USB Dual-mode Camera

  which looks like pay-dirt.

Now I'm not out of the woods yet, b/c nothing appears under /dev/usb for this device.  devfsd obviously fails to recognize anything.

Now I've had some pleasant private exchanges with another fellow in England who has exactly the kind of camera that I do (a cheap Cool-iCam CIC-175) for whom it worked "outa-da-box".  He has a RedHat distrib, and accesses it with something called Video4Linux (I think).  As for myself, I've installed sane-front/backends.  Running either xcam or xscanimage does nothing.  Both just seem to wait endlessly, without outputting any messages (I don't know whether they have a "verbose" mode - -v doesn't do anything for either utility).

So that's where I'm stuck right now.  If anyone out there wants to offer their 2 cents, I'll be happy to send my /usr/src/linux/.config and the output of /proc/modules.

Thanks in advance.

-Larry

----------

## taskara

there's a usb-storage (usb to scsi emulation) driver... is that loaded ?

----------

## lsiden

 *Quote:*   

> there's a usb-storage (usb to scsi emulation) driver... is that loaded ?

 

Yep.  It's there, alright.

 *Quote:*   

> 
> 
> ```
> 
> Module                  Size       Used by    Not tainted
> ...

 

----------

## bertrand

make sure the module sd_mod is loaded and then use the rescan-scsi-bus.sh script every time you plug a new device:

```

#!/bin/bash

# Skript to rescan SCSI bus, using the

# scsi add-single-device mechanism

# (w) 98/03/19 Kurt Garloff <kurt@garloff.de> (c) GNU GPL

# Return hosts. /proc/scsi/HOSTADAPTER/? must exist

findhosts ()

{

  hosts=

  for name in /proc/scsi/*/?; do

    name=${name#/proc/scsi/}

    if test ! $name = scsi

      then hosts="$hosts ${name#*/}"

      echo "Host adapter ${name#*/} (${name%/*}) found."

    fi

  done

}

# Test if SCSI device $host $channen $id $lun exists

# Outputs description from /proc/scsi/scsi, returns new

testexist ()

{

  grepstr="scsi$host Channel: 0$channel Id: 0*$id Lun: 0$lun"

  new=`cat /proc/scsi/scsi|grep -e"$grepstr"`

  if test ! -z "$new"

    then cat /proc/scsi/scsi|grep -e"$grepstr"

    cat /proc/scsi/scsi|grep -A2 -e"$grepstr"|tail -2|pr -o4 -l1

  fi

}

# Perform search (scan $host)

dosearch ()

{

  for channel in $channelsearch; do

    for id in $idsearch; do

      for lun in $lunsearch; do

        new=

        devnr="$host $channel $id $lun"

        echo "Scanning for device $devnr ..."

        printf "OLD: "

        testexist

        if test ! -z "$remove" -a ! -z "$new"

          then echo "scsi remove-single-device $devnr" >/proc/scsi/scsi

          echo "scsi add-single-device $devnr" >/proc/scsi/scsi

          printf "\r\x1b[A\x1b[A\x1b[AOLD: "

          testexist

          if test -z "$new"; then printf "\rDEL: \r\n\n\n\n"; let rmvd+=1; fi

        fi

        if test -z "$new"

          then printf "\rNEW: "

          echo "scsi add-single-device $devnr" >/proc/scsi/scsi

          testexist

          if test -z "$new"; then printf "\r\x1b[A"; else let found+=1; fi

        fi

      done

    done

  done

}

# main

if test @$1 = @--help -o @$1 = @-h

  then

    echo "Usage: rescan-scsi-bus.sh [-l] [-w] [-c] [host [host ...]]"

    echo " -l activates scanning for LUNs 0 .. 7 [default: 0]"

    echo " -w enables scanning for device IDs 0 .. 15 [def.: 0 .. 7]"

    echo " -r enables removing of devices        [default: disabled]"

    echo " -c enables scanning of channels 0 1   [default: 0]"

    echo " If hosts are given, only these are scanned [default: all]"

    exit 0

fi

# defaults

lunsearch="0"

idsearch="0 1 2 3 4 5 6 7"

channelsearch="0"

remove=""

# Scan options

opt="$1"

while test ! -z "$opt" -a -z "${opt##-*}"; do

  opt=${opt#-}

  case "$opt" in

    l) lunsearch="0 1 2 3 4 5 6 7" ;;

    w) idsearch="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" ;;

    c) channelsearch="0 1" ;;

    r) remove=1 ;;

    *) echo "Unknown option -$opt !" ;;

  esac

  shift

  opt="$1"

done

# Hosts given ?

if test @$1 = @; then findhosts; else hosts=$*; fi

declare -i found=0

declare -i rmvd=0

for host in $hosts; do dosearch; done

echo "$found new device(s) found.               "

echo "$rmvd device(s) removed.                 "

```

Works fine for all my hot-plug devices (firewire&usb).

----------

## lsiden

Don't mean to sound naive, but what do I have to set in menuconfig to build sd_mod.o?

----------

## lsiden

Okay, I found what where to enable sd_mod.o.  But I don't need to, it's already built into the kernel.  Same for sg_mod.o (SCSI generic driver).

It occured to me that I must be lacking some low-level driver, but which one?  There's a whole slew, but none of them in the menuconfig match "STM Microelectronics".

Thanks in adv.,

-Larry

----------

## lsiden

Do I need to load sd_mod.o as a module?  Won't it work if it's built into the kernel?

----------

## norvalk

hi!

i also own sony dsc-p71 and i 'persuaded' it to work (as an usb mass storage device) by compiling the following options as modules:

* support for usb (config_usb)

- with built-in preliminary usb device filesystem (config_usb_devicefs)

* uhci support (config_usb_uhci) - 'cause my motherboard is equipped with via chipset

* usb mass storage (config_usb_storage)

the following modules are probably not needed in your configuration but i mention them nonetheless:

* usb hid support (config_usb_hid)

- with built-in hid input layer support (config_usb_hidinput)

* usb scanner support (config_usb_scanner)

* usb printer support (config_usb_printer)

as far as scsi support is concerned i selected the following options as modules:

* scsi support (config_scsi)

* scsi disk support (config_blk_dev_sd)

* scsi cdrom support (config_blk_dev_sr) - 'cause i use cd writter

* scsi generic support  (config_chr_dev_sg)

and 'enabled extra checks in new queueing code' with 'verbose scsi error reporting' - but they're both optional.

after having compiled new modules, i did

```
modules-update
```

and put

```
usb-uhci
```

into my /etc/modules.autoload - this way the loading of any subsequently needed usb modules is done automatically.

next (as root) i created new mounting point by doing

```
mkdir /mnt/camera
```

and added new entry into my /etc/fstab:

```
/dev/sda1  /mnt/camera  vfat  noauto,user  0 0
```

this way any user is able to mount camera by issuing:

```
mount /mnt/camera
```

do note that you have to mount the right scsi device with the vfat filesystem option - in my case sda1. for hints on scsi devices use:

```
cdrecord -scanbus
```

and

```
ls -l /dev/sd*
```

i hope this will be of any help to you.

cheersLast edited by norvalk on Wed Feb 26, 2003 9:03 am; edited 2 times in total

----------

## faz

Well, I found my problem. To get you're camera to work with gphoto2 it has to be set to PTP USB mode. So that was what it was on when I tried to get it to work as a USB mass storage device. Turns out you have to put you're camera back to USB normal mode for this.

Nobdoy told me   :Crying or Very sad: 

----------

