From 51923bb67faa86402f627385f8a7c7ae56a6a9d9 Mon Sep 17 00:00:00 2001 From: Vladimir Zidar Date: Mon, 23 Oct 2017 23:00:45 +0200 Subject: [PATCH] LP-556 Allow DiscoveryF4Bare to spoof own board id through FirmwareIAPObj. --- flight/modules/FirmwareIAP/firmwareiap.c | 6 +++-- .../discoveryf4bare/firmware/UAVObjects.inc | 5 ++++ .../discoveryf4bare/firmware/pios_board.c | 27 +++++++++++++++++++ .../gcs/src/plugins/uavobjects/uavobjects.pro | 1 + .../hwdiscoveryf4baresettings.xml | 10 +++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 shared/uavobjectdefinition/hwdiscoveryf4baresettings.xml diff --git a/flight/modules/FirmwareIAP/firmwareiap.c b/flight/modules/FirmwareIAP/firmwareiap.c index 0d8b1c900..640be8993 100644 --- a/flight/modules/FirmwareIAP/firmwareiap.c +++ b/flight/modules/FirmwareIAP/firmwareiap.c @@ -96,10 +96,12 @@ int32_t FirmwareIAPInitialize() FirmwareIAPObjData data; FirmwareIAPObjGet(&data); - data.BoardType = bdinfo->board_type; PIOS_BL_HELPER_FLASH_Read_Description(data.Description, FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM); PIOS_SYS_SerialNumberGetBinary(data.CPUSerial); - data.BoardRevision = bdinfo->board_rev; + if (data.BoardRevision == 0 && data.BoardType == 0) { + data.BoardRevision = bdinfo->board_rev; + data.BoardType = bdinfo->board_type; + } data.BootloaderRevision = bdinfo->bl_rev; data.ArmReset = 0; data.crc = 0; diff --git a/flight/targets/boards/discoveryf4bare/firmware/UAVObjects.inc b/flight/targets/boards/discoveryf4bare/firmware/UAVObjects.inc index f85007c7e..53a928f57 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/UAVObjects.inc +++ b/flight/targets/boards/discoveryf4bare/firmware/UAVObjects.inc @@ -106,6 +106,11 @@ UAVOBJSRCFILENAMES += velocitydesired UAVOBJSRCFILENAMES += watchdogstatus UAVOBJSRCFILENAMES += flightstatus UAVOBJSRCFILENAMES += hwsettings +UAVOBJSRCFILENAMES += hwdiscoveryf4baresettings +UAVOBJSRCFILENAMES += hwpikoblxsettings +UAVOBJSRCFILENAMES += hwspracingf3evosettings +UAVOBJSRCFILENAMES += hwspracingf3settings +UAVOBJSRCFILENAMES += hwtinyfishsettings UAVOBJSRCFILENAMES += receiveractivity UAVOBJSRCFILENAMES += receiverstatus UAVOBJSRCFILENAMES += cameradesired diff --git a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c index 48d2ba9b2..faadc5f77 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c +++ b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c @@ -32,6 +32,13 @@ #include #include #include +#include "hwdiscoveryf4baresettings.h" +#include "firmwareiapobj.h" + +#include "hwpikoblxsettings.h" +#include "hwspracingf3evosettings.h" +#include "hwspracingf3settings.h" +#include "hwtinyfishsettings.h" #ifdef PIOS_INCLUDE_INSTRUMENTATION @@ -189,6 +196,26 @@ void PIOS_Board_Init(void) UAVObjInitialize(); SETTINGS_INITIALISE_ALL; + HwPikoBLXSettingsInitialize(); + HwSPRacingF3EVOSettingsInitialize(); + HwSPRacingF3SettingsInitialize(); + HwTinyFISHSettingsInitialize(); + + HwDiscoveryF4BareSettingsInitialize(); + + uint16_t boardId; + HwDiscoveryF4BareSettingsBoardIdGet(&boardId); + + FirmwareIAPObjInitialize(); + + FirmwareIAPObjData iap; + FirmwareIAPObjGet(&iap); + + iap.BoardType = boardId >> 8; + iap.BoardRevision = boardId & 0xff; + + FirmwareIAPObjSet(&iap); + /* Initialize the alarms library */ AlarmsInitialize(); diff --git a/ground/gcs/src/plugins/uavobjects/uavobjects.pro b/ground/gcs/src/plugins/uavobjects/uavobjects.pro index cdf94d760..9a7614360 100644 --- a/ground/gcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/gcs/src/plugins/uavobjects/uavobjects.pro @@ -101,6 +101,7 @@ UAVOBJS = \ $${UAVOBJ_XML_DIR}/hwspracingf3evosettings.xml \ $${UAVOBJ_XML_DIR}/hwpikoblxsettings.xml \ $${UAVOBJ_XML_DIR}/hwtinyfishsettings.xml \ + $${UAVOBJ_XML_DIR}/hwdiscoveryf4baresettings.xml \ $${UAVOBJ_XML_DIR}/i2cstats.xml \ $${UAVOBJ_XML_DIR}/magsensor.xml \ $${UAVOBJ_XML_DIR}/magstate.xml \ diff --git a/shared/uavobjectdefinition/hwdiscoveryf4baresettings.xml b/shared/uavobjectdefinition/hwdiscoveryf4baresettings.xml new file mode 100644 index 000000000..cec9ee30f --- /dev/null +++ b/shared/uavobjectdefinition/hwdiscoveryf4baresettings.xml @@ -0,0 +1,10 @@ + + + DiscoveryF4 Bare hardware configuration + + + + + + +