From a300d9030b139267291a45b1def460c940890ad0 Mon Sep 17 00:00:00 2001 From: andeyqi Date: Wed, 3 Jul 2024 09:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0THREADX=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cm_backtrace/cm_backtrace.c | 9 +++++++++ cm_backtrace/cmb_cfg.h | 2 +- cm_backtrace/cmb_def.h | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cm_backtrace/cm_backtrace.c b/cm_backtrace/cm_backtrace.c index 8390803..3e76321 100644 --- a/cm_backtrace/cm_backtrace.c +++ b/cm_backtrace/cm_backtrace.c @@ -214,6 +214,11 @@ static void get_cur_thread_stack_info(uint32_t *sp, uint32_t *start_addr, size_t osRtxThread_t *thread = osRtxInfo.thread.run.curr; *start_addr = (uint32_t)thread->stack_mem; *size = thread->stack_size; +#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_THREADX) + TX_THREAD * ptThread = NULL; + TX_THREAD_GET_CURRENT(ptThread); + *start_addr = (uint32_t)ptThread->tx_thread_stack_start; + *size = ptThread->tx_thread_stack_size; #endif } @@ -244,6 +249,10 @@ static const char *get_cur_thread_name(void) { return vTaskName(); #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) return osRtxInfo.thread.run.curr->name; +#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_THREADX) + TX_THREAD * ptThread = NULL; + TX_THREAD_GET_CURRENT(ptThread); + return ptThread->tx_thread_name; #endif } diff --git a/cm_backtrace/cmb_cfg.h b/cm_backtrace/cmb_cfg.h index b9a0b09..a269cb5 100644 --- a/cm_backtrace/cmb_cfg.h +++ b/cm_backtrace/cmb_cfg.h @@ -39,7 +39,7 @@ /* enable OS platform */ /* #define CMB_USING_OS_PLATFORM */ /* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */ -/* #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 */ +/* #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 or CMB_OS_PLATFORM_THREADX */ /* cpu platform type, must config by user */ #define CMB_CPU_PLATFORM_TYPE /* CMB_CPU_ARM_CORTEX_M0 or CMB_CPU_ARM_CORTEX_M3 or CMB_CPU_ARM_CORTEX_M4 or CMB_CPU_ARM_CORTEX_M7 or CMB_CPU_ARM_CORTEX_M33 */ /* enable dump stack information */ diff --git a/cm_backtrace/cmb_def.h b/cm_backtrace/cmb_def.h index a78894b..0740c61 100644 --- a/cm_backtrace/cmb_def.h +++ b/cm_backtrace/cmb_def.h @@ -47,6 +47,7 @@ #define CMB_OS_PLATFORM_UCOSIII 2 #define CMB_OS_PLATFORM_FREERTOS 3 #define CMB_OS_PLATFORM_RTX5 4 +#define CMB_OS_PLATFORM_THREADX 5 #define CMB_PRINT_LANGUAGE_ENGLISH 0 #define CMB_PRINT_LANGUAGE_CHINESE 1 @@ -348,6 +349,9 @@ if (!(EXPR)) \ extern char * vTaskName(void); #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) #include "rtx_os.h" + #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_THREADX) + #include "tx_api.h" + #include "tx_thread.h" #else #error "not supported OS type" #endif /* (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT) */