diff --git a/make/source.mk b/make/source.mk
index c0e3b57d3c..2264597875 100644
--- a/make/source.mk
+++ b/make/source.mk
@@ -65,6 +65,7 @@ OSD_SLAVE_SRC = \
FC_SRC = \
fc/fc_init.c \
+ fc/board_info.c \
fc/controlrate_profile.c \
drivers/camera_control.c \
drivers/accgyro/gyro_sync.c \
@@ -282,6 +283,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
drivers/vtx_rtc6705.c \
drivers/vtx_common.c \
fc/fc_init.c \
+ fc/board_info.c \
config/config_eeprom.c \
config/feature.c \
config/config_streamer.c \
diff --git a/src/main/fc/board_info.c b/src/main/fc/board_info.c
new file mode 100644
index 0000000000..c703ec177e
--- /dev/null
+++ b/src/main/fc/board_info.c
@@ -0,0 +1,94 @@
+/*
+ * This file is part of Cleanflight and Betaflight.
+ *
+ * Cleanflight and Betaflight are free software. You can redistribute
+ * this software and/or modify this software under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Cleanflight and Betaflight are distributed in the hope that they
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software.
+ *
+ * If not, see .
+ */
+
+#include
+#include
+
+#include "platform.h"
+
+#include "pg/board.h"
+
+static bool boardInformationSet = false;
+static char manufacturerId[MAX_MANUFACTURER_ID_LENGTH + 1];
+static char boardName[MAX_BOARD_NAME_LENGTH + 1];
+
+void initBoardInformation(void)
+{
+ boardInformationSet = boardConfig()->boardInformationSet;
+ if (boardInformationSet) {
+ strncpy(manufacturerId, boardConfig()->manufacturerId, MAX_MANUFACTURER_ID_LENGTH);
+ strncpy(boardName, boardConfig()->boardName, MAX_BOARD_NAME_LENGTH);
+ } else {
+ strcpy(manufacturerId, "");
+ strcpy(boardName, "");
+ }
+}
+
+char *getManufacturerId(void)
+{
+ return manufacturerId;
+}
+
+char *getBoardName(void)
+{
+ return boardName;
+}
+
+bool boardInformationIsSet(void)
+{
+ return boardInformationSet;
+}
+
+bool setManufacturerId(char *newManufacturerId)
+{
+ if (!boardInformationSet) {
+ strncpy(manufacturerId, newManufacturerId, MAX_MANUFACTURER_ID_LENGTH);
+
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool setBoardName(char *newBoardName)
+{
+ if (!boardInformationSet) {
+ strncpy(boardName, newBoardName, MAX_BOARD_NAME_LENGTH);
+
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool persistBoardInformation(void)
+{
+ if (!boardInformationSet) {
+ strncpy(boardConfigMutable()->manufacturerId, manufacturerId, MAX_MANUFACTURER_ID_LENGTH);
+ strncpy(boardConfigMutable()->boardName, boardName, MAX_BOARD_NAME_LENGTH);
+ boardConfigMutable()->boardInformationSet = true;
+
+ initBoardInformation();
+
+ return true;
+ } else {
+ return false;
+ }
+}
diff --git a/src/main/fc/board_info.h b/src/main/fc/board_info.h
new file mode 100644
index 0000000000..e5f43f39d3
--- /dev/null
+++ b/src/main/fc/board_info.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of Cleanflight and Betaflight.
+ *
+ * Cleanflight and Betaflight are free software. You can redistribute
+ * this software and/or modify this software under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Cleanflight and Betaflight are distributed in the hope that they
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software.
+ *
+ * If not, see .
+ */
+
+#pragma once
+
+void initBoardInformation(void);
+
+char *getBoardName(void);
+char *getManufacturerId(void);
+bool boardInformationIsSet(void);
+
+bool setBoardName(char *newBoardName);
+bool setManufacturerId(char *newManufacturerId);
+bool persistBoardInformation(void);
diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c
index cf6efc7863..f77a1b0c16 100644
--- a/src/main/fc/fc_init.c
+++ b/src/main/fc/fc_init.c
@@ -78,6 +78,7 @@
#include "drivers/usb_msc.h"
#endif
+#include "fc/board_info.h"
#include "fc/config.h"
#include "fc/fc_init.h"
#include "fc/fc_tasks.h"
@@ -241,6 +242,8 @@ void init(void)
ensureEEPROMStructureIsValid();
bool readSuccess = readEEPROM();
+ initBoardInformation();
+
if (!readSuccess || strncasecmp(systemConfig()->boardIdentifier, TARGET_BOARD_IDENTIFIER, sizeof(TARGET_BOARD_IDENTIFIER))) {
resetEEPROM();
diff --git a/src/main/interface/cli.c b/src/main/interface/cli.c
index d3b87fbd0b..98751d1aec 100644
--- a/src/main/interface/cli.c
+++ b/src/main/interface/cli.c
@@ -84,6 +84,7 @@ extern uint8_t __config_end;
#include "drivers/vtx_common.h"
#include "drivers/usb_msc.h"
+#include "fc/board_info.h"
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/fc_core.h"
@@ -171,6 +172,8 @@ static uint32_t bufferIndex = 0;
static bool configIsInCopy = false;
+static bool boardInformationUpdated = false;
+
static const char* const emptyName = "-";
static const char* const emptyString = "";
@@ -2229,6 +2232,49 @@ static void cliName(char *cmdline)
printName(DUMP_MASTER, pilotConfig());
}
+#define ERROR_MESSAGE "Error, %s is already set: %s"
+
+static void cliBoardName(char *cmdline)
+{
+ const unsigned int len = strlen(cmdline);
+ if (len > 0 && boardInformationIsSet() && strncmp(getBoardName(), cmdline, len)) {
+ cliPrintLinef(ERROR_MESSAGE, "board_name", getBoardName());
+ } else {
+ if (len > 0) {
+ setBoardName(cmdline);
+ boardInformationUpdated = true;
+ }
+ cliPrintLinef("board_name %s", getBoardName());
+ }
+}
+
+static void cliManufacturerId(char *cmdline)
+{
+ const unsigned int len = strlen(cmdline);
+ if (len > 0 && boardInformationIsSet() && strncmp(getManufacturerId(), cmdline, len)) {
+ cliPrintLinef(ERROR_MESSAGE, "manufactuer_id", getManufacturerId());
+ } else {
+ if (len > 0) {
+ setManufacturerId(cmdline);
+ boardInformationUpdated = true;
+ }
+ cliPrintLinef("manufacturer_id %s", getManufacturerId());
+ }
+}
+
+#undef ERROR_MESSAGE
+
+static void cliMcuId(char *cmdline)
+{
+ UNUSED(cmdline);
+
+ cliPrint("mcu_id 0x");
+ cliPrintf("%08x", U_ID_0);
+ cliPrintf("%08x", U_ID_1);
+ cliPrintf("%08x", U_ID_2);
+ cliPrintLinefeed();
+}
+
static void printFeature(uint8_t dumpMask, const featureConfig_t *featureConfig, const featureConfig_t *featureConfigDefault)
{
const uint32_t mask = featureConfig->enabledFeatures;
@@ -3100,6 +3146,9 @@ static void cliSave(char *cmdline)
UNUSED(cmdline);
cliPrintHashLine("saving");
+ if (boardInformationUpdated) {
+ persistBoardInformation();
+ }
writeEEPROM();
cliReboot();
}
@@ -3973,6 +4022,13 @@ static void printConfig(char *cmdline, bool doDiff)
if ((dumpMask & DUMP_MASTER) || (dumpMask & DUMP_ALL)) {
cliPrintHashLine("version");
cliVersion(NULL);
+ cliPrintLinefeed();
+
+ cliBoardName("");
+ cliManufacturerId("");
+ if (dumpMask & DUMP_ALL) {
+ cliMcuId(NULL);
+ }
if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) {
cliPrintHashLine("reset configuration to default settings");
@@ -4176,6 +4232,7 @@ const clicmd_t cmdTable[] = {
"\t<+|->[name]", cliBeeper),
#endif
CLI_COMMAND_DEF("bl", "reboot into bootloader", NULL, cliBootloader),
+ CLI_COMMAND_DEF("board_name", "name of the board model", NULL, cliBoardName),
#ifdef USE_LED_STRIP
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
#endif
@@ -4218,7 +4275,9 @@ const clicmd_t cmdTable[] = {
#ifdef USE_LED_STRIP
CLI_COMMAND_DEF("led", "configure leds", NULL, cliLed),
#endif
+ CLI_COMMAND_DEF("manufacturer_id", "id of the board manufacturer", NULL, cliManufacturerId),
CLI_COMMAND_DEF("map", "configure rc channel order", "[