Porting a Linux driver to Arduino

I’ve been porting a Linux driver to Arduino. Many old computers (late 80s, early 90s), especially Apple Macintosh computers, used a peripheral bus called SCSI to communicate between the motherboard and hard drive. The protocol is pretty simple, but there can be some high-speed activity, which was too fast for early CPUs to handle. So companies like NCR and AMD made interface chips to handle the high-speed aspects of the protocol, and the CPU just needs to insert/retrieve data from it. Well, the Linux kernel contains drivers for several such chips, including the most well-known SCSI interface chip, the NCR5380. I’ve been porting that code to Arduino, so that the lowly microcontroller can talk to retro hard drives. Pretty neat, eh?

Bottom: Old cartridge drive with SCSI interface. Top: Custom circuit board with an NCR5380, Arduino Mega clone, SCSI ribbon cable, and a Granite Digital SCSI terminator (with helpful protocol LEDs!)

Porting code from a full-fledged kernel driver to a microcontroller is surprisingly straightforward. Basically, you just delete all of the code for mutexes, queues, and other multithreaded OS nonsense like that. 😉 Then just make sure the low-level I/O interface is modified to talk to the Arduino pins, and the higher-level functions should just work.

This particular chip is very old (late 80s), and many CPUs back then were still 8-bit, so that’s another reason that this is fairly easy. I downloaded Linux version 1.0, from 1994, and the NCR5380 driver was in back then, and it looks like it hasn’t changed much over the years.

The Arduino code is a work-in-progress. I’ve barely scratched the surface. I’ve reached the point where sending SCSI commands is working, and that was the hard part. From here, all I have to do is issue the right commands to load a disk and read or write to it!

Code here: https://github.com/ehalferty/arduino-NCR5380

Leave a Reply

%d bloggers like this: