mirror of
https://github.com/LumaTeam/Luma3DS.git
synced 2026-02-22 01:44:38 +00:00
Revert some recent change wrt. remounting due to driver issues
This commit is contained in:
parent
97418ca9a1
commit
b20c79eda4
@ -40,11 +40,27 @@ DSTATUS disk_initialize (
|
||||
)
|
||||
{
|
||||
static u32 sdmmcInitResult = 4;
|
||||
DSTATUS res = 0;
|
||||
|
||||
if(sdmmcInitResult == 4) sdmmcInitResult = sdmmc_sdcard_init();
|
||||
if(sdmmcInitResult == 4)
|
||||
sdmmcInitResult = sdmmc_sdcard_init();
|
||||
|
||||
return ((pdrv == SDCARD && !(sdmmcInitResult & 2)) ||
|
||||
(pdrv == CTRNAND && !(sdmmcInitResult & 1) && !ctrNandInit())) ? 0 : STA_NOINIT;
|
||||
// Check physical drive initialized status
|
||||
switch (pdrv)
|
||||
{
|
||||
case SDCARD:
|
||||
res = (sdmmcInitResult & 2) == 0 ? 0 : STA_NOINIT;
|
||||
break;
|
||||
case CTRNAND:
|
||||
// Always update CTRNAND parameters when remounting
|
||||
res = (sdmmcInitResult & 1) == 0 && ctrNandInit() == 0 ? 0 : STA_NOINIT;
|
||||
break;
|
||||
default:
|
||||
res = STA_NODISK;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -60,8 +76,22 @@ DRESULT disk_read (
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
return ((pdrv == SDCARD && !sdmmc_sdcard_readsectors(sector, count, buff)) ||
|
||||
(pdrv == CTRNAND && !ctrNandRead(sector, count, buff))) ? RES_OK : RES_PARERR;
|
||||
DRESULT res = RES_OK;
|
||||
|
||||
switch (pdrv)
|
||||
{
|
||||
case SDCARD:
|
||||
res = sdmmc_sdcard_readsectors(sector, count, buff) == 0 ? RES_OK : RES_PARERR;
|
||||
break;
|
||||
case CTRNAND:
|
||||
res = ctrNandRead(sector, count, buff) == 0 ? RES_OK : RES_PARERR;
|
||||
break;
|
||||
default:
|
||||
res = RES_NOTRDY;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +109,27 @@ DRESULT disk_write (
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
return ((pdrv == SDCARD && (*(vu16 *)(SDMMC_BASE + REG_SDSTATUS0) & TMIO_STAT0_WRPROTECT) != 0 && !sdmmc_sdcard_writesectors(sector, count, buff)) ||
|
||||
(pdrv == CTRNAND && !ctrNandWrite(sector, count, buff))) ? RES_OK : RES_PARERR;
|
||||
DRESULT res = RES_OK;
|
||||
|
||||
switch (pdrv)
|
||||
{
|
||||
case SDCARD:
|
||||
{
|
||||
if ((*(vu16 *)(SDMMC_BASE + REG_SDSTATUS0) & TMIO_STAT0_WRPROTECT) == 0) // why == 0?
|
||||
res = RES_WRPRT;
|
||||
else
|
||||
res = sdmmc_sdcard_writesectors(sector, count, buff) == 0 ? RES_OK : RES_PARERR;
|
||||
break;
|
||||
}
|
||||
case CTRNAND:
|
||||
res = ctrNandWrite(sector, count, buff) == 0 ? RES_OK : RES_PARERR;
|
||||
break;
|
||||
default:
|
||||
res = RES_NOTRDY;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -72,16 +72,34 @@ bool mountSdCardPartition(bool switchMainDir)
|
||||
bool remountCtrNandPartition(bool switchMainDir)
|
||||
{
|
||||
static bool nandInitialized = false;
|
||||
int res = FR_OK;
|
||||
|
||||
#if 0
|
||||
Unfortunately the sdmmc driver is really flaky and returns TMIO_STAT_CMD_RESPEND as error.
|
||||
(after timing out)
|
||||
TODO: fix all this tech debt... one day, maybe?
|
||||
|
||||
if (nandInitialized)
|
||||
{
|
||||
if (f_unmount("nand:") != FR_OK)
|
||||
res = f_unmount("nand:");
|
||||
if (res != FR_OK)
|
||||
{
|
||||
error("f_unmount returned %d", res);
|
||||
return false;
|
||||
}
|
||||
nandInitialized = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!nandInitialized)
|
||||
nandInitialized = f_mount(&nandFs, "nand:", 1) == FR_OK;
|
||||
{
|
||||
res = f_mount(&nandFs, "nand:", 1);
|
||||
nandInitialized = res == FR_OK;
|
||||
if (res != FR_OK)
|
||||
{
|
||||
error("f_mount returned %d", res);
|
||||
}
|
||||
}
|
||||
|
||||
if (nandInitialized && switchMainDir)
|
||||
return f_chdrive("nand:") == FR_OK && switchToMainDir(false);
|
||||
@ -475,16 +493,27 @@ bool doLumaUpgradeProcess(void)
|
||||
FirmwareSource oldCtrNandLocation = ctrNandLocation;
|
||||
bool ok = true, ok2 = true, ok3 = true;
|
||||
|
||||
#if 0
|
||||
Unfortunately the sdmmc driver is really flaky and returns TMIO_STAT_CMD_RESPEND as error.
|
||||
(after timing out)
|
||||
TODO: fix all this tech debt... one day, maybe?
|
||||
|
||||
// Ensure SysNAND CTRNAND is mounted
|
||||
if (isSdMode)
|
||||
{
|
||||
ctrNandLocation = FIRMWARE_SYSNAND;
|
||||
if (!remountCtrNandPartition(false))
|
||||
{
|
||||
error("failed to mount");
|
||||
ctrNandLocation = oldCtrNandLocation;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)oldCtrNandLocation;
|
||||
// Ensure CTRNAND is mounted
|
||||
remountCtrNandPartition(false);
|
||||
#endif
|
||||
|
||||
// Try to boot.firm to CTRNAND, when applicable
|
||||
if (isSdMode && memcmp(launchedPathForFatfs, "sdmc:", 5) == 0)
|
||||
@ -497,10 +526,17 @@ bool doLumaUpgradeProcess(void)
|
||||
fileDelete("sdmc:/luma/config.bin");
|
||||
fileDelete("nand:/rw/luma/config.bin");
|
||||
|
||||
#if 0
|
||||
if (isSdMode)
|
||||
{
|
||||
ctrNandLocation = oldCtrNandLocation;
|
||||
ok3 = remountCtrNandPartition(false);
|
||||
if (!ok3)
|
||||
error("failed to unmount");
|
||||
}
|
||||
#else
|
||||
(void)ok3;
|
||||
#endif
|
||||
|
||||
return ok && ok2 && ok3;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user