Error if emuNAND is booted while the SD card is write protected

This commit is contained in:
Hikari-chin 2017-08-27 16:20:17 -04:00
parent 33436ae2a6
commit 2a6a655804
2 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include "crypto.h"
#include "memory.h"
#include "screen.h"
#include "fatfs/sdmmc/sdmmc.h"
extern CfgData configData;
extern ConfigurationStatus needConfig;
@ -308,6 +309,12 @@ boot:
if(nandType == FIRMWARE_SYSNAND) firmSource = FIRMWARE_SYSNAND;
}
//If we're using EmuNAND, make sure the SD card isn't write protected
if(nandType != FIRMWARE_SYSNAND && (*(vu16*)(SDMMC_BASE + REG_SDSTATUS0) & TMIO_STAT0_WRPROTECT) == 0)
{
error("The SD card is locked, EmuNAND can not be used.\n\nPlease turn the write protection switch off.");
}
//Same if we're using EmuNAND as the FIRM source
else if(firmSource != FIRMWARE_SYSNAND)
locateEmuNand(&firmSource);

View File

@ -109,6 +109,9 @@ void mcuPowerOff(void)
//Ensure that all memory transfers have completed and that the data cache has been flushed
flushEntireDCache();
//Deinitialize the screens
deinitScreens();
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
while(true);
}