Recent Changes - Search:

Recently Written

News

edit SideBar

USB in DOS

1.  About USB

Good info about USB can be found on Wikipedia: en.wikipedia.org/wiki/Universal_Serial_Bus .

There exist several generations of USB interfaces:

  • USB 1 can transfer by speed of 1.5 Mbit/s called Low speed or 12 Mbit/s called Full Speed (YES, “full” means in fact “slow” now ) and is implemented in controller standards UHCI and OHCI .
  • USB 2 is called High Speed and uses EHCI controller standard, handles 480 Mbit/s (speed-up by factor 20), but for old non compatible devices it can also work in slow USB 1.0 mode either in UHCI or OHCI protocol always (?) additionally implemented in controller and driver. USB 2 cables and connectors look very same as for USB 1, but have “better quality” and shielding, so for USB 2 usage also USB 2 cables are required.
  • USB 3 (XHCI) specification was finalized 2008-Nov-17, publicly available hardware coming only slowly since end 2009 / beginning of 2010, some controllers and USB devices available, not yet the “common standard”, as of end of 2010, USB 3 was still the minority, 2012 getting more popular, 2013-Jan an “update” doubling the speed was announced (???), somewhat compatible with USB 2.0 in both directions (???), also with USB 1 (???), but uses “updated” connectors and cables having additional wires.
  • Wireless USB (WHCI) currently isn’t build in computers

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:

  • Slow: much slower than in “Windows”, even more remarkable with USB 2 , probably because of low buffering capacity and real mode and “better safe than fast” approach
  • MBR vs superfloppy: USB devices can hold just a filesystem (the “superfloppy” style) or a MBR area and 1 partition with a filesystem. Other OS’es usually accept both and you won’t see any difference except you check using some tools providing “physical disk” access to USB storage devices, but this can make a crucial difference for BIOS behaviour or (bad) drivers. Also multiple partitions are possible although Windows apparently doesn’t like this anymore so won’t see such devices that frequently.
  • Limited amount of devices/controllers: Some solutions provide access to only one controller (theoretically you can have many active at same time, note that one physical piece of PCI USB card usually provides 2 or even more quasi-independent controllers like EHCI+OHCI or EHCI+UHCI), or only one device. Even if multiple controllers or devices are supported, you have to carefully select the correct ones, this won’t happen automatically. So you should start with one controller card (deactivate the onboard chip (if possible, not all BIOS’es allow it :-( ) if you want to use a USB card), and one device (avoid multi-card-readers, a typical reader with 4 holes requires 4 drive letters, and this might not work, use a stick or a single-slot reader, also better avoid hard disks since they are usually partitioned (not to talk about NTFS (no longer “in”) or Ex-FAT) and this can be an additional problem as well, also their huge size of them can cause problems).
  • Designed for “MS-DOS”: most of those drivers were intended for recovering broken “Windows” using recovery bootdisks having a sort of “IO.SYS” file - so called “MS-DOS 7.1″. Also, they might require HIMEM/XMS and not document this fact, since such IO.SYS unconditionally loads it even without any entry in CONFIG.SYS, or even EMM386. Using them of FreeDOS and Enhanced-DR-DOS unfortunately can work much worse than on such bootdisks.
  • None of the drivers (except USBDOS) is open source, however DUSE and USBASPI are “considered as” free for personal use, DOSUSB officially is
  • Lack of “official” announcement, download page, and documentation (DUSE and USBASPI).
  • Not all USB host controller cards and chips are supported.
  • No DOS driver “standard” - various DOS drivers implement various approaches, components of those can’t be “mixed”.

2.  USB drivers (sorted from latest and best to oldest and most historical)

2.1  Second generation of USB drivers for DOS

A 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” drivers

Project 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:

  • FAT28 capability autodetection doesn’t work with EDR-DOS - use switch to override
  • INT $13 support is not always uninstalled well at driver removal and causes a mess after reinstalling (Bad: don’t uninstall or reboot after)
  • Very slow - there is a switch to override, by default it’s “better safe than fast” for now
  • Callback address rejection doesn’t always work (just don’t try it)
  • Various efficiency and “internal” source issues
  • Some referenced documentation files don’t exist yet

Georg Potthast’s drivers DOSUSB

Project 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 drivers

In 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 support

Since 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 storage

Since cca 2003, many BIOS’es additionally support storage devices.

[1] by USB booting

They can just boot from an USB device, instead from floppy or internal HD.

[2] USB legacy emulation for USB mass storage

Partially 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 extender

A 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 Bootmanager

License: 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:

  • It implements only read access, no write support yet.
  • Using a memory manager like EMM386 will result in a crash, HIMEM is tolerable.
  • Still slow, driver is optimized for small size (to get a bootmanager fitting in MBR area only) and not optimized for speed (with caching).
  • No USB hub support.
  • Only support for USB-HDD, no USB-FDD, no USB-ZIP and no USB-CDROM.

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 drivers

Developed 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:

  • A low level driver providing ASPI (USBASPI.SYS from Panasonic) to DOS
  • A second driver actually using the new ASPI device (USBCD.SYS or DI1000DD.SYS)

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:

  • usbaspi.sys is the USB to ASPI driver.
  • usbcd.sys is a ASPI CD-ROM driver.
  • ramfd.sys purpose unknown.

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:

  • di1000dd.sys a device driver needing an ASPI driver.
  • RAMFD.SYS purpose unknown.
  • README.TXT google translate fails, which language is this?
  • USBASPI.SYS seems to be the ASPI driver and identifies itself with “ASPI for UHCI/OHCI USB mass-storage Version 1.07″ and “Copyright© 2001 NOVAC Co.,Ltd.”. It looks somewhat similar to USBASPI.SYS from Panasonic. Does someone know whenever novac’s USBASPI.SYS is just and outdated rebrand of usbaspi.sys from Panasonic?

DUSE

Developed 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 APSoft

License: closed source, shareware

Supports USB 2.0 transfers and can be loaded from command line.

Datoptic

Has 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:

  • NJ32DISK.SYS
  • SBP2ASPI.SYS
  • USBASPI.SYS

IOMEGA drivers

Also consists of two parts. IOMEGA.ZIP has the lowlevel set aspiohci, aspiuhci and aspiehci and the highlevel part guest.exe.

2.3  Theoretical / historical relevance

IBM

Has USB_CD.SYS. Link ? License ?

Adaptec drivers

No info

CATC USB4DOS

In 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 problems

The 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 reason

This 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 reason

Again, problem can be random (just retry) or persistent. If it seems persistent, following reasons are possible:

  • Device is getting recognized, but it takes unreasonably long time, see [11]
  • Buggy driver
  • Buggy device, see [9]

[3] Driver crashes / hangs / deadloops / bluescreens

Regrettably 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 performance

In 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:

  • USB 2 device recognized as USB 1 only, see [1]
  • Inferior driver. This is the “common standard” with DOS drivers, most of DOS USB driver development so far has been “getting it working at all” and fighting with compatibility and stability issues, there has been hardly any performance tuning.
  • Filesystem issues. Writes with DOS on FAT filesystems are typically cca 3 times slower than reading, can be worse in some cases depending from FAT subversion, cluster size, and block size used by the application. Also fragmentation and low free space can cause an additional slowdown.
  • Transfer errors, see [6]
  • Slow device, even if declared as “USB 2.0 High speed”. Early USB 2 sticks are barely faster than USB 1 - the memory chip can’t do better. Also USB 2 cardreaders can be slow (even very slow) - even if you insert a fast card and connect to a fast PC, some reader internals will slow down the transfer to near USB 1 performace.
  • Slow PC. You can install an EHCI USB 2.0 card into an early PCI PC, and it might even work, but the performace will hardly beat USB 1, simply because the PCI bus and memory having to transfer, supply and “eat” all the data are slow. Of course a slow hard disk used as source or destination for copying will also ruin the performance.

[6] Unstable / unrelibale / slow transfer / data corruption / random errors

USB 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:

  • Buggy driver
  • Buggy device, see [9]
  • Poor cable, see [8]
  • Mixing USB 1 with USB 2, see [12]
  • Power issues, see [15]

[7] Data corruption on USB device

Frequent / 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 long

This 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 2

When 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:

  • Copy from source device to internal HD, and then from there to destination device, keeping both plugged in all the time
  • Copy from source device to internal HD, and then from there to destination device, avoid having both plugged in at same time
  • Connect the 2 devices to 2 physically different controllers (2 PCI cards or PCI card + onboard chip)

[13] Workarounding bugs / compliance policy

[14] Sprurious activity light on USB devices

Most 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

Edit - History - Print - Recent Changes - Search
Page last modified on February 06, 2013, at 08:27 AM