From 3eaba1c8ce7331ecc4511e0ce4c192b9d05b1e8a Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Thu, 18 Oct 2018 19:10:33 +0300 Subject: [PATCH] esp32: Fixes SystemView lock's IRQ state restore --- components/app_trace/app_trace.c | 1 - .../app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h | 9 +++++---- .../Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/app_trace/app_trace.c b/components/app_trace/app_trace.c index 5552fe5e2a..20871b44dc 100644 --- a/components/app_trace/app_trace.c +++ b/components/app_trace/app_trace.c @@ -172,7 +172,6 @@ #define ESP_APPTRACE_PRINT_LOCK 0 -#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL #include "esp_log.h" const static char *TAG = "esp_apptrace"; diff --git a/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h b/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h index 787237a00b..2968c6e021 100644 --- a/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h +++ b/components/app_trace/sys_view/Config/SEGGER_SYSVIEW_Conf.h @@ -166,10 +166,11 @@ Revision: $Rev: 5927 $ #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function. #endif -void SEGGER_SYSVIEW_X_SysView_Lock(); -void SEGGER_SYSVIEW_X_SysView_Unlock(); -#define SEGGER_SYSVIEW_LOCK() SEGGER_SYSVIEW_X_SysView_Lock() -#define SEGGER_SYSVIEW_UNLOCK() SEGGER_SYSVIEW_X_SysView_Unlock() +unsigned SEGGER_SYSVIEW_X_SysView_Lock(); +void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state); +// to be recursive save IRQ status on the stack of the caller +#define SEGGER_SYSVIEW_LOCK() unsigned _SYSVIEW_int_state = SEGGER_SYSVIEW_X_SysView_Lock() +#define SEGGER_SYSVIEW_UNLOCK() SEGGER_SYSVIEW_X_SysView_Unlock(_SYSVIEW_int_state) #endif // SEGGER_SYSVIEW_CONF_H diff --git a/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c b/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c index 08e85678ef..2df7ee0c12 100644 --- a/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c +++ b/components/app_trace/sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c @@ -337,15 +337,18 @@ void SEGGER_SYSVIEW_X_RTT_Unlock() { } -void SEGGER_SYSVIEW_X_SysView_Lock() +unsigned SEGGER_SYSVIEW_X_SysView_Lock() { esp_apptrace_tmo_t tmo; esp_apptrace_tmo_init(&tmo, SEGGER_LOCK_WAIT_TMO); esp_apptrace_lock_take(&s_sys_view_lock, &tmo); + // to be recursive save IRQ status on the stack of the caller to keep it from overwriting + return s_sys_view_lock.int_state; } -void SEGGER_SYSVIEW_X_SysView_Unlock() +void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state) { + s_sys_view_lock.int_state = int_state; esp_apptrace_lock_give(&s_sys_view_lock); }