diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 93ebf3ab4e..db0d4799ee 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 e43d4a5185..dbb7e4500e 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)