BMOW title
Floppy Emu banner

FPGA-Based Disk Controller for Apple II

Apple II disk controller cards are weird, there are a crazy number of different types, and many are rare and expensive. Can an FPGA-based solution save the day for retro collectors? You bet! Nearly all the existing disk controllers connect the same 8-bit bus to the same 19-pin disk interface, so a universal clone is merely a question of replacing the vintage 80s guts of the card with a modern reprogrammable FPGA. This hypothetical universal controller card could connect to almost any Apple II disk drive, or a Floppy Emu. Here’s my first attempt.

 
An Idea Takes Root

This project has been nearly finished since August, but I’d hoped to delay announcing it until it was 100% done. Back in July there was a surge of interest in the Liron disk controller, when I updated the Floppy Emu firmware to add Liron support. For the first time, it was now possible to emulate a 32 MB Smartport disk on an Apple II, II+, or IIe with the Floppy Emu. But only Liron card owners could benefit, and the Liron card is fairly obscure and difficult to find. People started asking about the possibility of a Liron clone card, so I went to work.

Mapping out the complete schematic of the Liron took a couple of days. It’s a single IWM (the famous Integrated Wozniak Machine), combined with a small number of standard 7400-series logic chips, and a ROM to hold the boot code. Writing Verilog code for the FPGA to duplicate the 7400 chips’ functions was easy. Creating a Verilog reimplementation of the IWM was harder, but with the aid of the IWM spec and a logic analyzer I got it done. By selecting a moderately roomy FPGA, I was able to incorporate the boot ROM functionality too, so no actual ROM chips are needed. The entire design boiled down to some 3.3V level converters and a single FPGA, with a bunch of connectors and passive components. I realized the design wasn’t limited to being a Liron clone, but could also probably be a Disk 5.25 or Disk 3.5 controller with just a change of firmware. Maybe even a UDC controller. Ooh, the possibilities!

 
Hardware

I worked like mad to finish the design in late July, just before a trip to Yellowstone National Park, which gave this project its codename. The core of the prototype board is a Lattice MachXO2 FPGA, specifically the LCMXO2-1200HC. This 100-pin bad boy has 1280 LUTs for implementing logic, and 8 KB of embedded block RAM to serve as the boot ROM or for other functions. It also has some nice features like a built-in PLL oscillator and integrated programmable pull-up and pull-down resistors. Unlike some FPGAs, the MachXO2 family also has built-in flash memory to store the FPGA configuration, so it doesn’t need to be reloaded from an external source at power-up. The FPGA can be programmed through a JTAG header on the card.

The external disk is connected to the card with a standard 20-pin ribbon cable, just like what you’d find inside an Apple IIc, or on the Floppy Emu. In fact for the Floppy Emu, you can connect a 20-pin ribbon cable directly from the Emu to the FPGA card, with no DB-19 required. For other external disk drives, I built a small adapter that converts a short length of 20-pin ribbon cable to a DB-19 female connector.

Because the FPGA’s maximum supported I/O voltage is 3.3V, but the Apple II has a 5V bus, some level conversion is needed. I used four 74LVC245 chips as bus drivers. These chips operate at 3.3V but are fully 5V tolerant, and the Apple II happily accepts their 3.3V output as a valid logic “high”. One of the chips operates bidirectionally on the data bus, and the others handle the unidirectional address bus and control signals.

There’s a tiny 3.3V voltage regular on the board, which you can see at the lower-right at U3. It’s barely any bigger than a 0805 size SMD capacitor. Even with these small components, I was still able to solder the entire prototype board myself by hand.

Just for grins I added a 2 MB serial EEPROM to the board, which you can see at U2. 2 MB is enough to store 14 disk images of 5.25 inch disks, or a single larger disk image. It’s not central to the design, but if it works then the card could function as an all-in-one virtual disk like the CFFA3000, in addition to functioning as a disk controller for external drives. More options!

 
Status

Here comes the embarrassing part. After July’s spurt of activity, the PCBs and parts arrived in the mail. And then I did…. nothing. Finally in October I assembled one prototype board, stuck it in my Apple IIe, and played with it for a bit. But since that day I’ve done…. nothing. I’m struggling with some internal dilemma about the balance between a hobby and a business, and doing things because I want to or because I think I should want to. I’m hoping that by publishing this summary, I may spur myself into further action.

The prototype board works as far as I’ve tested it, but that’s not very far. I verified that I can program the FPGA via JTAG, and that it responds to address and data on the Apple II bus, but that’s about it. I haven’t yet looked at what it’s doing on the external disk interface, or tried connecting a real drive. My attention has just been focused on other things, and even though I always mean to return to this project “soon”, somehow I never do.

There’s at least one serious bug with JTAG programming that needs to be addressed. When the board is outside the Apple IIe and powered from a separate 5V supply, JTAG programming works fine. But when the board is actually inserted in the IIe and powered from the slot, JTAG programming doesn’t work. It always fails with a communication error. I thought this might be some kind of noise or poor signal integrity on the JTAG traces when the board is in the IIe, but the traces are quite short and don’t cross any other signal traces that might carry interfering signals. I also thought maybe I had power problems, and the IIe’s 5V supply was drooping briefly when I tried to program the FPGA via JTAG. But as far as I can tell with a logic analyzer’s analog functions, the 5V and 3.3V supplies remain stable. It’s a mystery that will require some better tools and more careful testing.

 
Next Steps

What’s next for this FPGA disk controller, assuming I ever finish it? Will it become a new product in the BMOW store? That was certainly my original plan, although my lack of motivation these past months has cast some doubt on that idea. I want to keep fun hobbies fun, and not have them become an obligation and a chore, which I fear is already happening with the other retro computer gizmos I’ve developed in the past few years. We’ll see how it plays out.

Assuming this eventually becomes a new product, how will users reprogram the FPGA in order to clone a different type of disk controller? It’s not reasonable to expect that everyone will own a stand-alone JTAG programmer and know how to use it. Unfortunately I can’t see any alternative solution that wouldn’t require extra hardware and complexity, and push up the cost of the board. I might add a microcontroller and an SD card socket for loading alternate firmware, but that would be a fairly ridiculous amount of extra baggage if it were used only for JTAG. Perhaps the Apple II itself could be used as a JTAG programmer, with some extra hardware that optionally bridged the data bus to the JTAG interface? Sounds complicated, and it would leave the question of how to get the firmware onto the Apple II first. Or maybe the user could choose between a few different built-in firmwares using a switch, but would be unable to load new ones? That sounds more plausible, but would mean a bug in the firmware couldn’t be easily fixed.

Fortunately those questions can wait. The first priority is to finish debugging the prototype, connect it to some real disk drives, and verify that it works. Maybe by Christmas…

Read 31 comments and join the conversation 

31 Comments so far

  1. Dillon Nichols December 7th, 2017 6:32 pm

    I know that feeling exactly. I have a hobby product on Tindie and have thought about it a lot and want to update it but have no motivation. I’ve also had long spurts where I don’t want to do any hobby electronics at home (my day job is EE). Eventually my desire to play with circuits comes back and I start something new. I wouldn’t force finishing the project. Your happiness is worth more than this project is to anyone out there. If you decide you don’t want to finish it, it would be nice to open source your efforts so maybe others can. In my experience, it’s not going to hurt your sales if you do come back and try to finish it someday (unless someone tries hard to make a business out of your product – but you can add a license to disallow that).

  2. Chris M. December 8th, 2017 4:47 pm

    Any chance it will support 1.4MB high density Superdrives? The Apple II 3.5 Controller is ridiculously rare and expensive. The CFFA3000 has the ability to update its FPGA, but it already has an obvious storage location for the firmware files.

  3. Steve December 8th, 2017 5:38 pm

    In theory it could clone the Apple 3.5 Superdrive controller, yes. It would be difficult though. I believe that card has an on-board 6502, so a soft-6502 would be needed in the FPGA. So far I’ve only looked at the Liron clone configuration in detail.

    CFFA3000 is more similar to the Floppy Emu: both combine an Atmel microcontroller and a small Xilinx CPLD with a slot for modern SD card / CF card / USB storage. The Yellowstone card described here is quite different, and is a controller card for a real external disk drive. It doesn’t have any microcontroller or modern storage media connectors. The hardware design is much simpler, and it should cost less (assuming reasonable sales volume for economies of scale).

  4. Ferdinand Keil December 9th, 2017 4:50 am

    Maybe your JTAG issue is caused by a ground loop. Have you tried programming it with a laptop on battery?

  5. John Van Walleghen December 9th, 2017 9:42 am

    Any chanch you could have these ready for KFEST? If you do, I want to buy one.

  6. Jeremy December 9th, 2017 12:17 pm

    If you’ve got storage space for disk images it might be neat to have a way to directly read/cache a real disk into there and a mechanism to swap between real and virtual disks. That way if you like real disks, but have limited patience you can minimize swaps. When you want to use a program you could load the program in and then just swap once to a data disk.

    Might also conveniently allow you to use 1 drive like 2 or 2 drives like 4. Is there any limit on the number of drives it can present. I thought regular controllers could only handle 2 drives per card?

  7. Adam Renie December 11th, 2017 8:25 am

    I second Ferdinand Keil’s comment. With Yellowstone installed in the Apple IIe and the JTAG wires disconnected, what potential do you measure between the Apple IIe and JTAG grounds with everything powered on? I’ve run into a few odd grounding issues like this myself. You may need to the a USB isolator (http://www.linear.com/solutions/5123).

    Also, I am assuming JTAG VCC is an input to the HW-USBN-2A. Looks like it is on the HW-USBN-2B.

  8. Steve December 11th, 2017 10:39 am

    Thanks for the suggestion. It could be a ground loop, but I’m a little bit skeptical. The Apple II and the PC with the JTAG programmer are both connected to the same wall outlet. I’ve had no problems using the same Apple II and PC with an AVR programmer for a Floppy Emu powered from the Apple II. But I will measure it to be sure. Yes, the VCC is an input to the JTAG programmer, it uses it to sense when there’s a device connected and to determine what voltage level to use for JTAG I/O.

  9. Adam Renie December 11th, 2017 11:19 am

    I know that on desktop PCs the chassis, and in turn the USB shield, is connected to safety ground. If the IIe chassis is also connected to safety ground, you could have a situation like this even if you’re connected to the same outlet with any length of power cable (see first figure under “Sources of ground current”):

    https://en.wikipedia.org/wiki/Ground_loop_(electricity)#Sources_of_ground_current

    Placing the IIe on an isolation transformer would be a good data point to rule this out or not. I’ve also seen people float or remove safety ground pin all together, but I cannot condone that as a permanent solution.

  10. Jose December 17th, 2017 12:53 pm

    Hi Steve!
    This project is great! The possibility to add a Liron or a 3.5 floppy controller to an Apple II is something I’ve been wanting for a long time. I hope you find the motivation to finish it.
    Thanks again for supporting the Apple II community.

  11. mac mahan December 26th, 2017 11:03 pm

    nice project.thanks for sharing with us http://www.icartoonhd.com

  12. willwinter December 29th, 2017 5:15 pm

    This sounds fantastic! I have one FloppyEmu and considering buying another – flashing between my Apple //e and Mac Plus takes the fun out of it. This would seal the deal and I hope there’s a bundle to buy the card and an Emu. Best of luck solving your issues and if released I’m a buyer for sure!

  13. Leeland January 6th, 2018 2:26 pm

    I would definitely buy one if you make them, and I actually have a LIRON card. It seems like the perfect companion for my FloppyEmu, which I love, BTW.

    I understand about finding time and motivation for hardware projects for retrocomputing. I also dabble in it a bit and I have several projects that are in various stages of completion that I need to finish up one of these days. I’m really more of a software guy, and you are way ahead of me as far as building hardware goes. I have a basic understanding of how to design stuff for Apple II, Arduino, etc., using basic TTL and CMOS devices. I’m currently learning how to lay out PCBs with modern software to get them fabbed. Once I get that down I will start learning how to create GALs as I already have a programmer that will do that (Minipro TL866CS). After that I want to get an FPGA dev kit and learn Verilog and/or VHDL. I’ve been looking at the Altera Cyclone IV or maybe the Xilinx Spartan 6. I’m leaning towards the Altera as it is less expensive and has a reputation of the software being easier for beginners.

  14. cooper January 6th, 2018 4:57 pm

    Steve

    What a great board and excellent idea, I know you talked about it not being fun and I hope this changes for you, I want you to know that you have made some amazing things that make it so people like myself get to relive our childhood enjoyment of these machine with a low cost and ease use. So be proud that made excellent things that have brought 100s of people great joy.

    I will buy one of your cards in a second, I agree with Chris M. in the comment support for High Density would be amazing. In my case it’s an AE HD+.

    If you get to implement the CFFA style image storage please talk to John Morris and make it so that it will support the new format that he is working on .WOZ.

    I hope you find the happiness and motivation that you look for in this project and any others in live that bring you happiness.

    Cooper

  15. Bunsen January 7th, 2018 5:03 am

    Nice work Steve πŸ™‚

    I’m wondering if you’ve ever had any thoughts about tackling the world of IIGS CPU accelerators?

  16. Dave Taylor January 8th, 2018 2:43 pm

    Would be glad to be a beta tester…:p

  17. Joel McWilliams January 10th, 2018 5:28 am

    Steve, I hope you find the motivation to finish this amazing project and the enjoyment of knowing how much you’ve helped the Apple II community already with your floppy emu and other gizmos. I know that you know how much everyone would love to see an alternative to the super rare and expensive Liron controller and to have support for other drives and all the other features you mentioned. Wow! I’d buy this card in a heartbeat. Thanks for all your efforts to help keep our hobby alive.

  18. Henry Pedro January 10th, 2018 6:59 am

    This is a great idea!
    I like the idea of multiple firmwares that are switch (or software switch) selectable.
    For instance, what’s sorely lacking in slotted Apple-II machines is a Smartport – something that you could plug an Apple 3.5, Unidisk 3.5 or other mass storage device into. The IIc and IIc+ have a smartport that’s awesome, but not the II+ and //e.
    If I were to give my vote, it would be for a Disk-II / Liron / Universal Drive Controller (a-la Vtech’s) that could run any common physical disk drive. Plus added functionality for mass storage via SD-card or CF card volume images.

  19. Steve January 10th, 2018 7:42 am

    I’m sure I’ll make more progress on the prototype, hopefully soon. I’m less sure about turning it into a finished product, but we’ll see. As I mentioned above, my biggest concern is the lack of any simple way to update the firmware on the card. So it would either be non-upgradable (and pray there are no bugs in the 1st revision firmware), or would need extra microcontroller and SD hardware solely for firmware updates (increasing complexity and cost).

  20. Leeland January 10th, 2018 8:09 pm

    I have no problem with it requiring an extra programmer tool to update. I have a JTAG tool and a Minipro TL866CS which I can update to add an ICSP port and I’m thinking of buying an Altera Cyclone IV dev kit which includes a USB blaster… If I had to buy another tool it wouldn’t be the end of the world either.

  21. Leeland January 10th, 2018 8:22 pm

    It would be a shame given the scarcity of LIRON and UDC cards at least if this wasn’t released. Even if the only functionality was to act as a replacement for those it would be worth it. And if it can do more all the better. As I said before, this looks like pretty much the perfect complement to the FloppyEmu. If you make it I for sure will buy at least one, and I already have both a LIRON and a UDC.

    If you wanted to make things more interesting… I don’t know how much space and pins you have left on that FPGA… but I think there would also be a demand for a WD17xxx compatible controller to handle PC and/or CP/M style floppy drives with the 34 pin interface.

    Or another idea is 4 floppy ports like a Rana Systems controller… Probably of extremely limited utility these days, but I always liked those controllers (have one of those too).

  22. Bunsen January 15th, 2018 4:26 am

    No possibility of uploading firmware via the Apple slot then?

  23. LEELAND HEINS January 15th, 2018 5:08 am

    The firmware might be large enough that it would be hard to deal with on the Apple II side. Anything that won’t fit on a floppy may be difficult for some people to manipulate. I would guess that the image for an FPGA could be megabytes? Or am I way off?

  24. Dave Taylor January 15th, 2018 8:36 am

    I would say the majority of people would not have any issues loading a file size larger that 1mb….

    Floppy EMU……or maybe this would give them a hint to pick one up….

  25. Steve January 15th, 2018 8:41 am

    Firmware flashing from inside the Apple II is theoretically possible, but would involve some difficulties as described in the post. The card would need additional hardware to somehow multiplex the data bus and the JTAG interface. Then once the user downloaded new firmware from the web, how would he get it onto his Apple II? He’d need to own some *other* disk solution already, like a Floppy Emu or CFFA3000. Then where would he store it? It’s about 350KB now, and will probably grow over time, so it’s too big for a floppy. But if you could overcome all that, and the cost of the extra hardware on the card, then you could probably write JTAG player software for the Apple II that would perform the firmware update.

    Having thought about this some more, I don’t really like that approach because it seems so cumbersome. So the two most plausible approaches are:

    1. Add an extra microcontroller and USB interface, purely for firmware updates.
    2. Keep the JTAG interface as the only avenue for firmware updates. The typical user wouldn’t be able to perform firmware updates, so the card would effectively be a fixed-function device (maybe with a switch to select a few different functions).

    But this is all getting ahead of myself, since I haven’t even proven that the card works yet. πŸ™‚

  26. LEELAND HEINS January 15th, 2018 8:44 am

    I’d rather have the JTAG option than add a lot of extra complexity and price to the card. But that’s maybe just me. As I’ve said before I already have a JTAG programmer and if I needed to buy another programmer it wouldn’t be a big deal as long as it isn’t super expensive.

  27. Steve January 15th, 2018 8:47 am

    I think any generic JTAG programmer would work, or maybe even something like a Bus Pirate. I haven’t tried any non-Lattice programmers yet though.

  28. LEELAND HEINS January 15th, 2018 9:44 am

    The JTAG programmer I have is a very generic one sold for doing things like installing a bootloader on Arduinos. I think I paid under $10 for it. I don\’t know about the Lattice programmer, but the ones for Altera (USB Blaster) aren\’t very expensive, under $30. I just checked; the Lattice ones are around the same price range. Not out of line if I ever needed one and the one that I have didn\’t work for some reason.

  29. dave taylor January 15th, 2018 10:13 am

    why not just make it universal and make it an apron? inthink more people would have this than the jtag..

  30. dave taylor January 15th, 2018 10:16 am

    stupid autocorrect..

    I meant to say why not make it universal and make it eprom? methinks more people would have this burner than the jtag….

  31. LEELAND HEINS January 15th, 2018 10:21 am

    I don’t think that will work. I have an EPROM programmer (Minipro TL866CS), and I don’t think it is compatible with an FPGA. I suppose you could put an EEPROM on the board and load the FPGA from that somehow, but that is just adding more components and complexity and cost to things.

Leave a reply. Comments may not be monitored regularly. For product support questions, visit the Contact page.