From c3979128da59ab3da1613e70e9abbceea1b39096 Mon Sep 17 00:00:00 2001 From: Kitlith Date: Sat, 12 Aug 2017 14:24:04 -0700 Subject: [PATCH] Add additional delays to properly initialize carts. Fixes detection issues for multiple carts. Thanks profi200, for noticing that the delays were a bit low. --- ntrboot_flasher/source/gamecart/protocol.cpp | 20 ++++++++++---------- ntrboot_flasher/source/gamecart/protocol.h | 3 +++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ntrboot_flasher/source/gamecart/protocol.cpp b/ntrboot_flasher/source/gamecart/protocol.cpp index 92e8636..65ffa5f 100644 --- a/ntrboot_flasher/source/gamecart/protocol.cpp +++ b/ntrboot_flasher/source/gamecart/protocol.cpp @@ -33,14 +33,11 @@ void ResetCartSlot(void) REG_CARDCONF2 = 0x8; while(REG_CARDCONF2 != 0x8); - ioDelay(0xF000); - - REG_NTRCARDROMCNT = 0x20000000; - REG_CARDCONF &= ~3; - REG_CARDCONF &= ~0x100; - REG_NTRCARDMCNTH = NTRCARD_CR1_ENABLE; - - ioDelay(0xF000); + // ioDelay(0xF000); + // + // SwitchToNTRCARD(); + // + // ioDelay(0xF000); } void SwitchToNTRCARD(void) @@ -55,8 +52,11 @@ void Cart_NTRInit(void) { ResetCartSlot(); //Seems to reset the cart slot? - //SwitchToNTRCARD(); - //ioDelay(0x30000); + REG_CTRCARDSECCNT &= 0xFFFFFFFB; + ioDelay(0x40000); + + SwitchToNTRCARD(); + ioDelay(0x40000); //REG_CTRCARDCNT |= 0x10000000u; //REG_CTRCARDCNT2 |= 0x10000000u; diff --git a/ntrboot_flasher/source/gamecart/protocol.h b/ntrboot_flasher/source/gamecart/protocol.h index ee96d32..8345d11 100644 --- a/ntrboot_flasher/source/gamecart/protocol.h +++ b/ntrboot_flasher/source/gamecart/protocol.h @@ -14,6 +14,9 @@ #define CARD_SPI_BUSY (1<<7) #define CARD_SPI_HOLD (1<<6) +// for CTRCARD, but GM9 uses it in NTRCARD init. +#define REG_CTRCARDSECCNT (*(vu32*)0x10004008) + #define LATENCY 0x822C void Cart_NTRInit(void);