Merge master into developer
This commit is contained in:
commit
a99b26ff8c
@ -29,9 +29,9 @@
|
|||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
#include "pin.h"
|
#include "pin.h"
|
||||||
|
|
||||||
bool readConfig(const char *configPath)
|
bool readConfig(void)
|
||||||
{
|
{
|
||||||
if(fileRead(&configData, configPath) != sizeof(cfgData) ||
|
if(fileRead(&configData, CONFIG_PATH) != sizeof(cfgData) ||
|
||||||
memcmp(configData.magic, "CONF", 4) != 0 ||
|
memcmp(configData.magic, "CONF", 4) != 0 ||
|
||||||
configData.formatVersionMajor != CONFIG_VERSIONMAJOR ||
|
configData.formatVersionMajor != CONFIG_VERSIONMAJOR ||
|
||||||
configData.formatVersionMinor != CONFIG_VERSIONMINOR)
|
configData.formatVersionMinor != CONFIG_VERSIONMINOR)
|
||||||
@ -43,7 +43,7 @@ bool readConfig(const char *configPath)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig)
|
void writeConfig(ConfigurationStatus needConfig, u32 configTemp)
|
||||||
{
|
{
|
||||||
/* If the configuration is different from previously, overwrite it.
|
/* If the configuration is different from previously, overwrite it.
|
||||||
Just the no-forcing flag being set is not enough */
|
Just the no-forcing flag being set is not enough */
|
||||||
@ -59,7 +59,7 @@ void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus nee
|
|||||||
//Merge the new options and new boot configuration
|
//Merge the new options and new boot configuration
|
||||||
configData.config = (configData.config & 0xFFFFFFC0) | (configTemp & 0x3F);
|
configData.config = (configData.config & 0xFFFFFFC0) | (configTemp & 0x3F);
|
||||||
|
|
||||||
if(!fileWrite(&configData, configPath, sizeof(cfgData)))
|
if(!fileWrite(&configData, CONFIG_PATH, sizeof(cfgData)))
|
||||||
error("Error writing the configuration file");
|
error("Error writing the configuration file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#define BOOTCONFIG(a, b) ((configData.config >> a) & b)
|
#define BOOTCONFIG(a, b) ((configData.config >> a) & b)
|
||||||
|
|
||||||
#define DEV_OPTIONS MULTICONFIG(2)
|
#define DEV_OPTIONS MULTICONFIG(2)
|
||||||
|
|
||||||
|
#define CONFIG_PATH "/luma/config.bin"
|
||||||
#define CONFIG_VERSIONMAJOR 1
|
#define CONFIG_VERSIONMAJOR 1
|
||||||
#define CONFIG_VERSIONMINOR 0
|
#define CONFIG_VERSIONMINOR 0
|
||||||
|
|
||||||
@ -49,6 +51,6 @@ typedef enum ConfigurationStatus
|
|||||||
|
|
||||||
extern cfgData configData;
|
extern cfgData configData;
|
||||||
|
|
||||||
bool readConfig(const char *configPath);
|
bool readConfig(void);
|
||||||
void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig);
|
void writeConfig(ConfigurationStatus needConfig, u32 configTemp);
|
||||||
void configMenu(bool oldPinStatus);
|
void configMenu(bool oldPinStatus);
|
@ -71,10 +71,8 @@ void main(void)
|
|||||||
//Mount filesystems. CTRNAND will be mounted only if/when needed
|
//Mount filesystems. CTRNAND will be mounted only if/when needed
|
||||||
mountFs();
|
mountFs();
|
||||||
|
|
||||||
const char configPath[] = "/luma/config.bin";
|
|
||||||
|
|
||||||
//Attempt to read the configuration file
|
//Attempt to read the configuration file
|
||||||
needConfig = readConfig(configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION;
|
needConfig = readConfig() ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION;
|
||||||
|
|
||||||
if(DEV_OPTIONS != 2)
|
if(DEV_OPTIONS != 2)
|
||||||
{
|
{
|
||||||
@ -216,7 +214,7 @@ void main(void)
|
|||||||
if(!isFirmlaunch)
|
if(!isFirmlaunch)
|
||||||
{
|
{
|
||||||
configTemp |= (u32)nandType | ((u32)firmSource << 2);
|
configTemp |= (u32)nandType | ((u32)firmSource << 2);
|
||||||
writeConfig(configPath, configTemp, needConfig);
|
writeConfig(needConfig, configTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 firmVersion = loadFirm(&firmType, firmSource);
|
u32 firmVersion = loadFirm(&firmType, firmSource);
|
||||||
|
@ -95,7 +95,7 @@ void newPin(bool allowSkipping)
|
|||||||
computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
|
computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
|
||||||
memcpy(pin.hash, tmp, 32);
|
memcpy(pin.hash, tmp, 32);
|
||||||
|
|
||||||
if(!fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)))
|
if(!fileWrite(&pin, PIN_PATH, sizeof(PINData)))
|
||||||
error("Error writing the PIN file");
|
error("Error writing the PIN file");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ bool verifyPin(void)
|
|||||||
|
|
||||||
PINData pin;
|
PINData pin;
|
||||||
|
|
||||||
if(fileRead(&pin, "/luma/pin.bin") != sizeof(PINData) ||
|
if(fileRead(&pin, PIN_PATH) != sizeof(PINData) ||
|
||||||
memcmp(pin.magic, "PINF", 4) != 0 ||
|
memcmp(pin.magic, "PINF", 4) != 0 ||
|
||||||
pin.formatVersionMajor != PIN_VERSIONMAJOR ||
|
pin.formatVersionMajor != PIN_VERSIONMAJOR ||
|
||||||
pin.formatVersionMinor != PIN_VERSIONMINOR)
|
pin.formatVersionMinor != PIN_VERSIONMINOR)
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define PIN_LENGTH 4
|
#define PIN_LENGTH 4
|
||||||
|
#define PIN_PATH "/luma/pin.bin"
|
||||||
#define PIN_VERSIONMAJOR 1
|
#define PIN_VERSIONMAJOR 1
|
||||||
#define PIN_VERSIONMINOR 0
|
#define PIN_VERSIONMINOR 0
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user