Fix upgrade process possibly copying non-Luma firms
Upgrade process always copied sdmc:/boot.firm to nand:/boot.firm even if Luma3DS was chainloaded from another path. Fix this by copying from argv[0], if Luma3DS was launched from the SD card. Also use "sdmc:" and "nand:" instead of "0:" and "1:" when using FatFS. Closes #1776.
This commit is contained in:
parent
fcd08d6614
commit
a7b840e531
@ -167,8 +167,8 @@
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 0
|
||||
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
|
||||
#define FF_STR_VOLUME_ID 1
|
||||
#define FF_VOLUME_STRS "sdmc", "nand"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
|
@ -64,14 +64,14 @@ bool mountFs(bool isSd, bool switchToCtrNand)
|
||||
if (isSd)
|
||||
{
|
||||
if (!sdInitialized)
|
||||
sdInitialized = f_mount(&sdFs, "0:", 1) == FR_OK;
|
||||
sdInitialized = f_mount(&sdFs, "sdmc:", 1) == FR_OK;
|
||||
return sdInitialized && switchToMainDir(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!nandInitialized)
|
||||
nandInitialized = f_mount(&nandFs, "1:", 1) == FR_OK;
|
||||
return nandInitialized && (!switchToCtrNand || (f_chdrive("1:") == FR_OK && switchToMainDir(false)));
|
||||
nandInitialized = f_mount(&nandFs, "nand:", 1) == FR_OK;
|
||||
return nandInitialized && (!switchToCtrNand || (f_chdrive("nand:") == FR_OK && switchToMainDir(false)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,10 +343,10 @@ u32 firmRead(void *dest, u32 firmType)
|
||||
{"00000003", "20000003"},
|
||||
{"00000001", "20000001"}};
|
||||
|
||||
char folderPath[35],
|
||||
path[48];
|
||||
char folderPath[64],
|
||||
path[128];
|
||||
|
||||
sprintf(folderPath, "1:/title/00040138/%s/content", firmFolders[firmType][ISN3DS ? 1 : 0]);
|
||||
sprintf(folderPath, "nand:/title/00040138/%s/content", firmFolders[firmType][ISN3DS ? 1 : 0]);
|
||||
|
||||
DIR dir;
|
||||
u32 firmVersion = 0xFFFFFFFF;
|
||||
@ -414,14 +414,14 @@ static bool backupEssentialFiles(void)
|
||||
|
||||
bool ok = !(isSdMode && !mountFs(false, false));
|
||||
|
||||
ok = ok && fileCopy("1:/ro/sys/HWCAL0.dat", "backups/HWCAL0.dat", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("1:/ro/sys/HWCAL1.dat", "backups/HWCAL1.dat", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("nand:/ro/sys/HWCAL0.dat", "backups/HWCAL0.dat", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("nand:/ro/sys/HWCAL1.dat", "backups/HWCAL1.dat", false, fileCopyBuffer, sz);
|
||||
|
||||
ok = ok && fileCopy("1:/rw/sys/LocalFriendCodeSeed_A", "backups/LocalFriendCodeSeed_A", false, fileCopyBuffer, sz); // often doesn't exist
|
||||
ok = ok && fileCopy("1:/rw/sys/LocalFriendCodeSeed_B", "backups/LocalFriendCodeSeed_B", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("nand:/rw/sys/LocalFriendCodeSeed_A", "backups/LocalFriendCodeSeed_A", false, fileCopyBuffer, sz); // often doesn't exist
|
||||
ok = ok && fileCopy("nand:/rw/sys/LocalFriendCodeSeed_B", "backups/LocalFriendCodeSeed_B", false, fileCopyBuffer, sz);
|
||||
|
||||
ok = ok && fileCopy("1:/rw/sys/SecureInfo_A", "backups/SecureInfo_A", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("1:/rw/sys/SecureInfo_B", "backups/SecureInfo_B", false, fileCopyBuffer, sz); // often doesn't exist
|
||||
ok = ok && fileCopy("nand:/rw/sys/SecureInfo_A", "backups/SecureInfo_A", false, fileCopyBuffer, sz);
|
||||
ok = ok && fileCopy("nand:/rw/sys/SecureInfo_B", "backups/SecureInfo_B", false, fileCopyBuffer, sz); // often doesn't exist
|
||||
|
||||
if (!ok) return false;
|
||||
|
||||
@ -460,15 +460,15 @@ bool doLumaUpgradeProcess(void)
|
||||
return false;
|
||||
|
||||
// Try to boot.firm to CTRNAND, when applicable
|
||||
if (isSdMode)
|
||||
ok = fileCopy("0:/boot.firm", "1:/boot.firm", true, fileCopyBuffer, sizeof(fileCopyBuffer));
|
||||
if (isSdMode && memcmp(launchedPathForFatfs, "sdmc:", 5) == 0)
|
||||
ok = fileCopy(launchedPathForFatfs, "nand:/boot.firm", true, fileCopyBuffer, sizeof(fileCopyBuffer));
|
||||
|
||||
// Try to backup essential files
|
||||
ok2 = backupEssentialFiles();
|
||||
|
||||
// Clean up some of the old files
|
||||
fileDelete("0:/luma/config.bin");
|
||||
fileDelete("1:/rw/luma/config.bin");
|
||||
fileDelete("sdmc:/luma/config.bin");
|
||||
fileDelete("nand:/rw/luma/config.bin");
|
||||
|
||||
return ok && ok2;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "memory.h"
|
||||
#include "screen.h"
|
||||
#include "i2c.h"
|
||||
#include "fmt.h"
|
||||
#include "fatfs/sdmmc/sdmmc.h"
|
||||
|
||||
extern u8 __itcm_start__[], __itcm_lma__[], __itcm_bss_start__[], __itcm_end__[];
|
||||
@ -46,6 +47,7 @@ extern ConfigurationStatus needConfig;
|
||||
extern FirmwareSource firmSource;
|
||||
|
||||
bool isSdMode;
|
||||
char launchedPathForFatfs[256];
|
||||
u16 launchedPath[80+1];
|
||||
BootType bootType;
|
||||
|
||||
@ -72,6 +74,8 @@ void main(int argc, char **argv, u32 magicWord)
|
||||
if((magicWord & 0xFFFF) == 0xBEEF && argc >= 1) //Normal (B9S) boot
|
||||
{
|
||||
bootType = isNtrBoot ? B9SNTR : B9S;
|
||||
strncpy(launchedPathForFatfs, argv[0], sizeof(launchedPathForFatfs) - 1);
|
||||
launchedPathForFatfs[sizeof(launchedPathForFatfs) - 1] = 0;
|
||||
|
||||
u32 i;
|
||||
for(i = 0; i < sizeof(launchedPath)/2 - 1 && argv[0][i] != 0; i++) //Copy and convert the path to UTF-16
|
||||
@ -85,7 +89,10 @@ void main(int argc, char **argv, u32 magicWord)
|
||||
u32 i;
|
||||
u16 *p = (u16 *)argv[0];
|
||||
for(i = 0; i < sizeof(launchedPath)/2 - 1 && p[i] != 0; i++)
|
||||
{
|
||||
launchedPath[i] = p[i];
|
||||
launchedPathForFatfs[i] = (u8)p[i]; // UCS-2 to ascii. Meh.
|
||||
}
|
||||
launchedPath[i] = 0;
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
@ -110,6 +117,7 @@ void main(int argc, char **argv, u32 magicWord)
|
||||
|
||||
for(u32 i = 0; i < 7; i++) //Copy and convert the path to UTF-16
|
||||
launchedPath[i] = path[i];
|
||||
strcpy(launchedPathForFatfs, path);
|
||||
}
|
||||
|
||||
setupKeyslots();
|
||||
|
@ -138,6 +138,7 @@ extern bool isSdMode;
|
||||
|
||||
extern BootType bootType;
|
||||
|
||||
extern char launchedPathForFatfs[256];
|
||||
extern u16 launchedFirmTidLow[8];
|
||||
extern u16 launchedPath[80+1];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user