I had the parts lying around for a few weeks now, but yesterday I found the time to solder everything together: the XU1541 created by Till Harbaum. Its a USB-to-IEC bus converter device that allows to connect modern hardware with retro CBM devices like a 1541 floppy. As you might have guessed already, I wanted to check out if it works with my Mac, too…
Hardware
Building the hardware was very easy, as Till published schematics and even a complete parts list with order numbers. Thank you! I am an old skool wire-prototype guy so the circuit was created on a small prototype board with some wires and some solder parts. Here is a snapshot:
Besides the ISP port for flashing the firmware and the (optional) parallel connector which is currently unused and not wired, there are no connectors on my board. I decided to use a single 10 pin connector and route all USB and IEC signals there. A connector cable then connects the 10 wires to the corresponding connectors. This allows me to place the board in a case later on and simplified the wire layout on the board. Also the status LED was routed there. Here is a picture of my prototype with attached connectors for USB and IEC:
Software
First of all, you need to flash the Firmware into the board. Otherwise nothing will work. Till has everything you will need described on his homepage in great detail. I also used the avrdude for flashing and only needed to adjust the ISP programmer avr910
as I use a mySmartUSB USB programmer and the Mac specific serial port /dev/cu.SLAB_USBtoUART
(see my DTV MMC2IEC blog entry for more details on AVR ISP programming on Macs).
The firmware file is available in the CVS repository of the OpenCBM project. Check out the XU1541 source from there, as it contains the current firmware that is required for the OpenCBM host tools found there, too:
cvs -d:pserver:anonymous@opencbm.cvs.sourceforge.net:/cvsroot/opencbm login cvs -z3 -d:pserver:anonymous@opencbm.cvs.sourceforge.net:/cvsroot/opencbm co -P xu1541
Go into xu1541/firmware
and call make to build it and then avrdude to burn it (first attach the ISP and disconnect the USB from the XU1541):
make -f Makefile-usbtiny
avrdude -c avr910 -P /dev/cu.SLAB_USBtoUART -p atmega8 -U lfuse:w:0x9f:m -U hfuse:w:0xc9:m -U flash:w:firmware-usbtiny.hex
Now your hardware is set up and ready to operate… Detach the ISP cable and attach your Mac with an USB cable directly. If everything works correctly then the LED flashes shortly after the connection is established.
Its time for a software test now. Change to the xu1541/misc
directory and compile the two binaries found there with the given Makefile. You will need libusb installed on your system otherwise the compilation will fail. Fortunately, libusb is available for Mac OS X, so just download and configure, make install it. I had to alter the Makefile xu1541/misc/Makefile
to add the -I and -L switches for my libusb installation:
LIBUSB=/Users/chris/Projekte/libusb CFLAGS=-I$(LIBUSB)/include LDFLAGS=-L$(LIBUSB)/lib ECHO_TEST = usb_echo_test EVENT_LOG = read_event_log all: $(ECHO_TEST) $(EVENT_LOG) clean: rm -f $(ECHO_TEST) $(EVENT_LOG) $(ECHO_TEST): $(ECHO_TEST).c $(CC) -Wall $(CFLAGS) $(LDFLAGS) -o $@ $< -lusb $(EVENT_LOG): $(EVENT_LOG).c $(CC) -Wall $(CFLAGS) $(LDFLAGS) -o $@ $< -lusb
If the make run completes successfully, you have two test programs: usb_echo_test and read_event_log. Run the first one and it will detect your attached adapter and perform some tests. As the current CVS version is not endian-aware at the moment, you will get Echo payload mismatch errors. You can ignore them as the adapter works well, only the test is not adapted to big-endian (PowerPC) Macs. Running read_event_log will show you the event log of the XU1541. Here you get:
-- XU1541 event log dumper -- -- (c) 2007 by Till Harbaum -- -- http://www.harbaum.org/till/xu1541 -- Found XU1541 device on bus 003 device 002-0403-c632-ff-00. Device reports version 2.08 Device reports capabilities 0xf700 Event log buffer size: 64 Event log: system started booted by external reset
The two tests showed that the adapter can be controlled from the Mac and it works as expected. The next step is to compile and run OpenCBM on the Mac. This toolset provides commands to copy disks from an IEC floppy or to send IEC commands. I use the current CVS of the project as it matches the XU1541 firmware version. Check it out with:
cvs -z3 -d:pserver:anonymous@opencbm.cvs.sourceforge.net:/cvsroot/opencbm co -P cbm4win
I started to hack the Linux port of OpenCBM to compile on Mac OS X. I had to tweak some files and add a hack here and there. Finally, I got a XU1541 driver compiled with libusb and the OpenCBM tools cbmctrl and d64copy as native Mac OS X binaries. The patches required for OpenCBM really need some polishing before they can be integrated into the source tree. So for now this a quick hack for me to proof the concept...
I attached my good old 1541-II to the XU1541 and ran a cbmctrl status 8 on my Mac and tadaaa! it works:
73,cbm dos v2.6 1541,00,00
Ok, OpenCBM basically works without any major changes to the source! A new test running d64copy to transfer a disk image did not succeed 🙁 I found out that the slow compatible mode works however but the fast default mode does not... I suspect that the download of code fragments to the IEC drive has some endianess issues in the code... I'll have a look at that later since I have to stop my experiments for today... so stay tuned!