mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Actually check if SD card is inserted when mounting
This commit is contained in:
parent
a7853e1cd9
commit
80e96f5815
@ -105,7 +105,8 @@ DSTATUS disk_initialize (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (pdrv == 0) { // a mounted SD card is the preriquisite for everything else
|
if (pdrv == 0) { // a mounted SD card is the preriquisite for everything else
|
||||||
sdmmc_sdcard_init();
|
if (!sdmmc_sdcard_init())
|
||||||
|
return RES_PARERR;
|
||||||
} else if (pdrv < 4) {
|
} else if (pdrv < 4) {
|
||||||
nand_type_sys = CheckNandType(false);
|
nand_type_sys = CheckNandType(false);
|
||||||
} else if (pdrv < 7) {
|
} else if (pdrv < 7) {
|
||||||
|
@ -30,6 +30,8 @@ bool InitSDCardFS() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool InitNandFS() {
|
bool InitNandFS() {
|
||||||
|
if (!fs_mounted[0])
|
||||||
|
return false;
|
||||||
for (u32 i = 1; i < MAX_FS; i++) {
|
for (u32 i = 1; i < MAX_FS; i++) {
|
||||||
char fsname[8];
|
char fsname[8];
|
||||||
snprintf(fsname, 7, "%lu:", i);
|
snprintf(fsname, 7, "%lu:", i);
|
||||||
|
@ -142,9 +142,9 @@ u32 GodMode() {
|
|||||||
u32 scroll = 0;
|
u32 scroll = 0;
|
||||||
|
|
||||||
ClearScreenF(true, true, COLOR_STD_BG);
|
ClearScreenF(true, true, COLOR_STD_BG);
|
||||||
if (!InitSDCardFS()) {
|
while (!InitSDCardFS()) {
|
||||||
ShowPrompt(false, "Initialising SD card failed!");
|
if (!ShowPrompt(true, "Initialising SD card failed! Retry?"))
|
||||||
return exit_mode;
|
return exit_mode;
|
||||||
}
|
}
|
||||||
InitNandCrypto();
|
InitNandCrypto();
|
||||||
InitNandFS();
|
InitNandFS();
|
||||||
@ -189,9 +189,9 @@ u32 GodMode() {
|
|||||||
} else if (pad_state & BUTTON_B) { // unmount SD card
|
} else if (pad_state & BUTTON_B) { // unmount SD card
|
||||||
DeinitFS();
|
DeinitFS();
|
||||||
ShowPrompt(false, "SD card unmounted, you can eject now.\nPut it back in before you press <A>.");
|
ShowPrompt(false, "SD card unmounted, you can eject now.\nPut it back in before you press <A>.");
|
||||||
if (!InitSDCardFS()) {
|
while (!InitSDCardFS()) {
|
||||||
ShowPrompt(false, "Reinitialising SD card failed!");
|
if (!ShowPrompt(true, "Reinitialising SD card failed! Retry?"))
|
||||||
return exit_mode;
|
return exit_mode;
|
||||||
}
|
}
|
||||||
InitNandFS();
|
InitNandFS();
|
||||||
GetDirContents(current_dir, current_path);
|
GetDirContents(current_dir, current_path);
|
||||||
|
@ -512,7 +512,11 @@ int SD_Init()
|
|||||||
{
|
{
|
||||||
inittarget(&handelSD);
|
inittarget(&handelSD);
|
||||||
//waitcycles(0x3E8);
|
//waitcycles(0x3E8);
|
||||||
waitcycles(0xF000);
|
//waitcycles(0xF000);
|
||||||
|
|
||||||
|
waitcycles(1u << 19); //Card needs a little bit of time to be detected, it seems
|
||||||
|
if (!(*((volatile uint16_t*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1; // check if card inserted
|
||||||
|
|
||||||
DEBUGPRINT(topScreen, "0x00000 ", handelSD.error, 10, 20 + 14*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
DEBUGPRINT(topScreen, "0x00000 ", handelSD.error, 10, 20 + 14*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
||||||
sdmmc_send_command(&handelSD,0,0);
|
sdmmc_send_command(&handelSD,0,0);
|
||||||
DEBUGPRINT(topScreen, "0x10408 ", handelSD.error, 10, 20 + 14*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
DEBUGPRINT(topScreen, "0x10408 ", handelSD.error, 10, 20 + 14*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
||||||
@ -607,7 +611,7 @@ int SD_Init()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdmmc_sdcard_init()
|
int sdmmc_sdcard_init()
|
||||||
{
|
{
|
||||||
DEBUGPRINT(topScreen, "sdmmc_sdcard_init ", handelSD.error, 10, 20 + 2*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
DEBUGPRINT(topScreen, "sdmmc_sdcard_init ", handelSD.error, 10, 20 + 2*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
||||||
InitSD();
|
InitSD();
|
||||||
@ -615,8 +619,10 @@ void sdmmc_sdcard_init()
|
|||||||
//Nand_Init();
|
//Nand_Init();
|
||||||
Nand_Init();
|
Nand_Init();
|
||||||
DEBUGPRINT(topScreen, "nand_res ", nand_res, 10, 20 + 3*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
DEBUGPRINT(topScreen, "nand_res ", nand_res, 10, 20 + 3*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
||||||
SD_Init();
|
if (SD_Init() != 0) return FALSE;
|
||||||
DEBUGPRINT(topScreen, "sd_res ", sd_res, 10, 20 + 4*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
DEBUGPRINT(topScreen, "sd_res ", sd_res, 10, 20 + 4*8, RGB(40, 40, 40), RGB(208, 208, 208));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sdmmc_get_cid( int isNand, uint32_t *info)
|
int sdmmc_get_cid( int isNand, uint32_t *info)
|
||||||
|
@ -122,7 +122,7 @@ extern "C" {
|
|||||||
uint32_t res;
|
uint32_t res;
|
||||||
} mmcdevice;
|
} mmcdevice;
|
||||||
|
|
||||||
void sdmmc_sdcard_init();
|
int sdmmc_sdcard_init();
|
||||||
int sdmmc_sdcard_readsector(uint32_t sector_no, uint8_t *out);
|
int sdmmc_sdcard_readsector(uint32_t sector_no, uint8_t *out);
|
||||||
int sdmmc_sdcard_readsectors(uint32_t sector_no, uint32_t numsectors, uint8_t *out);
|
int sdmmc_sdcard_readsectors(uint32_t sector_no, uint32_t numsectors, uint8_t *out);
|
||||||
int sdmmc_sdcard_writesector(uint32_t sector_no, uint8_t *in);
|
int sdmmc_sdcard_writesector(uint32_t sector_no, uint8_t *in);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user