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;
|
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)) ||
|
// Check physical drive initialized status
|
||||||
(pdrv == CTRNAND && !(sdmmcInitResult & 1) && !ctrNandInit())) ? 0 : STA_NOINIT;
|
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 */
|
UINT count /* Number of sectors to read */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return ((pdrv == SDCARD && !sdmmc_sdcard_readsectors(sector, count, buff)) ||
|
DRESULT res = RES_OK;
|
||||||
(pdrv == CTRNAND && !ctrNandRead(sector, count, buff))) ? RES_OK : RES_PARERR;
|
|
||||||
|
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 */
|
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)) ||
|
DRESULT res = RES_OK;
|
||||||
(pdrv == CTRNAND && !ctrNandWrite(sector, count, buff))) ? RES_OK : RES_PARERR;
|
|
||||||
|
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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -72,16 +72,34 @@ bool mountSdCardPartition(bool switchMainDir)
|
|||||||
bool remountCtrNandPartition(bool switchMainDir)
|
bool remountCtrNandPartition(bool switchMainDir)
|
||||||
{
|
{
|
||||||
static bool nandInitialized = false;
|
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 (nandInitialized)
|
||||||
{
|
{
|
||||||
if (f_unmount("nand:") != FR_OK)
|
res = f_unmount("nand:");
|
||||||
|
if (res != FR_OK)
|
||||||
|
{
|
||||||
|
error("f_unmount returned %d", res);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
nandInitialized = false;
|
nandInitialized = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!nandInitialized)
|
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)
|
if (nandInitialized && switchMainDir)
|
||||||
return f_chdrive("nand:") == FR_OK && switchToMainDir(false);
|
return f_chdrive("nand:") == FR_OK && switchToMainDir(false);
|
||||||
@ -475,16 +493,27 @@ bool doLumaUpgradeProcess(void)
|
|||||||
FirmwareSource oldCtrNandLocation = ctrNandLocation;
|
FirmwareSource oldCtrNandLocation = ctrNandLocation;
|
||||||
bool ok = true, ok2 = true, ok3 = true;
|
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
|
// Ensure SysNAND CTRNAND is mounted
|
||||||
if (isSdMode)
|
if (isSdMode)
|
||||||
{
|
{
|
||||||
ctrNandLocation = FIRMWARE_SYSNAND;
|
ctrNandLocation = FIRMWARE_SYSNAND;
|
||||||
if (!remountCtrNandPartition(false))
|
if (!remountCtrNandPartition(false))
|
||||||
{
|
{
|
||||||
|
error("failed to mount");
|
||||||
ctrNandLocation = oldCtrNandLocation;
|
ctrNandLocation = oldCtrNandLocation;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)oldCtrNandLocation;
|
||||||
|
// Ensure CTRNAND is mounted
|
||||||
|
remountCtrNandPartition(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Try to boot.firm to CTRNAND, when applicable
|
// Try to boot.firm to CTRNAND, when applicable
|
||||||
if (isSdMode && memcmp(launchedPathForFatfs, "sdmc:", 5) == 0)
|
if (isSdMode && memcmp(launchedPathForFatfs, "sdmc:", 5) == 0)
|
||||||
@ -497,10 +526,17 @@ bool doLumaUpgradeProcess(void)
|
|||||||
fileDelete("sdmc:/luma/config.bin");
|
fileDelete("sdmc:/luma/config.bin");
|
||||||
fileDelete("nand:/rw/luma/config.bin");
|
fileDelete("nand:/rw/luma/config.bin");
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (isSdMode)
|
if (isSdMode)
|
||||||
{
|
{
|
||||||
ctrNandLocation = oldCtrNandLocation;
|
ctrNandLocation = oldCtrNandLocation;
|
||||||
ok3 = remountCtrNandPartition(false);
|
ok3 = remountCtrNandPartition(false);
|
||||||
|
if (!ok3)
|
||||||
|
error("failed to unmount");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)ok3;
|
||||||
|
#endif
|
||||||
|
|
||||||
return ok && ok2 && ok3;
|
return ok && ok2 && ok3;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user