SD2IEC for Commodore 64/128 DIY
It’s time for some C64 stuff. For those new to all of this, SD2IEC is floppy drive emulator that emulates basic functions of Commodore 1541 floppy drive. Although I say C64, as far as I know it works with C128 and some older Commodore computers that can use 1541 compatible floppy drives. Back in the day I had C64 with cassette tapes. Surprisingly old tapes still worked after 20 years, but it was far from practical to use them. Even with Turbo cartridge that can load compressed games. Alternative was to get real floppy drive, but then again, 5.25” floppies are not that easy to come by, or reliable… Next alternative was to get some of commercial floppy emulators, like 1541 Ultimate, Ultimate-II and so on. Problem with them is that they tend to be pricey. In the end I stumbled upon SD2IEC which can be done at home. You can also find them prebuilt on ebay, but where’s the fun in that? 🙂 Although, to be fair, they have one characteristic that makes them somewhat more interesting than home made version. They’re way smaller since they’re professionally made and usually have cute cases that look like original 1541 drive, only waaaaay smaller :). SD2IEC is based on MMC2IEC device that was created by Lars Pontoppidan. Original MMC2IEC used ATMega32 micro controller (MCU for short), SD2IEC upgraded that to ATMega644p which has more RAM and more flash memory for program storage so it could be improved even further. Later it was upgraded to ATMega1284 which has double flash memory compared to ATMega64 and is pin compatible so you can use either one with this PCB. At the moment of writing latest “stable” firmware was 0.10.3 and most current is 1.0.0 alpha 0.84, there are versions for both ATMega644p and ATMega1284p. Schematic I give here is based on Lars’ schematic. There’s also Shadowolf’s version that uses different pinout so you can’t use firmware made for Lars’ version or vice versa. Actually you could as far as MCU is concerned, but SD2IEC as a device wouldn’t work.
After I made first one I learned one important thing. Although they all look the same, all voltage regulators don’t necesserily have the same pinout :D. ATMega MCU uses 5V as power supply, but SD cards use 3.3V, that’s why we need voltage regulator, to reduce 5V from C64 to 3.3V SD card needs. So, in my first schematic I used LF33CV voltage regulator and when I went to order parts I ordered LMT1117T’s because they were cheaper. Well, turns out they don’t use same pinout, so my first board didn’t work :D. After I figured what was the problem I soldered wires to correct this and it finally worked. For this reason I have two schematics, one is for LF33CV and the other is for LMT1117T voltage regulator.
LMT1117T version bill of materials 1x ATMega644p or ATMega1284p MCU 1x LED green 1x LED red 2x 560 ohm resistor 1x 100nF ceramic capacitor 2x 3 pin header 3x momentary switch 3x 1800 (1k8) ohm resistor 3x 3300 (3k3) ohm resistor 1x 10000 (10k) ohm resistor 1x 8MHz crystal 2x 22-33pF ceramic capacitor (I used 22pF) 2x 10uF electrolytic capacitor 1x LM1117T 3.3V voltage regulator 1x 2 pin KF2510 connector header 1x 3 pin KF2510 connector header 1x SC Card socket All in all, around $30.
LF33CV version bill of materials 1x ATMega644p or ATMega1284p MCU 1x LED green 1x LED red 2x 560 ohm resistor 2x 100nF ceramic capacitor 2x 3 pin header 3x momentary switch 3x 1800 (1k8) ohm resistor 3x 3300 (3k3) ohm resistor 1x 10000 (10k) ohm resistor 1x 8MHz crystal 2x 22-33pF ceramic capacitor (I used 22pF) 1x 2.2uF electrolytic capacitor 1x LF33CV 3.3V voltage regulator 1x 2 pin connector header 1x 3 pin connector header 1x SC Card socket All in all, around $34, LF33CV voltage regulator cost more than LMT1117T. 2x 3 pin headers are needed only if you intend to change ID (8, 9, 10, 11) it uses to identify itself to the computer, like if you have real 1451 floppy and you daisy chain SD2IEC to it. Without these headers it identifies as 8 which is mostly used ID. KF2510 connectors are not needed if you’re going to solder power and data cable directly to PCB, I prefer to have them detachable so that’s why I used them
In this PCB design DIP socket is needed as there are few components underneath it. It would be possible to solder MCU directly to PCB even with these components under it, but I don’t see the benefit of it. I always use sockets for practicality, if I need to reprogram the chip I simply pop it out and reprogram. If it’s soldered you’d have to desolder it and hope you don’t damage the PCB, or MCU while doing it. Of course if you burn bootloader to MCU you can update it via SD card. But since MCU can get damaged while soldering I wouldn’t risk it since sockets are cheap.
After it’s assembled firmware needs to be burned to ATMega MCU. You can get them from http://www.sd2iec.de/ , file sd2iec-current-binaries.zip. There are firmwares for different MCU’s and PCB versions inside. For this project we need ones marked as larsp and m644p or m1284p, depending on MCU used. As I mentioned at the beginning current version is 1.0.0 alpha 0.84, I haven’t used that version but the one before it, 0.10.3. Files for 0.10.3 are included in rar file at the end, for m644p and m1284p MCUs. When burning the firmware most important thing to do is to set fuses values correctly. For SD2IEC low fuse need to be set to 0xEF (or 11101111 binary), how exactly is that done depends on your atmel programmer and software it uses. In my case it looks like this. I changed low fuses to EF (default was 0x62 hex, or 01100010 binary) and left everything else as it was. Basically what it does is to change MCU setting to use external oscillator for frequency and not it’s internal one. First software I used to program my MCU didn’t set this correctly. While it programmed the firmware correctly MCU, fuses were unchanged so it run at internal 8 MHz, but with divide clock by 8 fuse (CKDIV8) set so it resulted in 1 MHz speed which was too slow. It did make my head spin for a few days because I believed this was set correctly, plus SD2IEC responded to info commands via C64, it only wouldn’t load anything, probably because it read and sent data 8 times slower than it’s expected so C64 didn’t “understood” the data.
I guess oscillator and it’s two capacitors could be thrown out of the schematic and internal 8 MHz oscillator used but I wanted to play safe. For those who want to experiment you can skip soldering oscillator and these two capacitors and set ATMega flag to 0xE2 instead of EF, that should set internal oscillator to 8MHz and disable clock divider. Alternatively you could try flashing one of bootloaders they offer at http://www.sd2iec.de/ . I’ve tried newboot 0.3. Naming convention is the same as with firmware, larsp and m644p or m1284p depending on MCU. I flashed it instead of SD2IEC firmware, flags should be set to EF, the same as with SD2IEC firmware. After that assemble SD2IEC, put SD2IEC firmware in the root of SD card, plug it in SD2IEC, connect to C64 and turn it on. Loader will flash LED2 (red) for two seconds while it looks for valid firmware and LED1 (green) should be lit while it accesses the card. When it starts the actual flash LED1 (green) should blink rapidly. I also included ATMega1284p firmware that has newboot 0.3 and 0.10.3 already installed. If you flash it you’ll have newboot 0.3 and SD2IEC 0.10.3 firmware. This way you can start using it right away and if there’s some firmware update you can update it via SD card as mentioned above. After PCB is finished you need cables to connect it to C64, they should be wired according to these schematics and connected or soldered to PCB. Pin numbers on 2 pin and 3 pin headers correspond to numbers on PCB layout.
And finished, as I said, it’s not as pretty as the ones from ebay, but it works and it’s home made :).
And to test if it works, enter this small program and run it 10 OPEN15,8,15:INPUT#15,A$,B$,C$,D$ 20 CLOSE15 30 PRINT A$,B$,C$,D$ This should get info from SD2IEC with current firmware version
And that’s it. In one of the next articles I’ll write how to guide.
Schematics, layout and firmware (after download remove .doc extension, it’s a wordpress thing…) :