Thursday, January 11, 2018

a2usbdsk mostly working on Raspberry Pi!

After much experimenting, I figured out that an unusually low usb timeout setting was causing usb transfers to stall on the Raspberry Pi. After I raised that, I was able to easily load disk images! Unfortunately, Karateka does not work. During the boot sequence, Karateka does a very quick jump from track 7 to about track 27. It is cycling the Disk ][ phase lines very quickly to make this happen. Unfortunately, I don't think the Raspberry Pi Zero is currently able to sample the USB data fast enough to keep up. As a result, it is only jumping to track 15 or so. I was having a similar problem in earlier versions of a2usbdsk. I tried some tricks to speed things up, to no avail. But, good news is:


So, as a proof of concept this is looking good. I should be able to move on to step 2 and get this running on the Raspberry Pi's native SPI port.

Tuesday, January 9, 2018

a2usbdsk not working on Raspberry Pi yet

Although my Apple IIe Platinum was not working correctly, I remembered that the color pattern I was seeing was actually a self-test mode that the Enhanced Apple IIe goes into without a keyboard connected. My keyboard was connected, but was also shattered and seriously damaged. Fortunately, another Apple IIe keyboard saved the day.

Unfortunately, a2usbdsk on the Raspberry Pi is not able to send data fast enough for the Apple IIe to read... yet. I have some code optimizations I need to test out which I think may help the situation. That said, even my old MacBook air was barely able to keep up. My newer 1.8 GHz dual-core Intel Core i5 MacBook Air seems to have no problem. I'll keep trying this weekend.


The Raspberry Pi is able to keep up! The problem is that the FT232H is stalling very often. I had this problem early on in the development of a2usbdsk on Mac OS X, but I worked around it by writing most of my own read/write loops and avoiding libmpsse for the most part. There must be some difference in how libusb or libftdi is handling the packets on the two operating systems. By frequently purging the buffers, I was able to get a disk to load! Need to find a better solution though. More testing should narrow down the problem.

Thursday, January 4, 2018

a2usbdsk ported to Raspberry Pi

I was able to port a2usbdsk to the Raspberry Pi quite easily due to it being based on libusb and libftdi. Really, I just had to set up a makefile. I had some issues getting it to open the FT232H though. libmpsse does not return any errors when attempting to open an FTDI device. This makes troubleshooting very difficult and frustrating. After adding some logging, I determined that the libftdi function ftdi_usb_open_desc_index() was returning error code -8, "get product description failed". Getting the product description is a pretty simple function and that error was not appearing on Mac OS X, so it left me baffled for a while. In the end, the issue was that Raspberry Pi/Linux strictly controls who can access USB devices. "sudo" got it running, but setting up a udev rule seems to be a better solution.

I have not tested this with a real Apple II yet, as my Platinum Apple //e was pretty much destroyed in a recent car accident due to air bag deployment. The case is shattered, but it may still work. I'll try this weekend.

Monday, January 1, 2018

Raspberry Pi A2-SPI-DSK

I received my first Raspberry Pi in the mail today. It is a Raspberry Pi Zero W. I am excited to really try it out. I have it running, but I need to get a USB keyboard and mouse hooked up to get everything installed.

The Raspberry Pi is pretty neat hardware that bridges the gap between a micro controller and a full desktop computer. I have done some micro controller development, but never got really engaged with it. Development on the Raspberry Pi looks a little more my speed. At $10 for the Raspberry Pi Zero W, it is significantly more powerful and cheaper than the Mega AVR Arduinos and the necessary add-on cards. Most of the cool stuff is already built in to the Pi!

So, my hope was to port a2usbdsk to Raspberry Pi, so that people never have to use 5.25" disks again. I love the nostalgia, but they are cumbersome to use and ADTpro transfers to and from the Apple II are fairly slow. Don't get me wrong, ADTpro is a wonderful piece of software that I have used and quite a bit myself. But if you don't want to actually use disks to use disk images on your Apple II, it seems like the wrong solution, and a piece that is missing in (and could easily supplement) other packages like Ivan Drucker's RASPPLE II.

To pull this off, I am going to attempt it in 2 steps:

  1. Port a2usbdsk to Raspberry Pi to run the FT232H adapter;
  2. Create a new program a2spidsk to run on the native SPI ports on the Raspberry Pi.

I am very concerned that the Raspberry Pi may not be able to analyze the incoming data fast enough from the USB adapter. There is quite a bit of latency between transmissions to the disk drive that I was barely able to overcome on my MacBook. This puts a long gap between sectors which the Apple II is pretty good about ignoring, but it will eventually give an I/O error.

I am also concerned that the SPI buffer for the bcm2708 in the Raspberry Pi is quite small (12-120 bytes) which could make it difficult to output the bytes fast enough and with the regularity needed by the Disk ][ interface card. Since the Disk ][ interface card doesn't really understand SPI, we need very regular SPI clock transitions and data to keep synced up with the card in order to match up the synchronous SPI bus to the asynchronous Disk ][ interface card connection.

Tuesday, December 19, 2017

Demo Video of a2usbdsk in a Apple II build and deployment pipeline

The build pipeline is an update of Jeremy Rand’s Apple2BuildPipline based on Quinn Dunki’s project of the same name. Using this allowed me to stop reinventing the wheel and focus on finishing coding my a2usbdsk tool. Definitely check those projects!

Retro redux: a2usbdsk Release

RetroChallenge 2017/10 is way over and I got sidetracked about half-way through. Way too much IRL stuff got in the way. However, I have had a little bit of time recently to try and finish off my project. Upon reviewing my A2-SPI-DSK tool, I noticed some problems in my code. It was causing some serious issues with getting it to compile and work correctly. I guess that’s one of the issues with trying to write that much code in a month.

Anyway I’ve had some time recently to get things working, and completed the a2usbdsk v1.5 tool (Download). It now works perfectly to get a virtual disk to a real Apple II via USB. In addition, I added support for a second drive. I was so happy to see it boot a disk again! It is still read-only, but I have some ideas for that issue.

So, if you are developing Apple II software, you can write it in Xcode with cc65, then when you build it, just add a line to your makefile like: /usr/local/bin/a2usbdsk -1 $(PGM).dsk

This will mount the disk image and make it available to your Apple II over USB via the A2-USB-DSK. The A2-USB-DSK is easy to build using the schematics below and a CJMCU-232H FT232H module available on eBay for less than $10. Total build including the other ICs and a proto-board should be in the $20 range.

I created a branch of Jeremy Rand's Apple2BuildPipeline project to showcase how it works in a real project. Hopefully I can get a video up in the next few days.

Thursday, October 12, 2017

DSKalyzer doubts

Hmm,I have been playing with DSKalyzer, and as great and as powerful as it appears to be for organizing your disk images, I don't think it can create a new one. That is sort of important for making a clean build for a new program. AppleCommander can do that nicely though. I may just stick with AppleCommander in my a2bdp Apple 2 build/deployment pipeline for now. It will make my project a little easier, too.

Tuesday, October 10, 2017

Some AII-SPI-USB problems resolved

I was having some serious issues getting my AII-SPI-USB command line tool (for transferring disk images to the UM232H) working on my newer MacBook. I tried rebuilding it, then rebuilding libftdi, and libusb, and libmpsse. I finally got things working and Xcode asked me to update my build settings. Then, of course, nothing would work again. The primary problem was "duplicate symbol" errors that were suddenly popping up. Some edits to libmpsse, and some changes to my code, and I finally was able to re-build it. I think I should staticly link the libraries I need for the tool, since most users won't have the will power to compile libftdi, or libusb to use it.

I need a new name for the program too. AII-SPI-USB is not a very posixy name for a command line tool. Maybe a2usbdsk.

It's ironic that one of the benefits of programming for retro computers is that the hardware or operating systems almost never change. Do it once, and it works forever! Not so for modern hardware, even the modern hardware interacting with the retro computer.

More AII-SPI-DSK problems

Found my AII-SPI-DSK adapter on the breadboard. Unfortunately, the counter was harvested off of it for some other project. Now I need to track down a 74LS161 ic...

Monday, October 9, 2017

AII-SPI-DSK problems

I downloaded my AII-SPI-DSK program and tried to get it running without success. First FTDI library version errors, then a file not found error. I need to get the adapter out and try again. Unfortunately, it is packed away since I am moving this month. But I think I should be able to dig it out today.