V1.7: Add repro entries to SNES menu

These two new entries just forward the user to the flashrom functions inside of flash.ino.     
I have only tested custom-made 29F033 repros using original SHVC-1J3M-20 and SHVC-1A3M-30 PCBs as shown here: https://github.com/sanni/cartreader/wiki/Reflashing-SNES-Repros
This commit is contained in:
sanni 2018-09-12 20:59:48 +02:00 committed by GitHub
parent 32f3cbfc59
commit b7c96ef0ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 156 additions and 111 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560 Cartridge Reader for Arduino Mega2560
Author: sanni Author: sanni
Date: 29-08-2018 Date: 12-09-2018
Version: 1.6 Version: 1.7
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306 LCD lib: https://github.com/adafruit/Adafruit_SSD1306
@ -35,7 +35,7 @@
infinest - help with GB Memory cart infinest - help with GB Memory cart
**********************************************************************************/ **********************************************************************************/
char ver[5] = "1.6"; char ver[5] = "1.7";
/****************************************** /******************************************
Define Starting Point Define Starting Point

View File

@ -13,6 +13,7 @@ unsigned long time;
unsigned long blank; unsigned long blank;
unsigned long sectorSize; unsigned long sectorSize;
byte bufferSize; byte bufferSize;
boolean hiROM = 1;
/****************************************** /******************************************
Menu Menu
@ -52,7 +53,7 @@ static const char epromMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsEprom[] PROGMEM = {epromMenuItem1, epromMenuItem2, epromMenuItem3, epromMenuItem4, epromMenuItem5}; static const char* const menuOptionsEprom[] PROGMEM = {epromMenuItem1, epromMenuItem2, epromMenuItem3, epromMenuItem4, epromMenuItem5};
void flashMenu() { void flashMenu() {
// create menu with title and 3 options to choose from // create menu with title and 4 options to choose from
unsigned char flashSlot; unsigned char flashSlot;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(menuOptionsFlash, 3); convertPgm(menuOptionsFlash, 3);
@ -64,7 +65,10 @@ void flashMenu() {
case 0: case 0:
display_Clear(); display_Clear();
display_Update(); display_Update();
hiROM = 1;
setup_Flash8(); setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8; mode = mode_FLASH8;
break; break;
@ -72,6 +76,8 @@ void flashMenu() {
display_Clear(); display_Clear();
display_Update(); display_Update();
setup_Flash16(); setup_Flash16();
id_Flash16();
wait();
mode = mode_FLASH16; mode = mode_FLASH16;
break; break;
@ -148,7 +154,7 @@ void flashromMenu8() {
writeFlash29F1601(); writeFlash29F1601();
else if ((strcmp(flashid, "C2F1") == 0) || (strcmp(flashid, "C2F9") == 0)) else if ((strcmp(flashid, "C2F1") == 0) || (strcmp(flashid, "C2F9") == 0))
writeFlash29F1610(); writeFlash29F1610();
else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0) || (strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0)) else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C249") == 0) || (strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0) || (strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0))
writeFlash29LV640(); writeFlash29LV640();
else if (strcmp(flashid, "017E") == 0) { else if (strcmp(flashid, "017E") == 0) {
// sector size, write buffer size // sector size, write buffer size
@ -268,7 +274,7 @@ void flashromMenu16() {
if (strcmp(flashid, "C2F3") == 0) { if (strcmp(flashid, "C2F3") == 0) {
writeFlash16_29F1601(); writeFlash16_29F1601();
} }
else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0) || (strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0)) { else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C249") == 0) || (strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0) || (strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0)) {
writeFlash16_29LV640(); writeFlash16_29LV640();
} }
else { else {
@ -379,29 +385,9 @@ void epromMenu() {
} }
/****************************************** /******************************************
Setup Flash IDs
*****************************************/ *****************************************/
void setup_Flash8() { void id_Flash8() {
// Set Address Pins to Output
//A0-A7
DDRF = 0xFF;
//A8-A15
DDRK = 0xFF;
//A16-A23
DDRL = 0xFF;
// Set Control Pins to Output RST(PH0) OE(PH1) BYTE(PH3) WE(PH4) WP(PH5) CE(PH6)
DDRH |= (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Setting RST(PH0) OE(PH1) WE(PH4) HIGH
PORTH |= (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5);
// Setting BYTE(PH3) and CE(PH6) LOW
PORTH &= ~((1 << 3) | (1 << 6));
// Set Data Pins (D0-D7) to Input
DDRC = 0x00;
// Disable Internal Pullups
PORTC = 0x00;
// ID flash // ID flash
idFlash29F032(); idFlash29F032();
@ -431,7 +417,7 @@ idtheflash:
flashSize = 4194304; flashSize = 4194304;
flashromType = 2; flashromType = 2;
} }
else if (strcmp(flashid, "C2C4") == 0) { else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C249") == 0)) {
println_Msg(F("MX29LV160 detected")); println_Msg(F("MX29LV160 detected"));
println_Msg(F("ATTENTION 3.3V")); println_Msg(F("ATTENTION 3.3V"));
flashSize = 2097152; flashSize = 2097152;
@ -514,7 +500,84 @@ idtheflash:
resetFlash29F032(); resetFlash29F032();
else else
resetFlash29F1610(); resetFlash29F1610();
wait(); }
void id_Flash16() {
// ID flash
idFlash16();
resetFlash16();
println_Msg(F("Flashrom Writer 16bit"));
println_Msg(" ");
print_Msg(F("Flash ID: "));
println_Msg(flashid);
if (strcmp(flashid, "C2F1") == 0) {
println_Msg(F("MX29F1610 detected"));
println_Msg(" ");
flashSize = 2097152;
flashromType = 2;
}
else if (strcmp(flashid, "C2F3") == 0) {
println_Msg(F("MX29F1601 detected"));
flashSize = 2097152;
flashromType = 2;
}
else if (strcmp(flashid, "C2F9") == 0) {
println_Msg(F("MX29L3211 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 4194304;
flashromType = 2;
}
else if ((strcmp(flashid, "C2C4") == 0) || (strcmp(flashid, "C249") == 0)) {
println_Msg(F("MX29LV160 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 2097152;
flashromType = 2;
}
else if ((strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0)) {
println_Msg(F("MX29LV320 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 4194304;
flashromType = 2;
}
else if ((strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0)) {
println_Msg(F("MX29LV640 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 8388608;
flashromType = 2;
}
else {
print_Error(F("Unknown flashrom"), true);
println_Msg(" ");
}
println_Msg(" ");
println_Msg(F("Press Button..."));
display_Update();
}
/******************************************
Setup
*****************************************/
void setup_Flash8() {
// Set Address Pins to Output
//A0-A7
DDRF = 0xFF;
//A8-A15
DDRK = 0xFF;
//A16-A23
DDRL = 0xFF;
// Set Control Pins to Output RST(PH0) OE(PH1) OE_SNS(PH3) WE(PH4) WE_SNS(PH5) CE(PH6)
DDRH |= (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Setting RST(PH0) OE(PH1) OE_SNS(PH3) WE(PH4) WE_SNS(PH5) HIGH
PORTH |= (1 << 0) | (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5);
// Setting CE(PH6) LOW
PORTH &= ~(1 << 6);
// Set Data Pins (D0-D7) to Input
DDRC = 0x00;
// Disable Internal Pullups
PORTC = 0x00;
} }
void setup_Flash16() { void setup_Flash16() {
@ -542,58 +605,6 @@ void setup_Flash16() {
PORTH &= ~(1 << 6); PORTH &= ~(1 << 6);
delay(100); delay(100);
// ID flash
idFlash16();
resetFlash16();
println_Msg(F("Flashrom Writer 16bit"));
println_Msg(" ");
print_Msg(F("Flash ID: "));
println_Msg(flashid);
if (strcmp(flashid, "C2F1") == 0) {
println_Msg(F("MX29F1610 detected"));
println_Msg(" ");
flashSize = 2097152;
flashromType = 2;
}
else if (strcmp(flashid, "C2F3") == 0) {
println_Msg(F("MX29F1601 detected"));
flashSize = 2097152;
flashromType = 2;
}
else if (strcmp(flashid, "C2F9") == 0) {
println_Msg(F("MX29L3211 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 4194304;
flashromType = 2;
}
else if (strcmp(flashid, "C2C4") == 0) {
println_Msg(F("MX29LV160 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 2097152;
flashromType = 2;
}
else if ((strcmp(flashid, "C2A7") == 0) || (strcmp(flashid, "C2A8") == 0)) {
println_Msg(F("MX29LV320 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 4194304;
flashromType = 2;
}
else if ((strcmp(flashid, "C2C9") == 0) || (strcmp(flashid, "C2CB") == 0)) {
println_Msg(F("MX29LV640 detected"));
println_Msg(F("ATTENTION 3.3V"));
flashSize = 8388608;
flashromType = 2;
}
else {
print_Error(F("Unknown flashrom"), true);
println_Msg(" ");
}
println_Msg(" ");
println_Msg(F("Press Button..."));
display_Update();
wait();
} }
void setup_Eprom() { void setup_Eprom() {
@ -661,46 +672,58 @@ void dataIn16() {
*****************************************/ *****************************************/
void writeByte_Flash(unsigned long myAddress, byte myData) { void writeByte_Flash(unsigned long myAddress, byte myData) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
if (hiROM) {
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
}
else {
PORTK = (myAddress >> 8) & 0x7F;
PORTL = (myAddress >> 15) & 0xFF;
}
PORTC = myData; PORTC = myData;
// Arduino running at 16Mhz -> one nop = 62.5ns // Arduino running at 16Mhz -> one nop = 62.5ns
// Wait till output is stable // Wait till output is stable
__asm__("nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Switch WE(PH4) to LOW // Switch WE(PH4) WE_SNS(PH5) to LOW
PORTH &= ~(1 << 4); PORTH &= ~((1 << 4) | (1 << 5));
// Leave WE low for at least 60ns // Leave WE low for at least 60ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Switch WE(PH4) to HIGH // Switch WE(PH4) WE_SNS(PH5) to HIGH
PORTH |= (1 << 4); PORTH |= (1 << 4) | (1 << 5);
// Leave WE high for at least 50ns // Leave WE high for at least 50ns
__asm__("nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
} }
byte readByte_Flash(unsigned long myAddress) { byte readByte_Flash(unsigned long myAddress) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
if (hiROM) {
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
}
else {
PORTK = (myAddress >> 8) & 0x7F;
PORTL = (myAddress >> 15) & 0xFF;
}
// Arduino running at 16Mhz -> one nop = 62.5ns // Arduino running at 16Mhz -> one nop = 62.5ns
__asm__("nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Setting OE(PH1) LOW // Setting OE(PH1) OE_SNS(PH3) LOW
PORTH &= ~(1 << 1); PORTH &= ~((1 << 1) | (1 << 3));
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
// Read // Read
byte tempByte = PINC; byte tempByte = PINC;
// Setting OE(PH1) HIGH // Setting OE(PH1) OE_SNS(PH3) HIGH
PORTH |= (1 << 1); PORTH |= (1 << 1) | (1 << 3);
__asm__("nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
return tempByte; return tempByte;
} }
@ -867,8 +890,8 @@ void busyCheck29F032(byte c) {
// Setting OE(PH1) CE(PH6)LOW // Setting OE(PH1) CE(PH6)LOW
PORTH &= ~((1 << 1) | (1 << 6)); PORTH &= ~((1 << 1) | (1 << 6));
// Setting WE(PH4) HIGH // Setting WE(PH4) WE_SNES HIGH
PORTH |= (1 << 4); PORTH |= (1 << 4) | (1 << 5);
//When the Embedded Program algorithm is complete, the device outputs the datum programmed to D7 //When the Embedded Program algorithm is complete, the device outputs the datum programmed to D7
while ((PINC & 0x80) != (c & 0x80)) {} while ((PINC & 0x80) != (c & 0x80)) {}

View File

@ -16,7 +16,7 @@ uint16_t sramEndAddress = 0;
// GBx start menu // GBx start menu
static const char gbxMenuItem1[] PROGMEM = "Game Boy (Color)"; static const char gbxMenuItem1[] PROGMEM = "Game Boy (Color)";
static const char gbxMenuItem2[] PROGMEM = "Game Boy Advance"; static const char gbxMenuItem2[] PROGMEM = "Game Boy Advance";
static const char gbxMenuItem3[] PROGMEM = "NintPower GB Memory"; static const char gbxMenuItem3[] PROGMEM = "NPower GB Memory";
static const char* const menuOptionsGBx[] PROGMEM = {gbxMenuItem1, gbxMenuItem2, gbxMenuItem3}; static const char* const menuOptionsGBx[] PROGMEM = {gbxMenuItem1, gbxMenuItem2, gbxMenuItem3};
// GB menu items // GB menu items

View File

@ -28,9 +28,11 @@ byte cx4Map = 0;
Menu Menu
*****************************************/ *****************************************/
// SNES/Nintendo Power SF Memory start menu // SNES/Nintendo Power SF Memory start menu
static const char snsMenuItem1[] PROGMEM = "SNES SFC"; static const char snsMenuItem1[] PROGMEM = "Super Nintendo";
static const char snsMenuItem2[] PROGMEM = "NintPower SF Memory"; static const char snsMenuItem2[] PROGMEM = "NPower SF Memory";
static const char* const menuOptionsSNS[] PROGMEM = {snsMenuItem1, snsMenuItem2}; static const char snsMenuItem3[] PROGMEM = "HiROM repro";
static const char snsMenuItem4[] PROGMEM = "LoROM repro";
static const char* const menuOptionsSNS[] PROGMEM = {snsMenuItem1, snsMenuItem2, snsMenuItem3, snsMenuItem4};
// SNES menu items // SNES menu items
static const char SnesMenuItem1[] PROGMEM = "Read Rom"; static const char SnesMenuItem1[] PROGMEM = "Read Rom";
@ -51,11 +53,11 @@ static const char* const menuOptionsConf[] PROGMEM = {confMenuItem1, confMenuIte
// SNES start menu // SNES start menu
void snsMenu() { void snsMenu() {
// create menu with title and 2 options to choose from // create menu with title and 4 options to choose from
unsigned char snsCart; unsigned char snsCart;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(menuOptionsSNS, 2); convertPgm(menuOptionsSNS, 4);
snsCart = question_box("Select Cart Type", menuOptions, 2, 0); snsCart = question_box("Select Cart Type", menuOptions, 4, 0);
// wait for user choice to come back from the question box menu // wait for user choice to come back from the question box menu
switch (snsCart) switch (snsCart)
@ -73,6 +75,26 @@ void snsMenu() {
setup_SFM(); setup_SFM();
mode = mode_SFM; mode = mode_SFM;
break; break;
case 2:
display_Clear();
display_Update();
hiROM = 1;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
case 3:
display_Clear();
display_Update();
hiROM = 0;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
} }
} }