From ad2ef95ddf8c533fe7868d9591c231ef9658b191 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 31 Aug 2017 07:39:12 -1000 Subject: [PATCH] stm32 FLASH allow non blocking operation on constrained devices On a very memory constrained device with a single task. The sem_wait and sem_post operations can be disabled, to save space. The default is blocking enabled. --- arch/arm/src/stm32/Kconfig | 8 ++++++++ arch/arm/src/stm32/stm32_flash.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 93ebf3ab4e7..db0d4799ee7 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -2832,6 +2832,14 @@ config STM32_FLASH_PREFETCH on F1 parts). Some early revisions of F4 parts do not support FLASH pre-fetch properly and enabling this option may interfere with ADC accuracy. +config STM32_FLASH_NONBLOCKING + bool "Remove Blocking operation in FLASH driver" + default n + ---help--- + Enable this on single task platforms to conserve code space. + It removes the sem_wait and post operations that are not + needed in a single task environment. + config STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW bool "Workaround for FLASH data cache corruption" default n diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index e43d4a5185f..dbb7e4500e8 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -100,23 +100,29 @@ * Private Data ************************************************************************************/ +#if !defined(CONFIG_STM32_FLASH_NONBLOCKING) static sem_t g_sem = SEM_INITIALIZER(1); +#endif /************************************************************************************ * Private Functions ************************************************************************************/ -static void sem_lock(void) +static inline void sem_lock(void) { +#if !defined(CONFIG_STM32_FLASH_NONBLOCKING) while (sem_wait(&g_sem) < 0) { DEBUGASSERT(errno == EINTR); } +#endif } static inline void sem_unlock(void) { +#if !defined(CONFIG_STM32_FLASH_NONBLOCKING) sem_post(&g_sem); +#endif } #if !defined(CONFIG_STM32_STM32L15XX)