mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-02 22:18:28 -04:00
AP_CheckFirmware: add separate AP_CheckFirmwareDefine for correctly setting firmware versions
This commit is contained in:
parent
c54521511c
commit
fd3c723103
@ -218,16 +218,7 @@ const app_descriptor_t *get_app_descriptor(void)
|
||||
|
||||
#if !defined(HAL_BOOTLOADER_BUILD)
|
||||
extern const AP_HAL::HAL &hal;
|
||||
|
||||
/*
|
||||
declare constant app_descriptor in flash
|
||||
*/
|
||||
extern const app_descriptor_t app_descriptor;
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||
const app_descriptor_t app_descriptor __attribute__((section(".app_descriptor")));
|
||||
#else
|
||||
const app_descriptor_t app_descriptor;
|
||||
#endif
|
||||
|
||||
/*
|
||||
this is needed to ensure we don't elide the app_descriptor
|
||||
|
@ -57,45 +57,45 @@ enum class check_fw_result_t : uint8_t {
|
||||
#define AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED { 0x40, 0xa2, 0xe4, 0xf1, 0x64, 0x68, 0x91, 0x06 }
|
||||
|
||||
struct app_descriptor_unsigned {
|
||||
uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED;
|
||||
uint8_t sig[8];
|
||||
// crc1 is the crc32 from firmware start to start of image_crc1
|
||||
uint32_t image_crc1 = 0;
|
||||
uint32_t image_crc1;
|
||||
// crc2 is the crc32 from the start of version_major to the end of the firmware
|
||||
uint32_t image_crc2 = 0;
|
||||
uint32_t image_crc2;
|
||||
// total size of firmware image in bytes
|
||||
uint32_t image_size = 0;
|
||||
uint32_t git_hash = 0;
|
||||
uint32_t image_size;
|
||||
uint32_t git_hash;
|
||||
|
||||
// software version number
|
||||
uint8_t version_major = APP_FW_MAJOR;
|
||||
uint8_t version_minor = APP_FW_MINOR;
|
||||
uint8_t version_major;
|
||||
uint8_t version_minor;
|
||||
// APJ_BOARD_ID (hardware version). This is also used in CAN NodeInfo
|
||||
// with high byte in HardwareVersion.major and low byte in HardwareVersion.minor
|
||||
uint16_t board_id = APJ_BOARD_ID;
|
||||
uint8_t reserved[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
uint16_t board_id;
|
||||
uint8_t reserved[8];
|
||||
};
|
||||
|
||||
struct app_descriptor_signed {
|
||||
uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_SIGNED;
|
||||
uint8_t sig[8];
|
||||
// crc1 is the crc32 from firmware start to start of image_crc1
|
||||
uint32_t image_crc1 = 0;
|
||||
uint32_t image_crc1;
|
||||
// crc2 is the crc32 from the start of version_major to the end of the firmware
|
||||
uint32_t image_crc2 = 0;
|
||||
uint32_t image_crc2;
|
||||
// total size of firmware image in bytes
|
||||
uint32_t image_size = 0;
|
||||
uint32_t git_hash = 0;
|
||||
uint32_t image_size;
|
||||
uint32_t git_hash;
|
||||
|
||||
// firmware signature
|
||||
uint32_t signature_length = 0;
|
||||
uint8_t signature[72] = {};
|
||||
uint32_t signature_length;
|
||||
uint8_t signature[72];
|
||||
|
||||
// software version number
|
||||
uint8_t version_major = APP_FW_MAJOR;
|
||||
uint8_t version_minor = APP_FW_MINOR;
|
||||
uint8_t version_major;
|
||||
uint8_t version_minor;
|
||||
// APJ_BOARD_ID (hardware version). This is also used in CAN NodeInfo
|
||||
// with high byte in HardwareVersion.major and low byte in HardwareVersion.minor
|
||||
uint16_t board_id = APJ_BOARD_ID;
|
||||
uint8_t reserved[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
uint16_t board_id;
|
||||
uint8_t reserved[8];
|
||||
};
|
||||
|
||||
#if AP_SIGNED_FIRMWARE
|
||||
|
35
libraries/AP_CheckFirmware/AP_CheckFirmwareDefine.h
Normal file
35
libraries/AP_CheckFirmware/AP_CheckFirmwareDefine.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef FORCE_VERSION_H_INCLUDE
|
||||
#error AP_CheckFirmwareDefines.h should never be included directly. You probably want to include AP_CheckFirmware/AP_CheckFirmware.h
|
||||
#endif
|
||||
#include "AP_CheckFirmware.h"
|
||||
|
||||
#if AP_CHECK_FIRMWARE_ENABLED
|
||||
/*
|
||||
declare constant app_descriptor in flash
|
||||
*/
|
||||
extern const app_descriptor_t app_descriptor;
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||
const app_descriptor_t app_descriptor __attribute__((section(".app_descriptor"))) = {
|
||||
#else
|
||||
const app_descriptor_t app_descriptor = {
|
||||
#endif
|
||||
#if AP_SIGNED_FIRMWARE
|
||||
.sig = AP_APP_DESCRIPTOR_SIGNATURE_SIGNED,
|
||||
#else
|
||||
.sig = AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED,
|
||||
#endif
|
||||
.image_crc1 = 0,
|
||||
.image_crc2 = 0,
|
||||
.image_size = 0,
|
||||
.git_hash = 0,
|
||||
#if AP_SIGNED_FIRMWARE
|
||||
.signature_length = 0,
|
||||
.signature = {},
|
||||
#endif
|
||||
.version_major = APP_FW_MAJOR,
|
||||
.version_minor = APP_FW_MINOR,
|
||||
.board_id = APJ_BOARD_ID,
|
||||
.reserved = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
|
||||
};
|
||||
#endif // AP_CHECK_FIRMWARE_ENABLED
|
Loading…
Reference in New Issue
Block a user