From df75c1796ab3cfc975828b54b849ebcdddbfe0a1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 11 Aug 2022 18:03:25 +1000 Subject: [PATCH] waf: added --enable-check-firmware option --- Tools/ardupilotwaf/ardupilotwaf.py | 1 + Tools/ardupilotwaf/boards.py | 10 ++++++++++ Tools/ardupilotwaf/chibios.py | 24 +++++++++--------------- wscript | 4 ++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index 1db0f43f9f..8495b8bff7 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -111,6 +111,7 @@ COMMON_VEHICLE_DEPENDENT_LIBRARIES = [ 'AP_CustomRotations', 'AP_AIS', 'AP_OpenDroneID', + 'AP_CheckFirmware', ] def get_legacy_defines(sketch_name, bld): diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 33133ee3af..a06feadacb 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -94,6 +94,16 @@ class Board: ENABLE_ONVIF=0, ) + # allow enable of firmware ID checking for any board + if cfg.options.enable_check_firmware: + env.CHECK_FIRMWARE_ENABLED = True + env.DEFINES.update( + AP_CHECK_FIRMWARE_ENABLED=1, + ) + cfg.msg("Enabled firmware ID checking", 'yes') + else: + cfg.msg("Enabled firmware ID checking", 'no', color='YELLOW') + d = env.get_merged_dict() # Always prepend so that arguments passed in the command line get # the priority. diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index 4c75d4f2a6..790e6c6096 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -236,17 +236,11 @@ class set_app_descriptor(Task.Task): def keyword(self): return "app_descriptor" def run(self): - if not 'APP_DESCRIPTOR' in self.env: - return - if self.env.APP_DESCRIPTOR == 'MissionPlanner': - descriptor = b'\x40\xa2\xe4\xf1\x64\x68\x91\x06' - else: - Logs.error("Bad APP_DESCRIPTOR %s" % self.env.APP_DESCRIPTOR) - return + descriptor = b'\x40\xa2\xe4\xf1\x64\x68\x91\x06' img = open(self.inputs[0].abspath(), 'rb').read() offset = img.find(descriptor) if offset == -1: - Logs.error("Failed to find %s APP_DESCRIPTOR" % self.env.APP_DESCRIPTOR) + Logs.info("No APP_DESCRIPTOR found") return offset += 8 # next 8 bytes is 64 bit CRC. We set first 4 bytes to @@ -263,7 +257,7 @@ class set_app_descriptor(Task.Task): githash = to_unsigned(int('0x' + os.environ.get('GIT_VERSION', self.generator.bld.git_head_hash(short=True)),16)) desc = struct.pack('