capaingles

Mega Drive cart fix.

Hey, welcome again!

This time i want to share my Mega Drive flash cart made of old BIOS chips. I made it because my Sonic cart was not working since always. I used Arduino, Python and a bit of Processing (nice to show visual info) to programm. Sorry for the bad pictures and a good reading!

The patient

I have my Mega drive since 12, (I have 20 now). One of the games I got with it was ‘Sonic the hedgehog’, but it never worked well, in the begining it bugged only in the ‘Marble Zone’ stage, and then it started to show the messages saying “illegal instruction” after reset. So i never had the chance to play the others stages than the first, but this changed this week…

WP_20150127_13_22_15_Pro

The victims

So, what is the thing with these flash carts? They are flash, don’t they? I have a pile of old tech and scrap here in the house, and these days I discovered these flash memories, they are in a lot of things: DVD players, Printer boards and old computers. The memories I found were EN29F040, 39v040 and others, but only one with parallel interface was the EN29F040.

I already saw people making Game Boy flash carts, they use exactly these kind of memories, but they are smd format. The only one memory I had, was a 8 bit memory, so i needed at leats two of them as the Mega Drive uses a 16 bit data bus.

Thinking, I found out that these memories are used in some really old computers, like the giant bunch of trash we have in university. I was in there and had harvest the most memories I could, that means 6, that was the number of memories that I could find. The memories used in the these motherboards are most 256KB or 2Mbit with 8 bit data bus.

I find the following memories:

ASD AE29f2008

EON 29f002

Winbond W49F002u

Macronix 28f1000

2x SST 39s020

WP_20150211_12_41_16_Pro

Who designed this board maybe never thought i would do this.

The plan

Ok. Now I have the memories(flash, not childhood), but they are 8 bit memories, and the Mega Drive is a 16 bit video game, what to do now?The answer is simple: Just use two chips.
I learned that in my microprocessors classes, if you want to make a memory with a 2n bits data bus from two memories with a n data bus, just share the addresses, write, enable, and read lines between the two, simple.

The procedure.

The first thing I did was stack the memories and solder them in the lines we talked before, VCC and VSS, leaving only the data pins unsoldered.

WP_20150127_13_51_57_Pro

The data pins aren’t soldered.

WP_20150127_14_01_40_Pro

16 bit memory. Done.

The pinout for the memory i’m using:

020
SST 39sf020 flash Memory pinout.

Then unsolder the faulty chip from the Sonic cartridge. That was simple.

WP_20150127_14_38_48_Pro

Original and faulty chip removed, I also changed the capacitors.

Someone has already made a pinout of the Sonic chip, what a luck, In this link you can found a lot of info about genesis development.

pinout Image from zophar.net

Knowing this, i rewired every pin on the flash memory to theiir places on the original ROM. It’s not be most beautiful thing you will see today, but gave me expected results.
I used the data pins D7-D0 from one of the memories as D15-D8 on the cart.

 

WP_20150211_12_43_06_ProCart made.

The thing was built, but his souls was still BIOS programs, i just needed to put 4194304 new bits on their places.

Connecting the wires.

I had the cart in hands, how to test If it was working at least?
Yeah, I could use a ATmega8 in a protoboard and some 595s to control the eighteen addresses, sixteen data and three control pins. Hey! I could use only NAND gates! Just kidding, I used my Arduino Mega.
Another thing from scrap was the ISA slot that I got from a old motherboard. The ISA slot, its largest sub-slot (that word exists?) actually, has 2×31 pins and the Mega Drive cart slot has  2×32 pins, the good thing is that the last pins are a redundant ground an unconnected pin, so the ISA slot can be used fine.
I used the pins 14-29 to data, 30 -50 to addresses and 51-53 as output enable, chip enable and write enable.

WP_20150212_16_07_26_Pro

Sorry for the bad photo.

Programming.

I made the cart in one afternoon, thinking that I could finish the software before the day after, completely wrong, I know nothing…

I used three software pairs:
1 – Test software, the standart Firmata example on the Arduino and an adaptation of one of the Firmata examples in Processing, that let me access every word on the chip and see what was programed in the chip, if the words were equal to the ones on the ROM and test if all the lines were connected right and if they were working.

Captura de Tela (30)This is the begining of the ROM header, 0x5345 can be read. That is Ascii ‘SE’ from ‘SEGA MEGA DRIVE’.

2 – Dumping software, well this was a learning trip, why not use the hardware to read ROMs? This also let me if the ROM image programmed is working. It’s composed by a Arduino code that read the words on the cart and send them as bytes to computer, and a python script to receive the bytes and save them in a file.
3 – Burning software, the burning software is composed by a python script that read a file in the ‘.bin’ format and sends them to the Arduino, and an Arduino code to receive the bytes and put them in their places on the flash.

All the codes used can be found here. Please, don’t expect beauty.

 

It’s alive!

To my surprise, the cart works very well, no bugs or “illegal intruction” messages as with the old chip.

Below it is a video of the thing working, I am not really good, but  at least I can reach Spring yard stage now without the old bugs.

 

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Robson Couto

Estudante de engenharia elétrica. As vezes parece gostar mais dos consoles antigos que dos jogos. Tem interesse em dominar bits, bytes e afins.

15 thoughts on “Mega Drive cart fix.

    1. Ah, muito obrigado.
      Na verdade eu faço engenharia elétrica, mas tenho uma paixãozinha por computadores haha.
      Programação geralmente eu tenho que estudar por mim mesmo ou pedir ajuda aos meus amigos integrantes do site que fazem todos engenharia da computação.
      Obrigado pela leitura.

  1. Hummm… legal, mas.. soh pra saber não era mais facil e pratico usar uma eprom 27C322?? tem a mesma pinagem do cartucho e praticamente o mesmo endereçamento, iria poupar uma mao de obra extrema e ficaria mais “apresentavel”

  2. Sou graduando em engenharia elétrica pela Unicamp, e achei fantástica sua ideia. acabei parando aqui na página ao buscar algumas referencias no google sobre memórias, para a disciplina de sistemas embarcados. Eu só queria entender melhor como funciona a última parte que você fez, a gravação do jogo em si na memória, o arquivo bin. Fiquei com vontade de reproduzir sua experiência aqui em casa, até porque tenho um megadrive aqui em pleno funcionamento. Abraços

    1. Ola Matheus, muito obrigado.
      Desculpa pela demora, mas se ainda esta interessado, a gravção na memoria é bastante simples.
      O que me guiou pelo processo foi apenas o datasheet das memorias que usei.
      O Arduino foi utilizado para controlar as linhas de enderço, dados e controle da memória, aproveitei as muitas portas do Mega pra controlar os chips diretamente, mas registradores de deslocamento podem ser usados pra controlar o baramento de endereco.
      Quanto ao chip, diferementemte de memorias RAM, apenas um pulso no pino WR não é suficiente para gravar um dado, sendo necessario uma sequencia de bytes para “desbloquear” ou permitir a gravacao de um byte.
      Do meu código:

      writeWord(0x5555,0xAAAA);//these comands enable writing
      writeWord(0x2AAA,0x5555);
      writeWord(0x5555,0xA0A0);
      writeWord(i,wordData); //the data itself

      Espero que tenha ajudado, mas se desejar especificar melhor sua duvida, pode responder aqui.
      Abraços.

Deixe uma resposta