diff --git a/libraries/AP_HAL_ChibiOS/Device.h b/libraries/AP_HAL_ChibiOS/Device.h index 9bd218d412..8225e017d9 100644 --- a/libraries/AP_HAL_ChibiOS/Device.h +++ b/libraries/AP_HAL_ChibiOS/Device.h @@ -16,7 +16,11 @@ #include #include +#if !defined(HAL_BOOTLOADER_BUILD) #include "Semaphores.h" +#else +#include +#endif #include "AP_HAL_ChibiOS.h" #if HAL_USE_I2C == TRUE || HAL_USE_SPI == TRUE || HAL_USE_WSPI == TRUE @@ -34,7 +38,11 @@ public: DeviceBus(uint8_t _thread_priority, bool axi_sram); struct DeviceBus *next; +#if defined(HAL_BOOTLOADER_BUILD) + Empty::Semaphore semaphore; +#else Semaphore semaphore; +#endif Shared_DMA *dma_handle; AP_HAL::Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, AP_HAL::Device::PeriodicCb, AP_HAL::Device *hal_device); diff --git a/libraries/AP_HAL_ChibiOS/QSPIDevice.cpp b/libraries/AP_HAL_ChibiOS/QSPIDevice.cpp index a4abdd6e52..04ec03ce7e 100644 --- a/libraries/AP_HAL_ChibiOS/QSPIDevice.cpp +++ b/libraries/AP_HAL_ChibiOS/QSPIDevice.cpp @@ -25,7 +25,6 @@ #include #include "Util.h" #include "Scheduler.h" -#include "Semaphores.h" #include #include "hwdef/common/stm32_util.h" diff --git a/libraries/AP_HAL_ChibiOS/QSPIDevice.h b/libraries/AP_HAL_ChibiOS/QSPIDevice.h index e3f8c3469e..5c04845a57 100644 --- a/libraries/AP_HAL_ChibiOS/QSPIDevice.h +++ b/libraries/AP_HAL_ChibiOS/QSPIDevice.h @@ -26,7 +26,10 @@ #if HAL_USE_WSPI == TRUE && defined(HAL_QSPI_DEVICE_LIST) +#if !defined(HAL_BOOTLOADER_BUILD) #include "Semaphores.h" +#endif + #include "Scheduler.h" #include "Device.h" @@ -99,8 +102,12 @@ public: AP_HAL::Semaphore* get_semaphore() override { +#if !defined(HAL_BOOTLOADER_BUILD) // if asking for invalid bus number use bus 0 semaphore return &bus.semaphore; +#else + return nullptr; +#endif } bool acquire_bus(bool acquire); diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 3cc0e66acd..a5ecb13b23 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -884,19 +884,19 @@ def write_mcu_config(f): #define HAL_NO_RCIN_THREAD #define HAL_NO_SHARED_DMA FALSE #define HAL_NO_ROMFS_SUPPORT TRUE -''') - if not env_vars['EXTERNAL_PROG_FLASH_MB']: - f.write(''' #define CH_CFG_USE_TM FALSE #define CH_CFG_USE_REGISTRY FALSE #define CH_CFG_USE_WAITEXIT FALSE #define CH_CFG_USE_MEMPOOLS FALSE #define CH_DBG_FILL_THREADS FALSE -#define CH_CFG_USE_SEMAPHORES FALSE -#define CH_CFG_USE_HEAP FALSE #define CH_CFG_USE_MUTEXES FALSE #define CH_CFG_USE_EVENTS FALSE #define CH_CFG_USE_EVENTS_TIMEOUT FALSE +''') + if not env_vars['EXTERNAL_PROG_FLASH_MB']: + f.write(''' +#define CH_CFG_USE_HEAP FALSE +#define CH_CFG_USE_SEMAPHORES FALSE #define CH_CFG_USE_MEMCORE FALSE ''') if env_vars.get('ROMFS_UNCOMPRESSED', False):