summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/eeprom_settings.c18
-rw-r--r--firmware/system.c10
2 files changed, 21 insertions, 7 deletions
diff --git a/firmware/eeprom_settings.c b/firmware/eeprom_settings.c
index 450eff9623..ad2c9c848f 100644
--- a/firmware/eeprom_settings.c
+++ b/firmware/eeprom_settings.c
@@ -27,13 +27,20 @@
struct eeprom_settings firmware_settings;
-static void reset_config(void)
+static bool reset_config(void)
{
memset(&firmware_settings, 0, sizeof(struct eeprom_settings));
+#ifdef BOOTLOADER
+ /* Don't reset settings if we are inside bootloader. */
+ firmware_settings.initialized = false;
+#else
firmware_settings.version = EEPROM_SETTINGS_VERSION;
firmware_settings.initialized = true;
firmware_settings.boot_disk = false;
firmware_settings.bl_version = 0;
+#endif
+
+ return firmware_settings.initialized;
}
bool eeprom_settings_init(void)
@@ -69,23 +76,20 @@ bool eeprom_settings_init(void)
if (firmware_settings.version != EEPROM_SETTINGS_VERSION)
{
logf("Version mismatch");
- reset_config();
- return true;
+ return reset_config();
}
if (firmware_settings.checksum != sum)
{
logf("Checksum mismatch");
- reset_config();
- return true;
+ return reset_config();
}
#ifndef BOOTLOADER
if (firmware_settings.bl_version < EEPROM_SETTINGS_BL_MINVER)
{
logf("Too old bootloader: %d", firmware_settings.bl_version);
- reset_config();
- return true;
+ return reset_config();
}
#endif
diff --git a/firmware/system.c b/firmware/system.c
index bb09dbcd59..c635254a8a 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -84,7 +84,17 @@ bool detect_flashed_rockbox(void)
struct flash_header hdr;
uint8_t *src = (uint8_t *)FLASH_ENTRYPOINT;
+# ifndef BOOTLOADER
+ int oldmode;
+ oldmode = system_memory_guard(MEMGUARD_NONE);
+# endif
+
memcpy(&hdr, src, sizeof(struct flash_header));
+
+# ifndef BOOTLOADER
+ system_memory_guard(oldmode);
+# endif
+
if (hdr.magic != FLASH_MAGIC)
return false;