in , , , ,

Floppy Controller Board

Reading Time: 3 minutes

For the uninitiated, floppy disks were once cutting edge technology – so-called because the original 8-inch and 5.25-inch versions were thin and bendy (give one a shake and you’ll see what we mean). They also came in smaller sizes including the more robust 3.5-inch and 3-inch varieties. Each offered fast and reliable storage – a world away from cassette tapes.

Scott feels nostalgic when he thinks of these disks, which is why he has created a floppy controller board. “The primary benefit is to make use of vintage hardware, in particular 5.25-inch disks which are not often usable on many newer computers,” he says. “The device allows disk images to be read and written, making it possible to back up a 360kB floppy or create a floppy from a disk image to use in another vintage computer.”

Time is of the essence

Creating the hardware proved to be fairly straightforward. Scott made use of the WD37C65 floppy controller integrated circuit – “a great single-chip solution,” he says – because it combines the floppy controller, data separator, and control latch. It was used to create a HAT for Raspberry Pi which also has a 34-pin floppy header for the connection of a disk drive.

The floppy controller HAT

One of the key challenges came in creating the accompanying software. “It was tricky to get right due to the timing requirements involved,” Scott explains. He started by taking the floppy driver from Wayne Warthen’s ROMWBC project which allows an old disk operating system called CP/M to be ROM-based.

“It’s written in Z80 assembly and I used that as a basis for writing a Raspberry Pi driver in Python with C extensions,” Scott continues. “Since the software is written as a user-mode Python program, it may make it feasible to accommodate more unusual – that is, non-IBM PC – disk formats, or even reproduce vintage copy protection schemes.”

Back to the future

To get to that point, however, Scott has had to overcome the fact that Raspberry Pi OS is not a real-time operating system. “That was the primary challenge,” he says. “For high density drives, and by that I mean 1.44MB and 1.2MB, bytes must be read from the disk controller every 13 microseconds. For low density, they must be read every 26 microseconds.

	The project allows for the reading and writing of floppy disks such as these once-popular 5.25-inch varieties

“If Raspberry Pi is unable to read a byte in time, then the controller will declare a buffer overrun and abort the transfer. General-purpose Linux does not provide the type of scheduling guarantees to user-mode processes necessary to meet these demands 100 percent of the time. The Linux kernel could decide to swap in another process at any time, leading to a multi-millisecond delay.”

For help, Scott turned to the official Raspberry Pi forum and found that contributor ‘tjrob’ had worked on a technique to improve the real-time performance of the user-mode process. “Transfers rarely fail on low-density disks, but the failure rate on higher density disks may be around two to three per cent,” Scott says.

Even so, the setup works and disks can be read and written using Raspberry Pi. It’s not yet at the stage where you could fire up an emulator and run software from the floppy drive. “The driver doesn’t provide the same interface as a Linux-block device, but that’s something that could be added in a straightforward way,” Scott says. Even so, it brings a new lease of life to an age-old format.

What do you think?


Written by Truskmedia

This archery robot always hits the target

Make a Raspberry Pi-powered BMO Adventure Time console