{"id":27,"date":"2007-04-09T13:34:13","date_gmt":"2007-04-09T11:34:13","guid":{"rendered":"http:\/\/lallafa.de\/blog\/??p=27"},"modified":"2007-04-09T13:34:13","modified_gmt":"2007-04-09T11:34:13","slug":"xu1541-for-my-mac","status":"publish","type":"post","link":"https:\/\/lallafa.de\/blog\/2007\/04\/xu1541-for-my-mac\/","title":{"rendered":"XU1541 for my Mac"},"content":{"rendered":"<p>\nI had the parts lying around for a few weeks now, but yesterday I found the time to solder everything together: the <a href=\"http:\/\/www.harbaum.org\/till\/xu1541\/index.shtml\">XU1541<\/a> 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&#8230;<\/p>\n<p><!--more--><\/p>\n<h3>Hardware<\/h3>\n<p>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:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/xu1541.jpg?w=584&#038;ssl=1\" \/><\/p>\n<p>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:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.lallafa.de\/blog\/wp-content\/uploads\/2007\/04\/xu1541-connectors.jpg?w=584&#038;ssl=1\" \/><\/p>\n<h3>Software<\/h3>\n<p>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 <em>avrdude<\/em> for flashing and only needed to adjust the ISP programmer <code>avr910<\/code> as I use a <em>mySmartUSB<\/em> USB programmer and the Mac specific serial port <code>\/dev\/cu.SLAB_USBtoUART<\/code> (see my <a href=\"http:\/\/lallafa.de\/blog\/??p=22\">DTV MMC2IEC<\/a> blog entry for more details on AVR ISP programming on Macs).<\/p>\n<p>The firmware file is available in the CVS repository of the <em>OpenCBM<\/em> 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:<\/p>\n<pre>\ncvs -d:pserver:anonymous@opencbm.cvs.sourceforge.net:\/cvsroot\/opencbm login\ncvs -z3 -d:pserver:anonymous@opencbm.cvs.sourceforge.net:\/cvsroot\/opencbm co -P xu1541\n<\/pre>\n<p>Go into <code>xu1541\/firmware<\/code> and call make to build it and then avrdude to burn it (first attach the ISP and disconnect the USB from the XU1541):<\/p>\n<p><code>make -f Makefile-usbtiny<br \/>\navrdude -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<\/code><\/p>\n<p>Now your hardware is set up and ready to operate&#8230; 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.<\/p>\n<p>Its time for a software test now. Change to the <code>xu1541\/misc<\/code> directory and compile the two binaries found there with the given Makefile. You will need <em>libusb<\/em> installed on your system otherwise the compilation will fail. Fortunately, <a href=\"http:\/\/libusb.sourceforge.net\/\">libusb<\/a> is available for Mac OS X, so just download and configure, make install it. I had to alter the Makefile <code>xu1541\/misc\/Makefile<\/code> to add the -I and -L switches for my libusb installation:<\/p>\n<pre>\nLIBUSB=\/Users\/chris\/Projekte\/libusb\nCFLAGS=-I$(LIBUSB)\/include\nLDFLAGS=-L$(LIBUSB)\/lib\n\nECHO_TEST = usb_echo_test\nEVENT_LOG = read_event_log\n\nall: $(ECHO_TEST) $(EVENT_LOG)\n\nclean:\n        rm -f $(ECHO_TEST) $(EVENT_LOG)\n\n$(ECHO_TEST): $(ECHO_TEST).c\n        $(CC) -Wall $(CFLAGS) $(LDFLAGS) -o $@ $< -lusb\n\n$(EVENT_LOG): $(EVENT_LOG).c\n        $(CC) -Wall $(CFLAGS) $(LDFLAGS) -o $@ $< -lusb\n<\/pre>\n<p>If the make run completes successfully, you have two test programs: <em>usb_echo_test<\/em> and <em>read_event_log<\/em>. 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 <em>Echo payload mismatch<\/em> errors. You can ignore them as the adapter works well, only the test is not adapted to big-endian (PowerPC) Macs. Running <em>read_event_log<\/em> will show you the event log of the XU1541. Here you get:<\/p>\n<pre>\n--       XU1541 event log dumper       --\n--      (c) 2007 by Till Harbaum       --\n-- http:\/\/www.harbaum.org\/till\/xu1541  --\nFound XU1541 device on bus 003 device 002-0403-c632-ff-00.\nDevice reports version 2.08\nDevice reports capabilities 0xf700\nEvent log buffer size: 64\nEvent log:\n  system started\n  booted by external reset\n<\/pre>\n<p>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 <em>OpenCBM<\/em> 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:<\/p>\n<pre>\ncvs -z3 -d:pserver:anonymous@opencbm.cvs.sourceforge.net:\/cvsroot\/opencbm co -P cbm4win<\/pre>\n<p>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 <em>cbmctrl<\/em> and <em>d64copy<\/em> 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...<\/p>\n<p>I attached my good old 1541-II to the XU1541 and ran a <em>cbmctrl status 8<\/em> on my Mac and <em>tadaaa!<\/em> it works:<\/p>\n<p><code>73,cbm dos v2.6 1541,00,00<\/code><\/p>\n<p>Ok, OpenCBM basically works without any major changes to the source! A new test running <em>d64copy<\/em> to transfer a disk image did not succeed \ud83d\ude41 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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/lallafa.de\/blog\/2007\/04\/xu1541-for-my-mac\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,6],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-commodore-64","category-mac-stuff"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/piBMF-r","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":0,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lallafa.de\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}