Skip to content

Commit 328ce32

Browse files
authored
Merge pull request #63 from gwnpeter/rtx5
增加rtx5支持,修改字符格式化方式适应更多场合
2 parents a8973df + b4ae8b9 commit 328ce32

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

cm_backtrace/Languages/en-US/cmb_en_US.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[PRINT_MAIN_STACK_INFO] = "====== Main stack information ======",
3737
[PRINT_THREAD_STACK_OVERFLOW] = "Error: Thread stack(%08x) was overflow",
3838
[PRINT_MAIN_STACK_OVERFLOW] = "Error: Main stack(%08x) was overflow",
39-
[PRINT_CALL_STACK_INFO] = "Show more call stack info by run: addr2line -e %s%s -a -f %.*s",
39+
[PRINT_CALL_STACK_INFO] = "Show more call stack info by run: addr2line -e %s%s -a -f %s",
4040
[PRINT_CALL_STACK_ERR] = "Dump call stack has an error",
4141
[PRINT_FAULT_ON_THREAD] = "Fault on thread %s",
4242
[PRINT_FAULT_ON_HANDLER] = "Fault on interrupt or bare metal(no OS) environment",

cm_backtrace/Languages/zh-CN/cmb_zh_CN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[PRINT_MAIN_STACK_INFO] = "============ 主堆栈信息 ============",
3737
[PRINT_THREAD_STACK_OVERFLOW] = "错误:线程栈(%08x)发生溢出",
3838
[PRINT_MAIN_STACK_OVERFLOW] = "错误:主栈(%08x)发生溢出",
39-
[PRINT_CALL_STACK_INFO] = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %.*s",
39+
[PRINT_CALL_STACK_INFO] = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %s",
4040
[PRINT_CALL_STACK_ERR] = "获取函数调用栈失败",
4141
[PRINT_FAULT_ON_THREAD] = "在线程(%s)中发生错误异常",
4242
[PRINT_FAULT_ON_HANDLER] = "在中断或裸机环境下发生错误异常",

cm_backtrace/Languages/zh-CN/cmb_zh_CN_UTF8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[PRINT_MAIN_STACK_INFO] = "============ 主堆栈信息 ============",
3737
[PRINT_THREAD_STACK_OVERFLOW] = "错误:线程栈(%08x)发生溢出",
3838
[PRINT_MAIN_STACK_OVERFLOW] = "错误:主栈(%08x)发生溢出",
39-
[PRINT_CALL_STACK_INFO] = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %.*s",
39+
[PRINT_CALL_STACK_INFO] = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %s",
4040
[PRINT_CALL_STACK_ERR] = "获取函数调用栈失败",
4141
[PRINT_FAULT_ON_THREAD] = "在线程(%s)中发生错误异常",
4242
[PRINT_FAULT_ON_HANDLER] = "在中断或裸机环境下发生错误异常",

cm_backtrace/cm_backtrace.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ static void get_cur_thread_stack_info(uint32_t sp, uint32_t *start_addr, size_t
207207
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
208208
*start_addr = (uint32_t)vTaskStackAddr();
209209
*size = vTaskStackSize() * sizeof( StackType_t );
210+
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
211+
osRtxThread_t *thread = osRtxInfo.thread.run.curr;
212+
*start_addr = (uint32_t)thread->stack_mem;
213+
*size = thread->stack_size;
210214
#endif
211215
}
212216

@@ -231,6 +235,9 @@ static const char *get_cur_thread_name(void) {
231235
return (const char *)OSTCBCurPtr->NamePtr;
232236
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
233237
return vTaskName();
238+
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
239+
osThreadId_t id = osThreadGetId();
240+
return osThreadGetName(id);
234241
#endif
235242
}
236243

@@ -371,8 +378,8 @@ static void print_call_stack(uint32_t sp) {
371378
}
372379

373380
if (cur_depth) {
374-
cmb_println(print_info[PRINT_CALL_STACK_INFO], fw_name, CMB_ELF_FILE_EXTENSION_NAME, cur_depth * (8 + 1),
375-
call_stack_info);
381+
call_stack_info[cur_depth * (8 + 1) - 1] = '\0';
382+
cmb_println(print_info[PRINT_CALL_STACK_INFO], fw_name, CMB_ELF_FILE_EXTENSION_NAME, call_stack_info);
376383
} else {
377384
cmb_println(print_info[PRINT_CALL_STACK_ERR]);
378385
}

cm_backtrace/cmb_cfg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
#define _CMB_CFG_H_
3131

3232
/* print line, must config by user */
33-
#define cmb_println(...) /* e.g., printf(__VA_ARGS__);printf("\r\n") */
33+
#define cmb_println(...) /* e.g., printf(__VA_ARGS__);printf("\r\n") or SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_WriteString(0, "\r\n") */
3434
/* enable bare metal(no OS) platform */
3535
/* #define CMB_USING_BARE_METAL_PLATFORM */
3636
/* enable OS platform */
3737
/* #define CMB_USING_OS_PLATFORM */
3838
/* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */
39-
/* #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS */
39+
/* #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 */
4040
/* cpu platform type, must config by user */
4141
#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 */
4242
/* enable dump stack information */

cm_backtrace/cmb_def.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#define CMB_OS_PLATFORM_UCOSII 1
4747
#define CMB_OS_PLATFORM_UCOSIII 2
4848
#define CMB_OS_PLATFORM_FREERTOS 3
49+
#define CMB_OS_PLATFORM_RTX5 4
4950

5051
#define CMB_PRINT_LANGUAGE_ENGLISH 0
5152
#define CMB_PRINT_LANGUAGE_CHINESE 1
@@ -336,6 +337,8 @@ if (!(EXPR)) \
336337
extern uint32_t *vTaskStackAddr(void);/* need to modify the FreeRTOS/tasks source code */
337338
extern uint32_t vTaskStackSize(void);
338339
extern char * vTaskName(void);
340+
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
341+
#include "rtx_os.h"
339342
#else
340343
#error "not supported OS type"
341344
#endif /* (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT) */

0 commit comments

Comments
 (0)