Featured PostsHackerspaceMain Stories

SNES (Super Nintendo Emulated System)

To set up I2C on the Raspberry Pi, I used a guide from SK Pang Electronics. After following the guide, and running “i2cdetect,” all I2C chips on the bus should register it’s address.

The “-y” flag stops the command from issuing warnings about probing the bus. The number, in this case 1, indicates which bus to scan. The Raspberry Pi actually has two separate I2C buses. On the original Model B Raspberry Pis, the bus broken out to GPIO header pins 3, and 5 are set as bus ‘0.’ On revision 2 of the Raspberry Pi, these pins now map to bus ‘1.’ Keep that in mind when adapting code between the newer and older model Pis.

Another thing to note is the address of the chips. MCP23017 chips register on the bus starting at address 0x20. There are three hardware address pins on the chips that when pulled high or low change the addressing of that particular chip. Giving a possibility of 8 of these chips on a single bus. I meant for these chips to read sequentially, but I derped when visualizing the binary addresses, thus there is no chip at address 0x21. It’s no big deal, though.

For the next step, I installed the SNESDev-RPi controller drivers….and this caused problems. Not only did the controllers not register, but now my I2C bus no longer worked. Over the course of the next few days I debugged the hardware as I thought I may have caused a short, or even fried some GPIO pins.

It wasn’t until I delved into the source of SNESDev-RPi where I found the problem. The pinout on the blog was no longer used by the code:

// pin out used in SNESDev article on blog
// pads.clock = RPI_GPIO_P1_18;
// pads.strobe = RPI_GPIO_P1_16;
// pads.data1 = RPI_GPIO_P1_22;
// pads.data2 = RPI_GPIO_P1_15;
 // pin out used pi gamecon GPIO driver
pads.clock = RPI_GPIO_P1_19;
pads.strobe = RPI_GPIO_P1_23;
pads.data1 = RPI_GPIO_P1_07;
pads.data2 = RPI_GPIO_P1_05;

The pinout was apparently changed to follow the convention of another coder’s “gamecon” GPIO driver. I had already wired my circuit around the old pinout, and on top of that “RPI_GPIO_P1_05” is also the I2C SDL pin. This explained why I2C stopped working, as well.

I commented out the gamecon pin mappings, and un-commented the original pin maps. I recompiled, and tested. Not only did the I2C bus report my expanders, my controllers now worked! It was actually a good thing that I went through the source, as I found that a little referenced feature of the driver was the ability to use a GPIO pin as a button. As it was configured by the driver, pressing the button sends an “ESC” key press to the terminal, and holding the button then releasing causing the system to shut down. (It would have been nice to know about this while working on the power management!)

I would come to revisit this code later on the wiring up of the Reset Button..

Next up, cartridge reading!

23 thoughts on “SNES (Super Nintendo Emulated System)

  • Mark Walker

    Oh my god. I LOVE that! How awesome to play anything emulated on the original hardware. Plus carts!

  • Pingback: Turning a Raspberry Pi into an SNES | Daily IT News on it news..it news..

  • Might be a silly question (as questions usually are) but assuming someone who can write / edit / hack, would it be possible to address the speed issues by throwing two Pi’s in the box, one to handle the graphics, the other to handle sound and other I/O rather than waiting for a faster PI?

  • Very nice project, congratulations!
    I still have two SNES in perfect working condition 🙂 They are bullet proof console!

  • Can you post the wiring you did for this? Rather than just showing off? 😛 JK man, very cool

  • waterbury

    Andy, I have actually considered something along those lines. I hadn’t considered offloading audio and I/O to a second Pi, I had just imagined spitting the threads, but your suggestion sounds better. Thanks for the tip! 😀

    I’m not exactly sure how I would pull it off though. I could link both Pis via GPIO, or Ethernet. I’m guessing GPIO communications would be the best, but I lack the skills needed for re-coding major portions of the emulator.

  • waterbury

    Shake, there are no schematics. I wired the level shifters by the datasheets, and actually screwed up a few times due to the fact I was wiring on a whim.

    As for the other components, the Arduino sketch has the pin numbers for power management, and the cart_reader.py script could clue you in to what cart pins go where. Also because you asked, I appended a spreadsheet I used for the cart to my GIT. 🙂

  • Why is not in fullscreen?

    This is very interesting, but I must find a broken SNES console and buy another Pi (my only one is in use).

    Very awesome project, congratulations.

  • Nobody

    You win 1 Internet Sir. Well done!!!!!!

  • Would it be possible to release a fast snes emulator which we can use with the RasPi? Every snes emulator I tried was very slow.

  • The cart reader aspect is pretty awesome!

  • >> offloading audio

    Maybe a USB soundcard with its own processor might be able to help.

    I’m just about to start doing the same thing as you yet to buy the raspberry Pi but got the broken snes lol 🙂 now who still got me soldering Iron lol

  • Nathan

    You are a god amongst men Ted. Awesome project. Well done.

  • Hey! I could have sworn I’ve been to this site before but
    after checking through some of the post I realized it’s new to me.
    Anyhow, I’m definitely delighted I found it and I’ll be book-marking and checking
    back frequently!

  • Hey I’m working on a similar project but my work is nothing compared to yours nice work.

  • Cloudinoob

    Hey! Nice job! Is it possible that you publish the material list and the solder layout. I realy love to reproduce this ’cause my old SNES start to bug :/.

  • Excellent site you have here but I was wanting to know if you knew of any forums
    that cover the same topics discussed in this article?
    I’d really like to be a part of community where I can get feedback from
    other knowledgeable people that share the same interest.
    If you have any suggestions, please let me know. Thanks a
    lot!

    Feel free to visit my web blog http://www.huishige.com

  • Hey just wanted to give you a quick heads up and let you know a few of the images
    aren’t loading properly. I’m not sure why but I
    think its a linking issue. I’ve tried it in two different
    browsers and both show the same results.

  • Another interesting project would be to put an raspberry pi in a snes cartridge which emulates an snes game on the cartridge pins. That would make it possible to play any rom with the original untouched snes 🙂 that would also make it possible to play custom roms, to build a simple web browser or an mdp client and much more, everything with the original untouched snes hardware 🙂 And who knows what you could do with the snes when you extend the snes with the 16 Bus B Expansion Chip Pins (or the ext port) and the help of the raspberry pi..

  • Pingback: 5 Old School Gadgets You Can Create With a Raspberry Pi | Retro Gamer

  • Pingback: 5 Old School Gadgets You Can Create With a Raspberry Pi | Retro Bunny

  • Joan Josep

    Hello. I really admire your work. Congratulations.
    I wanted to run Gameboy & Gameboy color cartridges with the Raspberry Pi 3B.
    Do you believe to be possible? Basing their work believed to be viable?
    Can you clarify some doubts if I need it?
    Thank you very much.

Comments are closed.