Re-added check to reset EEPROM config if board identifier has changed.
This commit is contained in:
parent
f7afaedffe
commit
76a6a5d306
|
@ -62,6 +62,7 @@ typedef enum {
|
||||||
// Header for the saved copy.
|
// Header for the saved copy.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t format;
|
uint8_t format;
|
||||||
|
char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER)];
|
||||||
} PG_PACKED configHeader_t;
|
} PG_PACKED configHeader_t;
|
||||||
|
|
||||||
// Header for each stored PG.
|
// Header for each stored PG.
|
||||||
|
@ -96,7 +97,7 @@ void initEEPROM(void)
|
||||||
BUILD_BUG_ON(offsetof(packingTest_t, word) != 1);
|
BUILD_BUG_ON(offsetof(packingTest_t, word) != 1);
|
||||||
BUILD_BUG_ON(sizeof(packingTest_t) != 5);
|
BUILD_BUG_ON(sizeof(packingTest_t) != 5);
|
||||||
|
|
||||||
BUILD_BUG_ON(sizeof(configHeader_t) != 1);
|
BUILD_BUG_ON(sizeof(configHeader_t) != 1 + sizeof(TARGET_BOARD_IDENTIFIER));
|
||||||
BUILD_BUG_ON(sizeof(configFooter_t) != 2);
|
BUILD_BUG_ON(sizeof(configFooter_t) != 2);
|
||||||
BUILD_BUG_ON(sizeof(configRecord_t) != 6);
|
BUILD_BUG_ON(sizeof(configRecord_t) != 6);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +123,11 @@ bool isEEPROMContentValid(void)
|
||||||
if (header->format != EEPROM_CONF_VERSION) {
|
if (header->format != EEPROM_CONF_VERSION) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strncasecmp(header->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
chk = updateChecksum(chk, header, sizeof(*header));
|
chk = updateChecksum(chk, header, sizeof(*header));
|
||||||
p += sizeof(*header);
|
p += sizeof(*header);
|
||||||
// include the transitional masterConfig record
|
// include the transitional masterConfig record
|
||||||
|
@ -227,6 +233,7 @@ static bool writeSettingsToEEPROM(void)
|
||||||
|
|
||||||
configHeader_t header = {
|
configHeader_t header = {
|
||||||
.format = EEPROM_CONF_VERSION,
|
.format = EEPROM_CONF_VERSION,
|
||||||
|
.boardIdentifier = TARGET_BOARD_IDENTIFIER,
|
||||||
};
|
};
|
||||||
|
|
||||||
config_streamer_write(&streamer, (uint8_t *)&header, sizeof(header));
|
config_streamer_write(&streamer, (uint8_t *)&header, sizeof(header));
|
||||||
|
|
|
@ -320,9 +320,6 @@ typedef struct master_s {
|
||||||
|
|
||||||
beeperConfig_t beeperConfig;
|
beeperConfig_t beeperConfig;
|
||||||
|
|
||||||
char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER)];
|
|
||||||
|
|
||||||
uint8_t magic_ef; // magic number, should be 0xEF
|
|
||||||
uint8_t chk; // XOR checksum
|
uint8_t chk; // XOR checksum
|
||||||
/*
|
/*
|
||||||
do not add properties after the MAGIC_EF and CHK
|
do not add properties after the MAGIC_EF and CHK
|
||||||
|
|
|
@ -1097,9 +1097,6 @@ void createDefaultConfig(master_t *config)
|
||||||
|
|
||||||
resetStatusLedConfig(&config->statusLedConfig);
|
resetStatusLedConfig(&config->statusLedConfig);
|
||||||
|
|
||||||
/* merely to force a reset if the person inadvertently flashes the wrong target */
|
|
||||||
strncpy(config->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER));
|
|
||||||
|
|
||||||
#if defined(TARGET_CONFIG)
|
#if defined(TARGET_CONFIG)
|
||||||
targetConfiguration(config);
|
targetConfiguration(config);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue