From 715d0813416a579685c5615996cc3ccfdeb8468b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 13 Oct 2017 08:33:57 +0800 Subject: [PATCH] freertos: fix compilation errors with portMUX debugging enabled Fixes https://github.com/espressif/esp-idf/issues/1057 Ref TW15702. --- components/app_trace/app_trace_util.c | 8 ++++++++ components/freertos/include/freertos/portmacro.h | 2 +- components/freertos/port.c | 2 +- components/freertos/tasks.c | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/app_trace/app_trace_util.c b/components/app_trace/app_trace_util.c index 524a861ab..2af3cd4d9 100644 --- a/components/app_trace/app_trace_util.c +++ b/components/app_trace/app_trace_util.c @@ -54,7 +54,11 @@ esp_err_t esp_apptrace_lock_take(esp_apptrace_lock_t *lock, esp_apptrace_tmo_t * // FIXME: if mux is busy it is not good idea to loop during the whole tmo with disabled IRQs. // So we check mux state using zero tmo, restore IRQs and let others tasks/IRQs to run on this CPU // while we are doing our own tmo check. +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + bool success = vPortCPUAcquireMutexTimeout(&lock->mux, 0, __FUNCTION__, __LINE__); +#else bool success = vPortCPUAcquireMutexTimeout(&lock->mux, 0); +#endif if (success) { lock->int_state = int_state; return ESP_OK; @@ -75,7 +79,11 @@ esp_err_t esp_apptrace_lock_give(esp_apptrace_lock_t *lock) unsigned int_state = lock->int_state; // after call to the following func we can not be sure that lock->int_state // is not overwritten by other CPU who has acquired the mux just after we released it. See esp_apptrace_lock_take(). +#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG + vPortCPUReleaseMutex(&lock->mux, __FUNCTION__, __LINE__); +#else vPortCPUReleaseMutex(&lock->mux); +#endif portEXIT_CRITICAL_NESTED(int_state); return ESP_OK; } diff --git a/components/freertos/include/freertos/portmacro.h b/components/freertos/include/freertos/portmacro.h index fbfe9828f..525cd27a5 100644 --- a/components/freertos/include/freertos/portmacro.h +++ b/components/freertos/include/freertos/portmacro.h @@ -206,7 +206,7 @@ void vPortCPUInitializeMutex(portMUX_TYPE *mux); #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *function, int line); bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles, const char *function, int line); -portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *function, int line); +void vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *function, int line); void vTaskEnterCritical( portMUX_TYPE *mux, const char *function, int line ); diff --git a/components/freertos/port.c b/components/freertos/port.c index 63aa55371..99d4454b3 100644 --- a/components/freertos/port.c +++ b/components/freertos/port.c @@ -319,7 +319,7 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *fnName, int line) { portEXIT_CRITICAL_NESTED(irqStatus); } -bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, uint32_t timeout_cycles, const char *fnName, int line) { +bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles, const char *fnName, int line) { unsigned int irqStatus = portENTER_CRITICAL_NESTED(); bool result = vPortCPUAcquireMutexIntsDisabled(mux, timeout_cycles, fnName, line); portEXIT_CRITICAL_NESTED(irqStatus); diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 15d2e135d..2c843664c 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -2841,7 +2841,7 @@ void vTaskSwitchContext( void ) //Exit critical region manually as well: release the mux now, interrupts will be re-enabled when we //exit the function. #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG - vPortCPUReleaseMutex( &xTaskQueueMutex, function, line ); + vPortCPUReleaseMutex( &xTaskQueueMutex, __FUNCTION__, __LINE__ ); #else vPortCPUReleaseMutex( &xTaskQueueMutex ); #endif