BusLink 20 GB USB HD

Linux Device Driver


Disclaimer
This program has been written without any support whatsoever form either BusLink or Prolific.
This work is based on the behavior of the driver delivered with the unit under windows98 and my personal knowledge acquired through lengthy protocol debugging. BusLink and Prolific didn't want to collaborate, they simply never replied to my inquiries. No support or liability can be expected from the mentioned companies for this program.

This page describes the Linux driver I wrote for the Buslink 20 GB USB-HD

The text in this page is mostly outdated so don't take it too seriously.

At the moment the driver works with Linux kernels 2.6.x (tested on 2.6.24-16 UBUNTU 8.04) and 2.4.x (tested up to 2.4.18). Versions 2.2.x are not supported due to bugs in the USB stack and other reasons (with some hack in the usb drivers I was able to use this device with kernel 2.2.18, but performances are very poor and the machine is unusable while copying big directories).

Version for kernels 2.6.x now available - This is a major rewrite of the usbide module and has not been tested for very long yet !!!

The BusLink USB-HD uses a Prolific 2307chip which is a USB-ATAPI bridge. According to Prolific the PL-2307 has the following features:


This driver however was specifically written for the BusLink device thus only the master drive is probed.
The throughput of the order of 700-800 kB/s is achieved by clustering consecutive requests into one single usb-bulk transfer (up to 64 consecutive sectors). This requires copying to/from an intermediate buffer (which eats up 32k of system memory). The gain of this technique is however worth, 2-3 times faster for ext2 (typical request 8 sectors) and much better for vfat where every request is one single sector (at least in 2.2.18).

It should be relatively easy to incorporate support for other USB-ATA bridges since the USB part is kept separated from the block part (there are two files: usbide-core.c which deals with the block part and prolific.c which deals with the USB part.)

The driver is still under development. It is available AS-IS and for free under the standard GPL license (see .c files for more details). No liability for possible damages or losses induced by the use of this driver is taken by the author.
 
 

Old and new versions

It looks like there are at least two versions of the buslink 20GB HD. There is no way you can tell the difference from the outside but if you look in /proc/bus/usb/devices after you have plugged your device and turned it on you should have something like this:

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=067b ProdID=2307 Rev= 1.00
.
.
.
C:* #Ifs= 1 Cfg#= 1 Atr=04 MxPwr=  6mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=usbide
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=   7 Ivl=  1ms
I:  If#= 0 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=usbide
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=

In this case you have the new version.

On the other hand if what you get is like this:

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=067b ProdID=2307 Rev= 1.00
.
.
.
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=   7 Ivl=  1ms

you have the old version

The difference is in the number of  Alternative settings (the part in blue).

Finally I managed to support both protocols although the old one needs further testing.
Since I only have a new model I can test the old protocol on a new model which is not necessarily the same as the old protocol on the old model ;-)

If you decide to use this driver please send me some feedback saying  if it works or not and including some details about your system (kernel version, uhci, usb-uhci, ohci etc.). In case it doesn't work please include the /var/log/messages portion relative to the startup of "usbide" and the /proc/bus/usb/devices portion relative to the buslink.
 

I refer to the two versions as new and old but I am the less and less sure which one is the new and which one is the old ;-)

Download 

Last updated on May 23 2008

usbide-1.2.1.tar.gz
usbide-1.2.2.tgz
usbide-1.2.2-b.tgz (kernels <= 2.4.7)
usbide-1.2.2-c.tgz
usbide-1.2.2-d.tgz   (kernels >= 2.4.9)
usbide-2.0.tar.gz  (major rewrite) (kernels >= 2.6.0)
usbide-2.1.tar.gz  (fixes for kernels >= 2.6.16)
usbide-2.2.tar.gz  ( fixes for kernels >= 2.6.24 [tested ubuntu 8.04])
usbide-2.3.tar.gz  (latest - fixes for kernels >= 2.6.25 [tested ubuntu 8.10 2.6.27-9]) does not work with previous kernels use one of the above for those


I have tested this driver with RH kernels until RH 7.3 and then on SLC 3 and 4 kernels (and updates). The module can be build separately from the kernel source but needs a syncronized source tree in /usr/src/linux (see INSTALL for more information) (with 2.6 kernels in redhat (and I guess other distributions) you don't need to install the source code anymore). Instructions are also given on how to incorporate it to the kernel tree.

The driver has been reported to work up to 2.4.18 (2.5.0)

Here is the driver as a patch to the kernel tree (the patch works on original kernels in the range 2.4.0-2.4.4 but not on Red-Hat 7.x kernels)

The version 2.0 is a major rewrite and has still to be thoroughly validated!!! (Please send reports)

usbide-1.0-patch-k2.4.4.bz2 OUTDATED

Changelog

Jan xx 2001

Got the blody thing to work (new protocol)

Jan 21 2001

Added support for the old protocol, fixed a problem with the partition re-reading

Feb 02 2001

Fixed a problem with the ATA signature of a 6GB model

Apr 30 2001

Fixed a problem with multiple spinlock requests under kernels > 2.4.1

Aug 23 2001

Fixed a problem with the ATA signature of a 40GB model


Nov 23 2001

Fixed problems with ATA set_multiple; Introduced partition table based head recognition
Introduced clusterorder module option (default now is 1 (16 sectors) was 3, -1 disables it)

Feb 25 2002

Fixed gcc ## VARARGS macro issue (failed to compile with gcc older than 2.96)

Apr 19 2002

Fixed licence problem (added license directive to avoid tainting the kernel)

July 18 2002

Fixed problem with RH7.3 (undefined symbol gendisk_head)

December 10 2002

Fixed problem with RH 8.0 undefined urb_t

August 10 2006

Added a first version for kernel 2.6.x, major rework

December 3 2006

Fixed changes in the kernel API for kernels >=2.6.16

December 23 2008

Fixed changes in the kernel API for kernels >=2.6.25 (end_that_request_first)

The current status is:
New model works fine (I'm testing it myself ;-)

Old model(s) as far as I understand it works ok (20GB 13GB 6GB and 20GB-Mac)

I can run my unit in either new or old mode and can't see any performance difference.

Thanks to all those who helped me with information and logs for the different models.

Installation

Download the archive file usbide.tar.gz and save it somewhere on your hard disk. Extract the content with the command:

tar -xvzf usbide-2.3.tgz

At this point a directory named usbide has been created.

cd usbide

Follow the instructions in the INSTALL file

From version 2.0 I use devfs, the devices are now /dev/uda, /dev/uda1, /dev/uda2 etc. The major is automatically allocated so static devices can not be used.
MANDRAKE USERS: I've got reports that Mandrake 8.1 uses devfs. This means that the partitions of your BusLink device will not be dev/pda, /dev/pda1, /dev/pda2 etc. but /dev/ud/disc0/disc (the whole disk, equivalent to /dev/pda)
/dev/ud/disc0/part1 /dev/ud/disc0/part2 (the partitions (if any) equivalent to /dev/pda1 /dev/pda2).


Some device got shipped with no partition defined but with the signature of a partition sector on the first sector of the disk. This will cause some trash in fdisk if you try to run it. Don't be surprised if you get a list of weird partitions with a lot of warnings/errors in this case. If you want to repartition your HD (you'll loose all data on it!!!) just delete those four crap partitions and create yours or you can use dd to blank the first sector before running fdisk (you must know what you are doing)



IMPORTANT
Loading-unloading-reloading the usbide module will fail.
The disk inside (my) buslink only executes the IDENTIFY command once (this is where one gets the disk info's).
If you need to unload/reload the module unplug (or switch off/on) the device in-between.


Unloading/reloading the controller driver (ex. usb-uhci) issues a USB reset which is the same as unplugging/replugging your unit. If you reset the computer this issues an USB reset as well. The unplugging/replugging is only required if you want to unload/reload usbide for who knows what reason.
You can however unplug/replug your unit as many times you want without touching usbide (not true if you have mounted any partition).

Power save modes (like the green button on my PC(s)) may not be compatible (so far) with usbide since in powersave state a disconnect/reconnect is issued but I'm not sure if the usb reset is issued as well (anyway the problem of mounted volumes will always be present). This might be solved using powersave/resume in the usb stack one day which I think is on its way.

something like this should appear in your /var/log/messages
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:1366 driver for Prolific ide-usb bridge
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:1367 ud compiled Nov 23 2001 14:25:15
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:1368 usbide: version V1.1 - experimental, major 45
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:1369 (C) Enrico Bravin <Enrico.Bravin@cern.ch>
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:1370 Request grouping will be used (max requests= 16)
Nov 23 14:29:19 pspc7842 kernel: usb.c: registered new driver usbide
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:573 Detected device vendor=0x067b  product=0x2307  interface=0
Nov 23 14:29:19 pspc7842 kernel: usbide-core.c:575 Using new protocol

and if your BusLink unit is attached and ON

also something like

Nov 23 14:29:20 pspc7842 kernel: usbide-core.c:1013: do_request called...
Nov 23 14:29:20 pspc7842 kernel: usbide-core.c:734 Registered new usbide disk /dev/pda QUANTUM FIREBALL128
Nov 23 14:29:20 pspc7842 kernel: usbide-core.c:1419 registered usb part

and some information about partitions

If you turn on the unit after modprobing the driver it might not register correctly (the driver  keeps probing the unit for up to10 seconds allowing the disk to spin up, but this might not be sufficient although it is for me.)
Just unplug the device do modprobe -r usbide and modprobe usbide again, plug the unit and that should work. If it still doesn't work check (lsmod) that usbcore, usb-uhci (or ohci etc..) and usbide are there. If they are there and still nothing happens try to uncomment  //#define DEBUG in usbide.h and recompile/install the module. If you open a console (xconsole) and enable any kernel message in /etc/syslog.conf and restart /etc/rc.d/initd/syslog when you modprobe usbide a bunch of messages are printed out and you can try to figure out what is amiss or just send the log to me.

Frequently asked question

Any reason why your driver wouldn't work with Buslink's bigger (80-100 GB) hard drives?

The capacity of the HD does not matter (at ~1MB/s it will take a while to transfer 100GB ;-) ).



Any reason why your driver wouldn't work with Buslink's faster (USB 2.0) external USB hard drives?

I think USB2.0 is now more or less supported in Linux (at least in the latest 2.4 ande 2.5 development kernels.)
The Buslink USB 2 devices are storage class devices i.e. they should work with usb-storage,
this means they should work out of the box with recent distributions, you plug it and you have it.
The partition naming under /dev/ will be totally different since it will be seen as a SCSI device I guess /dev/sd[a-z][1-nn] but this is just a guess
http://www2.one-eyed-alien.net/~mdharm/linux-usb/ for more info's on usb-storage.


Make install (depmod -ae) gives a lot of unresolved symbols and/or
I get the following (similar) errors in my console when I plug a Buslink USB drive in:
/lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/usbide.o: kernel-module version mismatch
/lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/usbide.o was compiled for kernel version 2.4.18
while this kernel is version 2.4.18-64GB-SMP.

1) Then the kernel source (or configuration) you are using does not match the kernel you are running
2) You previously compiled the module with a different kernel -> make clean; make; make install



The driver is unstable and the device stops working requiring a reboot


This is often a memory allocation issue in the usb controller driver (uhci, usb-uhci or ohci).
If you have a uhci controller try the other driver (on RedHat you can chenge it in /etc/modules.conf "alias usb-controller usb-uhci")
I though this problem had vanished around 2.4.2 but seems to be still there for some kernel version.



I was using your v.1.2 driver under Linux 2.4.7-10 without any issues.  I upgraded to 2.4.18 and now I receive the following error from the install.sh script:
depmod: *** Unresolved symbols in /lib/modules/2.4.18-3/kernel/drivers/usb/usbide.o
depmod:         gendisk_head
make: *** [install] Error

In newer kernels gendisk_head as been masked into helper functions. This has been fixed in version usbide-1.2.2-c.tgz



Are there other devices working with your driver

Some unbranded enclosures as well as  BAFO enclosures have been reported using the Prolific PL2307 chip and to work with this driver.

Eric Brombaugh has written a patch that allows it's use with a Butterfly Media Compact Flash Adapter. You can find it at:
http://home.earthlink.net/~ebrombaugh/butterfly.html


How to install USBIDE on Debian 3.0r1 (from one of you)

This is how you install the BUSlink usb 1.0 hard drive on a Debian system.  The system I am running is Debian 3.0r1 with kernel 2.4.22.  I have hotplugging, and the normal usb modules installed.  As far as I know everything seems to work great.  I will not say I'm absolutely sure the driver won't mess up things, but it has been proven to work on other linux boxen.  You may replace the 2.4.22 with your respective kernel version.    

1. First you need the tarball from http://bravin.home.cern.ch/bravin/usbide/usbide.html (You could also search for buslink at http://www.linux-usb.org/)
2. Save the tarball somewhere like /usr/src. Untar, and cd into the directory created.
tar -xvzf usbide-x.x.x-x.tgz
cd usbide
3. Follow the instructions in the INSTALL doc. Making sure you make a symbolic link to your current kernel src to /usr/linux-2.4. Before proceeding, then make, and make install.
ln -s /usr/src/linux-2.4.22 /usr/linux-2.4
make
make install
4. This is where debian strays since debian has no /dev/pda device. You must make one with the appropriate major, minor numbers.
mknod --mode=660 /dev/pda b 45 0
mknod --mode=660 /dev/pda1 b 45 1
chgrp disk /dev/pda*
This will create the right device files for a single partition on the disk.
5. Now you should be able to try out the module. If it says you've registered a new usbide disk, then you may install the device module into your system, and set up a mount point to /dev/pda1, etc.
6. I copied the modules to /lib/modules/2.4.22/kernel/drivers/usb/storage. I then updated the dependencies, and hotplug could easily discover the device.
cp /usr/src/usbide/*.o /lib/modules/2.4.22/kernel/drivers/usb/storage
depmod -a

-=- That is my Debian 3.0r1 install for the BUSlink




 Comments can be sent to Enrico.Bravin[at]cern.ch