SD2IEC for Commodore 64/128 DIY

Logo 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.

Board schematic using LF33CV voltage regulator

Board schematic using LF33CV voltage regulator

Board schematic using LMT1117T voltage regulator

Board schematic using LMT1117T voltage regulator

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.

Board layout using LMT1117T voltage regulator

Board layout using 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.

Board layout using LF33CV voltage regulator

Board layout using LF33CV voltage regulator

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

Components before soldering

Components before soldering

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.

Halfway there

Halfway there

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.

ATMega SD2IEC fuses

ATMega SD2IEC fuses

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.

Data cable schematic

Data cable schematic

Power cable schematic

Power cable schematic

And finished, as I said, it’s not as pretty as the ones from ebay, but it works and it’s home made :).

All done

All done

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

It works!!

It works!!

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…) :

SD2IECv1.2.rar

SD2IEC v1.2 LF33CV layout pdf

SD2IEC v1.2 LM1117T layout pdf

Advertisements

Posted on December 4, 2014, in Commodore, Commodore 64, DIY, Retro computing and tagged , , , , . Bookmark the permalink. 68 Comments.

  1. Hi.
    I`m goinig to realized your sd2iec but I need to know the Voltage of the 2 2.2uF electrolytic capacitor.
    Thank you.

    Like

    • It’s on 3,3V regulator output so it should be anything larger than 3,3V. Usually practice is to use at least double of voltage that’s on the rail, so 6,3V would be minimum recommended value.

      But it’s not that important, it can be larger. On these simply DIY projects I mostly use 50V ones as I have large number of those.

      Like

  2. there is an error in your schematic, but it is fixed in the pcb πŸ˜‰ You must connect the switches common to ground. Took me a while to figure it out πŸ™‚

    http://smdprutser.nl/blog/c64sx64-ram-cartridge-sd2iec-part/

    Like

    • What exactly do you mean? All grounds are connected, in schematic all GND symbols have the same name, that means all of them are the same, so there’s only one (common) ground. If that’s what you mean. I could have made only one GND symbol and connect them all to it, but that would make schematic messy.

      I don’t know if you’re familiar with Eagle PCB, but both PCB and schematic were made with it, they’re connected if you open it with the program it will simultaneously open both PCB and schematic, if you highlight connection in schematic it will also be highlighted if you switch to PCB. Both files are included in rar archive at the end. There’s freeware version of Eagle PCB that has some limitations, but should be able to open these files.

      http://www.cadsoftusa.com/download-eagle/freeware/

      Since you also design your PCBs I guess you know all this but… πŸ™‚

      Like

      • Sorry for the late replay. I ment the common_sw pin on the card connector. Prolly connected somewhere else to GND. I used your schematic (the png/jpg/gif) but used an uSD in my design which hasn’t got a carddetect nor writeprotect. I didn’t connect those line as I assumed they are active high or not used. But both needed to be grounded for detecting the card and being able to write to the card.

        And yes I know Eagle πŸ˜‰

        Like

  3. Hi Solo761,
    and thanks for a great tutorial !

    I have replicated the LM1117T board. Works well, when i flashed my ATMega644P
    with firmware 0.10.3. However, I tried with another ATMega chip bootloader
    v. 0.4.1. Unfortunately, my sd2iec is dead with bootloader chip installed.
    There is no any red or green led activity, even with SD card inside the slot.
    Which bootloader version did you use ?

    I am hoping to reflash that ATMega chip with bootloader again, but there is another
    issue. The ATMega chip becomes nonresponsive, after low fuse is set to “EF”.
    I am assuming, that the chip becomes nonresponsive, because after low fuse is set to EF, it expects external 8mhz crystal and 5V power source, would you agree ? For programming ATMega644P I am using very cheap usbasp v2.0 programmer.

    I’m wondering, if ATMega644p can still be reflashed, if I connect it to external power source and crystal – as it is connected on sd2iec board ?

    Lastly, the momentary switches. Reset switch is obviously clear, what it does. But
    what is the purpose of the two other momentary switches ? Jumper sets the device
    number, so it is confusing, what these switches actually do ?

    Thanks again, I enjoyed a lot building my own sd2iec and I’m very happy
    with the results !

    Like

    • I used newboot v0.3 bootloader, but I see that it’s been updated to v.0.4.1

      http://www.sd2iec.de/bootloader/

      If you used that one be sure to use newboot-0.4.1-larsp-m644p.hex since you used ATMega644P.

      After you flashed bootloader have you updated it with sd2iec frimware? Bootloader it overwrote sd2iec firmware so it’s basically a blank, only bootloader is running on it.

      Put sd2iec firmware file for your ATMega on SD card, insert it into card socket and turn it on. Bootloader should find it and flash ATMega with it. After it successfully flashes delete firmware file from SD card as it’s not needed and you don’t want it to flash firmware every time you turn it on (I’m not sure if it checks if the same file is already flashed).

      As for flashing after fuses were set yes, you need to recreate that part of the circuit. I usually use breadboard to connect crystal and it’s capacitors so I can flash it.

      Those two other momentary switches are used to switch between multiple discs in case the game is on more than one floppy. You need to have autoswap.lst file that has them all. For more info look here:

      http://www.thefuturewas8bit.com/index.php/sd2iec-info

      Like

      • Thanks a lot for your quick response, Solo761!

        “newboot-0.4.1-larsp-m644p.hex” is the exact bootloader, that I flashded to the ATMega644p. After that, I flashed low fuse to “EF”.

        I do realize, that Atmega now has only bootloader. And I put firmware file to SD card (actually micro sd, with adapter) and inserted it to sd2iec for firmware update.

        Then I switch on the C64. What happens is… actually nothing. C64 boots normally, but sd2iec device leds, both red and green are not lit, not blinking even once.

        Anyway, now that you confirmed the need to use external crystal on low fuse “EF”
        programmed chip, I am confident I can reflash now nonresponsive ATmega chip.
        I will just use working firmware, eventhough it means, I do not have nice bootloader with it. At least, I do not waste the ATMega chip :).

        And finaly, thanks for the link to autoswap feature !

        Like

      • What filesystem did you use on SD card? It’s a longshot as you probably used SD card that worked already, but it only supports FAT variations (FAT12, FAT(16), FAT32). Ill probably try to flash this updated bootloader to mine and see what happens.

        I just checked fuse configurations on 644p and 1284p and they’re the same, EF should work for both.

        *edit*

        I just tried to read my 1284p without crystal and I get “Target doesn’t answer” error, after I connected the crystal it worked immediately. This is how I connected it. That thing on the left is 5V USB PSU for breadboard, it’s not used in this. After that it worked, I successfully read old firmware.

        I flashed newboot 0.4.1 bootloader, but it’s kinda late here so It’ll have to wait until tomorrow to set ma C64 up and connect it to see if it’ll flash the firmware.

        *edit No2*

        I’ve just tried it on C64, newloader 0.4.1 worked as expected. I put firmware file in root of SD card, inserted it into SD2IEC and turned it on. Bootloader found it on SD card and flashed it (red LED lit). After that it worked. I messed commands so I entered LIST”$”,8 instead of LOAD”$”,8 and DIR instead of LIST, but I think it would work even on first try. After this I turned C64 off and back on, bootloader on SD even figured out atmega was flashed with this firmware so it didn’t reflash it. LOAD and LIST commands worked as expected, you can see in LIST command that firmware bin file is still on the card.

        Like

      • Yes, I used FAT in micro sd card.

        My windows 7 did not specify if it was fat12, fat16 or fat32, when I
        formatted it.

        i haven’t yet built board to reflash now unusable Atmega644p chips
        (been repairing a couple of c64 with black screen). It’s nice to know, that
        using external crystal, i will be able to reflash the chips!

        It’s really curious, why bootloader 0.4.1 works for you, but not for me.
        But, I am already happy with the fact, that firmware itself works in my board
        as well.

        Wow, what directory loading speeds with jiffydos! For now, I have to
        rely on sjload.

        Like

    • If you’d like to experiment you can try some older newboot version, maybe there’s a bug with this one for ATMega644. You might even try different application for flashing, I’ve noticed that some work better than others. I’ve had success with Khazama AVR programmer http://khazama.com/project/programmer/

      Like

  4. cookiemonster

    Hi,
    i,m building your sd2iec and my question is.. what kind of files should i “put” to atmega?

    Like

    • You have to use some programmer that supports ATMega1284p microcontroller and use it to “put” code (aka firmware) into it. It doesn’t store any files, just program that makes it do what it does.

      Most current firmware can be found here: http://www.sd2iec.de/

      Filename is sd2iec-current-binaries.zip , you need the one that has “larsp” and “m1284p” in it’s name (if you use ATMega1284p, for ATMega644p you need the one with m644p).

      Like

      • cookiemonster

        okay thanks.. πŸ˜€ and my second question is.. em… because i bought LF33CV… but i built sd2iec for LMT1117T.. so can i use this lf33cv, or should i buy LMT1117T?

        Like

      • You can use it, but not by simply plugging it in spot for LM1117T. Problem is that they have different pinout (i.e. their “legs” don’t have the same functions)

        This is LF33CV

        And this is LM1117T

        You could use it if you solder wires to pin holes and then those wires to regulator’s pins.

        So, wire from hole “1” would go to regulator pin “2”, wire from hole “2” would go to regulator pin 3 and wire from hole “3” would go to regulator pin “1”.
        On PCB that uses LM1117T hole number “1” is the one closest to SD card slot.

        Of course, if you do this make sure that wires have good insulation so they don’t touch.

        Like

  5. And my secon question is..emm.. Because I bought lf33cv, but I built this sd2iec for lmt1117t, and my question is.. Can I use this lf33cv or I should buy lmt1117t?

    Like

  6. My second question is that.. Emm.. Because I bought lf33cv but I built Your sd2iec forlmt1117t.. So can I use lf33cv or I should buy lmt1117t?

    Like

  7. Cookiemonster

    Hi again!
    I’ve got one more question.. Because my sd2iec with atmega1284p doesn’t work.. Red led all the time flashes with sd card.. And green led burning for less than one sec I think.. Without card It shines longer.. Can You help me? And sorry for my bad English πŸ˜›

    Like

  8. cookiemonster

    everything is working now.. but.. i don’t it’s working with lf33cv.. not with lmt117t :/

    Like

  9. cookiemonster

    Yep

    Like

  10. cookiemonster

    Hi again…. :P.. i’ve got big problem(i think) because my both sd2iec works only if I plug it to my PC by usb port… if i trying to turn it on other computers or other power supply.. it doesn’t work.. and i don’t know why… :<<<<

    Like

    • How do you connect it to USB? It doesn’t have USB connector in my design . Have you tried connecting it to C64 tape port? If you tried and it doesn’t work are you sure you’ve connected +5V and GND correctly?

      Like

  11. Cookiemonster

    I used usb cable πŸ˜› yea.. Everything is correct.. If I plug it to mobile charge or other computer only green led lighting(?) for a few sec.. And when I’m writing “load”$”,8″ commodore “stop” work and I see only “searching for$”… But! πŸ˜€ if I plug it to my own pc computer it works and everything is ok .. Lol and I don’t know why

    Like

    • I had the same issue with a mobile charger. I gave a try to a generic charger that I tested to provide 5.6v and says to provide 600mA. It doesn’t read the Sd Card and stays in “searching for $”… Meanwhile with USB power it works fine just like you say.
      I also wonder why? Maybe these generic chargers are crappy? I also tried a 9v power source and leds blinked really crazy :O I guess it was the atmega chip saying “unplug this now or I’ll be fried”. It still works anyway. πŸ˜€
      I don’t have other power source with less than 9v to try, unfortunatelly.

      Like

  12. Cookiemonster

    I cant connect it to commodore because I haven’t right connector(?) and I can’t by it in Poland..so usb cable was cheaper for me

    Like

    • I got tape connectors from ebay, there are similar ones that fit. http://www.ebay.com/itm/252366368433

      I’m not sure why it won’t work charger. My guess is that GND is problem. If GND on C64 and charger is not the same level signals from SD2IEC won’t get recognized by C64. I guess it’s pure luck that PC’s power supply GND level is close to C64’s so it works. That’s why it’s best (and safest) to use 5V and GND from C64.

      There’s 5V line on joystick port too and DB9 connectors are easily available, but it’s rated for only 100mA. I’m not sure how much SD2IEC uses, but I’d guess it’s more than this so it’s safer to not do this.

      Like

      • Now the GND pin of the IEC plug is not connected. I wonder if connecting the IEC’s GND pin in some manner to the circuit could solve this issue and make it compatible with other power sources than the C64?

        Like

  13. Cookiemonster

    Okay.. So can i connect It to user port? Because connector for this port is cheaper πŸ˜€

    Like

  14. Cookiemonster

    Ohh f*ck :< ship to Poland is too expensive.. Eghhh.. So.. Can I plug it only to 1 and 2 port.. Without 7 and 8? I gonna to use something like that http://static4.tme.eu/products_pics/a/1/b/a1b75daa1d1d3fe6bc2c7b2c07759343/366463.jpg πŸ˜›

    Like

  15. User port is also not safe, it says it’s only up to 100 mA

    https://www.c64-wiki.com/index.php/User_Port

    But expansion port should be enough, it has two 5V rails and they should be up to 450 mA

    https://www.c64-wiki.com/index.php/Expansion_Port

    If you can make PCBs at home it shouldn’t be too hard to make small PCB that plugs into expansion port for power, you don’t even need any connector.
    Only thing you can do to make it nicer is to make big enough to fit into some case, like these two

    http://www.sklep.cyfronika.com.pl/pl/p/Z-7-Obudowa-z-tworzywa-Z7-wymiary-90x68x19mm-CARTRIDGE-czarna-polistyren/16448
    http://www.sklep.cyfronika.com.pl/pl/p/KM-20-Obudowa-z-tworzywa-KM20-wymiary-91x68x18mm-czarna-ABS/30264

    They’re almost the same as original C64 cartridge cases. You could even redesign the PCB so it would fit in these cases and make it plug into expansion port for power and just use the cable for plugging in serial port.

    That connector might work, you only need to be carfull when plugging it in to not make a short on the motherboard. It doesn’t need 7 and 8, they’re connected on the motherboard, you can use either side of the connector.

    Like

  16. cookiemonster

    hi again… egh.. i’ve got problem again… because one of sd2iec works only if i plugin it when commodore is turn on… then leds light normal.. when i reset sd2iec.. it’s stop works.. lol :<.. in my second sd2iec leds light barely only when if i'm touching crystla. :<

    Like

    • Unfortunately I have no idea what could be the issue. Especially since I don’t exactly know what you did and you did make a few “shortcuts”. I’ve built 4-5 of them and all work fine. Tested them on C64, C128 and even Commodore Plus 4.

      Like

  17. Hi! Thank you for these schematics and tutorial, I succesfully have a working SD2IEC!
    I have encountered a problem with bootloader 0.4.1 on atmega1284. I had first flashed alpha version 10.0.98 and when I wrote and run the version query program it worked fine. Then I flashed bootloader and then let it flash firmware 10.0.3 from the sdcard. It does seem to work, loads prgs and file list, etc. But now the version query program gives out a Syntax error no matter how I type it, retype it, check it or check it again. Do you think that is normal with bootloader that the query program doesn’t work anymore? Also now if I want to flash it again I don’t need to program the atmega again, right? I’m asking because I programmed with LPT port and soldered the wires to the back of the PCB, so I want to unsolder them and not program it again ever via LPT πŸ™‚
    Thank you again!!

    Like

    • To be honest I don’t know. I have old 0.3 bootloader on mine and querry worked OK. I didn’t try with new bootloaders. Although I have one SD2IEC that I made few months ago that has new bootloader, I’ll try to query it and see what happens.

      Like

  18. Hi again solo761. I finally flashed regular 10.0.3 firmware and it all seems to be working fine. I don’t really care about the bootloader, should a new firmware appear I will reprogram it.
    Now I have a new inquiry πŸ™‚ I’ve been experimenting with different power sources (there is no edge connector I can purchase here), and I’d been using USB power from a PC and it works like a charm. My intention is to get power from a joystick port, do you think that would work ok?
    If I use an external dc power source, what is the max voltage it should withstand?

    Like

    • Using joystick port wouldn’t be safe, i don’t know how much does sd2iec use, but joy port can supply only 100 mA and there’s atmega mcu, leds and sd card to power. It would be too close and it would tax CIA chip too much and it could burn out. If you cant find edge 2×6 connector (I bought them on ebay) you might try to find longer version and cutting it to size. Or you could try taking power from user port (cartridge port) by making pcb with pins to connect to it. It’s rated for up to 450mA which is more than enough.
      As for external dc supply, it should be 5V, but I’m not sure if it would be OK to use it since it’s an c64 GND might not be on the same level.

      Like

      • Thanks. After writing the question I then realised you had already replied everything to another user. I finally found a way to recycle an old PC floppy cable edge connector so it would connect to the datassette port and draw appropriate power from it. The external dc supply as you said, didn’t work, it powers the device but the IEC bus can’t communicate. I wonder if that could be solved connecting the GND pin through the IEC bus as well as ATN, CLK and DATA. But maybe that would require some protection components on the SD2IEC side. I didn’t want to mess around, and it’s the obvious and most convenient way to get power from the C64 so I’ll leave it as it is. Simple and working.

        Like

      • Problem is in GND, I guess C64 GND and mobile charger GND are not at the same zero (in lack of better expresion). So although they/re both 5V when compared to “their” GND when compared between them they’re not necessarily 5V, they can be more or less. I’d guess it was less so C64 didn’t “hear” what SD2IEC was saying to it :).

        Connecting 9V is too much and dangerous. You’re lucky you didn’t burn something. ATmega MCU on SD2IEC operates at 5V, that’s why we take 5V from C64, you don’t need any extra voltage regulators because it’s already at 5V. SD Card operates at 3.3V, that’s why there’s one voltage regulator on the board, it’s only function is to reduce 5V from C64 to 3.3V that SD cards need to work. To simplify design there are six resistor in voltage divider configuration on three lines that go from Atmega (5V) to SD card (3.3V) to lower Atmega’s 5V so SD card won’t burn out. Luckily 3.3V from SD card’s output to ATmega is high enough to be picked as logic 1 so there doesn’t need to be anything on that line. It could have been done with special level shifter chip between SD card and ATmega that would take care of different voltage levels between them but that would make PCB more complex and expensive and in this case it’s not necessary.

        I don’t know how much you’re into electronics, but voltage is easier to describe as something relative and not fixed. We say GND (0V) and 5V for wires/leads, but they’re not necessarily that. They are when compared with each other, but not when compared to some other GND and 5V.
        Or if for example you take old IDE power connector (molex connector) for CD/DVDs and hard drives, they have 4 wired, 2 GND, 5V and 12V. Between GND and 5V wire there is 5V difference, and between GND and 12V wire there’s 12V difference, but between 5V and 12V there’s only 7V difference. Back in the day I used to connect PC fans that way so that they would only get 7V, they would rotate slower than they were supposed to and, more importantly, quieter :).

        I guess it’s technological issue. Old C64 has different method of getting that GND when compared to modern mobile chargers so they’re not the same. Old floppies had their own PSUs and they worked fine because they used the same technology, no problem there. But I don’t exactly know.
        Although I have an Idea how this could be “fixed”. I think if there was additional 5V voltage regulator on PCB that would make it “play ball” with C64. In that case 5V needed by ATmega would be generated on PCB with C64 GND already connected so that would made it sure it’s 5V from the same GND. Although in this case you’d need to have external PSU with minimally 7V, it wouldn’t work with mobile charger or power from tape port because voltage regulator needs to have input power bigger than it’s output (which would be 5V) and I think 7V is lowest possible. That 9V you have would be ideal in this case :).

        Like

      • Thanks for the thorough reply, it’s very enlightening! I’ve seen other designs that work perfectly with external psu of 7V or 9V so I mistakingly thought this one did too. But you’re totally right those other designs have other ways to regulate voltage, the voltage that comes inside the circuit and the ones that go into the sd slot and the atmega chip distinctively. I don’t know much about electronics really so I have to admit some things are a bit over my head so I won’t modify what I don’t understand. A friend of mine who knows about electronics has picked your design to build here in Argentina because the “official” 1.2 sd2iec pcb was excessively complex and we couldn’t easily find the parts, let alone DIY. I think this design being so functional and simple is a good alternative for Latin American countries, so I’m creating a guide in spanish for people in spanish speaking countries to be able to build their own. Of course your tutorial is being credited and linked to.
        The only component that is a bit of a pain to get here and overly expensive for its purpose is the edge connector. It’s really cheap buying it from ebay, but we have some blocking rules here to buy stuff from internet, it’s sort of a very limited “quota” that once surpassed makes it complicated to buy anything.
        So what I did is salvage an old Floppy cable edge connector, cut a part of it and only left the two pins that would connect to the cassette port’s power pins. It works fine.

        Like

  19. Hi,i have a SD2IEC bought on ebay and have same MCU ATMEGA1284P-PU DIP 40PIN
    How to update new firmware?

    Like

    • To be sure you need to ask that the person you bought it from.

      If he flashed some bootloader to it you only need to put update firmware on SD card and turn it on, it will flash updated version. Afterwards be sure remove it from SD card, some bootloaders check to see if it’s the same firmware already flashed, but some simper ones would flash it every time you turn it on and that’s not “healthy” for flash. So after update it’s bast to remove firmware from SD card.

      if he didn’t use bootloader only way to update it would be with some atmega programmer, if it’s removable from SD2IEC PCB and not soldered in. If it’s soldered in it needs to have ICSP header so it can be reprogrammed, if that’s missing too then it would need to be desoldered.

      But, before any updating you would need to know what layout (they have functions on different pins so PCB is differently wired) your SD2IEC uses. There are few of them and if you flash wrong one it wouldn’t work. This one I made uses LarsP layout, original variant.

      Like

      • eBay seller do not response in my question,the chip is socketed,that the programmer need? i have a original usbasp.

        Like

      • You can use usbasp, I also use it for flashing Atmel MCUs.

        You can download newest firmware from here

        https://www.sd2iec.de/

        File is called “sd2iec-current-binaries.zip”, that’s the latest “official” firmware. In it are firmwares for all SD2IEC versions, you’d need one for 1284p MCU, there are four of them (larsp, petSD, sw1 and sw2), to know which one exactly to use you need to know layout your SD2IEC uses.

        Since you have usbasp you could flash one and test, if it doesn’t work, flash the next, test, and so on… but that sounds too risky. I don’t know exact differences between them but if you flash wrong one it could potentially fry your SD card or even worse, C64.

        But all in all I don’t think it’s necessary to update it. On mine I have firmware from 2012. It works fine.

        Like

  20. OK then, I do not update anything too risky I keep the old firmware.
    Many thanks for support.

    Like

  21. I want to use one of the SD Card Modules for the Arduino in your design. It already has a 5V-to-3.3V regulator on the module. Also, it does not break out the Card Detect or Write Protect pins. How should these pins be used on the 1284 chip? Both tied to ground or Vcc? Thanks!

    Like

    • Hi Scott, I can reply to you because I built it with arduino SD card module as you intend. It’s actually much better to do that! Card detect and write protect must be connected to ground.
      I made a tutorial to build this without the need of a printed PCB. It’s in spanish but maybe it’s useful to you anyway. There’s a diagram that I think can help you.
      http://pungas.space/blog/index.php?option=com_content&view=article&id=6:sd2iec-punga-v2-0-ahora-sin-pcb&catid=8&Itemid=102

      Like

      • Good page Uctumi Sid. I used Google Translate to change it to English. So I got the device working and communicating with my C64. But I have an issue now that I have not seen anyone else on this forum have. My device is reading and writing to the internal Data Space on the ATMega 1284 instead of the SD card! I saved a file named “Test” to the device, then when I did a LOAD “$”,8, then LIST, it gave me a file list that showed the disk name as “EEPROMFS”, and showed only 12 blocks free. I have C64 files on the SD card, but it is not looking at the SD card. Any Suggestions?

        Like

    • The problem you have is maybe because there’s a problem for the Atmega to connect to the SD card reader or the detect card pin is not properly grounded. You should check your connections to the arduino module and check that pins 16 and 20 are properly connected to ground. It could also be a faulty arduino module. Also in my guide I use a microSD module, maybe you’re using the SD module which is a bit different, because it has a 3.3v input pin, you should only use the 5v pin, not the 3.3v as it would bypass the regulator.
      I think I’m going to make a translated version of the guide, I didn’t expect it would be needed in english πŸ™‚

      Like

  22. What exact SD Card module do you use? Maybe something like this?

    I’m asking because of resistors that are on CS, Clock and DataIn lines. I think Arudino SD card modules have them onboard so if you also have them that sound like potential trouble as they’re there to reduce 5V coming from MCU to 3.3V SD card works on (simple voltage divider).

    Since Arduino also works on 5V I’d guess that these modules have this problem solved on board, it has 3.3V voltage regulator for SD power supply so why not this. If this is the case R4, R5 and R6 would need to be removed, and R1, R2 and R3 jumpered.

    Maybe this is the issue, if it already has some kind of voltage reduction, and we add another on the line, signal from MCU to SD card gets reduced too much and MCU “thinks” it can’t write to it.

    Like

    • I’ve already built several SD2IEC using the arduino SD module and the micro SD module as well and they all work like a charm. They must be connected directly to the IC, no resistors or regulators needed in between.

      Like

  23. Yea thats the module i’m using. But i figured out my problem. I had no system clock to the SD module. I fixed that and everything is now working! Thanks for the replies, it was very helpful!

    Like

  24. You don’t need the 8Mhz external crystal. The Atmega644p/1284p can use the internal RC at 8Mhz, but you have to disable the fusebit that divide the RC internal 8Mhz clock by 8.

    Like

    • Yup, as I wrote above “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.”

      Like

  25. Hi, because I’m new with these atmel mcu (Im only familiar with microchip pic) what is the sequence of flashing the bootloader on the atmega?
    first I flash the hex file of bootloader and then burn the fuses? or is it in the same procedure?
    also I have usbasp, can I just use the pcb I’ve made for sd2iec(lm1117t) and solder wires between usbasp header and directly under the mcu socket to program?

    Like

    • Load hex file to programming application, set fuses and burn. You can do both at the same time.

      It should work if you solder wires directly to MCU socket. Just be sure that SD2IEC isn’t connected to C64 (or powered generally) and that SD card socket is empty (I doubt it would do anything but…).
      I usually program DIP ATmega MCU’s in breadboard by using jumper wires between usbasp plug and MCU pins.

      Like

      • I thought that mcu have to be powered when programming otherwise there is a risk of bricking it.
        thank you very much for your help!

        Like

      • It get’s power from usbasp. To use it you need 6 wires from usbasp to MCU’s MISO, MOSI, SCK, RESET, GND and Vcc, so that takes care of power, i.e. usbasp powers it.

        Here’s an image that shows this, only difference is that it uses arduino as usbasp

        Liked by 1 person

  26. I tried installing winavr USBasp and khazamaAVRProgrammer into win7x64 all went good.

    When I open khazama I can choose atmega1284P but when I choose the command “Fuse and Lockbit settings” I get an error saying “Fuses and Lockbits are not supported yet for ATMEGA1284P” .
    If I press OK on the dialog box it opens the window with fuses but I’m not sure if I can continue with the procedure, I’m afraid that it can brick the MCU.
    Is that normal and is it OK to go ahead and program the flash (bootloader) and save fuses?
    Or am I missing something?

    Like

  1. Pingback: SD2IEC | KernelCrash

  2. Pingback: C64/SX64 RAM Cartridge | smdprutser.nl

  3. Pingback: C64/SX64 RAM Cartridge (SD2IEC part) | smdprutser.nl

  4. Pingback: C64/SX64 RAM Cartridge revisited | smdprutser.nl

  5. Pingback: Συνάντηση 12-10-2016 | www.retroclub.info

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: