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
This commit is contained in:
Andrew Tridgell 2022-01-14 21:33:43 +11:00
parent d85dae8e50
commit 8b7ea70029
2 changed files with 16 additions and 3 deletions

View File

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

View File

@ -23,6 +23,17 @@
#include <AP_Common/AP_FWVersion.h>
#include <AP_Vehicle/AP_Vehicle_Type.h>
/*
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