1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Merged in mindnever/librepilot/LP-556-Allow_BoardId_and_Revision_spoofing (pull request #475)

LP-556 Allow BoardId and Revision spoofing

Approved-by: Alessio Morale <alessiomorale@gmail.com>
Approved-by: Vladimir Zidar <mr_w@mindnever.org>
Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
Approved-by: Lalanne Laurent <f5soh@free.fr>
This commit is contained in:
Vladimir Zidar 2018-03-11 12:23:18 +00:00 committed by Philippe Renon
commit 784efc12cf
5 changed files with 51 additions and 2 deletions

View File

@ -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.BoardType == 0) {
data.BoardRevision = bdinfo->board_rev;
data.BoardType = bdinfo->board_type;
}
data.BootloaderRevision = bdinfo->bl_rev;
data.ArmReset = 0;
data.crc = 0;

View File

@ -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

View File

@ -33,6 +33,8 @@
#include <taskinfo.h>
#include <pios_ws2811.h>
#include "hwdiscoveryf4baresettings.h"
#include "firmwareiapobj.h"
#ifdef PIOS_INCLUDE_INSTRUMENTATION
#include <pios_instrumentation.h>
@ -58,6 +60,19 @@ uintptr_t pios_user_fs_id;
uint32_t pios_ws2811_id;
#endif
static HwDiscoveryF4BareSettingsData boardHwSettings;
static void hwDiscoveryF4BareSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
HwDiscoveryF4BareSettingsData currentBoardHwSettings;
HwDiscoveryF4BareSettingsGet(&currentBoardHwSettings);
if (memcmp(&currentBoardHwSettings, &boardHwSettings, sizeof(HwDiscoveryF4BareSettingsData)) != 0) {
ExtendedAlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL, SYSTEMALARMS_EXTENDEDALARMSTATUS_REBOOTREQUIRED, 0);
}
}
static const PIOS_BOARD_IO_UART_Function flexiio_function_map[] = {
[HWSETTINGS_RM_RCVRPORT_PPMTELEMETRY] = PIOS_BOARD_IO_UART_TELEMETRY,
[HWSETTINGS_RM_RCVRPORT_PPMDEBUGCONSOLE] = PIOS_BOARD_IO_UART_DEBUGCONSOLE,
@ -189,6 +204,21 @@ void PIOS_Board_Init(void)
UAVObjInitialize();
SETTINGS_INITIALISE_ALL;
HwDiscoveryF4BareSettingsConnectCallback(hwDiscoveryF4BareSettingsUpdatedCb);
HwDiscoveryF4BareSettingsGet(&boardHwSettings);
if (boardHwSettings.BoardType != 0) {
FirmwareIAPObjInitialize();
FirmwareIAPObjData iap;
FirmwareIAPObjGet(&iap);
iap.BoardType = boardHwSettings.BoardType;
iap.BoardRevision = boardHwSettings.BoardRevision;
FirmwareIAPObjSet(&iap);
}
/* Initialize the alarms library */
AlarmsInitialize();

View File

@ -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 \

View File

@ -0,0 +1,11 @@
<xml>
<object name="HwDiscoveryF4BareSettings" singleinstance="true" settings="true" category="System">
<description>DiscoveryF4 Bare hardware configuration</description>
<field name="BoardRevision" units="" type="uint16" elements="1" defaultvalue="0"/>
<field name="BoardType" units="" type="uint8" elements="1" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="manual" period="0"/>
</object>
</xml>