News Categories |
Main /
USB in DOS
On this page… (hide) 1. About USBGood info about USB can be found on Wikipedia: en.wikipedia.org/wiki/Universal_Serial_Bus . There exist several generations of USB interfaces:
USB support in DOS is not trivial, since DOS was officially considered as “dead” at the time of coming up of USB (1995…1997). Also some design limitations of DOS (single tasking, the volume letter management (assuming that internal disks are “fixed”, the “block device driver” design, memory limitations) present additional challenges when writing an USB driver for DOS. Nevertheless there are methods to get USB devices recognized and working in DOS. Since the year 2007 the USB support in DOS considerably improved. While there is no USB support in any existing DOS kernel (latest EDR-DOS just better cooperates with the BIOS, it doesn’t access any USB controller at all) and only very limited support in the BIOS, two very powerful USB drivers of second generation vere written from this time. They are DOSUSB by Georg Potthast and USBDOS by Bret Johnsonn. Both allow you to use not only storage devices like flashdisks or USB connected floppy or CD/DVD drives, but also some other types of devices like input devices or printers. Computer manufacturers on present days don’t care much about legacy compatibility however there is usually some BIOS emulation support for USB keyboards and USB mice. If you have such BIOS you don’t need any DOS drivers (but you still may use such of you have reasons to do) for interfacing them because DOS and it’s drivers see them like a normal PS/2 devices (mouse may not work very well, though). Some good BIOSes even support storage devices so your USB disks are emulated as a floppy disk drives (later seen as A: or B:) or sometimes with certain hardware as internal harddisks (later seen as C: or D:) and this makes them accessible in legacy way via INT $13. However it usually doesn’t work good, it is incompatible with many flashdisks, it is slow and unreliable and doesn’t support hotplugging. It works only in USB 1 mode. Important thing is that most newer BIOSes support also booting from USB devices. But note that it doesn’t guarrantee the legacy access via INT $13 will work in DOS later. Up to now most methods of using USB storage devices in DOS do suffer from similar problems:
2. USB drivers (sorted from latest and best to oldest and most historical)2.1 Second generation of USB drivers for DOSA great leap forward in adding USB usability in DOS. In present two such driver sets are available - it is DOSUSB by Georg Potthast and USBDOS by Bret Johnson. They are comparable, both provide not only USB storage support but also USB keyboards, mice, printers and other devices. They have modular design but don’t use the complicated ASPI interface like the older drivers, instead they have own clean APIs. Both can be loaded and unloaded from command line (limited in DOSUSB). Bret Johnson’s “USBDOS” driversProject site and download: http://bretjohnson.us/ There is also a lot of other (mostly old) open source DOS related software on his website. Historical pre-release news from 2008–11–17 : groups.google.com/group/alt.msdos…. Note: It includes a driver for printers (USBPRINT) which makes it possible to print from pure DOS to an USB printer via LPT! They were initially released into public in 2009–07 and they are still in intensive development. Currently (last update 2010–01–30) they support only USB 1.1 protocol and only UHCI controllers, but OHCI, EHCI and USB 2.0 are planned. OHCI is currently under development. It is generally the most advanced one (forgiving lack of OHCI and EHCI support for now), has the best documentation, is the only one fully supporting hot-plug, the only one that is open source, the only one supporting “physical disk” access through INT $13, and the only one allowing complete uninstallation from memory, including the “block device” part. What is important - the modules for input devices (mouse, keyboard and joystick) and printers are fully working (ready for every day use) and transparent to DOS so everything works like normal legacy devices. The drivers work in the background and are able to handle more than one USB device at the same time. It is fine that it supports hot-plugging not partially but completely and you can change one flashdisk to another. This project is open source. The sources are written mostly in assembler (A86 and A386), few tools are in CPP. Besides the source code you can find a great manual and programming info about USB. The design is modular, although the “block device” support is in the same module as the INT $13 support, and there is not even a commandline switch to select only one of them, just FAT28 filesystems can be “rejected” by DOS capability autodetection (doesn’t work very well) or commandline switch. Both MBR and “superfloppy” filesystems are recognized. The low level USB services are implemented on INT $14, enhancing the original RS232 serial port support, and well documented. There are various open bugs the author is aware of, and should be fixed in next version:
Georg Potthast’s drivers DOSUSBProject pages: License: closed source, versions 1.xx were free for personal use, 2.xx is “demo” that stops working after 20 minutes (make sure to unload it BEFORE, otherwise it hangs), see documentation or contact author for exact information and licensing options
DOSUSB is also a promising project, still under development, last update is version 2.0 from 2010 May, last 1.xx version called “October 2008″ was released end of September 2008. Originally project was called “DOSUHCI” and supported UHCI controllers only (cca 2005), later OHCI support was added and name changed to DOSUSB (cca 2007), and in 2010 version 2.0 with EHCI support was released. Author reportedly is working on USB 3 support now, stay tuned or contact him if interested in beta testing. The driver supports on-board and addon card PCI and PCIe controllers (as far as BIOS is cooperative), it doesn’t support CardBus addon controllers used in laptops (if you previously “enable” the thing using some other driver, DOSUSB hangs (???)). It is not only the mass storage driver but general low level driver for USB devices with various addons which support special devices like storage, printers, mouse, keyboard etc. The main module is a TSR (can be loaded and unloaded at any time) and provides a generic but very low level set of services, available via INT $65 (by default, can be “moved” if needed). It doesn’t provide ASPI nor “physical disk” access with INT $13, so reading sectors with it is a bit a pain (see included open source examples). Probably the most interesting module is the USB disk driver, provided as .SYS file (can be loaded using DEVLOAD also). It provides limited hotplug support only. It means you can plug and remove flashdisks without restarting, you can manipulate with content of the flash disk even on another computer and plug it back. But you can’t change one flashdisk to another one (except some exceptions) without restart. After you unplug your storage device (“stick”, “flashdisk”) you can unload the main module (only) to free more memory. After plugging you simply load it again from the command line. Can assign only one volume letter, mounts only one (the lowest primary) partition. It works perfectly for some people but other report or reported problems, including incompatibility with some mainboard and controller models (most notably fixed onboard UHCI chip + PCI EHCI card), crashes/data corruption (?), conflicts with DPMI (fixed ?), etc. Except USB disks there are many of other devices supported but most of the modules serve more like programming examples about how to work with DOSUSB rather than being finished ready-to-use drivers. 2.2 Older support: BIOS, BIOS extender, first generation of USB driversIn late 90s first USB drivers for DOS appeared. Most of them support only storage devices (in one exception also mouse, in one other reportedly all) and they are not intended to be a general drivers for all USB disks. They are supposed to work only with some specified hardware by one manufacturer. Fortunately they usually work also with some other devices but they definitely can’t be called universal USB drivers. They have also other limitations: they don’t support the hotplugging and some need certain memory configurations. Some can handle only USB 1 mode, some also USB 2 mode. A good resource about first generation USB drivers is here: http://www.stefanthoolen.nl/darkehorse/PC/DOS/Drivers/USB/ USB keyboard and USB mouse supportSince cca 1999, most BIOS’es provide sort of “emulation” for USB keyboards and mice - accesses to those devices through BIOS INT’s do work without any driver. Look at KeyboardAndMouse . BIOS support of storageSince cca 2003, many BIOS’es additionally support storage devices. [1] by USB bootingThey can just boot from an USB device, instead from floppy or internal HD. [2] USB legacy emulation for USB mass storagePartially they also provide access to them through INT $13, making them accessible from DOS. DOS does not have to “know” anything about USB, it “thinks” to talk to a floppy or “standard” internal hard drive. USB sticks are often “mounted” as “Floppy” (“A:” or “B:”) or as hard disk (“C:”, “D:”, …), USB hard disks usually as the latter. [3] With BIOS extenderA BIOS extender is a software which extends or fixes features the BIOS, provided with third party software, in this case USB support is interesting. Further information about BIOS and USB at grub4dos Wiki:PLoP BootmanagerLicense: closed source, freeware
If you want to boot USB but your BIOS does not support booting from USB then there is currently one known software, PLoP Bootmanager. Can be booted from floppy or CD. It has the ability to boot from USB even if BIOS does not support from USB. It’s still in pre-release phase as in 2008 and there is no guarantee that it will work. However, it comes with several limitations:
Any issues (not working for your USB device) may be reported to the developer and maybe he can provide an improved version. Before contacting him make sure the fault is not on your side, only if the USB device is booting on another computers BIOS contact him. See also: grub4dos.sf.net/…PLoP_Bootmanager Motto Hairu / USBASPI / Panasonic / Novac driversDeveloped by Panasonic in 2002…2008, latest version seems to be 2.27 , should support USB 2 also (but still slow). License is unclear and there is almost no documentation. Seems to be intended for use with some Panasonic hardware, however the driver “accidentally” got “too generic” - it works with various other products as well. To get USB to work in DOS this approach uses two device drivers:
The “core” of the driver is technically not that bad, it usually perfectly finds all present USB controllers (even CardBus addon modules), as well as USB devices connected to them, and supports even EHCI and USB 2.0 . It is an EXE/SYS combo, it “should” be loaded as a SYS driver, but when used as an EXE, at runs in a “test-mode”, also listing and initializing (?) all devices, but is unable (?) to install itself and provide the ASPI services (it says “ASPI manager installed” nevertheless). The problems of this driver are (besides the license and lack of documentation) the ASPI approach (no “physical disk” support), the design as .SYS drivers (rather than unlodable TSR), and most notably the very buggy DI1000DD.SYS that is additionally required to be able to use USBASPI for file access. Download:
The Panasonic’s webpages are in Japanese only, also most of the text files contain only Japanese text, USBASPI.SYS itself is English. The files are WinLHA SFX archives, thus some effort and luck is needed to get the driver extracted. The archive contains three files:
There used to be the Motto Hairu diver included but now you have to download it separately: http://www.hiren.info/download/dos-files/di1000dd.sys The archive contains three files:
Links:
DUSEDeveloped by Pocketech and Cypress in 2002, considered as “free for personal use”. Versions 4.2, 4.4 and 4.9 available, but no official release announcement. It consists of just one module which can be loaded from CONFIG.SYS or from command line. Supports USB 2.0 but does not work on all memory configurations. Download here: http://www.pocketec.net/downloads/duse_4_9.zip The “official” (?) manual: http://www.pocketec.co.kr/support/img/DUSEUsersGuide.pdf USBmass/386 / Massusb by APSoftWebsite: http://www.tssc.de
License: closed source, shareware
Supports USB 2.0 transfers and can be loaded from command line. DatopticHas a driver Speedzter which also use ASPI and consists from lowlevel and hilevel parts. You can even try to mix them with counterparts by Panasonic. The lowlevel part is called sbp2aspi and the highlevel nj32disk. Download here: http://www.datoptic.com/Drivers/DAT.zip DATOPTIC.ZIP contains:
IOMEGA driversAlso consists of two parts. IOMEGA.ZIP has the lowlevel set aspiohci, aspiuhci and aspiehci and the highlevel part guest.exe. 2.3 Theoretical / historical relevanceIBMHas USB_CD.SYS. Link ? License ? Adaptec driversNo info CATC USB4DOSIn 1999, CATC announced USB4DOS, a professional full-featured USB driver (USB 1 only at that time) for DOS, expensive ($1000 ???), not available for download. Later CATC was eaten by LeCroy, and since then USB4DOS seems no longer available, and all what remained from this “breakthrough” is the archived announcement (PDF): http://www.lecroy.com/PressReleases/document.aspx?news_id=605&capid=103&mid=514 ”CATC Brings USB Availability to the DOS Programmer” 3. Troubleshooting / Known problemsThe USB technology introduced a “new era” in (besides non-storage devices) dealing with large amounts of data - storage and transfer of such has never been that easy, safe and comfortable before. Nevertheless, there has been also, possibly well justified, criticism about USB (like being “messy” and “flawed”) around all the time since announcement. Following is an (incomplete) list of USB flaws and problems that could or can be observed: [1] USB 2 device recognized as USB 1 device only for no valid reasonThis problem can be persistent (a certain arrangement of components (controller, USB device, driver) always triggers the problem), or random (occurs with some small (<10%) probability, unplugging and replugging a few seconds later “fixes” the problem). The exact reasons for this effect are unknown, some inferior/incompliant implementation of at least 1 component can be assumed. This is bad, since data transfer will take more than 10 times longer than expected, and the problem most likely will be discovered “too late” - when some “large” transfer is already in progress and “suspiciously bad” performance can be observed. This also makes filesystem flaws (see [18]) worse. Devices revealing this problem by the activity light (for example different colour for USB 1 vs USB 2 mode) exist but are very rare. [2] USB device not recognized at all for no valid reasonAgain, problem can be random (just retry) or persistent. If it seems persistent, following reasons are possible:
[3] Driver crashes / hangs / deadloops / bluescreensRegrettably this problem is most typical for DOS drivers, also early attempts of USB support on Win ME / 98 had such problems, while with Win XP it is almost inexistent. Obviously this is a driver bug, an incompliant or defective USB device or transfer errors should not be able to cause such effects. Unplugging the device may terminate a driver deadloop, or not. [4] USB device “hangs”As a consequence of transfer errors (see [6]), it can happen that the USB storage device “hangs”, while the (Win XP) driver “survives” the incident. The device “vanishes”, doesn’t answer anymore, pretends to be empty, or reports “strange” errors. It’s necessary to unplug and replug or switch the device OFF and ON to “get it back”. Obviously, such a behaviour is a fault of the device, and a bad sign for usability in DOS. [5] Very bad performanceIn some cases, a transfer performance much worse than expected can be observed. In practice, achieving an “end-user-performance” of cca 1/2 of the “theoretical” or “internal” transfer frequency can be considered as good, expecting more is not realistic. But obtaining much less in not that uncommon and can have various reasons:
[6] Unstable / unrelibale / slow transfer / data corruption / random errorsUSB protocols are intended to be safe, and to recover from errors by resending data blocks that seem to have got lost or corrupted. So transfer errors might not be obvious and the visible symptoms can be only bad performace or “strange random errors” or data corruption. Possible reasons for transfer errors include:
[7] Data corruption on USB deviceFrequent / severe transfer errors can cause data corruption, while a transfer abort (driver crash) definitely will cause such. Usually only the transferred file or files can be affected, and some “SCANDISK” having “good access” to the device can correct the errors then. Data present on the media before “should” be safe even then. There is a small / theoretical risk of corruption of other data, by misscalculating / corrupting / truncating the sectors number on writing, and an even more unrealistic “chance” that a “read turns into a write”, by a driver bug or as a “follow-up-damage” after corrupting the driver or DOS kernel in memory. OTOH, USB transfers don’t suffer from the infamous “LBA28 vs LBA48 problem”. A problem may arise from huge USB 2 harddisks, bigger than any internal disk the DOS kernel could be tested with before. To be on the safe side, test “scratch” devices before such with valuable data, smaller devices before huge ones (see also [18]), and reads before writing. [8] Cable issues[9] Buggy USB device / USB 2 device works on USB 1 controllers only[10] USB 1 device doesn’t work on USB 2 controller[11] Regognition of USB device takes unreasonably longThis is a problem mostly occurring in Win XP. When plugging in an USB device the earliest time, XP has to “install drivers” and this can take a long time, up to several minutes. Drivers have to be “installed” for every different model (or even piece ???) of device. After the “installation” is done, on subsequent cases of plugging in the very same device it should be recognized almost immediately (less than 5 seconds). Devices have been observed taking unreasonably long (> 10 seconds or even several minutes) every time, this is definitely a bad sign, the device most likely is buggy / has inferior compliance and probably will cause problems (up to not work at all) in DOS as well. In DOS no “automatic driver installation” occurs after plugging in, with USBDOS as the only driver supporting hot-plug at all, there is an “automatic recognition” in the background, so you should wait several seconds before accessing the device. Non-DOS systems usually “evaluate” the filesystem immediately after plugging in so reading a huge FAT or searching for a valid supported filesystem (if there is none) can cause an additional slowdown, see also [18]. In DOS low level drivers (USBDOS and DOSUSB) don’t care about filesystems, reading the FAT is postponed until you peek the free space or try to write, see also [18]. [12] Mixing USB 1 with USB 2When designing USB 2, care has been taken to achieve maximum compatibility with existing USB 1 technology. If any of the “active” components (driver, controller, USB device) supports USB 1 only, the other ones are supposed to “switch down” and the transfer is supposed to work slowly but correctly. But in some cases this might not work, especially if an USB 1 and an USB 2 devices are connected to the same controller and data is copied from one to another, symptoms can be device getting “hanged” (see [4]) or strange errors like “disk full” or “disk write protected” while it is neither full nor write protected. Workarounds worth to try:
[13] Workarounding bugs / compliance policy[14] Sprurious activity light on USB devicesMost USB storage devices have some activity light revealing that a data transfer is running. A good but rarely implemented idea is to additionally reveal speed mode (USB 1 or USB 2), for example by colour, or distinguish reads from writes. More frequently, flaws in this area can be observed, like light too weak or “hidden”, or inconsistent activity: OFF when idle vs ON when idle, or even blinking already when idle (faster when active), or failure to go OFF after device is ready for unplugging. It’s a troubleshooting help, but use with care and be prepared for surprises. [15] Power issues… flawed … [16] Write protection / data encryption… reportedly not reliable / doesn’t work … [17] Progress indicator puking or none exists at all… aggressive write caching of Win32 ruins the progress indicator … [18] Filesystem flaws / peking free space takes ages… and no progress indicator for it … [19] Partitions / filesystems… MBR vs “superfloppy” … EX-FAT … [20] Decay of printer standards… 4. See also |
Recent Comments