diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index 14b0a8d009..506d30ddf8 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -616,6 +616,7 @@ typedef enum reset_mode_e { int board_configure_reset(reset_mode_e mode, uint32_t arg); #endif +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) /**************************************************************************** * Name: board_booted_by_px4 * @@ -631,7 +632,7 @@ int board_configure_reset(reset_mode_e mode, uint32_t arg); ****************************************************************************/ bool board_booted_by_px4(void); - +#endif /************************************************************************************ * Name: board_query_manifest * diff --git a/platforms/nuttx/src/canbootloader/uavcan/main.c b/platforms/nuttx/src/canbootloader/uavcan/main.c index b6492cce02..5e64734093 100644 --- a/platforms/nuttx/src/canbootloader/uavcan/main.c +++ b/platforms/nuttx/src/canbootloader/uavcan/main.c @@ -84,8 +84,6 @@ #pragma message "******** DANGER DEBUG_APPLICATION_INPLACE is DEFINED ******" #endif -extern bootloader_alt_app_shared_t _sapp_bl_shared; - typedef volatile struct bootloader_t { can_speed_t bus_speed; volatile uint8_t health; @@ -1104,7 +1102,7 @@ __EXPORT int main(int argc, char *argv[]) bootloader.app_bl_request = (OK == bootloader_app_shared_read(&common, App)) && common.bus_speed && common.node_id; - +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) /* Was this boot a result of An Alternate Application being told it has a FW update ? */ bootloader_alt_app_shared_t *ps = (bootloader_alt_app_shared_t *) &_sapp_bl_shared; @@ -1117,6 +1115,7 @@ __EXPORT int main(int argc, char *argv[]) ps->signature = 0; } +#endif /* * Mark CRC to say this is not from * auto baud and Node Allocation diff --git a/platforms/nuttx/src/px4/stm/stm32_common/board_reset/board_reset.cpp b/platforms/nuttx/src/px4/stm/stm32_common/board_reset/board_reset.cpp index 7dc3c14942..c5bf204779 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/board_reset/board_reset.cpp +++ b/platforms/nuttx/src/px4/stm/stm32_common/board_reset/board_reset.cpp @@ -131,6 +131,7 @@ int board_reset(int status) #endif /* CONFIG_BOARDCTL_RESET */ +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) /**************************************************************************** * Name: board_booted_by_px4 * @@ -152,3 +153,4 @@ bool board_booted_by_px4(void) return (vectors[2] == vectors[3]) && (vectors[4] == vectors[5]); } +#endif diff --git a/src/drivers/bootloaders/boot_alt_app_shared.c b/src/drivers/bootloaders/boot_alt_app_shared.c index ecab7df9bb..ac0b726e85 100644 --- a/src/drivers/bootloaders/boot_alt_app_shared.c +++ b/src/drivers/bootloaders/boot_alt_app_shared.c @@ -34,6 +34,7 @@ #include +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) #include #include @@ -46,8 +47,6 @@ #include -extern void *_sapp_bl_shared; - /**************************************************************************** * Name: bootloader_alt_app_shared_read * @@ -142,3 +141,4 @@ __EXPORT void bootloader_alt_app_shared_invalidate(void) bootloader_alt_app_shared->signature = 0; } +#endif diff --git a/src/drivers/bootloaders/boot_alt_app_shared.h b/src/drivers/bootloaders/boot_alt_app_shared.h index 40e7d7f9e8..a4ede85718 100644 --- a/src/drivers/bootloaders/boot_alt_app_shared.h +++ b/src/drivers/bootloaders/boot_alt_app_shared.h @@ -35,7 +35,7 @@ #pragma once #include - +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) __BEGIN_DECLS /**************************************************************************** @@ -73,6 +73,7 @@ typedef begin_packed_struct struct bootloader_alt_app_shared_t { } end_packed_struct bootloader_alt_app_shared_t; #pragma GCC diagnostic pop +extern bootloader_alt_app_shared_t _sapp_bl_shared; /**************************************************************************** * Name: bootloader_alt_app_shared_read @@ -144,3 +145,4 @@ void bootloader_alt_app_shared_write(bootloader_alt_app_shared_t *alt_shared); void bootloader_alt_app_shared_invalidate(void); __END_DECLS +#endif diff --git a/src/drivers/uavcannode/UavcanNode.cpp b/src/drivers/uavcannode/UavcanNode.cpp index fbac32ffd4..49396dae6b 100644 --- a/src/drivers/uavcannode/UavcanNode.cpp +++ b/src/drivers/uavcannode/UavcanNode.cpp @@ -251,17 +251,19 @@ void UavcanNode::cb_beginfirmware_update(const uavcan::ReceivedDataStructure uavcan::NodeID::Max || !uavcan::NodeID(node_id).isUnicast())) { + if ( +#if defined(SUPPORT_ALT_CAN_BOOTLOADER) + board_booted_by_px4() && +#endif + (node_id < 0 || node_id > uavcan::NodeID::Max || !uavcan::NodeID(node_id).isUnicast())) { PX4_ERR("Invalid Node ID %i", node_id); return 1; }