Do not try to convert the eeprom until radio is fully ON. (#6668)

This commit is contained in:
Raphael Coeffic
2019-08-27 10:20:03 +02:00
committed by Bertrand Songis
parent 3531e29cad
commit f9903dca66
7 changed files with 30 additions and 10 deletions
+3 -1
View File
@@ -1817,7 +1817,8 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageReadRadioSettings();
storageClearRadioSetting();
storageReadRadioSettings(false);
#endif
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
@@ -1876,6 +1877,7 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageReadRadioSettings(true);
storageReadCurrentModel();
#endif
+11 -3
View File
@@ -86,9 +86,17 @@ void eeLoadModelHeaders()
}
}
void storageReadRadioSettings()
void storageClearRadioSetting()
{
if (!eepromOpen() || !eeLoadGeneral()) {
memclear(&g_eeGeneral, sizeof(RadioData));
}
void storageReadRadioSettings(bool allowConversion)
{
if (g_eeGeneral.version != 0)
return;
if (!eepromOpen() || !eeLoadGeneral(allowConversion)) {
storageEraseAll(true);
}
else {
@@ -110,7 +118,7 @@ void storageReadCurrentModel()
void storageReadAll()
{
storageReadRadioSettings();
storageReadRadioSettings(true);
storageReadCurrentModel();
}
+2 -1
View File
@@ -32,6 +32,7 @@ void selectModel(uint8_t sub);
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
void eeLoadModelHeaders();
void storageReadRadioSettings();
void storageClearRadioSetting();
void storageReadRadioSettings(bool allowConversion);
void storageReadCurrentModel();
+6 -1
View File
@@ -256,13 +256,18 @@ void writeModel(int index)
writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model));
}
bool eeLoadGeneral()
bool eeLoadGeneral(bool allowConversion)
{
eeLoadGeneralSettingsData();
if (g_eeGeneral.version != EEPROM_VER) {
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
#if defined(PCBSKY9X)
if (!allowConversion) {
storageClearRadioSetting();
return true; // prevent eeprom from being wiped
}
if (!eeConvert()) {
return false;
}
+2 -2
View File
@@ -24,8 +24,8 @@
#include <inttypes.h>
#include <stdint.h>
bool eeLoadGeneral( void ) ;
void eeDeleteModel( uint8_t id ) ;
bool eeLoadGeneral(bool allowConversion);
void eeDeleteModel( uint8_t id );
bool eeCopyModel(uint8_t dst, uint8_t src);
void eeSwapModels(uint8_t id1, uint8_t id2);
+5 -1
View File
@@ -757,7 +757,7 @@ uint16_t eeLoadModelData(uint8_t index)
return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
}
bool eeLoadGeneral()
bool eeLoadGeneral(bool allowConversion)
{
theFile.openRlc(FILE_GENERAL);
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) {
@@ -796,6 +796,10 @@ bool eeLoadGeneral()
#endif
#if defined(EEPROM_CONVERSIONS)
if (g_eeGeneral.version != EEPROM_VER) {
if (!allowConversion) {
storageClearRadioSetting();
return true; // prevent eeprom from being wiped
}
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
if (!eeConvert()) {
return false;
+1 -1
View File
@@ -180,7 +180,7 @@ void loadModel(int index, bool alarms=true);
bool eepromOpen();
void eeLoadModelName(uint8_t id, char *name);
bool eeLoadGeneral();
bool eeLoadGeneral(bool allow_conversion);
// For EEPROM backup/restore
inline bool isEepromStart(const void * buffer)