From 243cf2199d367d2647aa752ce3a7c269b2df6292 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Feb 2021 15:07:53 +1100 Subject: [PATCH] HAL_ChibiOS: disable shared DMA on IOMCU this saves about 600 bytes of ram --- libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp | 3 +++ libraries/AP_HAL_ChibiOS/RCOutput.cpp | 2 ++ libraries/AP_HAL_ChibiOS/Util.cpp | 2 ++ libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c | 1 - libraries/AP_HAL_ChibiOS/hwdef/iomcu/hwdef.dat | 1 + libraries/AP_HAL_ChibiOS/shared_dma.cpp | 3 ++- libraries/AP_HAL_ChibiOS/shared_dma.h | 4 ++++ 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp index acfcefde71..91e928f6ab 100644 --- a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp +++ b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp @@ -192,7 +192,10 @@ static void main_loop() ChibiOS::I2CBus::clear_all(); #endif +#ifndef HAL_NO_SHARED_DMA ChibiOS::Shared_DMA::init(); +#endif + peripheral_power_enable(); hal.serial(0)->begin(115200); diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index 40da4eb60a..1a22accf54 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -154,6 +154,7 @@ void RCOutput::rcout_thread() } } +#ifndef HAL_NO_SHARED_DMA // release locks on the groups that are pending in reverse order void RCOutput::dshot_collect_dma_locks(uint32_t last_run_us) { @@ -192,6 +193,7 @@ void RCOutput::dshot_collect_dma_locks(uint32_t last_run_us) } } } +#endif // HAL_NO_SHARED_DMA /* setup the output frequency for a group and start pwm output diff --git a/libraries/AP_HAL_ChibiOS/Util.cpp b/libraries/AP_HAL_ChibiOS/Util.cpp index c24a128afd..cb88434669 100644 --- a/libraries/AP_HAL_ChibiOS/Util.cpp +++ b/libraries/AP_HAL_ChibiOS/Util.cpp @@ -375,7 +375,9 @@ void Util::thread_info(ExpandingString &str) // request information on dma contention void Util::dma_info(ExpandingString &str) { +#ifndef HAL_NO_SHARED_DMA ChibiOS::Shared_DMA::dma_info(str); +#endif } #endif diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c index 44997c02b4..a75bef595d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c @@ -276,7 +276,6 @@ void set_rtc_backup(uint8_t idx, const uint32_t *v, uint8_t n) // get RTC backup registers starting at given idx void get_rtc_backup(uint8_t idx, uint32_t *v, uint8_t n) { - return 0; } #endif // NO_FASTBOOT diff --git a/libraries/AP_HAL_ChibiOS/hwdef/iomcu/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/iomcu/hwdef.dat index ffbb9dbbd7..0c97ca4013 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/iomcu/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/iomcu/hwdef.dat @@ -120,6 +120,7 @@ define HAL_NO_TIMER_THREAD define HAL_NO_RCIN_THREAD define HAL_NO_MONITOR_THREAD define HAL_NO_RCOUT_THREAD +define HAL_NO_SHARED_DMA #defined to turn off undef warnings define __FPU_PRESENT 0 diff --git a/libraries/AP_HAL_ChibiOS/shared_dma.cpp b/libraries/AP_HAL_ChibiOS/shared_dma.cpp index 68c5c11caa..6a631a3900 100644 --- a/libraries/AP_HAL_ChibiOS/shared_dma.cpp +++ b/libraries/AP_HAL_ChibiOS/shared_dma.cpp @@ -20,7 +20,7 @@ code to handle sharing of DMA channels between peripherals */ -#if CH_CFG_USE_MUTEXES == TRUE +#if CH_CFG_USE_MUTEXES == TRUE && !defined(HAL_NO_SHARED_DMA) #include @@ -267,3 +267,4 @@ void Shared_DMA::dma_info(ExpandingString &str) } #endif // CH_CFG_USE_SEMAPHORES + diff --git a/libraries/AP_HAL_ChibiOS/shared_dma.h b/libraries/AP_HAL_ChibiOS/shared_dma.h index c987a370b3..f408cf7b56 100644 --- a/libraries/AP_HAL_ChibiOS/shared_dma.h +++ b/libraries/AP_HAL_ChibiOS/shared_dma.h @@ -23,6 +23,8 @@ // DMA stream ID for stream_id2 when only one is needed #define SHARED_DMA_NONE 255 +#ifndef HAL_NO_SHARED_DMA + class ChibiOS::Shared_DMA { public: @@ -108,3 +110,5 @@ private: uint32_t transactions; } *_contention_stats; }; + +#endif // HAL_NO_SHARED_DMA