# strange usb flashdisk behaviour

## sLumpia

my friend's usb flashdisk has strange behaviour. it is detected by Gentoo, but it detected as CD-ROM, not sdX.

my usb flashdisk (and some other) work fine though ( detect as sd[x] )

here is the dmesg output:

```

usb 4-2: new full speed USB device using uhci_hcd and address 10

usb 4-2: configuration #1 chosen from 1 choice

scsi32 : SCSI emulation for USB Mass Storage devices

usb-storage: device found at 10

usb-storage: waiting for device to settle before scanning

scsi 32:0:0:0: CD-ROM            USB2.0   Flash Disk       2.00 PQ: 0 ANSI: 2

usb-storage: device scan complete

usb 4-2: USB disconnect, address 10

usb 4-2: new full speed USB device using uhci_hcd and address 11

usb 4-2: configuration #1 chosen from 1 choice

scsi33 : SCSI emulation for USB Mass Storage devices

usb-storage: device found at 11

usb-storage: waiting for device to settle before scanning

scsi 33:0:0:0: CD-ROM            USB2.0   Flash Disk       2.00 PQ: 0 ANSI: 2

usb-storage: device scan complete

usb 4-2: USB disconnect, address 11

usb 4-2: new full speed USB device using uhci_hcd and address 12

usb 4-2: configuration #1 chosen from 1 choice

scsi34 : SCSI emulation for USB Mass Storage devices

usb-storage: device found at 12

usb-storage: waiting for device to settle before scanning

scsi 34:0:0:0: CD-ROM            USB2.0   Flash Disk       2.00 PQ: 0 ANSI: 2

usb-storage: device scan complete

```

lsmod

```

$ lsmod | grep usb

usbhid                 15828  0

hid                    24064  1 usbhid

usb_storage            33284  0

usbcore               108692  5 usbhid,usb_storage,uhci_hcd,ehci_hcd

```

how could this happend? what is the problem?

thanks

----------

## eccerr0r

That's indeed pretty weird, does the device work, or do you need to access via /dev/srX ?  Does it work in Windows?

Seems the SCSI media type got confused somehow.  What brand/model is this, is it an off-brand device?

----------

## NeddySeagoon

lun4,

Do you have SCSI Disk support missing from your kernel ?

----------

## sLumpia

 *eccerr0r wrote:*   

> That's indeed pretty weird, does the device work, or do you need to access via /dev/srX ?  Does it work in Windows?
> 
> Seems the SCSI media type got confused somehow.  What brand/model is this, is it an off-brand device?

 

the device didn't work, i cannot mount it. but it work on Winblows

@NeddySeagoon, i have enable SCSI Disk support in my kernel, otherwise my Gentoo will not be able to detect other usb flashdisk, right?

----------

## sLumpia

 *eccerr0r wrote:*   

> That's indeed pretty weird, does the device work, or do you need to access via /dev/srX ?  Does it work in Windows?
> 
> Seems the SCSI media type got confused somehow.  What brand/model is this, is it an off-brand device?

 

the device didn't work, i cannot mount it. but it work on Winblows

@NeddySeagoon, i have enable SCSI Disk support in my kernel, otherwise my Gentoo will not be able to detect other usb flashdisk, right?

----------

## NeddySeagoon

lun4,

Your dmesg entry looks very short. I get 

```
[10037.071092] usb 1-2.1: new high speed USB device using ehci_hcd and address 9

[10037.164264] usb 1-2.1: configuration #1 chosen from 1 choice

[10037.164755] scsi2 : SCSI emulation for USB Mass Storage devices

[10037.165182] usb-storage: device found at 9

[10037.165219] usb-storage: waiting for device to settle before scanning

[10042.155651] usb-storage: device scan complete

[10042.156268] scsi 2:0:0:0: Direct-Access     Pendrive DatawriteVoyager 2.00 PQ: 0 ANSI: 2

[10042.157999] sd 2:0:0:0: [sdc] 506495 4096-byte hardware sectors (2075 MB)

[10042.158745] sd 2:0:0:0: [sdc] Write Protect is off

[10042.158790] sd 2:0:0:0: [sdc] Mode Sense: 0b 00 00 08

[10042.158820] sd 2:0:0:0: [sdc] Assuming drive cache: write through

[10042.160493] sd 2:0:0:0: [sdc] 506495 4096-byte hardware sectors (2075 MB)

[10042.161240] sd 2:0:0:0: [sdc] Write Protect is off

[10042.161285] sd 2:0:0:0: [sdc] Mode Sense: 0b 00 00 08

[10042.161315] sd 2:0:0:0: [sdc] Assuming drive cache: write through

[10042.161353]  sdc: unknown partition table

[10042.162669] sd 2:0:0:0: [sdc] Attached SCSI removable disk

[10042.162961] sd 2:0:0:0: Attached scsi generic sg2 type 0
```

Notice the [sdc] ... which you don't have, neither do you have a description of the device.

----------

## sLumpia

NeddySeagoon,

here is the output of lsusb and proc (as you said on IRC):

```

$ cat /proc/bus/usb/devices

T:  Bus=04 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.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=0000 ProdID=0000 Rev= 2.06

S:  Manufacturer=Linux 2.6.22-gentoo-r2 uhci_hcd

S:  Product=UHCI Host Controller

S:  SerialNumber=0000:00:10.2

C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=04 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 0

D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=0204 ProdID=6025 Rev= 1.00

S:  Manufacturer=USB2.0

S:  Product=Flash Disk

S:  SerialNumber=124366264305

C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA

I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms

T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2

B:  Alloc= 11/900 us ( 1%), #Int=  1, #Iso=  0

D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=0000 ProdID=0000 Rev= 2.06

S:  Manufacturer=Linux 2.6.22-gentoo-r2 uhci_hcd

S:  Product=UHCI Host Controller

S:  SerialNumber=0000:00:10.1

C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=1.5 MxCh= 0

D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1

P:  Vendor=062a ProdID=0000 Rev= 0.00

C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid

E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=10ms

T:  Bus=02 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.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=0000 ProdID=0000 Rev= 2.06

S:  Manufacturer=Linux 2.6.22-gentoo-r2 uhci_hcd

S:  Product=UHCI Host Controller

S:  SerialNumber=0000:00:10.0

C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 6

B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0

D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1

P:  Vendor=0000 ProdID=0000 Rev= 2.06

S:  Manufacturer=Linux 2.6.22-gentoo-r2 ehci_hcd

S:  Product=EHCI Host Controller

S:  SerialNumber=0000:00:10.3

C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

```

```

$ lsusb

Bus 004 Device 002: ID 0204:6025

Bus 004 Device 001: ID 0000:0000

Bus 003 Device 002: ID 062a:0000 Creative Labs

Bus 003 Device 001: ID 0000:0000

Bus 002 Device 001: ID 0000:0000

Bus 001 Device 001: ID 0000:0000

```

----------

## NeddySeagoon

lun4,

Humm its an odd device

```

T:  Bus=04 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 0 

D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1

P:  Vendor=0204 ProdID=6025 Rev= 1.00

S:  Manufacturer=USB2.0

S:  Product=Flash Disk 
```

 The Ver= 1.1 says its a USB 1.1 device, which is confirmed by the Spd=12, for 12 Mbit/sec.

I wonder why is has USB2.0 in the Manufactuer field. As its installed in your PC, it has a root hub to itself, so its not being forced to operate at USB 1 speeds. You have USB 2 support but the device cant use it. 

Reading one of your earlier posts we see

```
 usb 4-2: new full speed USB device using uhci_hcd and address 10

usb 4-2: configuration #1 chosen from 1 choice

scsi32 : SCSI emulation for USB Mass Storage devices

usb-storage: device found at 10

usb-storage: waiting for device to settle before scanning

scsi 32:0:0:0: CD-ROM            USB2.0   Flash Disk       2.00 PQ: 0 ANSI: 2 
```

We can tell its USB 1.1 from the 

```
new full speed USB device using uhci_hcd
```

The  USB2.0   Flash Disk clearly comes from the 

```
S:  Manufacturer=USB2.0

S:  Product=Flash Disk 
```

which will be designed to fool users into believing its really a USB 2 flash disk. Anyway, while thats interesting, it not the cause of your problem.

This post to the linux-usb-devel mailing list, shows your device needs a quirk and provides a patch. I have looked at the 2.6.22-r6 and 2.6.23-rc6 kernels and that patch is not there, meanwhile you need to add it yourself and rebuild your kernel.

Its not as hard as it sounds. As its a two line addition, you don't even need to use the patch utility.

Do 

```
cd /usr/src/linux 
```

as if you were going to rebuild your kernel.

now do 

```
nano -w drivers/usb/core/quirks.c
```

to open the file you need to change.

Find  

```
* Right now the logic aborts if it finds a valid device in the table, we might

 * want to change that in the future if it turns out that a whole class of

 * devices is broken...

 */

static const struct usb_device_id usb_quirk_list[] = {

        /* HP 5300/5370C scanner */

        { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },

        /* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */

        { USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },

        /* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
```

close to the top of the file.

and make it read

```
static const struct usb_device_id usb_quirk_list[] = {

   /* CBM - Flash disk */

   { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },

        /* HP 5300/5370C scanner */

        { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
```

by adding the lines 	

```
/* CBM - Flash disk */

   { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
```

Notice how the new USB_DEVICE(0x0204, 0x6025) matches your Vendor and Device IDs, the 0x means that the numbers that follow are hex.

Save the change, rebuild and reinstall your kernel, now it should work properly.

I shall be interested to see the  /proc/bus/usb/devices ouput, and the dmesg data it generates when its detected properly.

----------

## sLumpia

i'm using kernel 2.6.22-gentoo-r2 right now. when i try to compile the kernel after i modify quirks.c (as you suggest), it gives me this error:

```

# make && make modules_install

scripts/kconfig/conf -s arch/i386/Kconfig

  CHK     include/linux/version.h

  CHK     include/linux/utsrelease.h

  CALL    scripts/checksyscalls.sh

  CHK     include/linux/compile.h

  CC [M]  drivers/usb/core/quirks.o

drivers/usb/core/quirks.c:32: error: 'USB_QUIRK_RESET_RESUME' undeclared here (not in a function)

make[3]: *** [drivers/usb/core/quirks.o] Error 1

make[2]: *** [drivers/usb/core] Error 2

make[1]: *** [drivers/usb] Error 2

make: *** [drivers] Error 2

```

should i emerge kernel 2.6.22-gentoo-r6?

----------

## NeddySeagoon

lun4,

I don't have 2.6.22-r2 to check but USB_QUIRK_RESET_RESUME is not defined in 2.6.22-r1, nor is it in 2.6.22-r6

Try the testing vanillia-sources, that was 2.6.23-rc7 last time I looked, you will still need the patch.

This line from a grep

```
./patch-2.6.23-rc6:+#define USB_QUIRK_RESET_RESUME              0x00000004
```

tells that the definition was introduced into 2.6.23 somewhere, as the +#define USB_QUIRK_RESET_RESUME shows its an addition.

If you use nvidia-drivers, they will not work with kernel 2.6.23 without a patch

----------

## sLumpia

i'm using tar ball portage-20070914.tar.bz2 and there is no 2.6.23 kernel (my conection didn't allow me to do a rsync update). i guess i'll to wait for the latest snapshot

----------

## NeddySeagoon

sLumpia

Dig about in /usr/portage/distfiles for the file linux-2.6.22.tar.bz2. Copy it to your /home/sLumpia dir and untar it.

That will get you a vanillia linux-2.6.22 to start from. 

```
tar xvjf linux-2.6.22.tar.bz2
```

Rename the linux-2.6.22 dir to linux-2.6.23-rc8

Go to kernel.org and get The latest prepatch for the stable Linux kernel tree is:  	2.6.23-rc8.

Put the downloaded file into /home/sLumpia/linux-2.6.22 and decompress it there. The command is 

```
bunzip2 <file>
```

unlike the kernel file tarball, its a single huge patch file.

Now to apply the patch to the kernel

```
patch -p 1 < <patch-file-name>
```

It will apply patches to many files. When it is complete, look at the exit message. It will tell you how many 'hunks' were applied successfully and how many failed. If none have failed, you now have a linux-2.6.23-rc8 kernel tree.

----------

