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
|
* Code for locating the SDMMC struct by Normmatt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "emunand.h"
|
#include "emunand.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -35,7 +36,7 @@
|
|||||||
#include "../build/bundled.h"
|
#include "../build/bundled.h"
|
||||||
|
|
||||||
u32 emuOffset,
|
u32 emuOffset,
|
||||||
emuHeader = 0;
|
emuHeader;
|
||||||
|
|
||||||
void locateEmuNand(FirmwareSource *nandType)
|
void locateEmuNand(FirmwareSource *nandType)
|
||||||
{
|
{
|
||||||
@ -77,6 +78,7 @@ void locateEmuNand(FirmwareSource *nandType)
|
|||||||
{
|
{
|
||||||
emuOffset = nandOffset + 1;
|
emuOffset = nandOffset + 1;
|
||||||
emuHeader = nandOffset + 1;
|
emuHeader = nandOffset + 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for Gateway EmuNAND
|
//Check for Gateway EmuNAND
|
||||||
@ -84,14 +86,6 @@ void locateEmuNand(FirmwareSource *nandType)
|
|||||||
{
|
{
|
||||||
emuOffset = nandOffset;
|
emuOffset = nandOffset;
|
||||||
emuHeader = nandOffset + nandSize;
|
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;
|
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)
|
u32 fileRead(void *dest, const char *path, u32 maxSize)
|
||||||
{
|
{
|
||||||
FIL file;
|
FIL file;
|
||||||
|
FRESULT result = FR_OK;
|
||||||
u32 ret = 0;
|
u32 ret = 0;
|
||||||
|
|
||||||
if(f_open(&file, path, FA_READ) != FR_OK) return ret;
|
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);
|
u32 size = f_size(&file);
|
||||||
if(dest == NULL) ret = size;
|
if(dest == NULL) ret = size;
|
||||||
else if(size <= maxSize)
|
else if(size <= maxSize)
|
||||||
f_read(&file, dest, size, (unsigned int *)&ret);
|
result = f_read(&file, dest, size, (unsigned int *)&ret);
|
||||||
f_close(&file);
|
result |= f_close(&file);
|
||||||
|
|
||||||
return ret;
|
return result == FR_OK ? ret : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getFileSize(const char *path)
|
u32 getFileSize(const char *path)
|
||||||
@ -181,9 +182,7 @@ bool payloadMenu(char *path)
|
|||||||
payloadNum++;
|
payloadNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
f_closedir(&dir);
|
if(f_closedir(&dir) != FR_OK || !payloadNum) return false;
|
||||||
|
|
||||||
if(!payloadNum) return false;
|
|
||||||
|
|
||||||
u32 pressed = 0,
|
u32 pressed = 0,
|
||||||
selectedPayload = 0;
|
selectedPayload = 0;
|
||||||
@ -281,9 +280,7 @@ u32 firmRead(void *dest, u32 firmType)
|
|||||||
if(tempVersion < firmVersion) firmVersion = tempVersion;
|
if(tempVersion < firmVersion) firmVersion = tempVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
f_closedir(&dir);
|
if(f_closedir(&dir) != FR_OK || firmVersion == 0xFFFFFFFF) goto exit;
|
||||||
|
|
||||||
if(firmVersion == 0xFFFFFFFF) goto exit;
|
|
||||||
|
|
||||||
//Complete the string with the .app name
|
//Complete the string with the .app name
|
||||||
sprintf(path, "%s/%08x.app", folderPath, firmVersion);
|
sprintf(path, "%s/%08x.app", folderPath, firmVersion);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "fatfs/sdmmc/sdmmc.h"
|
||||||
|
|
||||||
extern CfgData configData;
|
extern CfgData configData;
|
||||||
extern ConfigurationStatus needConfig;
|
extern ConfigurationStatus needConfig;
|
||||||
@ -306,6 +307,8 @@ boot:
|
|||||||
{
|
{
|
||||||
locateEmuNand(&nandType);
|
locateEmuNand(&nandType);
|
||||||
if(nandType == FIRMWARE_SYSNAND) firmSource = FIRMWARE_SYSNAND;
|
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
|
//Same if we're using EmuNAND as the FIRM source
|
||||||
|
Reference in New Issue
Block a user