From 3b92f31e85181d40768b7b664527966ac6b2426b Mon Sep 17 00:00:00 2001 From: AlbertoSONIC Date: Mon, 10 Aug 2015 23:56:39 +0200 Subject: [PATCH] Fixed emunand detection on n3ds --- rxtools/source/features/cfw.c | 2 +- rxtools/source/features/cfw.h | 1 + rxtools/source/lib/nand.c | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rxtools/source/features/cfw.c b/rxtools/source/features/cfw.c index 6e7e0055..4eebd518 100644 --- a/rxtools/source/features/cfw.c +++ b/rxtools/source/features/cfw.c @@ -47,7 +47,7 @@ _Noreturn void (* const _softreset)() = (void *)0x080F0000; // @breif Determine platform of the console. // @retval PLATFORM_N3DS for New3DS, and PLATFORM_3DS for Old3DS. // @note Maybe modified to support more platforms -static Platform_UnitType Platform_CheckUnit(void) { +Platform_UnitType Platform_CheckUnit(void) { return *(u32 *)PLATFORM_REG_ADDR; } diff --git a/rxtools/source/features/cfw.h b/rxtools/source/features/cfw.h index f9522b71..21084f1d 100644 --- a/rxtools/source/features/cfw.h +++ b/rxtools/source/features/cfw.h @@ -36,6 +36,7 @@ typedef enum { PLATFORM_N3DS=7, } Platform_UnitType; +Platform_UnitType Platform_CheckUnit(void); int DevMode(); void FirmLoader(); void rxModeWithSplash(int emu); diff --git a/rxtools/source/lib/nand.c b/rxtools/source/lib/nand.c index cd04a5c7..34eaf122 100644 --- a/rxtools/source/lib/nand.c +++ b/rxtools/source/lib/nand.c @@ -20,6 +20,7 @@ #include "crypto.h" #include "fatfs/sdmmc.h" #include "nand.h" +#include "cfw.h" u8 NANDCTR[16]; int sysversion = 0; @@ -64,13 +65,16 @@ void FSNandInitCrypto(void) { unsigned int checkEmuNAND() { u8 *check = (u8 *)0x26000000; - sdmmc_sdcard_readsectors(0x3AF00000 / 0x200, 1, check); + int isn3ds = 0; + if (Platform_CheckUnit() == PLATFORM_N3DS)isn3ds = 1; + + sdmmc_sdcard_readsectors(isn3ds ? 0x4D800000 /0x200 : 0x3AF00000 / 0x200, 1, check); if (*((char *)check + 0x100) == 'N' && *((char *)check + 0x101) == 'C' && *((char *)check + 0x102) == 'S' && *((char *)check + 0x103) == 'D') { - return 0x3AF00000; + return isn3ds ? 0x4D800000 : 0x3AF00000; } else { - sdmmc_sdcard_readsectors(0x3BA00000 / 0x200, 1, check); + sdmmc_sdcard_readsectors(isn3ds ? 0x76000000 /0x200 : 0x3BA00000 / 0x200, 1, check); if (*((char *)check + 0x100) == 'N' && *((char *)check + 0x101) == 'C' && *((char *)check + 0x102) == 'S' && *((char *)check + 0x103) == 'D') { - return 0x3BA00000; + return isn3ds ? 0x76000000 : 0x3BA00000; } else { return 0; }