Sunday, July 14, 2024

The Power of the Modern Gotek Floppy Drive Emulator


The Gotek Floppy Drive emulator is a diamond in the rough as it comes from the factory. While cheap, the common Goteks only emulate a single type of floppy. While this may be all you need if you only need a DOS or Windows 95 boot disk, running floppy disk images on vintage computers is quite possible with a Gotek flashed with community-based firmware. In this article I will take a look at what the Gotek can do with the Flash Floppy firmware.

Hardware

The Gotek is an inexpensive device, usually retailing for around $30. The Gotek was originally designed as a floppy drive replacement for MIDI equipment, Embroidery and CNC machines and so on. Those machines typically only supported one type of floppy disk drive. PCs support six types of floppy disk drives (5.25" Single Sided, 5.25" Double Sided, 5.25" High Density, 3.5" Double Density, 3.5" High Density, 3.5" Extra Density) and many formats. The Gotek was not originally designed for vintage PCs but can be adapted to work with them.

While there are many Gotek models, (21 are shown on Gotek's website), most use a 34-pin floppy drive connector and fit into a 3.5" drive bay. From the factory most Goteks come with a 3-digit 8-segment display, a USB port, a drive status LED and a pair of buttons on the front to select disk images. There are usually several jumpers on the back and a 4-pin mini-molex power connector. A mini-molex power connector has wires for +5v and +12v but the Gotek only uses the +5v line. 

Most Gotek models only support 1.44MiB PC-compatible images but some alternatively support 1.2MiB or 720KiB images. Images are loaded off a USB drive plugged into the USB port. The USB drive can easily be as large as 32GB and must be formatted as FAT32. Images are placed into the root of the drive.

The Gotek, while useful as it comes from the factory, can be expanded to do so much more with community developed custom firmware. The are two custom firmware options for the device, Flash Floppy and HxC, but the latter costs money to install. Flashing custom firmware usually involves using a special USB cable (USB-A to USB-A) and bridging a pair of pins on the Gotek's mainboard.

You can also install an LCD or OLED Display in place of the segment display for more convenient feedback, a speaker to simulate disk drive noises and a rotary push-in knob to select images and options in place of the two buttons. Soldering may or may not be required depending on the Gotek model. One of the most recent models, the SFR1M44-U100LQD, has the OLED display and rotary knob preinstalled from the factory. Adding a speaker requires no soldering.

The Goteks use a microcontroller to simulate a floppy drive. Goteks originally used the STMicroelectronics STM32F105 MCU. Chip-shortages during the pandemic necessitated the replacement of the STM chip with the Artery AT32F415.  The ST chip had 64KiB of SRAM while the Artery chip only had 32KiB. The Flash Floppy firmware may have difficulty with formatting disks and writing to high density HFE images with the limited amount of RAM available to the AT32F415 compared to the STM32F105.

While previous MCUs came on a variety of Gotek boards and modules, they have all been superseded by the model which uses the Artery AT32F435 MCU. These Goteks use a PCB type called the SFRKC30.AT4.35. The AT32F435 has 384KiB of RAM and runs at 288MHz vs 72MHz of the STM chip. The AT32F435 has been supported in the Flash Floppy and HxC firmwares for several years now. Only buy this model and look for listing that explicitly says it uses the AT32F435 and avoid anything which does not. Compared to earlier boards, this board adds a pin header to connect a rotary dial and allows the Gotek to adjust the motor delay without soldering a wire and a resistor.

My advice for anyone wanting to explore the Gotek is to buy a unit directly off eBay. There are several sellers who offer Goteks with the OLED display, the rotary knob and Flash Floppy pre-installed for around $50. When I had to replace a Gotek with HxC firmware which was no longer functioning, I bought a new Gotek from here.

Firmware

I have used both the Flash Floppy and HxC Firmware and for IBM PC compatible usage I see little added value with the HxC firmware for PC usage. As I mentioned the firmware is not free (10 Euro) and installing it involved a convoluted dance of sending a file to the Gotek, emailing a file back from the Gotek to the HxC firmware's author and receiving a file from the author with your Gotek's unique serial embedded into the firmware which you then flash to the Gotek. Flash Floppy and HxC can do the same things, more or less, but Flash Floppy is free and can be pre-installed in a Gotek you can buy online.

Flash Floppy supports standard sector-dump disk images in all the common PC formats: 160KiB, 180KiB, 320KiB, 360KiB, 720KiB, 1.2MiB, 1.44MiB. These images typically use an .IMA or .IMG extension but can use any extension. I cannot speak to how Flash Floppy works with non-IBM PC compatible machines, but the non-IBM and non-Shugart floppy-style systems like the Apple II, Commodore 64 or Atari 8-bit computers generally have their own specialized floppy emulators which should be used with those systems.

Flash Floppy can boot images on a PC or permit images to be accessed through DOS or Windows. Images can be read, written and formatted. They can also be write protected. You can run games and programs off the emulated floppy drive and you can swap disks when a program or an installer requires it. Flash Floppy only simulates a disk drive, not a disk controller, so if you have a PC with only 8-bit slots you will need a floppy controller that supports the high density 1.2MiB and 1.44MiB drives to use those images.

Usage

A Flash Floppy-Gotek does not need a configuration file for basic functionality. With a rotary knob, turning the knob scrolls through the images and the OLED screen will display the image's file name. If the file name is longer than the OLED's display, the display will scroll the file name back and forth. By default selecting an image "inserts" the disk into the drive. You can push the rotary knob to "eject" the disk and access menu commands. With the OLED display you can use regular filenames, with the 8-segment displays you may find it hard to keep track of your images unless you maintain a copy of the files as stored on the USB stick elsewhere. 

The OLED display allows Flash Floppy to present useful functions to the user. Pressing in on the rotary knob will enter the menu. Entering the menu "removes" the floppy from the drive. Write Protect can be set to On or Off, overriding the image's read-only flag setting. An image can be copied and pasted, and if copied and pasted to the same directory will have a _xxx added to the file name. An image can also be deleted. Names given in [] signify subdirectories, and you return up a level by selecting [..]. For a subdirectory with a large number of files, you can press the two buttons to the left of the rotary dial together to jump instantly to [..] and then wait a second to jump up one level higher in the directory tree.

The OLED shows the number of files and folders and the current number of the file or folder currently selected, which is useful for navigating. For the PC compatible systems, Exit and Reinsert and Exit to Selector do the same thing because PC drives do not signal the host system that a disk has been inserted or remove. The exit and reinsert command may be useful for Amigas and Atari STs because their drives signal when a disk has been inserted and removed to their systems.

Placing an FF.CFG file in the root of the USB drive overrides the Flash Floppy default settings. You can find a sample FF.CFG in the github releases page under the folder "examples". For the section in FF.CFG called "DRIVE EMULATION" you should not need to make any changes for PC drive emulation. "STARTUP / INITIALISATION" allows you to choose whether to start the Gotek with an image inserted in the drive on the computer's bootup and which image to select. The changes made by the FF.CFG file will stay with the Gotek after power down and if the FF.CFG is removed from the USB drive. If the FF.CFG is changed and then the USB stick is reinserted the changes will take effect immediately. You can reset the settings of the Gotek by holding the two buttons down for three seconds while the USB drive is removed.

While initially flashing the Flash Floppy firmware to the Gotek can be a bit involved, upgrading the firmware is easy. Copy over the firmware file, which is called flashfloppy-x.x.upd, to the USB drive and then hold down the two Gotek buttons while powering the Gotek on. The firmware will be flashed very quickly. You can downgrade firmware but older firmware prior to v3.25 may not work or work reliably with Artery MCUs.

"IMAGE NAVIGATION" is useful because Flash Floppy can support subdirectories and can navigate them using the rotary knob or buttons. If you want to eject/insert a disk and do not have the rotary knob, you can do so by pressing both Gotek buttons at the same time and set twobutton-action = eject. If you do not have a If your OLED screen appears upside down when you place an FF.CFG on a USB drive, then change display-type = oled-128x64-rotate. Other DISPLAY options allow you to change the OLED brightness and font.

IBM PC/XT, IBM PCjr. & Tandy 1000 Usage

The Gotek drive is easiest to use with an IBM PC, XT or standard compatible floppy controller. The only thing you may need to concern yourself with is that the IBM floppy cable uses card edge connectors for both drives and the controller and the Gotek uses a pin connector. Either a 34-pin card edge to pin adapter or a Universal Floppy Drive Cable will work.

The Gotek drive can work with an IBM PCjr., you need an untwisted cable with 34-pin connectors on both ends. Keep the cable short if you do not want your cable to push against the PCjr.'s cover. With a PC, XT or PCjr. keep the Gotek's drive select jumper to S1.

Tandy 1000s also can use the Gotek, but you need a cable without twists. Additionally, the drive select jumper must be set on Tandy 1000s, so assign the Gotek's drive select jumper to S0 for an A: drive and S1 for a B: drive. Later Tandys require holes punched in the drive cable to prevent power from being sent through the drive cable and shorting the system.

IBM PS/2's have non-standard floppy drive connectors, which is ironic as IBM defined the original PC floppy connector standard which was widely cloned. Systems with 40-pin connectors supply power on pins 38 & 40. Systems with 34-pin connectors supply power on pins 3 and 6. There are adapters available for card edge systems.

Making a custom floppy cable is easy, you will need 34-pin ribbon cable, some 2x17 pin connectors and card edge connectors. An X-Acto knife is very handy for making holes in cables or inserting a twist. In order to get the connectors to snap together properly on the ribbon, use a vice and close it gently but firmly over the connector.

PC Compatible Floppy Disk Image Formats

You may want to review my revised article IBM PC Floppy Disks - A Deeper Look at Disk Formats and Copy Protection before reading further.

A. Sector Dumps

There are many PC floppy disk formats beyond the basic sector image dumps. Sector images only contain the 512 bytes for each data sector field on a disk. They typically have an .img, or .ima filename extension but could have almost anything like .dsk. 7Zip can explore most DOS-formatted images. .imz images are zip compressed sector images. Sector images are only useful when the disk image is not copy protected. They do not contain sector ID fields, CRC values or gap bytes, all of which are essential for copy protection schemes and proper disk preservation. The Gotek can format sector image disk images, an issue which can cause trouble for other floppy emulators like the Floppy Emu for the Apple II.

B. Sector Dumps with Metadata

One step up from the sector dump are certain formats like TeleDisk (.td0), PCE Sector Image (.psi), ImageDisk (.imd) or CopyIIPC + Snatchit (.cp2). These formats try to capture some of the structures surrounding the data sector fields using custom metadata formats but cannot capture all of it. These formats are good enough for simple protections but cannot accurately reproduce more complex protections. They may be able to retain enough information to allow a skilled individual to replicate a protection scheme, often by using a dump of an original disk from a different game which uses the same protection for assistance.

C. Bitcell Formats

Above these formats are Transcopy (.tc/.img), which was the bitcell format used by the Central Point Software Option Boards back in the 1980s. PC software programs alone cannot capture data at the bitcell level, the floppy disk controller does not provide that low level of data. Bitcells can be encoded in the FM, MFM or GCR formats to provide useful data to the system's disk operating system. Bitcell formats can capture all the necessary data to emulate almost all PC compatible floppy disk-based protections. More modern bitcell formats are 86Box (.86f), MAME (.mfm), KryoFlux (.ipf), PC-PCE Utilities (.pri), Applesauce (.woz), Flash Floppy and HxC (.hfe/.hfe3).

Flash Floppy supports the .hfe and .hfe3 formats, but .hfe3 files must be renamed to .hfe. .hfe3 files are only needed for weak bit protections. I have tried many, many images which were converted into the .hfe format and I could get all of them to work on my IBM PC XT and Tandy 1000 TX. Most of the copy protected images also worked with my IBM PCjr. but images that used Electronics Arts' Interlock protection always failed in my PCjr. when they worked in the XT or TX. One of the few advantages the HxC firmware has over the Flash Floppy firmware is support for .mfm images, which can be used by most protection schemes that do not rely on weak bit protections.

D. Flux-level Formats

The lowest level of disk imaging is at the flux level, which results from Kryoflux stream files (.kfx), a Super Card Pro stream file (.scp) or an Applesauce stream file (.a2r). Flux represents a change in magnetic polarity on a track and the incidence of this change, when clocked, is the building block for bitcells. These images are not supported in any emulator as these files represent the raw flux representation of the disk as read and must be analyzed and converted into a bitcell format, which for copy protected disks may require user intervention. They must be converted to the .hfe format to work in Flash Floppy. The HxC Floppy Emulator Software can convert these formats to the .hfe format, but success may be hit and miss.

Miscellaneous PC Floppy Drive Topics

Making Save Disks

Many self-booting games which support save games require the user to make a save disk. These games were released in the days when hard disks were either not yet implemented on the PC platform or were extremely expensive, so saving to hard drive is not an option when running original disk images. With physical floppies this is easy, just stick to the right type of double density floppy (5.25" or 3.5") your game uses. With floppy drive emulators the situation is more complicated. There are five standard PC double density floppy drive formats:

160KiB 5.25" = 40 tracks x 1 side  x 8 sectors per track x 512 bytes per sector (DOS 1.0)
180KiB 5.25" = 40 tracks x 1 side  x 9 sectors per track x 512 bytes per sector (DOS 2.0)
320KiB 5.25" = 40 tracks x 2 sides x 8 sectors per track x 512 bytes per sector (DOS 1.1)
360KiB 5.25" = 40 tracks x 2 sides x 9 sectors per track x 512 bytes per sector (DOS 2.0)
720KiB 3.5"   = 80 tracks x 2 sides x 9 sectors per track x 512 bytes per sector (DOS 3.2)

If you wish to use save floppies it is essential to have a blank pre-formatted floppy disk image for each of these capacities on hand. Early games like Adventure in Serenia and Ulysses and the Golden Fleece use 160KiB, the PCjr. exclusive Wizard and the Princess uses 180KiB, the 5.25" Wizardry games (I-V) all use 320KiB and King's Quest I & II and The Black Cauldron use 360KiB. A sector image such as an .ima file will work properly with these games with the Flash Floppy firmware. Sierra booters require the command "FORMAT DISK" or "INIT DISK" to prepare a save disk except for King's Quest, where the command is "COPY DISK."

The Seven Cities of Gold is a little different from the above games because, unlike them, its disk structure is not conventional. Electronic Arts booters use 10 sectors per track, whether single sided or double sided. This game requires the user to make a historical map disk in order to save progress in the game. The easiest way is to use a second copy of the disk image and let the game create a map disk with it.

Floppy-only DOS Disks and Early Limited Hard Drive Installers

It was often the case in the first years of when IBM PC software was developed that developers wanted their disks to be bootable but did not want to write their own bootloader. DOS permitted disks to be formatted with the files necessary to make the disk bootable. However, as that required paying IBM or Microsoft licensing fees for the use of the software, developers and publishers were reluctant to do that when the user could be assumed to have a copy of PC-DOS or MS-DOS which they could use.

A bootable DOS compatible disk requires three files on it, IBMBIO.COM/IO.SYS, IBMDOS.COM/MSDOS.SYS and COMMAND.COM. The most critical part is that IBMBIO.SYS/IO.SYS must be the first file on that disk. The SYS and FORMAT /S commands copy IBMBIO.COM/IO.SYS and IBMDOS.COM/MSDOS.SYS to the disk in that order. 

But what if the disk already has other files on it, does that not preclude it from being made bootable? Well, if there are placeholder files with those two names on it, then SYS will copy the data in those files from a real DOS disk to the dummy files on the disk with those same names. The placeholder files just need to be large enough to fit the version of the DOS files you are attempting to copy and will usually contain a single repeated byte. IBMBIO.COM and IBMBIO.SYS grew in size as DOS versions progressed. And even though the files always used the IBM names, a non-IBM version of DOS can transfer their appropriately named system files to the disk to be made bootable.

If you try to boot an image which has only placeholder files, the disk will not boot and you may observe all sorts of interesting errors. It is important to note that DOS software does not require to be made bootable to run, you can boot DOS in Drive A and run the program in Drive B or swap out the disk after DOS has booted and run the program in Drive A. COMMAND.COM in earlier versions of DOS needed to be copied manually to load the command line interpreter, if it is not present you will see an error "Missing Command Line Interpreter". Often such disks came with an installation batch file which automated the making the disk bootable process. A game may also have required a BASIC interpreter to be copied over.

Many times I tried to boot a disk I thought was self-booting only to encounter an error. Then I would load DOS, list the contents of the disk's directory and see the tell-tale signs of a DOS floppy. There invariably is an AUTOEXEC.BAT file on the disk. The AUTOEXEC.BAT file completes the boot process by running the game's executable without having to type the executable's name on the DOS prompt. There are several self-booter games which can have their directory listed by DOS but contain no executable or an executable which cannot be run from a command line.

In the first five years of the PC's life, very little in terms of game software could be installed to the hard drive. Hard drives were very, very expensive then, half the cost of an IBM PC/XT was its hard drive and controller card. Games usually came on one or two floppy disks and most systems only had floppy disk drives. Many of these games would not run if their files were copied to a hard drive and some were based on DOS 1.0, which did not support subdirectories.

Eventually as the disk counts became higher and hard drives faster, cheaper and more common, games began to support hard drive installation. Some games turned from disk based protections to document based protections, some required a key disk to be checked when the game started and a few had an option to allow for a limited number of installations to a hard drive. Mindscape was particularly fond of this system, implementing it in their releases of Gauntlet and Paperboy. MicroProse also did so for the final release of Gunship, v429.05. When you performed the installation, the installer would write hidden files to the hard drive and decrement a count somewhere on the floppy disk. The uninstaller would perform the reverse operation.

Final Words

If you want to use floppy disks with a vintage PC compatible, then a Gotek with Flash Floppy firmware is a no-brainer choice. The price of the Gotek is very affordable and what it can do once expanded is incredible. While I have focused on using the Gotek with older machines it can work with later PCs as well. Older PC games do not assume the user has a hard drive, which was a significant expense then and an additional expense (in the form of an XT-IDE) today. The authentic PC experience for many in its first decade relied on disk swapping and copy protection. As more disks are being dumped we can look again at how games were played when they were first released, not through cracks and compilations. The Gotek and Flash Floppy makes that experience obtainable again without having to rely on writing disks all the time. The device is an essential component of modern retro-computing.

2 comments:

  1. With FlasFloppy I have been able to make 4.7MB images work with PC 1.44 interface. Just make a apropriate image and up the track count to 255.

    ReplyDelete