diff --git a/libraries/AP_Common/AP_FWVersion.h b/libraries/AP_Common/AP_FWVersion.h index 0bf66e978e..bbbbe9c621 100644 --- a/libraries/AP_Common/AP_FWVersion.h +++ b/libraries/AP_Common/AP_FWVersion.h @@ -3,21 +3,35 @@ #include #include -class AP_FWVersion { +class PACKED AP_FWVersion { public: - + /** + * @brief Struct to hold infomation about the software version struct + * + */ + // First 7 MSBs are a start sequence, LSB is a checksum + const uint64_t header; + // MSB (major version breaks compatibility), LSB (minor version no compatibility break) + const uint16_t header_version; + // Pointer size to extract pointer values + const uint8_t pointer_size; + + const uint8_t reserved; // padding + const uint8_t vehicle_type; + const uint8_t board_type; + const uint16_t board_subtype; const uint8_t major; const uint8_t minor; const uint8_t patch; - const FIRMWARE_VERSION_TYPE fw_type; + const uint8_t fw_type; /*FIRMWARE_VERSION_TYPE*/ + const uint32_t os_sw_version; const char *fw_string; const char *fw_hash_str; const char *middleware_name; const char *middleware_hash_str; const char *os_name; const char *os_hash_str; - const uint32_t os_sw_version; static const AP_FWVersion &get_fwverz() { return fwver; } diff --git a/libraries/AP_Common/AP_FWVersionDefine.h b/libraries/AP_Common/AP_FWVersionDefine.h index a93fc7c78c..aff9210b8d 100644 --- a/libraries/AP_Common/AP_FWVersionDefine.h +++ b/libraries/AP_Common/AP_FWVersionDefine.h @@ -21,12 +21,27 @@ #endif #include +#include const AP_FWVersion AP_FWVersion::fwver{ + // Version header struct + .header = 0x61706677766572fb, // First 7 MSBs: "apfwver", LSB is the checksum of the previous string: 0xfb + .header_version = 0x0100U, // Major and minor version + .pointer_size = static_cast(sizeof(void*)), + .reserved = 0, + .vehicle_type = static_cast(APM_BUILD_DIRECTORY), + .board_type = static_cast(CONFIG_HAL_BOARD), + .board_subtype = static_cast(CONFIG_HAL_BOARD_SUBTYPE), .major = FW_MAJOR, .minor = FW_MINOR, .patch = FW_PATCH, .fw_type = FW_TYPE, +#ifdef BUILD_DATE_YEAR + // encode build date in os_sw_version + .os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY, +#else + .os_sw_version = 0, +#endif #ifndef GIT_VERSION .fw_string = THISFIRMWARE, .fw_hash_str = "", @@ -43,10 +58,4 @@ const AP_FWVersion AP_FWVersion::fwver{ .os_name = nullptr, .os_hash_str = nullptr, #endif -#ifdef BUILD_DATE_YEAR - // encode build date in os_sw_version - .os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY, -#else - .os_sw_version = 0, -#endif };