mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_CheckFirmware: allow access to app descriptor from bootloader
This commit is contained in:
parent
7fabce6cb6
commit
c54521511c
@ -78,7 +78,7 @@ static check_fw_result_t check_firmware_signature(const app_descriptor_signed *a
|
|||||||
/*
|
/*
|
||||||
check firmware CRC and board ID to see if it matches
|
check firmware CRC and board ID to see if it matches
|
||||||
*/
|
*/
|
||||||
static check_fw_result_t check_good_firmware_signed()
|
static check_fw_result_t check_good_firmware_signed(void)
|
||||||
{
|
{
|
||||||
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_SIGNED;
|
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_SIGNED;
|
||||||
const uint8_t *flash1 = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
|
const uint8_t *flash1 = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
|
||||||
@ -130,7 +130,7 @@ static check_fw_result_t check_good_firmware_signed()
|
|||||||
check firmware CRC and board ID to see if it matches, using unsigned
|
check firmware CRC and board ID to see if it matches, using unsigned
|
||||||
signature
|
signature
|
||||||
*/
|
*/
|
||||||
static check_fw_result_t check_good_firmware_unsigned()
|
static check_fw_result_t check_good_firmware_unsigned(void)
|
||||||
{
|
{
|
||||||
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED;
|
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED;
|
||||||
const uint8_t *flash1 = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
|
const uint8_t *flash1 = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
|
||||||
@ -201,6 +201,19 @@ check_fw_result_t check_good_firmware(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const app_descriptor_t *get_app_descriptor(void)
|
||||||
|
{
|
||||||
|
#if AP_SIGNED_FIRMWARE
|
||||||
|
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_SIGNED;
|
||||||
|
#else
|
||||||
|
const uint8_t sig[8] = AP_APP_DESCRIPTOR_SIGNATURE_UNSIGNED;
|
||||||
|
#endif
|
||||||
|
const uint8_t *flash1 = (const uint8_t *)(FLASH_LOAD_ADDRESS + (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB)*1024);
|
||||||
|
const uint32_t flash_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024;
|
||||||
|
const app_descriptor_t *ad = (const app_descriptor_t *)memmem(flash1, flash_size-sizeof(app_descriptor_t), sig, sizeof(sig));
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // HAL_BOOTLOADER_BUILD
|
#endif // HAL_BOOTLOADER_BUILD
|
||||||
|
|
||||||
#if !defined(HAL_BOOTLOADER_BUILD)
|
#if !defined(HAL_BOOTLOADER_BUILD)
|
||||||
|
@ -126,6 +126,7 @@ struct PACKED ap_secure_data {
|
|||||||
|
|
||||||
#ifdef HAL_BOOTLOADER_BUILD
|
#ifdef HAL_BOOTLOADER_BUILD
|
||||||
check_fw_result_t check_good_firmware(void);
|
check_fw_result_t check_good_firmware(void);
|
||||||
|
const app_descriptor_t *get_app_descriptor(void);
|
||||||
#else
|
#else
|
||||||
void check_firmware_print(void);
|
void check_firmware_print(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user