From 8b7ea70029f3a50e42c20c1385b258801c98e3b2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 Jan 2022 21:33:43 +1100 Subject: [PATCH] AP_Common: support AP_CUSTOM_FIRMWARE_STRING this allows vendors to setup a custom firmware string in hwdef.dat, which makes maintaining a vehicle specific firmware easier --- libraries/AP_Common/AP_FWVersion.h | 1 + libraries/AP_Common/AP_FWVersionDefine.h | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libraries/AP_Common/AP_FWVersion.h b/libraries/AP_Common/AP_FWVersion.h index dc361c765e..033f45f0fb 100644 --- a/libraries/AP_Common/AP_FWVersion.h +++ b/libraries/AP_Common/AP_FWVersion.h @@ -28,6 +28,7 @@ public: const uint32_t os_sw_version; const char *fw_string; const char *fw_hash_str; + const char *fw_string_original; const char *fw_short_string; const char *middleware_name; const char *middleware_hash_str; diff --git a/libraries/AP_Common/AP_FWVersionDefine.h b/libraries/AP_Common/AP_FWVersionDefine.h index d2fe56ea74..4d3f18e56f 100644 --- a/libraries/AP_Common/AP_FWVersionDefine.h +++ b/libraries/AP_Common/AP_FWVersionDefine.h @@ -23,6 +23,17 @@ #include #include +/* + allow vendors to set AP_CUSTOM_FIRMWARE_STRING in hwdef.dat + */ +#ifdef AP_CUSTOM_FIRMWARE_STRING +#define ACTIVE_FWSTR AP_CUSTOM_FIRMWARE_STRING +#define ORIGINAL_FWSTR THISFIRMWARE +#else +#define ACTIVE_FWSTR THISFIRMWARE +#define ORIGINAL_FWSTR nullptr +#endif + const AP_FWVersion AP_FWVersion::fwver{ // Version header struct .header = 0x61706677766572fb, // First 7 MSBs: "apfwver", LSB is the checksum of the previous string: 0xfb @@ -43,13 +54,14 @@ const AP_FWVersion AP_FWVersion::fwver{ .os_sw_version = 0, #endif #ifndef GIT_VERSION - .fw_string = THISFIRMWARE, + .fw_string = ACTIVE_FWSTR, .fw_hash_str = "", #else - .fw_string = THISFIRMWARE " (" GIT_VERSION ")", + .fw_string = ACTIVE_FWSTR " (" GIT_VERSION ")", .fw_hash_str = GIT_VERSION, #endif - .fw_short_string = THISFIRMWARE, + .fw_string_original = ORIGINAL_FWSTR, + .fw_short_string = ACTIVE_FWSTR, .middleware_name = nullptr, .middleware_hash_str = nullptr, #ifdef CHIBIOS_GIT_VERSION