Saturday, December 28, 2019

The Gotek Floppy Drive Emulator in the IBM PC World


The Gotek floppy drive emulator is a simple, cheap and little device that, as its name says, emulates a floppy drive.  There are many varieties of these devices and they usually come with a USB port on the front of the unit and a 34-pin header + 4-pin power header on the back.  While originally intended to replace disk drives in industrial, sewing and musical equipment, they can be used with standard PC floppy controllers.  However, as they come they are at best diamonds in the rough, so in this blog entry I will describe how to make these devices more useful for vintage IBM PCs and compatibles.


A basic Gotek model can be had for less than $30.  Look here for a fairly priced and functional unit.  As they come, these devices only support one kind of floppy disk format.  Most support only 1.44MB disks, some only support 720KB disks and I believe one mode does only 1.2MB disks.  The device will partition a USB disk into 1000 partitions of the disk size it supports.  Then you can copy data onto each partition, insert the USB disk into the Gotek and use the left button and right button to increment the partition by 10 and 1, respectively.  You can press both buttons to implement by 100 partitions.  The Gotek has special software to format these partitions onto a USB stick and to copy data over to them.  Windows will not recognize 1000 partitions.

As described, the official Gotek firmware has somewhat less than stellar features for vintage PCs.  Vintage PCs commonly used seven formats, 160KB, 180KB, 320KB, 360KB, 720KB, 1.2MB and 1.44MB.  The floppy disk drive controllers which came with the IBM PC, XT, PCjr. and most of the Tandy 1000s could only support double density drives, 720KB and lower.  These are the systems where your need to use floppy disks will arguably be at its most frequent.  As it comes from the factory, the Gotek is good for little more than using boot disks and installing some programs to DOS.

But the Gotek has hidden potential.  The chip that drives the Gotek is an STM32 ARM Cortex-M with built-in flash memory.  This flash memory holds the device's firmware and can be reprogrammed to serve other purposes.  There are two third-party firmware projects which can be flashed onto the Gotek to give it more vintage-friendly functionality.  The first is FlashFloppy, which is free and open source software.  The other is the HxC firmware, but that costs 10 Euro and may not offer a great deal of additional functionality for my intended uses.  Both firmwares can also make the Gotek simulate drives intended for non-PC compatible systems.

I decided to try out the Flash Floppy firmware.  I used this guide to buy a unit which would work with my vintage PCs.  Because I was just starting out, I downloaded the stable release version, v2.13. I used the USB-A to USB-A cable method described here to get the Flash Floppy firmware onto my Gotek.  You can use a pair of bent paper clips to make the appropriate temporary connections on the JTAG header.  You have to give STM Electronics your email for them to send you the download.  My Flash Floppy firmware update did not take the first time with the "upload" function, so I used the "upgrade" function and that got the Gotek to take the Flash Floppy firmware.

The IBM PC Diskette Drive Controller, found in virtually all IBM PCs, XTs and Portables, uses card edge connectors.  Almost all 5.25" Double Density drives also use card edge connectors.  So you will need a custom cable or a pin header to card edge adapter to use the Gotek floppy drive with these systems.  If you go the custom cable route, I recommend obtaining a "Universal Floppy Cable", removing the lone 34-pin connector on one end and crimping a 34-pin "IDC" female card edge connector on it in the pin connector's place.  For older computers, you may need a 4-pin Molex to mini-Molex cable adapter.

The cable I used in my IBM PC/XT did not have a twist in it, so I had to set the Gotek to the S0 position to get it working.  The IBM PCjr. supports only one drive and uses a straight-through cable to connect drive to controller, but its drive is jumpered as DS1.  You will need to ensure the jumper on the Gotek is set to the S1 position.  The "The Tandy 1000s also use straight-through cables, but its A drive is jumpered as DS0.  Set the jumper on the Gotek to the S0 position.  For both the PCjr. and Tandy 1000s, I recommend taking your cable and "untwisting the twist".  Don't forget that for the HX, TX and later 1000s, those computers use a single cable for data and power.  You will need to punch holes in your cable to avoid shorting out your Gotek.  Alternatively you can cut the pins on the Gotek's drive connector, but make sure you cut them down really close to the plastic on the pin.

When you have flashed your Gotek device, you will need some disk images to put on a USB stick.  The USB stick is formatted as a FAT32 volume, so I would recommend one with a capacity between 2GB and 32GB.  Flash Floppy only supports standard "raw" sector formats, so a 360KB image will have a size of 368,640KB (40 tracks x 9 sectors per track x 512 bytes per sector x 2 sides).  These usually have the extension .IMG or .IMA.

The IBM PC, PCjr. and early Tandy 1000s often had games and other software released on self-booting disks.  These disks had their own bootloaders and loaded themselves without the need for DOS.  All you did was stick the disk into Drive A:, boot the computer and your program will load once the PC has finished booting.  Other programs may not be bootable in and of themselves but the files were arranged in such a way that they could be made bootable (dummy COMMAND.COM, IBMBIO.COM and IBMDOS.COM files which would be overwritten when the user executed a SYS command).

There are over 200 "PC booter" games, many with specific support for interesting features like CGA composite artifact colors, PCjr. graphics and/or sound or Tandy 1000 graphics or sound.  Hundreds more require DOS but can be fully contained and played on floppy disk images.  Before the Gotek, if I wanted to run one of these booters on my vintage equipment, I had to copy the disk image to a floppy disk and hope it worked.  Sometimes disks would work in one computer but not another.  And I only had a limited number of floppy disks, so keeping track of what was on each disk was a chore.  Two or three disk games were extremely annoying to use.

The Gotek with Flash Floppy solves these issues.  On a PC with a double density controller, it can support disk images in the standard sizes : 160KB, 180KB, 320KB, 360KB, 720KB.  It can also handle the 200KB and 400KB sized disks frequently used on Electronic Arts booters.  The standard Gotek comes with two buttons and a three digit, seven segment display.  When you boot a Gotek Drive with Flash Floppy on it, you will see the display flash "F-F".  Then the display will show the number of the disk image currently "inserted" into the drive.  The LED on the Gotek should behave like a regular floppy drive.  If it is always on, you inserted the floppy cable upside down!  Remember that pin 1 is on the right side of the connector when looking down at the Gotek.  The ribbon cable typically uses a special color (typically pink) to designate the wire corresponding to pin 1. Use the right button to cycle the disk images forward (A -> Z) or the left button to cycle the disk images backward (Z -> A).`

When you get to the disk image number you want, leave the Gotek alone so it can load the new image.  If your PC is still booting, it will boot this image.  If you have booted to DOS, then the DOS will show the contents of the disk, if it can, when you change to the drive letter.  If you have many disk images loaded onto your USB stick, you will need to have a list with the numbers corresponding to disk image names.  Flash Floppy will automatically sort your files alphabetically by file name, not by their location on the disk, so feel free to add and delete images to your USB stick as you see fit.

The best way to get file numbers for your disk images is, from the Windows Command Prompt, is to perform the following command : dir /b > dir.txt.  This will write the basic directory listing to a text file called dir.txt.  Then open the file in a text editor which has line numbering support or copy the text into a spreadsheet program.  Remember that Flash Floppy starts counting disk images at 0, not 1, so be sure to account for the offset.  It may also include in that number any other file on the root of the USB stick, including files it creates, like IMAGE-A.CFG (which holds the name of the last image loaded), FF.CFG (global configuration parameters) IMG.CFG (which designates floppy disk geometry) and INIT_A.CFG (initial image to load).

The Flash Floppy firmware will remember the last disk image selected before powering off.  This is handy if your program was the 240th image on the drive and you were going to use it for multiple power cycles.  If you hold down a button it will automatically increment the disk image, slowly at first, then much more rapidly.  It will also cycle backwards from disk image #0 to the last disk image on the USB stick, which makes getting to the lower half of the alphabet easier.  If you can't "beat the boot", then let the system boot an DOS disk image, use the buttons to get to the disk image you want and reboot the PC.  If you land on an image that is not bootable, your PC may act strange but a reset or power cycle will resolve that.

If Flash Floppy has a weakness, it is that it has no support for any kind of image format that contains information outside data sectors (this also applies to non-PC disk formats the firmware supports).  This means that almost all programs with disk based copy protection, whether self-booting or DOS requiring, will not work with the Gotek and the Flash Floppy firmware.  That means you must use deprotected versions of these programs.

In the old days, if you wanted unprotected PC booters, Retrograde Station was the place to go.  Unfortunately, several disk images from Retrograde Station were damaged, only partially cracked or available only as DOS conversions.  Some of those DOS conversions may require a V20 or 286 or only run from a hard drive.  The site went down and while there is a mirror of it, the site owner has retired.  The Total DOS Collection has taken up the torch and has fixes for many of the Retrograde Station games and has added many more booters and disk images.  Certain games will require making a save disk, so keep a couple of "blank" formatted DOS images handy.  Mainstream DOSBox is terrible at formatting disk images.

There are mods for the Gotek to exchange the seven-segment display with an 128x32 OLED display, the up and down buttons with a rotary dial, to connect a piezo tweeter for drive sounds and to incorporate a distinct eject button.  They may require a bit of case cutting and drilling or a little soldering, but they may make the experience of using a Gotek more enjoyable.  More information can be found here.

No comments:

Post a Comment