1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

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

View file

@ -1817,7 +1817,8 @@ void opentxInit()
#endif #endif
#if defined(EEPROM) #if defined(EEPROM)
storageReadRadioSettings(); storageClearRadioSetting();
storageReadRadioSettings(false);
#endif #endif
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
@ -1876,6 +1877,7 @@ void opentxInit()
#endif #endif
#if defined(EEPROM) #if defined(EEPROM)
storageReadRadioSettings(true);
storageReadCurrentModel(); storageReadCurrentModel();
#endif #endif

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); storageEraseAll(true);
} }
else { else {
@ -110,7 +118,7 @@ void storageReadCurrentModel()
void storageReadAll() void storageReadAll()
{ {
storageReadRadioSettings(); storageReadRadioSettings(true);
storageReadCurrentModel(); storageReadCurrentModel();
} }

View file

@ -32,6 +32,7 @@ void selectModel(uint8_t sub);
void eeLoadModelHeader(uint8_t id, ModelHeader *header); void eeLoadModelHeader(uint8_t id, ModelHeader *header);
void eeLoadModelHeaders(); void eeLoadModelHeaders();
void storageReadRadioSettings(); void storageClearRadioSetting();
void storageReadRadioSettings(bool allowConversion);
void storageReadCurrentModel(); void storageReadCurrentModel();

View file

@ -256,13 +256,18 @@ void writeModel(int index)
writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model)); writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model));
} }
bool eeLoadGeneral() bool eeLoadGeneral(bool allowConversion)
{ {
eeLoadGeneralSettingsData(); eeLoadGeneralSettingsData();
if (g_eeGeneral.version != EEPROM_VER) { if (g_eeGeneral.version != EEPROM_VER) {
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER); TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
if (!allowConversion) {
storageClearRadioSetting();
return true; // prevent eeprom from being wiped
}
if (!eeConvert()) { if (!eeConvert()) {
return false; return false;
} }

View file

@ -24,8 +24,8 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h> #include <stdint.h>
bool eeLoadGeneral( void ) ; bool eeLoadGeneral(bool allowConversion);
void eeDeleteModel( uint8_t id ) ; void eeDeleteModel( uint8_t id );
bool eeCopyModel(uint8_t dst, uint8_t src); bool eeCopyModel(uint8_t dst, uint8_t src);
void eeSwapModels(uint8_t id1, uint8_t id2); void eeSwapModels(uint8_t id1, uint8_t id2);

View file

@ -757,7 +757,7 @@ uint16_t eeLoadModelData(uint8_t index)
return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model)); return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
} }
bool eeLoadGeneral() bool eeLoadGeneral(bool allowConversion)
{ {
theFile.openRlc(FILE_GENERAL); theFile.openRlc(FILE_GENERAL);
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) { if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) {
@ -796,6 +796,10 @@ bool eeLoadGeneral()
#endif #endif
#if defined(EEPROM_CONVERSIONS) #if defined(EEPROM_CONVERSIONS)
if (g_eeGeneral.version != EEPROM_VER) { 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); TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
if (!eeConvert()) { if (!eeConvert()) {
return false; return false;

View file

@ -180,7 +180,7 @@ void loadModel(int index, bool alarms=true);
bool eepromOpen(); bool eepromOpen();
void eeLoadModelName(uint8_t id, char *name); void eeLoadModelName(uint8_t id, char *name);
bool eeLoadGeneral(); bool eeLoadGeneral(bool allow_conversion);
// For EEPROM backup/restore // For EEPROM backup/restore
inline bool isEepromStart(const void * buffer) inline bool isEepromStart(const void * buffer)