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
#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

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();
}

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();

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;
}

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);

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;

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)