mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 07:15:12 +03:00
Do not try to convert the eeprom until radio is fully ON. (#6668)
This commit is contained in:
parent
3531e29cad
commit
f9903dca66
7 changed files with 30 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool eeLoadGeneral( void ) ;
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue