A driver for Y-E Data Incorporated PC-Card Floppy Drive David Bateman dbateman@eng.uts.edu.au Version 1.02 INTRODUCTION ------------ This driver is for use with the Y-E Data Incorporated FlashBuster PC-Card floppy drive. These are commonly found on the Toshiba Librettos and are available as a separate product (at least in Japan). This driver was written on my Libretto 50, so the only machine I'll vouch for it working on is my own. However I believe it should work without difficulty on any of the Libretto machines. This code was developed on a linux 2.0.34 kernel, and later ported to a 2.1.122 kernel. It will probably work fine with other 2.0.X, 2.1.X or 2.2.X kernels, but might need to have some of the rejected files from the kernel patch reconciled by hand. For most floppy disk controllers (FDC's) data is sent between the CPU and the FDC using a DMA channel. However the PCMCIA 2.0/2.1 standard doesn't support DMA transfers, and consequently data must be written to the FlashBuster with programmed I/O (PIO). The linux kernels floppy driver doesn't support PIO, and so this new method of communicating with FDC's is added to the floppy driver. Unfortunately, as it stands, the linux floppy driver assumes that all FDC's will use the same means of communicating. Hence the fact that the FlashBuster uses a different method of talking to the FDC limits the floppy driver from supporting a FlashBuster and another FDC at the same time. In addition supporting two FDC's is further complicated by the issue of sharing the interrupt line (IRQ) between the two FDC's. Working around these problems will require a significant level of alteration to the floppy driver, which I might do at a future date. INSTALLATION ------------ This driver consists of two components. A package for use with David Hinds linux PC-Card package version 3.0.5 or later, and a small patch to the linux kernel. The package will work with earlier versions of the linux PC-Card package than 3.0.5, however due to changes in the file format for the "pack_cis" program there will be errors when building the replacement CIS. Hence using a version later than 3.0.5 is highly recommended. The patch to the linux kernel is necessary to allow the configuration of the floppy's IRQ and I/O base address to be deferred till after the FlashBuster PC-Card is correctly configured, and to use PIO. It is hoped that the changes to the linux kernel will be included in the available kernels at a later date. The package is fully installed with a 2.0.X kernel in the following manner % cd /usr/src/pcmcia-cs-3.0.5 % tar xpBvzf /tmp/floppy_cs-1.02.tar.gz % cd /usr/src/linux % cat /usr/src/pcmcia-cs-3.0.5/modules/patches/floppy20.fix | patch -p0 and with a 2.1.X or 2.2.X kernel in the following manner % cd /usr/src/pcmcia-cs-3.0.5 % tar xpBvzf /tmp/floppy_cs-1.02.tar.gz % cd /usr/src/linux % cat /usr/src/pcmcia-cs-3.0.5/modules/patches/floppy22.fix | patch -p0 This assumes that the linux FlashBuster package is in the file /tmp/floppy_cs-1.02.tar.gz, /usr/src contains the linux kernel source in the directory (or symbolic link) linux, and the PC-Card sources are in the directory /usr/src/pcmcia-cs-3.0.5. Some modification to the instructions above will be necessary if this is not the case. At this point you are ready to configure and rebuild the linux kernel with PC-Card floppy support. This process is best described by reading the relevant documentation in /usr/src/linux. However one point to note is that the kernels floppy driver MUST be built as a module (i.e. "CONFIG_BLK_DEV_FD=m"). I originally supported the use of PCMCIA floppy drives with the floppy driver built into the kernel, but the issue of reconfiguring the FlashBuster driver made this option so undesirable that I stopped even testing that building the floppy driver into the kernel worked. Also the linux FlashBuster driver has introduced a new configuration option "CONFIG_BLK_DEV_FD_PCMCIA" to the linux kernel. You will need to configure the linux kernel with this option, so that the FlashBuster is supported. Once the kernel is built and installed, PC-Card services can be built and installed in the usual manner. The linux PC-Card package will attempt to automatically build and install the FlashBuster floppy driver. However they can be built separately by executing the following % cd /usr/src/pcmcia-cs-3.0.5 % make -f floppy_cs.mk all % make -f floppy_cs.mk install CONFIGURATION ------------- After installing the FlashBuster floppy package, you'll need to update your /etc/pcmcia/config file so that the PC-Card package can identify your FlashBuster floppy and take the appropriate actions. You'll need to add some lines to your /etc/pcmcia/config file. If you have built the floppy driver as a module as recommended then you need to add device "floppy_cs" class "floppy" module "block/floppy" opts "floppy='pcmcia'", "floppy_cs" in the top half of /etc/pcmcia/config. The device definition above assumes that the linux kernel's floppy driver is compiled as a module and lives in the directory /lib/modules/2.X.X/block. For some kernel versions the floppy module is actually located in /lib/modules/2.X.X/misc and so if you are using an earlier kernel, the above device definition will need to be modified to reflect this. Please read "modules.txt" in the linux kernel documentation for a more general discussion of loading kernel modules, and /usr/src/linux/drivers/block/README.fd for a discussion of the options to the linux kernels floppy driver. To correctly recognise the FlashBuster also requires a card definition in /etc/pcmcia/config. An appropriate card definition that should correctly identify all currently released FlashBusters is card "Y-E DATA External FDD Controller" version "Y-E DATA", "External FDD", "Controller", "*" bind "floppy_cs" There are a few problems in the CIS's in some FlashBuster cards. From the linux drivers point of view, the only effect of these problems is to limit the number of valid I/O base addresses. This is not a serious problem as there will still be a large number of valid addresses. Even so a replacement CIS is desirable, and so you might prefer to use the card definition card "Y-E DATA External FDD Controller" version "Y-E DATA", "External FDD", "Controller", "*" cis "cis/FB2FDC.dat" bind "floppy_cs" where the line "cis/FB2FDC.dat" forces the cardmanager to install a corrected CIS from the file FB2FDC.dat that makes all of the valid I/O base addresses available. This file is created from the text file "FB2FDC.cis", and it contains all of the information needed by the linux PC-Card package for correct operation. The latest releases of the FlashBuster don't seem to need the replacement CIS. If you have a FlashBuster with a Toshiba part number of "PA2940U" rather than the older "PA2612U" then chances are you won't need the replacement CIS. The FlashBuster can be configured to use any eight consecutive 8bit I/O address with a starting address in the set 0x3C8, 0x3C0, 0x3A8, 0x3A0, 0x388, 0x380, 0x368, 0x360, 0x348, 0x340, 0x328, 0x320, 0x308, 0x300, 0x2E8, 0x2E0, 0x2C8, 0x2C0, 0x2A8, 0x2A0, 0x288, 0x280, 0x268, 0x260, 0x248, 0x240, 0x228, 0x220, 0x208, 0x200 So for instance, if an address 0x3A8 is selected then the I/O addresses from 0x3A8 to 0x3AF will be used by the FlashBuster. The addresses in this set are searched by the FlashBuster driver in a descending order, to find an unused address. However to avoid potential conflict with hard disk controllers, serial ports, etc, where even probing an address that is in use can cause a lockup, the linux FlashBuster driver limits the addresses it searches to those above 0x2FF. If you prefer to have the FlashBuster use a particular address then the driver can be forced to use any of the above, and only the above, addresses with the following device section device "floppy_cs" class "floppy" module "block/floppy" opts "floppy='pcmcia'", "floppy_cs" opts "iobase=0x3A8" where in this case the FlashBuster is forced to use the address 0x3A8. By default the IRQ used by the FlashBuster will be assigned by the cardmanager and can be any IRQ that is not bound to another device, or explicitly excluded in your configuration files (usually in /etc/pcmcia/config.opts). However you can further limit the IRQ's that are used by the FlashBuster with the "irq_list" option. So for instance to force the FlashBuster to use either IRQ 5 or 11 you'd change your device section to read device "floppy_cs" class "floppy" module "block/floppy" opts "floppy='pcmcia'", "floppy_cs" opts "irq_list=5,11" Any comma separated list of IRQ's can be used here to limit the IRQ's available to the FlashBuster. When the FlashBuster floppy has been correctly recognised, it will be attached to the relevant block device. In general this will be /dev/fd0. However if multiple FDC's are supported in the future, and the FlashBuster floppy is not the only FDC in the system, then the PC-Card floppy might be attached to /dev/fd4. USAGE ----- Be warned that some distributions have /dev/fd0h1440 setup with minor device number 40. This is actually the device number for a 1.44MB format on a 5 1/2 inch disk. The FlashBuster doesn't like the geometry given by minor device 40. Hence where possible use the generic /dev/fd0 or check the minor device numbers. For instance a simple format command might be of the form % setfdprm /dev/fd0 1440/1440 % fdformat /dev/fd0 or % superformat -d /dev/fd0 --hd For more information on the device numbers of the floppy disks, please examine the manual page fd(4). MODE 3 SUPPORT -------------- If you don't know what Mode 3 is, then chances are you won't need to read this section. Mode 3 is the name for a common 3 1/2 inch disk format in Japan. However there appears to be two slightly different disk geometries called Mode 3. The first of these is compatible with a 1.2MB 5 1/2 inch disk, while the second has a slightly denser format. The two formats are usually distinguish by the names "1.21MB" and "1.25MB" respectively. The exact geometries of these formats are Heads Tracks Sectors Bytes/Sector 1.21MB 2 80 15 512 1.25MB 2 80 8 1024 As the linux floppy driver has been very stable in the last few years, the changes to the linux floppy driver for FlashBuster support have a better chance of being included in mainstream kernels if they minimise their impact on the kernel. Hence one of the aims when writing the FlashBuster driver was to keep the changes to the linux floppy driver simple and isolated. Unfortunately this means that the 1024 byte sector size used for 1.25MB format can not be included, and so 1.25MB Mode 3 disks are not supported by this driver. The distinguishing feature of a 3 1/2 inch Mode 3 disk is that the rotation rate of the head is 6 revs/sec, rather than the 5 revs/sec of a normal 3 1/2 inch disk. So for the linux FlashBuster driver to support Mode 3, requires that the FDC is told to change the rotation rate by the driver. So another simplification to reduce the impact on the linux kernel is that the FlashBuster driver tells the FDC to change its rotation rate when the FlashBuster is first inserted. For this reason if you wish to read both Mode 3 and normal 1.44MB floppy disks without rebooting, then the floppy driver must be built as a module. To install the FlashBuster to use Mode 3, the device section of /etc/pcmcia/config should be adjusted to read device "floppy_cs" class "floppy" module "block/floppy" opts "floppy='pcmcia'", "floppy_cs" opts "mode3=1" To switch between mode 3 and normal 3 1/2 inch disk support requires that the floppy module is removed and reinserted. Assuming the FlashBuster is in the PC-Card slot 0 the commands % cardctl eject 0 % insmod /lib/modules/2.0.34/block/floppy.o floppy='pcmcia' % insmod /lib/modules/2.0.34/pcmcia/floppy_cs.o mode3=1 % cardctl insert 0 can be used to switch to Mode 3, while % cardctl eject 0 % insmod /lib/modules/2.0.34/block/floppy.o floppy='pcmcia' % insmod /lib/modules/2.0.34/pcmcia/floppy_cs.o % cardctl insert 0 can be used to switch to a normal 3 1/2 inch mode. This process might easily be incorporated into a script. The commands above of course assume that the modules reside in the directory /lib/modules/2.0.34, and will need to be altered in a kernel other than 2.0.34 is used. When formatting Mode 3 floppy disks, the linux kernel driver doesn't know about the geometry of these disks internally. So the user must give sufficient information to the format command to tell the driver the geometry. For instance a "1.21MB" disk might be formated with the command % superformat -d /dev/fd0 -H 2 -t 80 -s 15 -S 2 TROUBLESHOOTING --------------- In this section I hope to describe some of the possible problems you'll have installing the linux FlashBuster driver. Please refer to this section before you send me a request for help or a bug report. Q. I get the error messages "unresolved symbol floppy_register", "unresolved symbol floppy_unregister" and "unresolved symbol floppy_set_mode3" A. This is probably the most common bug report I have been sent so far. Unfortunately it is also the least informative. These three symbols were introduced to the kernel by the kernel patch included in the linux FlashBuster driver. So if you get this message it can mean 1. You haven't applied the kernel patch correctly. A special note here, the version 1.00 release of the linux FlashBuster driver said to use "patch -p" while patching the kernel. Recent versions of patch will require "patch -p0". 2. You haven't reconfigured the kernel and/or you haven't set the option CONFIG_BLK_DEV_FD_PCMCIA. 3. You haven't rebuilt and installed the kernel after patching and configuring it. 4. You haven't altered /etc/pcmcia/config correctly to load the kernel's floppy driver before loading floppy_cs.o. You can get more information on which of these is in fact the case by looking at the messages in your log files immediately above the unresolved symbols. Q. I get an error message "floppy_cs: GetFirstTuple: No more items" A. Check the size of the file /etc/pcmcia/cis/FB2FDC.dat. It should be at least 300 bytes in size, with the exact size varying depending on how it was installed. If it is only a few bytes in size then remove the line cis "cis/FB2FDC.dat" from /etc/pcmcia/config. The reason for this happening is that the program "pack_cis" was significantly modified in the linux PC-Card package version 3.0.5. The file FB2FDC.cis in version 1.00 of the linux FlashBuster driver is incompatible with this new "pack_cis". This problem is resolved in version 1.02 of the linux FlashBuster driver. Q. I get an error message "floppy_cs: RequestIRQ: Resource in use" A. The linux PC-Card package attempted to assign an IRQ to the linux FlashBuster driver that was already in use. The linux PC-Card package probes the available IRQ's when it is first started, usually by running "rc.pcmcia start" when booting. Sometimes this process can get confused and the IRQ given to the linux FlashBuster driver is already taken. If you can run "rc.pcmcia restart" and then the linux FlashBuster driver works, then this is probably what has happened. Solutions are to move "rc.pcmcia start" to later during booting, or you can exclude IRQs that cause problems by adding lines like exclude irq 12 to the file /etc/pcmcia/config.opts, or you can use the "irq_list" option in /etc/pcmcia/config to force the linux FlashBuster driver to use a particular IRQ that is known to work. This problem is unlikely to happen with 2.1.X or 2.2.X kernels which have better IRQ management. Q. Whatever I do I just can't seem to load the FlashBuster driver A. If you forgot to include the option "floppy='pcmcia'" in device section /etc/pcmcia/config, then it is possible that the kernel's floppy module will be loaded and be stuck with a "Resource busy". Try ejecting the FlashBuster PC-card and then running "lsmod". If you see something like % lsmod Module: #pages: Used by: floppy 11 [uninitialized] then chances are you have this problem. In this case you should re-read the configuration section of this README and ensure that you have included the "floppy='pcmcia'" option as suggested there. You will then have to reboot as nothing will be able to remove the uninitialized kernel floppy module. Q. I get one of the error messages "fdc 0 is still active", "motor off timer 0 still active", "floppy_timer still active", "auxiliary floppy timer still active" or "task queue still active" when trying to load the FlashBuster driver A. From version 1.02 of the FlashBuster driver, there is some limited testing for whether there is another FDC using the kernel's floppy driver before inserting the FlashBuster driver. These messages tell that the kernel's floppy driver is still busy servicing another request and you can't insert the FlashBuster driver at this point. Note that this doesn't mean that multiple FDC's are supported. Only that a FlashBuster can be supported in the presence of another FDC. When the FlashBuster is in use, this other FDC will be disabled. If you have a problem not addressed in this section, and you feel you have exhausted all other possible sources of help, then I can be contacted at "dbateman@eng.uts.edu.au". TO DO ----- This is a rough list of the features I believe to be missing in this driver. Some of them might not be too difficult to include, whilst others might be next to impossible. I've listed them in what I consider to be their order of difficulty. * Support 1024 byte sector size required for 1.25MB Mode 3 floppies. As 2m disks are already supported, this doesn't seem that it would be too difficult. * Autodetect Mode 3 floppy disk rather than have to switch manually. I think this could be done by switching between Mode 3 and normal 3 1/2 inch disk modes after a certain number of retries for a disk operation. * Support a FlashBuster FDC in the presence of another FDC. The changes required for this seem quite large, and so difficult to get included in a mainstream linux kernel. The alternative of repeating all of the floppy code in the PC-Card driver and making the changes there is equally unattractive. So it seems unlikely this will be supported. COPYRIGHT --------- Copyright (C) 1998 David Bateman -- dbateman@eng.uts.edu.au The FlashBuster driver was written using dummy_cs as a starting point. dummy_cs bears the following copyright Copyright (C) 1998 David A. Hinds -- dhinds@hyper.stanford.edu LICENSE ------- This driver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ACKNOWLEDGEMENT --------------- I would like to thank Y-E Data for their support in producing this driver and in particular I'd like to thank Jim Blackson for his help in supplying the relevant documentation. CHANGELOG --------- Rev: 0.01 Date: 1998/02/20 20:54:23 (David Bateman) Started writing floppy driver based on skelton_cs (now dummy_cs) Rev: 0.07 Date 1998/04/24 20:15:43 (David Bateman) Updated to more closely resemble dummy_cs in the pre 3.0.1 releases of linux PC-Card package Rev: 0.08 Date 1998/05/14 02:11:16 (David Bateman) First pass at getting driver to work with PIO after receiving documentation Rev: 0.30 Date 1998/05/17 13:55:34 (David Bateman) First working version. However there are problems with the DCL line flagging phantom disk changes causing some I/O errors. Workaround by forcing the FD_BROKEN_DCL option. Only a single FDC supported at the point, so if you plug in a FlashBuster with another FDC, you'll only see the FlashBuster. The floppy driver in the linux kernel MUST be built as a module!! Rev: 0.40 Date 1998/05/25 01:12:48 (David Bateman) Japanese Mode 3 support. Included better workaround for the problem with the DCL. Inclusion of the PC-Card floppy code in the kernel is now controlled with the CONFIG_BLK_DEV_FD_PCMCIA configuration option. Rev 1.00 Date 1998/06/01 20:35:34 (David Bateman) Hopefully the final pre-release. If this release has no problems, will ask Y-E Data to relax NDA sufficiently to release the source code. Rev 1.01 Date 1998/09/18 00:25:51 (David Bateman) (not released) Port the driver to the linux 2.1.122 kernel and update docs to reflect this Rev 1.02 Date 1999/01/12 15:15:13 (David Bateman) Include better code to use a FlashBuster in the presence of another FDC. Add a troubleshooting section to the README.