diff --git a/src/main/config/config_eeprom.c b/src/main/config/config_eeprom.c index 295cd77b9..c95e55248 100644 --- a/src/main/config/config_eeprom.c +++ b/src/main/config/config_eeprom.c @@ -62,6 +62,7 @@ typedef enum { // Header for the saved copy. typedef struct { uint8_t format; + char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER)]; } PG_PACKED configHeader_t; // Header for each stored PG. @@ -96,7 +97,7 @@ void initEEPROM(void) BUILD_BUG_ON(offsetof(packingTest_t, word) != 1); 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(configRecord_t) != 6); } @@ -122,6 +123,11 @@ bool isEEPROMContentValid(void) if (header->format != EEPROM_CONF_VERSION) { return false; } + + if (strncasecmp(header->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER))) { + return false; + } + chk = updateChecksum(chk, header, sizeof(*header)); p += sizeof(*header); // include the transitional masterConfig record @@ -227,6 +233,7 @@ static bool writeSettingsToEEPROM(void) configHeader_t header = { .format = EEPROM_CONF_VERSION, + .boardIdentifier = TARGET_BOARD_IDENTIFIER, }; config_streamer_write(&streamer, (uint8_t *)&header, sizeof(header)); diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h index 392cf05b4..77ce577c6 100644 --- a/src/main/config/config_master.h +++ b/src/main/config/config_master.h @@ -325,9 +325,6 @@ typedef struct master_s { beeperConfig_t beeperConfig; - char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER)]; - - uint8_t magic_ef; // magic number, should be 0xEF uint8_t chk; // XOR checksum /* do not add properties after the MAGIC_EF and CHK diff --git a/src/main/fc/config.c b/src/main/fc/config.c index 1bdba3e79..daef6d54a 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -1103,9 +1103,6 @@ void createDefaultConfig(master_t *config) resetStatusLedConfig(&config->statusLedConfig); #endif - /* 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) targetConfiguration(config); #endif