Add more checks, make the emuNAND SD check only occur when emuNAND is being booted
This commit is contained in:
parent
ecd27f7eaa
commit
bc1aa15dd7
@ -28,6 +28,7 @@
|
||||
* Code for locating the SDMMC struct by Normmatt
|
||||
*/
|
||||
|
||||
|
||||
#include "emunand.h"
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
@ -35,7 +36,7 @@
|
||||
#include "../build/bundled.h"
|
||||
|
||||
u32 emuOffset,
|
||||
emuHeader = 0;
|
||||
emuHeader;
|
||||
|
||||
void locateEmuNand(FirmwareSource *nandType)
|
||||
{
|
||||
@ -77,6 +78,7 @@ void locateEmuNand(FirmwareSource *nandType)
|
||||
{
|
||||
emuOffset = nandOffset + 1;
|
||||
emuHeader = nandOffset + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
//Check for Gateway EmuNAND
|
||||
@ -84,14 +86,6 @@ void locateEmuNand(FirmwareSource *nandType)
|
||||
{
|
||||
emuOffset = nandOffset;
|
||||
emuHeader = nandOffset + nandSize;
|
||||
}
|
||||
|
||||
if(emuHeader != 0)
|
||||
{
|
||||
//Make sure the SD card isn't write protected
|
||||
if((*(vu16 *)(SDMMC_BASE + REG_SDSTATUS0) & TMIO_STAT0_WRPROTECT) == 0)
|
||||
error("The SD card is locked, EmuNAND can not be used.\nPlease turn the write protection switch off.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
15
source/fs.c
15
source/fs.c
@ -66,6 +66,7 @@ bool mountFs(bool isSd, bool switchToCtrNand)
|
||||
u32 fileRead(void *dest, const char *path, u32 maxSize)
|
||||
{
|
||||
FIL file;
|
||||
FRESULT result = FR_OK;
|
||||
u32 ret = 0;
|
||||
|
||||
if(f_open(&file, path, FA_READ) != FR_OK) return ret;
|
||||
@ -73,10 +74,10 @@ u32 fileRead(void *dest, const char *path, u32 maxSize)
|
||||
u32 size = f_size(&file);
|
||||
if(dest == NULL) ret = size;
|
||||
else if(size <= maxSize)
|
||||
f_read(&file, dest, size, (unsigned int *)&ret);
|
||||
f_close(&file);
|
||||
result = f_read(&file, dest, size, (unsigned int *)&ret);
|
||||
result |= f_close(&file);
|
||||
|
||||
return ret;
|
||||
return result == FR_OK ? ret : 0;
|
||||
}
|
||||
|
||||
u32 getFileSize(const char *path)
|
||||
@ -181,9 +182,7 @@ bool payloadMenu(char *path)
|
||||
payloadNum++;
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
if(!payloadNum) return false;
|
||||
if(f_closedir(&dir) != FR_OK || !payloadNum) return false;
|
||||
|
||||
u32 pressed = 0,
|
||||
selectedPayload = 0;
|
||||
@ -281,9 +280,7 @@ u32 firmRead(void *dest, u32 firmType)
|
||||
if(tempVersion < firmVersion) firmVersion = tempVersion;
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
if(firmVersion == 0xFFFFFFFF) goto exit;
|
||||
if(f_closedir(&dir) != FR_OK || firmVersion == 0xFFFFFFFF) goto exit;
|
||||
|
||||
//Complete the string with the .app name
|
||||
sprintf(path, "%s/%08x.app", folderPath, firmVersion);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "crypto.h"
|
||||
#include "memory.h"
|
||||
#include "screen.h"
|
||||
#include "fatfs/sdmmc/sdmmc.h"
|
||||
|
||||
extern CfgData configData;
|
||||
extern ConfigurationStatus needConfig;
|
||||
@ -306,6 +307,8 @@ boot:
|
||||
{
|
||||
locateEmuNand(&nandType);
|
||||
if(nandType == FIRMWARE_SYSNAND) firmSource = FIRMWARE_SYSNAND;
|
||||
else if((*(vu16 *)(SDMMC_BASE + REG_SDSTATUS0) & TMIO_STAT0_WRPROTECT) == 0) //Make sure the SD card isn't write protected
|
||||
error("The SD card is locked, EmuNAND can not be used.\nPlease turn the write protection switch off.");
|
||||
}
|
||||
|
||||
//Same if we're using EmuNAND as the FIRM source
|
||||
|
Reference in New Issue
Block a user