Greetings dear readers, today we are going to cover something I worked on at least two years ago but always felt there was room for improvement. I’m of course referring to my Apple Classic, super charged with a Raspberry Pi3b motherboard inside. Now before I continue, I want to make one thing clear, I only mod old computers that are beyond repair or have been gifted to me by friends in a state worse than death. So no working or repairable system is ever broken, we don’t rip SID chips off working C64’s around here you know! Anyone found doing so would be given a stern telling off and sent to bed without any beer!
So where was I? Ah thats right, the Apple Classic! So last time we visiting this topic, I had been gifted a partially modded Classic and by partial, I mean it had everything floating loose inside the case and was in dire need of TLC. The amp cut out when you cranked it up or worse took the screen out and the RPI2B was awful slow, emulating an old mac on it was not a nice experience. It now sports a reasonably nippy Pi3B over clocked to 1.3Ghz, emulating an 020 mac the Pi doesn’t even break a sweat, idling at about 45 degrees for both the CPU and GPU. Seriously I’m sat here typing all this on AppleWorks, running Mac OS 7.5.3 and it’s pretty much like using a supercharged Classic on steroids.
I might have to cover compiling and using Basilisk II on a Raspberry Pi as there isn’t that much written online about getting a decent build. It took me a few false starts until I was able to get the emulator working without mouse stutter. This could just be down to the fact I was trying to use a RPi2, which should theoretically be powerful enough, but past experience with my AmigaPi has taught me things are never straight forward.
Ever since I finished or almost finished the ApplePi, I’ve wanted to do more. I wanted to fit an internal ADB socket so I could use a real Apple keyboard for a start. Luckily there is code available online and with a £7 Teensy 2.0 board, I was able to solder together a USB – ADB adapter. ADB is a funny socket, in that its the same pin out as S-video, which means picking up connectors isn’t that hard. Plenty of people have made these adapters but most the time they’re either inside the keyboard or inside a tiny external box. That’s all well and good, but firstly you’re modding the keyboard so that it’s no longer ADB and secondly, I lose USB pens to my sofa on a monthly basis. I’d lose my keyboard adapter and not be able to type on my ApplePi! For me there was no question how I wanted it, the ADB port would go on the back of the computer, as part of the custom laser cut rear I/O shield. It wouldn’t be a true Apple + Raspberry Pi hybrid without ADB nestled along side the USB ports.
For this mod I opted to use the source code by Shay Green (https://github.com/gblargg/adb-usb), while his code doesn’t include mouse support like some others did. I had think whether using a single button mouse was really all that practical in a modern Linux environment. I think I’d eventually tear my hair out with it’s limitations.
All in the Code
Programming the Teensy board isn’t that hard, you can do it on a Mac, Windows, Linux and the Raspberry Pi. To program a Teensy on a Pi you’ll need something called “Teensy Loader” (https://www.pjrc.com/teensy/loader.html). This software makes programming the tiny boards a breeze. On their website it says to run the program from the linux terminal, however I found this to be a fiddly method, constantly typing the same command in each time. Instead I made a script that allowed me to click an icon to load it up right away. Using a text editor of your choice, Nano (from within the terminal) or Text Editor from
the desktop. Create a text file in the same directory as teensy loader, call it something like “Teensyflash.sh”. Inside the text file paste the following, leaving out the speech marks.
Save the file off and close the editor. Now assuming you still have the window open, you should see a new file called “Teensyflash.sh”. Right click on the file and select Properties and then select the Permissions tab. Next to the “Execute:” field, click the drag down menu and select “Anyone”. Click the “ok” button to close the window and save your changes. You’ve now told Linux this file is an executable, so next time you double click on it, Linux will ask if you wish to run it. Tell it yes and the loader should pop up, voila no terminal commands involved.
Using a Teens 2.0 not 2.0++
Unpacked, Shays program is designed to run on a Teensy 2.0++, if you have one of those fine skip this part. However I had a Teensy 2.0, the same board I used to make my custom USB Amiga Joystick last year. The two boards use different chipsets and as such will not run the same programs, you have to compile a HEX specific to 2.0 and 2.0++. If you wish to use a Teensy 2.0 board, you will need to edit a file before you can compile your HEX. Inside the “adb-usb-master” folder, you should find a file called “Makefile”, open it with a text editor and edit it to look like this.
#MCU = at90usb1286 # Teensy++ 2.0
MCU = atmega32u4 # Teensy 2.0/Pro Micro
#FLASH = teensy_loader_cli -mmcu=$(MCU) -w main.hex # Teensy
FLASH = avrdude -p atmega32u4 -c avr109 -P /dev/ttyACM0 -D -U main.hex # Pro Micro
Save the file off and close it, the program is now ready to compile for the Teensy 2.0.
I’m not going to bother covering using Teensyflash, as there is plenty of information online covering the subject, however I do wish to briefly go over building the hex file. This is essentially the program you are going to load in the memory of the Teensy, without it your dead in the water. When I first tried to compile Shay’s ADB software, my Raspberry Pi threw a fit, telling me I was missing files. It took me a while to nail down what I was missing, running the following command in the Linux terminal did clear up my problems.
“sudo apt-get install libusb-dev gcc-avr binutils-avr avr-libcapt-get install libusb-dev gcc-avr binutils-avr avr-libc”
I think Shay’s code might expect the command line version of Teensy loader to be present in the same folder as his code, because after my Pi successfully compiled the hex, it threw up an error about not finding Flash. Don’t be too concerned about this as the HEX has still been created and is ready to load in the GUI loader.
Once you have Teensy Loader up and running, it’s just a case of loading in your HEX file, pressing a button and a mouse click later the program is stored on the tiny board. With the code loaded in the memory of the Teensy, it’s just a matter of wiring the correct pins together between the board and the four pin s-video connector. Given the size of the connector, I highly recommend using some heat shrink around your solder joints. This will prevent any of your wires shorting and frying your Teensy or Keyboard. A Data line is no place to stick your 5 volt input and certain components might take offense and die as a sign of protest. Then my friend you be wading in the brown smelly stuff without any wellies on! Don’t forget to solder a 1k resister between the data line and your 5v. Apparently some ADB cables suffer with signal drop and the 1k resister helps, if a jobs worth doing, do it right and fit a resistor!
After it was all wired up, I had to modify my rear panel as there was no hole for the ADB port. With a lot of cursing and armed with a dremmel, I was able to make a half decent circular hole, just wide enough to accept the end of the ADB cable. Oh a word on plugging your Teensy to your computer, make sure you use the cable that came with it. I made the foolish mistake of using a spare mini USB cable I had laying around, the darn thing wouldn’t load up properly. Twenty minutes spent testing for breaks in my wiring and it all came down to a tiny USB lead.
When it works, the ADB-USB adapter is amazing, switching from a Bluetooth Apple Keyboard to an original Apple Keyboard II is a massive difference. It feels better, keys are spread out and in general I’m not finger typing any more. It also looks a million times better in front of the ApplePi, seriously you would be forgiven for thinking it was a real Apple computer when Basilisk II is running. Shay Green has my thanks for posting the code
up that made this hack possible. Were it not for him, I wouldn’t be sitting here typing to the sound of klacky keys! Thanks dude!
Next up I shall be designing a rear panel to cover the holes left behind by the old power switch and power socket. In their place, I plan of installing a control panel for the IPS screen, allowing me to change the brightness, contrast etc.