# mounting usb flash disk [SOLVED+patch inside]

## m0sia

i'm using gentoo-dev-sources-2.6.9-r6, latest hotplug and coldplug and usb1.0 flash disk(Seitec 64mb).

# lsusb

Bus 005 Device 001: ID 0000:0000

Bus 004 Device 001: ID 0000:0000

Bus 003 Device 003: ID 0ea0:6828 Ours Technology, Inc. OTI-6828 Flash Disk

Bus 003 Device 001: ID 0000:0000

Bus 002 Device 003: ID 045e:0059 Microsoft Corp. Wireless IntelliMouse Explorer

Bus 002 Device 001: ID 0000:0000

Bus 001 Device 001: ID 0000:0000

# lsmod|grep usb

usbhid                 23936  0

usbcore               101732  7 ub,ohci_hcd,ehci_hcd,usbhid,uhci_hcd

#dmesg|tail

usb 4-1: new full speed USB device using address 2

ub: sizeof ub_scsi_cmd 60 ub_dev 940

uba: device 2 capacity nsec 50 bsize 512

uba: made changed

uba: device 2 capacity nsec 127744 bsize 512

uba: device 2 capacity nsec 127744 bsize 512

 /dev/ub/a: p1

 /dev/ub/a: p1

devfs_mk_dev: could not append to parent for ub/a/part1

kobject_register failed for uba1 (-17)

 [<c01cb63a>] kobject_register+0x57/0x65

 [<c018a76d>] add_partition+0xfe/0x133

 [<c018a95f>] register_disk+0x15f/0x1bd

 [<c0238a2e>] add_disk+0x47/0x54

 [<c02389c5>] exact_match+0x0/0xa

 [<c02389cf>] exact_lock+0x0/0x18

 [<e1ca8fd7>] ub_probe+0x29d/0x30e [ub]

 [<e1a73060>] usb_probe_interface+0x5a/0x70 [usbcore]

 [<c02300ce>] bus_match+0x3f/0x7a

 [<c023020a>] driver_attach+0x4d/0x8c

 [<c02306e3>] bus_add_driver+0x92/0xc5

 [<e1a73124>] usb_register+0x3e/0x8f [usbcore]

 [<e1cac052>] ub_init+0x52/0x86 [ub]

 [<c0134d8d>] sys_init_module+0x179/0x260

 [<c0105bfd>] sysenter_past_esp+0x52/0x71

usbcore: registered new driver ub

#modprobe usb-storage

#dmesg|tail

Initializing USB Mass Storage driver...

usbcore: registered new driver usb-storage

USB Mass Storage support registered.

BUT there is no device in /dev!

btw usb2.0 flash disk works perfectly.

Problem exisit on all 2.6.8-* and 2.6.9-* sources(love,gentoo,nitro,mm,ck)

ps motherboard P4P800

SOLVED

1) Disabled "Low Performance USB Block driver (BLK_DEV_UB)"

2) http://bugme.osdl.org/show_bug.cgi?id=3223 found this bug.

3) write little patch for my own "unusial device"

#cat /proc/bus/usb/devices

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

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

P:  Vendor=0ea0 ProdID=6828 Rev= 1.10

S:  Manufacturer=USB

S:  Product=Flash Disk

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

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

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

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

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

```
===== drivers/usb/storage/transport.c 1.145 vs edited =====

--- 1.145/drivers/usb/storage/transport.c       Tue Aug  3 10:17:59 2004

+++ edited/drivers/usb/storage/transport.c      Wed Aug 18 11:48:27 2004

@@ -1054,8 +1054,10 @@

        /* try to compute the actual residue, based on how much data

         * was really transferred and what the device tells us */

-       residue = min(residue, transfer_length);

-       srb->resid = max(srb->resid, (int) residue);

+       if (!(us->flags & US_FL_IGNORE_RESIDUE)) {

+               residue = min(residue, transfer_length);

+               srb->resid = max(srb->resid, (int) residue);

+       }

        /* based on the status code, we report good or bad */

        switch (bcs->Status) {

===== drivers/usb/storage/unusual_devs.h 1.144 vs edited =====

--- 1.144/drivers/usb/storage/unusual_devs.h    Fri Aug  6 03:59:29 2004

+++ edited/drivers/usb/storage/unusual_devs.h   Wed Aug 18 11:47:06 2004

@@ -265,6 +265,13 @@

                US_SC_8070, US_PR_BULK, NULL,

                US_FL_FIX_INQUIRY ),

+/* Reported by m0sia <m0sia@plotinka.ru> */

+UNUSUAL_DEV(  0x0ea0, 0x6828, 0x0110, 0x0110,

+               "USB",

+               "FLASH DISK",

+               US_SC_DEVICE, US_PR_DEVICE, NULL,

+               US_FL_IGNORE_RESIDUE ),

+

 /* This entry is needed because the device reports Sub=ff */

 UNUSUAL_DEV(  0x054c, 0x0010, 0x0106, 0x0450,

                "Sony",

===== drivers/usb/storage/usb.h 1.60 vs edited =====

--- 1.60/drivers/usb/storage/usb.h      Tue Jul 20 19:30:35 2004

+++ edited/drivers/usb/storage/usb.h    Wed Aug 18 11:46:58 2004

@@ -73,6 +73,7 @@

 #define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets      */

 #define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs faking   */

 #define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */

+#define US_FL_IGNORE_RESIDUE  0x00000100 /* reported residue is wrong      */

 /* Dynamic flag definitions: used in set_bit() etc. */

 #define US_FLIDX_URB_ACTIVE    18  /* 0x00040000  current_urb is in use  */

```

now it works!Last edited by m0sia on Wed Dec 08, 2004 10:50 pm; edited 4 times in total

----------

## SZwarts

Do you have all the correct scsi emulation in your kernel?

I guess not, because dmesg should tell you... Without it, it does see your usb drive, but is unable to mount it.

And sometimes the device /dev/sda1 (or another number) is already there, and you can just mount it... But you do need scsi emulation.

----------

## m0sia

of course "SCSI generic support","SCSI disk support" compiled in kernel because i have sata disk.

btw AS I mentioned ABOVE usb2.0 flash disk works great!!!! so i have necessary scsi support in kernel.

----------

## jeremydc

See this thread:

https://forums.gentoo.org/viewtopic.php?t=257712

I believe you have the low-performance usb blk driver mentioned in the thread which superceeds the scsi emulation.  You could try removing the low-performance usb blk driver and see if the scsi emulation works.

----------

## m0sia

thanks a lot, it don't works! 

I tried scsi emulation and have(Low Performance USB Block driver (BLK_DEV_UB) is off):

#mount /dev/sdb1 /mnt/usb

mount: /dev/sdb1: can't read superblock

#dmesg|tail

USB Mass Storage support registered.

<skiped>

usb-storage: *** thread sleeping.

SCSI error : <2 0 0 0> return code = 0x10070000

end_request: I/O error, dev sdb, sector 42

FAT: unable to read boot sector

some questions:

1)i wonder why "Low Performance USB Block driver (BLK_DEV_UB)" is in block devices, but not in usb section(and why it doesn't work?)?

2)i wonder why "scsi emulation" is in "ata support section",but not in scsi section(as i remember it was there in kernels <2.4.20)? btw how "ide scsi emulation work with my usb flash disk"??? there is no logic. i'm confused.  :Embarassed: Last edited by m0sia on Wed Dec 08, 2004 8:07 pm; edited 1 time in total

----------

## jeremydc

Lots of devices can be accessed via some sort of scsi emulation driver, old parport zip drives used a scsi emulation over parport  for instance, but  I don't exactly understand why the USB Block driver interfers with the scsi emulation. 

If you haven't reformated the flash disk and you can see a /dev/sdb and a /dev/sdb1 . Then try mounting /dev/sdb instead of /dev/sdb1 it depends on how the manufacutre formated the drive. Also make sure you have the correct code page installed and specify the correct filesystem. 

Try both:

```
mount -t vfat /dev/sdb /mnt/usb

mount -t vfat /dev/sdb1 /mnt/usb
```

This thread also might be helpful:

https://forums.gentoo.org/viewtopic.php?t=260048

----------

## m0sia

thanks... but see my first message in this thread. there is "edit" with solution of this problem.

The problem is in usb-storage driver. This error messages report  that the device says no valid data was transferred.  This was

necessary for the iRiver flash device, which sometimes actually does fail to

transfer any information. The result was data corruption.

My problem is that storage device _does_ transfer data but then mistakenly

says that the data is not valid.  More technically, the dCSWDataResidue value is

wrong.  It's definitely a bug in the device.

The only way is to patch usb-storage driver for it. (The patch is included in this thread in first post)

----------

## jeremydc

I'm glad you got it working, hopfully somone else can benifit from your patch when they ahve the same issue in the future.  :Smile: 

----------

## m0sia

 *jeremydc wrote:*   

> I'm glad you got it working, hopfully somone else can benifit from your patch when they ahve the same issue in the future. 

 

after googling i found,that there is th same problem with some of video cameras,photo cameras and flash disk.... so "Linus & Co" must add all "unusial devices" in kernel.

----------

