mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Merge pull request #3600 from blckmn/boardIdentifier
Board identifier being moved to systemConfig
This commit is contained in:
commit
03caa1cc8d
10 changed files with 46 additions and 38 deletions
|
@ -1197,7 +1197,7 @@ static bool blackboxWriteSysinfo(void)
|
|||
BLACKBOX_PRINT_HEADER_LINE("Firmware revision", "%s %s (%s) %s", FC_FIRMWARE_NAME, FC_VERSION_STRING, shortGitRevision, targetName);
|
||||
BLACKBOX_PRINT_HEADER_LINE("Firmware date", "%s %s", buildDate, buildTime);
|
||||
BLACKBOX_PRINT_HEADER_LINE("Log start datetime", "%s", blackboxGetStartDateTime());
|
||||
BLACKBOX_PRINT_HEADER_LINE("Craft name", "%s", systemConfig()->name);
|
||||
BLACKBOX_PRINT_HEADER_LINE("Craft name", "%s", pilotConfig()->name);
|
||||
BLACKBOX_PRINT_HEADER_LINE("I interval", "%d", blackboxIInterval);
|
||||
BLACKBOX_PRINT_HEADER_LINE("P interval", "%d/%d", blackboxGetRateNum(), blackboxGetRateDenom());
|
||||
BLACKBOX_PRINT_HEADER_LINE("P denom", "%d", blackboxConfig()->p_denom);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "config/config_eeprom.h"
|
||||
#include "config/config_streamer.h"
|
||||
#include "config/parameter_group.h"
|
||||
#include "fc/config.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
|
||||
|
@ -56,7 +57,6 @@ typedef enum {
|
|||
typedef struct {
|
||||
uint8_t eepromConfigVersion;
|
||||
uint8_t magic_be; // magic number, should be 0xBE
|
||||
char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER)];
|
||||
} PG_PACKED configHeader_t;
|
||||
|
||||
// Header for each stored PG.
|
||||
|
@ -91,7 +91,6 @@ void initEEPROM(void)
|
|||
BUILD_BUG_ON(offsetof(packingTest_t, word) != 1);
|
||||
BUILD_BUG_ON(sizeof(packingTest_t) != 5);
|
||||
|
||||
BUILD_BUG_ON(sizeof(configHeader_t) != 2 + sizeof(TARGET_BOARD_IDENTIFIER));
|
||||
BUILD_BUG_ON(sizeof(configFooter_t) != 2);
|
||||
BUILD_BUG_ON(sizeof(configRecord_t) != 6);
|
||||
}
|
||||
|
@ -108,9 +107,6 @@ bool isEEPROMContentValid(void)
|
|||
if (header->magic_be != 0xBE) {
|
||||
return false;
|
||||
}
|
||||
if (strncasecmp(header->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t crc = CRC_START_VALUE;
|
||||
crc = crc16_ccitt_update(crc, header, sizeof(*header));
|
||||
|
@ -145,6 +141,11 @@ bool isEEPROMContentValid(void)
|
|||
|
||||
eepromConfigSize = p - &__config_start;
|
||||
|
||||
/* TODO: Check to be removed when moving to generic targets */
|
||||
if (strncasecmp(systemConfig()->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// CRC has the property that if the CRC itself is included in the calculation the resulting CRC will have constant value
|
||||
return crc == CRC_CHECK_VALUE;
|
||||
}
|
||||
|
@ -203,7 +204,6 @@ static bool writeSettingsToEEPROM(void)
|
|||
configHeader_t header = {
|
||||
.eepromConfigVersion = EEPROM_CONF_VERSION,
|
||||
.magic_be = 0xBE,
|
||||
.boardIdentifier = TARGET_BOARD_IDENTIFIER,
|
||||
};
|
||||
|
||||
config_streamer_write(&streamer, (uint8_t *)&header, sizeof(header));
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define EEPROM_CONF_VERSION 159
|
||||
#define EEPROM_CONF_VERSION 160
|
||||
|
||||
bool isEEPROMContentValid(void);
|
||||
bool loadEEPROM(void);
|
||||
|
|
|
@ -1915,22 +1915,22 @@ static void cliVtx(char *cmdline)
|
|||
|
||||
#endif // VTX_CONTROL
|
||||
|
||||
static void printName(uint8_t dumpMask, const systemConfig_t *systemConfig)
|
||||
static void printName(uint8_t dumpMask, const pilotConfig_t *pilotConfig)
|
||||
{
|
||||
const bool equalsDefault = strlen(systemConfig->name) == 0;
|
||||
cliDumpPrintLinef(dumpMask, equalsDefault, "name %s", equalsDefault ? emptyName : systemConfig->name);
|
||||
const bool equalsDefault = strlen(pilotConfig->name) == 0;
|
||||
cliDumpPrintLinef(dumpMask, equalsDefault, "name %s", equalsDefault ? emptyName : pilotConfig->name);
|
||||
}
|
||||
|
||||
static void cliName(char *cmdline)
|
||||
{
|
||||
const uint32_t len = strlen(cmdline);
|
||||
if (len > 0) {
|
||||
memset(systemConfigMutable()->name, 0, ARRAYLEN(systemConfig()->name));
|
||||
memset(pilotConfigMutable()->name, 0, ARRAYLEN(pilotConfig()->name));
|
||||
if (strncmp(cmdline, emptyName, len)) {
|
||||
strncpy(systemConfigMutable()->name, cmdline, MIN(len, MAX_NAME_LENGTH));
|
||||
strncpy(pilotConfigMutable()->name, cmdline, MIN(len, MAX_NAME_LENGTH));
|
||||
}
|
||||
}
|
||||
printName(DUMP_MASTER, systemConfig());
|
||||
printName(DUMP_MASTER, pilotConfig());
|
||||
}
|
||||
|
||||
static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault)
|
||||
|
@ -2269,9 +2269,9 @@ void printEscInfo(const uint8_t *escInfoBytes, uint8_t bytesRead)
|
|||
escInfoReceived = true;
|
||||
|
||||
if (calculateCrc8(escInfoBytes, frameLength - 1) == escInfoBytes[frameLength - 1]) {
|
||||
uint8_t firmwareVersion;
|
||||
char firmwareSubVersion;
|
||||
uint8_t escType;
|
||||
uint8_t firmwareVersion = 0;
|
||||
char firmwareSubVersion = 0;
|
||||
uint8_t escType = 0;
|
||||
switch (escInfoVersion) {
|
||||
case 1:
|
||||
firmwareVersion = escInfoBytes[12];
|
||||
|
@ -2291,23 +2291,18 @@ void printEscInfo(const uint8_t *escInfoBytes, uint8_t bytesRead)
|
|||
switch (escType) {
|
||||
case 1:
|
||||
cliPrintLine("KISS8A");
|
||||
|
||||
break;
|
||||
case 2:
|
||||
cliPrintLine("KISS16A");
|
||||
|
||||
break;
|
||||
case 3:
|
||||
cliPrintLine("KISS24A");
|
||||
|
||||
break;
|
||||
case 5:
|
||||
cliPrintLine("KISS Ultralite");
|
||||
|
||||
break;
|
||||
default:
|
||||
cliPrintLine("unknown");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2508,8 +2503,8 @@ static void cliMotor(char *cmdline)
|
|||
return;
|
||||
}
|
||||
|
||||
int motorIndex;
|
||||
int motorValue;
|
||||
int motorIndex = 0;
|
||||
int motorValue = 0;
|
||||
|
||||
char *saveptr;
|
||||
char *pch = strtok_r(cmdline, " ", &saveptr);
|
||||
|
@ -3331,7 +3326,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
}
|
||||
|
||||
cliPrintHashLine("name");
|
||||
printName(dumpMask, &systemConfig_Copy);
|
||||
printName(dumpMask, &pilotConfig_Copy);
|
||||
|
||||
#ifdef USE_RESOURCE_MGMT
|
||||
cliPrintHashLine("resources");
|
||||
|
|
|
@ -117,6 +117,12 @@ PG_RESET_TEMPLATE(featureConfig_t, featureConfig,
|
|||
.enabledFeatures = DEFAULT_FEATURES | DEFAULT_RX_FEATURE
|
||||
);
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig,
|
||||
.name = { 0 }
|
||||
);
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 0);
|
||||
|
||||
#ifndef USE_OSD_SLAVE
|
||||
|
@ -127,7 +133,7 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
|||
.debug_mode = DEBUG_MODE,
|
||||
.task_statistics = true,
|
||||
.cpu_overclock = false,
|
||||
.name = { 0 } // FIXME misplaced, see PG_PILOT_CONFIG in CF v1.x
|
||||
.boardIdentifier = TARGET_BOARD_IDENTIFIER
|
||||
);
|
||||
#else
|
||||
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||
|
@ -135,7 +141,7 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
|||
.activeRateProfile = 0,
|
||||
.debug_mode = DEBUG_MODE,
|
||||
.task_statistics = true,
|
||||
.name = { 0 } // FIXME misplaced, see PG_PILOT_CONFIG in CF v1.x
|
||||
.boardIdentifier = TARGET_BOARD_IDENTIFIER
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -143,7 +149,8 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
|||
#ifdef USE_OSD_SLAVE
|
||||
PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
||||
.debug_mode = DEBUG_MODE,
|
||||
.task_statistics = true
|
||||
.task_statistics = true,
|
||||
.boardIdentifier = TARGET_BOARD_IDENTIFIER
|
||||
);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -59,6 +59,9 @@ typedef enum {
|
|||
} features_e;
|
||||
|
||||
#define MAX_NAME_LENGTH 16
|
||||
typedef struct pilotConfig_s {
|
||||
char name[MAX_NAME_LENGTH + 1];
|
||||
} pilotConfig_t;
|
||||
|
||||
#ifndef USE_OSD_SLAVE
|
||||
typedef struct systemConfig_s {
|
||||
|
@ -69,7 +72,7 @@ typedef struct systemConfig_s {
|
|||
#if defined(STM32F4) && !defined(DISABLE_OVERCLOCK)
|
||||
uint8_t cpu_overclock;
|
||||
#endif
|
||||
char name[MAX_NAME_LENGTH + 1]; // FIXME misplaced, see PG_PILOT_CONFIG in CF v1.x
|
||||
char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER) + 1];
|
||||
} systemConfig_t;
|
||||
#endif
|
||||
|
||||
|
@ -77,9 +80,11 @@ typedef struct systemConfig_s {
|
|||
typedef struct systemConfig_s {
|
||||
uint8_t debug_mode;
|
||||
uint8_t task_statistics;
|
||||
char boardIdentifier[sizeof(TARGET_BOARD_IDENTIFIER) + 1];
|
||||
} systemConfig_t;
|
||||
#endif
|
||||
|
||||
PG_DECLARE(pilotConfig_t, pilotConfig);
|
||||
PG_DECLARE(systemConfig_t, systemConfig);
|
||||
PG_DECLARE(adcConfig_t, adcConfig);
|
||||
PG_DECLARE(beeperDevConfig_t, beeperDevConfig);
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
#endif
|
||||
|
||||
static const char * const flightControllerIdentifier = BETAFLIGHT_IDENTIFIER; // 4 UPPER CASE alpha numeric characters that identify the flight controller.
|
||||
static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
||||
|
||||
#ifndef USE_OSD_SLAVE
|
||||
|
||||
|
@ -346,7 +345,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
|||
break;
|
||||
|
||||
case MSP_BOARD_INFO:
|
||||
sbufWriteData(dst, boardIdentifier, BOARD_IDENTIFIER_LENGTH);
|
||||
sbufWriteData(dst, systemConfig()->boardIdentifier, BOARD_IDENTIFIER_LENGTH);
|
||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||
sbufWriteU16(dst, hardwareRevision);
|
||||
#else
|
||||
|
@ -695,9 +694,9 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
|
|||
|
||||
case MSP_NAME:
|
||||
{
|
||||
const int nameLen = strlen(systemConfig()->name);
|
||||
const int nameLen = strlen(pilotConfig()->name);
|
||||
for (int i = 0; i < nameLen; i++) {
|
||||
sbufWriteU8(dst, systemConfig()->name[i]);
|
||||
sbufWriteU8(dst, pilotConfig()->name[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1806,9 +1805,9 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
#endif
|
||||
|
||||
case MSP_SET_NAME:
|
||||
memset(systemConfigMutable()->name, 0, ARRAYLEN(systemConfig()->name));
|
||||
memset(pilotConfigMutable()->name, 0, ARRAYLEN(pilotConfig()->name));
|
||||
for (unsigned int i = 0; i < MIN(MAX_NAME_LENGTH, dataSize); i++) {
|
||||
systemConfigMutable()->name[i] = sbufReadU8(src);
|
||||
pilotConfigMutable()->name[i] = sbufReadU8(src);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -442,12 +442,12 @@ static void osdDrawSingleElement(uint8_t item)
|
|||
}
|
||||
|
||||
case OSD_CRAFT_NAME:
|
||||
if (strlen(systemConfig()->name) == 0)
|
||||
if (strlen(pilotConfig()->name) == 0)
|
||||
strcpy(buff, "CRAFT_NAME");
|
||||
else {
|
||||
for (int i = 0; i < MAX_NAME_LENGTH; i++) {
|
||||
buff[i] = toupper((unsigned char)systemConfig()->name[i]);
|
||||
if (systemConfig()->name[i] == 0)
|
||||
buff[i] = toupper((unsigned char)pilotConfig()->name[i]);
|
||||
if (pilotConfig()->name[i] == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ extern "C" {
|
|||
PG_REGISTER(batteryConfig_t, batteryConfig, PG_BATTERY_CONFIG, 0);
|
||||
PG_REGISTER(ledStripConfig_t, ledStripConfig, PG_LED_STRIP_CONFIG, 0);
|
||||
PG_REGISTER(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 0);
|
||||
PG_REGISTER(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 0);
|
||||
PG_REGISTER_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges, PG_ADJUSTMENT_RANGE_CONFIG, 0);
|
||||
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 0);
|
||||
PG_REGISTER(mixerConfig_t, mixerConfig, PG_MIXER_CONFIG, 0);
|
||||
|
|
|
@ -64,6 +64,7 @@ extern "C" {
|
|||
PG_REGISTER(batteryConfig_t, batteryConfig, PG_BATTERY_CONFIG, 0);
|
||||
PG_REGISTER(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 0);
|
||||
PG_REGISTER(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 0);
|
||||
PG_REGISTER(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 0);
|
||||
|
||||
timeUs_t simulationTime = 0;
|
||||
batteryState_e simulationBatteryState;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue