diff --git a/source/arm9/dev.c b/source/arm9/dev.c index aab513a..cbf01bc 100644 --- a/source/arm9/dev.c +++ b/source/arm9/dev.c @@ -148,7 +148,7 @@ // thanks yellows8 *((vu16*)0x10000020) = (*((vu16*)0x10000020) & ~0x1u) | 0x200u; - u32 timeout = 4; // In ms. 2 works. 4 for safety. + u32 timeout = 34; // In ms. 33 works. 34 for safety. do { // if sd card is ready, stop polling diff --git a/source/arm9/hardware/sdmmc.c b/source/arm9/hardware/sdmmc.c index 48c6f96..70c09be 100644 --- a/source/arm9/hardware/sdmmc.c +++ b/source/arm9/hardware/sdmmc.c @@ -23,18 +23,10 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include - #include "types.h" #include "util.h" #include "arm9/dev.h" +#include "arm9/hardware/timer.h" #include "arm9/hardware/sdmmc.h" #define DATA32_SUPPORT @@ -359,7 +351,7 @@ handleNAND.SDOPT = 0; handleNAND.res = 0; handleNAND.initarg = 1; - handleNAND.clk = 0x10; // ~523 KHz + handleNAND.clk = 0x20; // ~261 KHz handleNAND.devicenumber = 1; //SD @@ -397,10 +389,10 @@ *(volatile uint16_t*)0x10006002 &= 0xFFFCu; //SDPORTSEL #ifdef DATA32_SUPPORT *(volatile uint16_t*)0x10006024 = 0x20; - *(volatile uint16_t*)0x10006028 = 0x40E0; + *(volatile uint16_t*)0x10006028 = 0x40EB; #else *(volatile uint16_t*)0x10006024 = 0x40; //Nintendo sets this to 0x20 - *(volatile uint16_t*)0x10006028 = 0x40E0; //Nintendo sets this to 0x40EE + *(volatile uint16_t*)0x10006028 = 0x40EB; //Nintendo sets this to 0x40EE #endif *(volatile uint16_t*)0x10006002 &= 0xFFFCu; ////SDPORTSEL *(volatile uint16_t*)0x10006026 = 512; //SDBLKLEN @@ -409,8 +401,8 @@ int Nand_Init() { + // The eMMC is always on. Nothing special to do. set_target(&handleNAND); - wait(0xF000); sdmmc_send_command(&handleNAND,0,0); @@ -460,9 +452,10 @@ int SD_Init() { + // We need to send at least 74 clock pulses. + // This is roughly 261 pulses at 261 KHz. set_target(&handleSD); - - wait(0xF000); + TIMER_sleep(1); sdmmc_send_command(&handleSD,0,0); sdmmc_send_command(&handleSD,0x10408,0x1AA);