diff --git a/components/app_trace/app_trace_util.c b/components/app_trace/app_trace_util.c index 524a861abe..2af3cd4d9e 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 d4f96eb1d2..370551ceaf 100644 --- a/components/freertos/include/freertos/portmacro.h +++ b/components/freertos/include/freertos/portmacro.h @@ -203,7 +203,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 79e42160b4..ba406d88fe 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 f20715903d..91ee39ad87 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -2840,7 +2840,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