Go Down

Topic: ROM-Reader for Super Nintendo / Super Famicom Game Cartridges (Read 197713 times) previous topic - next topic

Cyber_Akuma

Sorry that it took me a while to get back to you about this:

No risk that I know of.

Here I have re-arranged the commands so that it's easier to go line by line
Huh, well this is weird. I copy-pasted that re-arranged code, and was going to comment all of it out and one-by-one uncomment each line to see which one causes it.

But just as a baseline test, I uploaded it to the cart reader as-is without anything commented out yet just to make sure I get the same behavior as the original arrangement of the code.

.... and I didn't.

This time, it actually didn't erase the save from the cart, even though I had not commented any of the lines in that post out. I tried doing both a save and rom dump of all 4 SRAM GBA games I have (even though only two of them were erasing), and none of them erased their saves. I did a CRC-check of both the saves and roms from the earlier dumps and they matched as well. One had the latest save be different, but I think I actually had played it a bit so that's understandable.

Seems that somehow re-arranging the order of instructions in setROM_GBA in the order you write in post #743 makes it work correctly... I have no idea how or why though.


I notice that this redesign has five cartridge ports now, is support for another system being added? If it was mentioned before in the thread I must have missed it. I recall there were people contributing to TG16 support via an adapter, I admit I am not too familiar with the TG16 but that doesn't look like a TG16 card port.

sanni

I don't know exactly why this fixed it but I updated the code on github anyway. :)
The added slot on the design idea I posted is a NES slot but ofc there is no code written for it.

I worked on the design idea a little more, now it has two build options: with or without a backplate.

First build option that should be cheaper.


Second build option with the modules mounted on the underside and thus requiring a backplate.


And the backside of the second build option.


Also by using those longer male pin headers to connect the Mega 2560 Pro you can make an expansion port where you can plug in daughter boards like this one that breaks-out all the pins to two 40pin IDE connectors for prototyping.


MostroVeneno

#752
Feb 22, 2019, 04:45 am Last Edit: Feb 22, 2019, 12:20 pm by MostroVeneno
Hi,

I was wondering how to write a rom to the satellaview 8m cart through bsx.
The rom must be .sfc? I get invalid file response.
Please any info will be helpful. Thanks

Newbie2

According to the datasheet of the 29W640 the flash commands are pretty much the same as with the 29F033, so if you re-solder the WE wire or change the WE pin in the code and change the flash ID in the code from "04D4" to "22ED" or "22FD", depending on if you have a 29W640FT or 29W640FB, it might just program without any major changes.
Is the code I'd need to change to change the WE pin within the "Write 29F032 flashrom" function in gb.ino? I'm trying hard to attempt to figure things out on my own and not ask too many questions, but narrowing down what to look at would be very helpful.

sanni

Yes it's inside gb.ino, right now WE/WR is set to PH5.

Quote
void setup_GB() {
  // Set RST(PH0) to Input
  DDRH &= ~(1 << 0);
  // Activate Internal Pullup Resistors
  PORTH |= (1 << 0);

  // Set Address Pins to Output
  //A0-A7
  DDRF = 0xFF;
  //A8-A15
  DDRK = 0xFF;

  // Set Control Pins to Output CS(PH3) WR(PH5) RD(PH6)
  DDRH |= (1 << 3) | (1 << 5) | (1 << 6);
  // Output a high signal on all pins, pins are active low therefore everything is disabled now
  PORTH |= (1 << 3) | (1 << 5) | (1 << 6);
Quote
void writeByte_GB(int myAddress, uint8_t myData) {
  PORTF = myAddress & 0xFF;
  PORTK = (myAddress >> 8) & 0xFF;
  PORTC = myData;

  // Arduino running at 16Mhz -> one nop = 62.5ns
  // Wait till output is stable
  __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");

  // Pull WR(PH5) low
  PORTH &= ~(1 << 5);

  // Leave WE low for at least 60ns
  __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");

  // Pull WR(PH5) HIGH
  PORTH |= (1 << 5);

  // Leave WE high for at least 50ns
  __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
}
The pinout.xls from the github will help you with figuring out what Arduino pin is connected to which GB cart slot pin.


Newbie2

Perfect, I will give it a shot and see what happens.

KnightofTime

I don't know exactly why this fixed it but I updated the code on github anyway. :)
The added slot on the design idea I posted is a NES slot but ofc there is no code written for it.
Oh wow, I'm surprised you added an NES slot to the cart reader sanni.

Just wondering if you're working on code for it?  I think I remember seeing another device which can backup/restore NES saves, although I believe it's in the beta stage (as tempting as it is to buy this device, I think I'm gonna stick with the Arduino).  I'm looking forward to hearing more news about the new NES slot in the future.

sanni

Well, I would love to order the new PCB but it's $50 or more just to see if I made any mistakes designing it so I'm probably not going to place the order since there are better alternatives to read NES carts with the new infinitneslives dumper.

The goal of the new PCB design was to make building the Cart Reader cheaper but since a 150x100mm PCB is so much more expensive than a 100x100mm PCB that didn't really happen.
Maybe when PCBs get cheaper in the future I'll build it just for fun.

Newbie2

In terms of the pcb redesign, would doing an nes adapter be feasible as an alternative? The other item that might be attractive to people is a gamegear adapter.

Tried the bennvenn cart, but after making the changes it gets past the "Blankcheck" and erase phase but then stops at the flashing stage. On the plus side, it didn't actually erase the cart, so it still functions as before.

Any additional suggestions?

Edit: Could the fact that MBM29F033C expects 256 bank be an issue? Or does the flashing effectively ignore that and just use whatever it detects the cartridge has (it correctly detects the cart is 128 bank)

pyroesp

Hey, new here, really like the project you made Sanni. Having bought a SFC not too long ago with a few games on ebay, I wanted to read and patch some of my Japanese games.

The github page / wiki has all the links necessary to buy everything you need to build one of these, thanks for that!

My advice, as you mentioned yourself, is to try and keep the PCB to 10x10cm, unless some other PCB fab has a better deal than JLPCB.

Now, I've put the dimensions of your new board (15x10cm) into PCB shopper and JLPCB is still the cheapest at 20$ for 5, https://pcbshopper.com/


I do want to build one, but I'd like to know if and when you're going to update the current design to the new one?
Should I just wait for the new board or go ahead and buy the current version ?

sanni

I'm not planning to update the PCB on github any time soon so you can go ahead and build the current version.

pyroesp

I'm not planning to update the PCB on github any time soon so you can go ahead and build the current version.
All right, just bought the essentials for the SNES.
Some of the components from the BOM list are unavailable, but I found replacements pretty easily.

Hope nothing gets lost in transit from China.

sanni

Any additional suggestions?
First, you should make sure that the cart gets erased properly.
So you could, for example, add while(1); into the function void writeFlash_GB:

Quote
delay(100);
    println_Msg(F("Erasing flash"));
    display_Update();

    // Erase flash
    writeByte_GB(0x555, 0xaa);
    writeByte_GB(0x2aa, 0x55);
    writeByte_GB(0x555, 0x80);
    writeByte_GB(0x555, 0xaa);
    writeByte_GB(0x2aa, 0x55);
    writeByte_GB(0x555, 0x10);

    dataIn_GB();

    // Read the status register
    byte statusReg = readByte_GB(0);

    // After a completed erase D7 will output 1
    while ((statusReg & 0x80) != 0x80) {
      // Blink led
      PORTB ^= (1 << 4);
      delay(100);
      // Update Status
      statusReg = readByte_GB(0);
    }

    // Blankcheck
    println_Msg(F("Blankcheck"));
 display_Update();
to:

Quote
delay(100);
    println_Msg(F("Erasing flash"));
    display_Update();

    // Erase flash
    writeByte_GB(0x555, 0xaa);
    writeByte_GB(0x2aa, 0x55);
    writeByte_GB(0x555, 0x80);
    writeByte_GB(0x555, 0xaa);
    writeByte_GB(0x2aa, 0x55);
    writeByte_GB(0x555, 0x10);

    dataIn_GB();

    // Read the status register
    byte statusReg = readByte_GB(0);

    // After a completed erase D7 will output 1
    while ((statusReg & 0x80) != 0x80) {
      // Blink led
      PORTB ^= (1 << 4);
      delay(100);
      // Update Status
      statusReg = readByte_GB(0);
    }

    // Blankcheck
    println_Msg(F("Blankcheck"));
 display_Update();
    while(1);
The while(1); will make sure that after the erase nothing will be written to the cartridge. Then once "Blankcheck" is displayed you can switch the Cart Reader off and then on again and try to dump the cartridge and then check with a hex editor like HxD if the whole file you dumped consists out of 0xFF, meaning it erased fully.

If it did not erase then you need to change the code according to the datasheet of the used flashrom until it is erased.

If it is fully erased you can remove the while(1); again and write a rom to the cartridge, then dump the cartridge again and compare the dump in HxD to the file you wanted to write and see where exactly the writing failed.

Pirateiro_Digital

sanni, can I use this card reader to mount the cartreader?
https://pt.aliexpress.com/item/FREE-SHIPPING-1PCS-LOT-Reading-and-writing-module-SD-Card-Module-Slot-Socket-Reader/32262829840.html?spm=a2g0s.9042311.0.0.6acfb90aEdyPlI

Or can I use it directly from your tutorial without converting to SD?

I would like to save on these pcb.

sanni

Yes, you can use both directly:
https://www.aliexpress.com/item/FREE-SHIPPING-1PCS-LOT-Reading-and-writing-module-SD-Card-Module-Slot-Socket-Reader/32262829840.html
https://www.aliexpress.com/item/Micro-SD-card-mini-TF-card-reader-module-SPI-interfaces-with-level-converter-chip/1000001126725.html

Go Up