Forráskód Böngészése

Merge pull request #5 from ChenxuanZhao/develop

Add Chinese UTF-8
朱天龙 (Armink) 5 éve
szülő
commit
3fcbc5ca26
9 módosított fájl, 249 hozzáadás és 88 törlés
  1. 8 0
      Languages/README.md
  2. 68 0
      Languages/en-US/cmb_en_US.h
  3. 68 0
      Languages/zh-CN/cmb_zh_CN.h
  4. 68 0
      Languages/zh-CN/cmb_zh_CN_UTF8.h
  5. 4 0
      SConscript
  6. 4 76
      cm_backtrace.c
  7. 8 0
      cm_backtrace.h
  8. 8 0
      cmb_cfg.h
  9. 13 12
      cmb_def.h

+ 8 - 0
Languages/README.md

@@ -0,0 +1,8 @@
+# CmBacktrace: ARM Cortex-M 系列 MCU 错误追踪库
+
+## 多语言支持
+
+| Language             | Location (or type)         | Language tag |
+|----------------------|----------------------------|--------------|
+| English              | United States              | en-US        |
+| Chinese (Simplified) | People's Republic of China | zh-CN        |

+ 68 - 0
Languages/en-US/cmb_en_US.h

@@ -0,0 +1,68 @@
+/*
+ * This file is part of the CmBacktrace Library.
+ *
+ * Copyright (c) 2020, Armink, <armink.ztl@gmail.com>
+ *                     Chenxuan, <chenxuan.zhao@icloud.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * 'Software'), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * NOTE: DO NOT include this file on the header file.
+ * Encoding: UTF-8
+ * Created on: 2020-09-06
+ */
+
+[PRINT_MAIN_STACK_CFG_ERROR]  = "ERROR: Unable to get the main stack information, please check the configuration of the main stack",
+[PRINT_FIRMWARE_INFO]         = "Firmware name: %s, hardware version: %s, software version: %s",
+[PRINT_ASSERT_ON_THREAD]      = "Assert on thread %s",
+[PRINT_ASSERT_ON_HANDLER]     = "Assert on interrupt or bare metal(no OS) environment",
+[PRINT_THREAD_STACK_INFO]     = "===== Thread stack information =====",
+[PRINT_MAIN_STACK_INFO]       = "====== Main stack information ======",
+[PRINT_THREAD_STACK_OVERFLOW] = "Error: Thread stack(%08x) was overflow",
+[PRINT_MAIN_STACK_OVERFLOW]   = "Error: Main stack(%08x) was overflow",
+[PRINT_CALL_STACK_INFO]       = "Show more call stack info by run: addr2line -e %s%s -a -f %.*s",
+[PRINT_CALL_STACK_ERR]        = "Dump call stack has an error",
+[PRINT_FAULT_ON_THREAD]       = "Fault on thread %s",
+[PRINT_FAULT_ON_HANDLER]      = "Fault on interrupt or bare metal(no OS) environment",
+[PRINT_REGS_TITLE]            = "=================== Registers information ====================",
+[PRINT_HFSR_VECTBL]           = "Hard fault is caused by failed vector fetch",
+[PRINT_MFSR_IACCVIOL]         = "Memory management fault is caused by instruction access violation",
+[PRINT_MFSR_DACCVIOL]         = "Memory management fault is caused by data access violation",
+[PRINT_MFSR_MUNSTKERR]        = "Memory management fault is caused by unstacking error",
+[PRINT_MFSR_MSTKERR]          = "Memory management fault is caused by stacking error",
+[PRINT_MFSR_MLSPERR]          = "Memory management fault is caused by floating-point lazy state preservation",
+[PRINT_BFSR_IBUSERR]          = "Bus fault is caused by instruction access violation",
+[PRINT_BFSR_PRECISERR]        = "Bus fault is caused by precise data access violation",
+[PRINT_BFSR_IMPREISERR]       = "Bus fault is caused by imprecise data access violation",
+[PRINT_BFSR_UNSTKERR]         = "Bus fault is caused by unstacking error",
+[PRINT_BFSR_STKERR]           = "Bus fault is caused by stacking error",
+[PRINT_BFSR_LSPERR]           = "Bus fault is caused by floating-point lazy state preservation",
+[PRINT_UFSR_UNDEFINSTR]       = "Usage fault is caused by attempts to execute an undefined instruction",
+[PRINT_UFSR_INVSTATE]         = "Usage fault is caused by attempts to switch to an invalid state (e.g., ARM)",
+[PRINT_UFSR_INVPC]            = "Usage fault is caused by attempts to do an exception with a bad value in the EXC_RETURN number",
+[PRINT_UFSR_NOCP]             = "Usage fault is caused by attempts to execute a coprocessor instruction",
+[PRINT_UFSR_UNALIGNED]        = "Usage fault is caused by indicates that an unaligned access fault has taken place",
+[PRINT_UFSR_DIVBYZERO0]       = "Usage fault is caused by Indicates a divide by zero has taken place (can be set only if DIV_0_TRP is set)",
+[PRINT_DFSR_HALTED]           = "Debug fault is caused by halt requested in NVIC",
+[PRINT_DFSR_BKPT]             = "Debug fault is caused by BKPT instruction executed",
+[PRINT_DFSR_DWTTRAP]          = "Debug fault is caused by DWT match occurred",
+[PRINT_DFSR_VCATCH]           = "Debug fault is caused by Vector fetch occurred",
+[PRINT_DFSR_EXTERNAL]         = "Debug fault is caused by EDBGRQ signal asserted",
+[PRINT_MMAR]                  = "The memory management fault occurred address is %08x",
+[PRINT_BFAR]                  = "The bus fault occurred address is %08x",

+ 68 - 0
Languages/zh-CN/cmb_zh_CN.h

@@ -0,0 +1,68 @@
+/*
+ * This file is part of the CmBacktrace Library.
+ *
+ * Copyright (c) 2020, Armink, <armink.ztl@gmail.com>
+ *                     Chenxuan, <chenxuan.zhao@icloud.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * 'Software'), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * NOTE: DO NOT include this file on the header file.
+ * Encoding: GB18030
+ * Created on: 2020-09-06
+ */
+
+[PRINT_MAIN_STACK_CFG_ERROR]  = "错误:无法获取主栈信息,请检查主栈的相关配置",
+[PRINT_FIRMWARE_INFO]         = "固件名称:%s,硬件版本号:%s,软件版本号:%s",
+[PRINT_ASSERT_ON_THREAD]      = "在线程(%s)中发生断言",
+[PRINT_ASSERT_ON_HANDLER]     = "在中断或裸机环境下发生断言",
+[PRINT_THREAD_STACK_INFO]     = "=========== 线程堆栈信息 ===========",
+[PRINT_MAIN_STACK_INFO]       = "============ 主堆栈信息 ============",
+[PRINT_THREAD_STACK_OVERFLOW] = "错误:线程栈(%08x)发生溢出",
+[PRINT_MAIN_STACK_OVERFLOW]   = "错误:主栈(%08x)发生溢出",
+[PRINT_CALL_STACK_INFO]       = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %.*s",
+[PRINT_CALL_STACK_ERR]        = "获取函数调用栈失败",
+[PRINT_FAULT_ON_THREAD]       =  "在线程(%s)中发生错误异常",
+[PRINT_FAULT_ON_HANDLER]      = "在中断或裸机环境下发生错误异常",
+[PRINT_REGS_TITLE]            = "========================= 寄存器信息 =========================",
+[PRINT_HFSR_VECTBL]           = "发生硬错误,原因:取中断向量时出错",
+[PRINT_MFSR_IACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域取指令",
+[PRINT_MFSR_DACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域读、写数据",
+[PRINT_MFSR_MUNSTKERR]        = "发生存储器管理错误,原因:出栈时企图访问不被允许的区域",
+[PRINT_MFSR_MSTKERR]          = "发生存储器管理错误,原因:入栈时企图访问不被允许的区域",
+[PRINT_MFSR_MLSPERR]          = "发生存储器管理错误,原因:惰性保存浮点状态时发生错误",
+[PRINT_BFSR_IBUSERR]          = "发生总线错误,原因:指令总线错误",
+[PRINT_BFSR_PRECISERR]        = "发生总线错误,原因:精确的数据总线错误",
+[PRINT_BFSR_IMPREISERR]       = "发生总线错误,原因:不精确的数据总线错误",
+[PRINT_BFSR_UNSTKERR]         = "发生总线错误,原因:出栈时发生错误",
+[PRINT_BFSR_STKERR]           = "发生总线错误,原因:入栈时发生错误",
+[PRINT_BFSR_LSPERR]           = "发生总线错误,原因:惰性保存浮点状态时发生错误",
+[PRINT_UFSR_UNDEFINSTR]       = "发生用法错误,原因:企图执行未定义指令",
+[PRINT_UFSR_INVSTATE]         = "发生用法错误,原因:试图切换到 ARM 状态",
+[PRINT_UFSR_INVPC]            = "发生用法错误,原因:无效的异常返回码",
+[PRINT_UFSR_NOCP]             = "发生用法错误,原因:企图执行协处理器指令",
+[PRINT_UFSR_UNALIGNED]        = "发生用法错误,原因:企图执行非对齐访问",
+[PRINT_UFSR_DIVBYZERO0]       = "发生用法错误,原因:企图执行除 0 操作",
+[PRINT_DFSR_HALTED]           = "发生调试错误,原因:NVIC 停机请求",
+[PRINT_DFSR_BKPT]             = "发生调试错误,原因:执行 BKPT 指令",
+[PRINT_DFSR_DWTTRAP]          = "发生调试错误,原因:数据监测点匹配",
+[PRINT_DFSR_VCATCH]           = "发生调试错误,原因:发生向量捕获",
+[PRINT_DFSR_EXTERNAL]         = "发生调试错误,原因:外部调试请求",
+[PRINT_MMAR]                  = "发生存储器管理错误的地址:%08x",
+[PRINT_BFAR]                  = "发生总线错误的地址:%08x",

+ 68 - 0
Languages/zh-CN/cmb_zh_CN_UTF8.h

@@ -0,0 +1,68 @@
+/*
+ * This file is part of the CmBacktrace Library.
+ *
+ * Copyright (c) 2020, Armink, <armink.ztl@gmail.com>
+ *                     Chenxuan, <chenxuan.zhao@icloud.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * 'Software'), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * NOTE: DO NOT include this file on the header file.
+ * Encoding: UTF-8
+ * Created on: 2020-09-06
+ */
+
+[PRINT_MAIN_STACK_CFG_ERROR]  = "错误:无法获取主栈信息,请检查主栈的相关配置",
+[PRINT_FIRMWARE_INFO]         = "固件名称:%s,硬件版本号:%s,软件版本号:%s",
+[PRINT_ASSERT_ON_THREAD]      = "在线程(%s)中发生断言",
+[PRINT_ASSERT_ON_HANDLER]     = "在中断或裸机环境下发生断言",
+[PRINT_THREAD_STACK_INFO]     = "=========== 线程堆栈信息 ===========",
+[PRINT_MAIN_STACK_INFO]       = "============ 主堆栈信息 ============",
+[PRINT_THREAD_STACK_OVERFLOW] = "错误:线程栈(%08x)发生溢出",
+[PRINT_MAIN_STACK_OVERFLOW]   = "错误:主栈(%08x)发生溢出",
+[PRINT_CALL_STACK_INFO]       = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %.*s",
+[PRINT_CALL_STACK_ERR]        = "获取函数调用栈失败",
+[PRINT_FAULT_ON_THREAD]       =  "在线程(%s)中发生错误异常",
+[PRINT_FAULT_ON_HANDLER]      = "在中断或裸机环境下发生错误异常",
+[PRINT_REGS_TITLE]            = "========================= 寄存器信息 =========================",
+[PRINT_HFSR_VECTBL]           = "发生硬错误,原因:取中断向量时出错",
+[PRINT_MFSR_IACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域取指令",
+[PRINT_MFSR_DACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域读、写数据",
+[PRINT_MFSR_MUNSTKERR]        = "发生存储器管理错误,原因:出栈时企图访问不被允许的区域",
+[PRINT_MFSR_MSTKERR]          = "发生存储器管理错误,原因:入栈时企图访问不被允许的区域",
+[PRINT_MFSR_MLSPERR]          = "发生存储器管理错误,原因:惰性保存浮点状态时发生错误",
+[PRINT_BFSR_IBUSERR]          = "发生总线错误,原因:指令总线错误",
+[PRINT_BFSR_PRECISERR]        = "发生总线错误,原因:精确的数据总线错误",
+[PRINT_BFSR_IMPREISERR]       = "发生总线错误,原因:不精确的数据总线错误",
+[PRINT_BFSR_UNSTKERR]         = "发生总线错误,原因:出栈时发生错误",
+[PRINT_BFSR_STKERR]           = "发生总线错误,原因:入栈时发生错误",
+[PRINT_BFSR_LSPERR]           = "发生总线错误,原因:惰性保存浮点状态时发生错误",
+[PRINT_UFSR_UNDEFINSTR]       = "发生用法错误,原因:企图执行未定义指令",
+[PRINT_UFSR_INVSTATE]         = "发生用法错误,原因:试图切换到 ARM 状态",
+[PRINT_UFSR_INVPC]            = "发生用法错误,原因:无效的异常返回码",
+[PRINT_UFSR_NOCP]             = "发生用法错误,原因:企图执行协处理器指令",
+[PRINT_UFSR_UNALIGNED]        = "发生用法错误,原因:企图执行非对齐访问",
+[PRINT_UFSR_DIVBYZERO0]       = "发生用法错误,原因:企图执行除 0 操作",
+[PRINT_DFSR_HALTED]           = "发生调试错误,原因:NVIC 停机请求",
+[PRINT_DFSR_BKPT]             = "发生调试错误,原因:执行 BKPT 指令",
+[PRINT_DFSR_DWTTRAP]          = "发生调试错误,原因:数据监测点匹配",
+[PRINT_DFSR_VCATCH]           = "发生调试错误,原因:发生向量捕获",
+[PRINT_DFSR_EXTERNAL]         = "发生调试错误,原因:外部调试请求",
+[PRINT_MMAR]                  = "发生存储器管理错误的地址:%08x",
+[PRINT_BFAR]                  = "发生总线错误的地址:%08x",

+ 4 - 0
SConscript

@@ -10,7 +10,11 @@ LOCAL_CCFLAGS = ''
 if rtconfig.CROSS_TOOL == 'gcc':
     LOCAL_CCFLAGS += ' -std=c99'
 elif rtconfig.CROSS_TOOL == 'keil':
+    # Using ARM Compiler Version 5
     LOCAL_CCFLAGS += ' --c99'
+    LOCAL_CCFLAGS += ' --no-multibyte-chars'
+    # Using ARM Compiler Version 6
+    # pass
 
 group = DefineGroup('cm_backtrace', src, depend = ['PKG_USING_CMBACKTRACE'], CPPPATH = path, LOCAL_CCFLAGS = LOCAL_CCFLAGS)
 

+ 4 - 76
cm_backtrace.c

@@ -104,83 +104,11 @@ enum {
 
 static const char * const print_info[] = {
 #if (CMB_PRINT_LANGUAGE == CMB_PRINT_LANGUAGE_ENGLISH)
-        [PRINT_MAIN_STACK_CFG_ERROR]  = "ERROR: Unable to get the main stack information, please check the configuration of the main stack",
-        [PRINT_FIRMWARE_INFO]         = "Firmware name: %s, hardware version: %s, software version: %s",
-        [PRINT_ASSERT_ON_THREAD]      = "Assert on thread %s",
-        [PRINT_ASSERT_ON_HANDLER]     = "Assert on interrupt or bare metal(no OS) environment",
-        [PRINT_THREAD_STACK_INFO]     = "===== Thread stack information =====",
-        [PRINT_MAIN_STACK_INFO]       = "====== Main stack information ======",
-        [PRINT_THREAD_STACK_OVERFLOW] = "Error: Thread stack(%08x) was overflow",
-        [PRINT_MAIN_STACK_OVERFLOW]   = "Error: Main stack(%08x) was overflow",
-        [PRINT_CALL_STACK_INFO]       = "Show more call stack info by run: addr2line -e %s%s -a -f %.*s",
-        [PRINT_CALL_STACK_ERR]        = "Dump call stack has an error",
-        [PRINT_FAULT_ON_THREAD]       = "Fault on thread %s",
-        [PRINT_FAULT_ON_HANDLER]      = "Fault on interrupt or bare metal(no OS) environment",
-        [PRINT_REGS_TITLE]            = "=================== Registers information ====================",
-        [PRINT_HFSR_VECTBL]           = "Hard fault is caused by failed vector fetch",
-        [PRINT_MFSR_IACCVIOL]         = "Memory management fault is caused by instruction access violation",
-        [PRINT_MFSR_DACCVIOL]         = "Memory management fault is caused by data access violation",
-        [PRINT_MFSR_MUNSTKERR]        = "Memory management fault is caused by unstacking error",
-        [PRINT_MFSR_MSTKERR]          = "Memory management fault is caused by stacking error",
-        [PRINT_MFSR_MLSPERR]          = "Memory management fault is caused by floating-point lazy state preservation",
-        [PRINT_BFSR_IBUSERR]          = "Bus fault is caused by instruction access violation",
-        [PRINT_BFSR_PRECISERR]        = "Bus fault is caused by precise data access violation",
-        [PRINT_BFSR_IMPREISERR]       = "Bus fault is caused by imprecise data access violation",
-        [PRINT_BFSR_UNSTKERR]         = "Bus fault is caused by unstacking error",
-        [PRINT_BFSR_STKERR]           = "Bus fault is caused by stacking error",
-        [PRINT_BFSR_LSPERR]           = "Bus fault is caused by floating-point lazy state preservation",
-        [PRINT_UFSR_UNDEFINSTR]       = "Usage fault is caused by attempts to execute an undefined instruction",
-        [PRINT_UFSR_INVSTATE]         = "Usage fault is caused by attempts to switch to an invalid state (e.g., ARM)",
-        [PRINT_UFSR_INVPC]            = "Usage fault is caused by attempts to do an exception with a bad value in the EXC_RETURN number",
-        [PRINT_UFSR_NOCP]             = "Usage fault is caused by attempts to execute a coprocessor instruction",
-        [PRINT_UFSR_UNALIGNED]        = "Usage fault is caused by indicates that an unaligned access fault has taken place",
-        [PRINT_UFSR_DIVBYZERO0]       = "Usage fault is caused by Indicates a divide by zero has taken place (can be set only if DIV_0_TRP is set)",
-        [PRINT_DFSR_HALTED]           = "Debug fault is caused by halt requested in NVIC",
-        [PRINT_DFSR_BKPT]             = "Debug fault is caused by BKPT instruction executed",
-        [PRINT_DFSR_DWTTRAP]          = "Debug fault is caused by DWT match occurred",
-        [PRINT_DFSR_VCATCH]           = "Debug fault is caused by Vector fetch occurred",
-        [PRINT_DFSR_EXTERNAL]         = "Debug fault is caused by EDBGRQ signal asserted",
-        [PRINT_MMAR]                  = "The memory management fault occurred address is %08x",
-        [PRINT_BFAR]                  = "The bus fault occurred address is %08x",
+    #include "Languages/en-US/cmb_en_US.h"
 #elif (CMB_PRINT_LANGUAGE == CMB_PRINT_LANGUAGE_CHINESE)
-        [PRINT_MAIN_STACK_CFG_ERROR]  = "错误:无法获取主栈信息,请检查主栈的相关配置",
-        [PRINT_FIRMWARE_INFO]         = "固件名称:%s,硬件版本号:%s,软件版本号:%s",
-        [PRINT_ASSERT_ON_THREAD]      = "在线程(%s)中发生断言",
-        [PRINT_ASSERT_ON_HANDLER]     = "在中断或裸机环境下发生断言",
-        [PRINT_THREAD_STACK_INFO]     = "=========== 线程堆栈信息 ===========",
-        [PRINT_MAIN_STACK_INFO]       = "============ 主堆栈信息 ============",
-        [PRINT_THREAD_STACK_OVERFLOW] = "错误:线程栈(%08x)发生溢出",
-        [PRINT_MAIN_STACK_OVERFLOW]   = "错误:主栈(%08x)发生溢出",
-        [PRINT_CALL_STACK_INFO]       = "查看更多函数调用栈信息,请运行:addr2line -e %s%s -a -f %.*s",
-        [PRINT_CALL_STACK_ERR]        = "获取函数调用栈失败",
-        [PRINT_FAULT_ON_THREAD]       =  "在线程(%s)中发生错误异常",
-        [PRINT_FAULT_ON_HANDLER]      = "在中断或裸机环境下发生错误异常",
-        [PRINT_REGS_TITLE]            = "========================= 寄存器信息 =========================",
-        [PRINT_HFSR_VECTBL]           = "发生硬错误,原因:取中断向量时出错",
-        [PRINT_MFSR_IACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域取指令",
-        [PRINT_MFSR_DACCVIOL]         = "发生存储器管理错误,原因:企图从不允许访问的区域读、写数据",
-        [PRINT_MFSR_MUNSTKERR]        = "发生存储器管理错误,原因:出栈时企图访问不被允许的区域",
-        [PRINT_MFSR_MSTKERR]          = "发生存储器管理错误,原因:入栈时企图访问不被允许的区域",
-        [PRINT_MFSR_MLSPERR]          = "发生存储器管理错误,原因:惰性保存浮点状态时发生错误",
-        [PRINT_BFSR_IBUSERR]          = "发生总线错误,原因:指令总线错误",
-        [PRINT_BFSR_PRECISERR]        = "发生总线错误,原因:精确的数据总线错误",
-        [PRINT_BFSR_IMPREISERR]       = "发生总线错误,原因:不精确的数据总线错误",
-        [PRINT_BFSR_UNSTKERR]         = "发生总线错误,原因:出栈时发生错误",
-        [PRINT_BFSR_STKERR]           = "发生总线错误,原因:入栈时发生错误",
-        [PRINT_BFSR_LSPERR]           = "发生总线错误,原因:惰性保存浮点状态时发生错误",
-        [PRINT_UFSR_UNDEFINSTR]       = "发生用法错误,原因:企图执行未定义指令",
-        [PRINT_UFSR_INVSTATE]         = "发生用法错误,原因:试图切换到 ARM 状态",
-        [PRINT_UFSR_INVPC]            = "发生用法错误,原因:无效的异常返回码",
-        [PRINT_UFSR_NOCP]             = "发生用法错误,原因:企图执行协处理器指令",
-        [PRINT_UFSR_UNALIGNED]        = "发生用法错误,原因:企图执行非对齐访问",
-        [PRINT_UFSR_DIVBYZERO0]       = "发生用法错误,原因:企图执行除 0 操作",
-        [PRINT_DFSR_HALTED]           = "发生调试错误,原因:NVIC 停机请求",
-        [PRINT_DFSR_BKPT]             = "发生调试错误,原因:执行 BKPT 指令",
-        [PRINT_DFSR_DWTTRAP]          = "发生调试错误,原因:数据监测点匹配",
-        [PRINT_DFSR_VCATCH]           = "发生调试错误,原因:发生向量捕获",
-        [PRINT_DFSR_EXTERNAL]         = "发生调试错误,原因:外部调试请求",
-        [PRINT_MMAR]                  = "发生存储器管理错误的地址:%08x",
-        [PRINT_BFAR]                  = "发生总线错误的地址:%08x",
+    #include "Languages/zh-CN/cmb_zh_CN.h"
+#elif (CMB_PRINT_LANGUAGE == CMB_PRINT_LANGUAGE_CHINESE_UTF8)
+    #include "Languages/zh-CN/cmb_zh_CN_UTF8.h"
 #else
     #error "CMB_PRINT_LANGUAGE defined error in 'cmb_cfg.h'"
 #endif

+ 8 - 0
cm_backtrace.h

@@ -31,10 +31,18 @@
 
 #include "cmb_def.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, const char *software_ver);
 void cm_backtrace_firmware_info(void);
 size_t cm_backtrace_call_stack(uint32_t *buffer, size_t size, uint32_t sp);
 void cm_backtrace_assert(uint32_t sp);
 void cm_backtrace_fault(uint32_t fault_handler_lr, uint32_t fault_handler_sp);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CORTEXM_BACKTRACE_H_ */

+ 8 - 0
cmb_cfg.h

@@ -31,6 +31,7 @@
 
 /* print line, must config by user */
 #include <rtthread.h>
+
 #ifndef RT_USING_ULOG
 #ifndef CMB_USING_FLASH_LOG_BACKUP
 #define cmb_println(...)               rt_kprintf(__VA_ARGS__);rt_kprintf("\r\n")
@@ -43,12 +44,14 @@ extern void cmb_flash_log_println(const char *fmt, ...);
 #define CMB_LOG_TAG                    "cmb"
 #define cmb_println(...)               ulog_e(CMB_LOG_TAG, __VA_ARGS__);ulog_flush()
 #endif /* RT_USING_ULOG */
+
 /* enable bare metal(no OS) platform */
 /* #define CMB_USING_BARE_METAL_PLATFORM */
 /* 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
+
 /* cpu platform type, must config by user */
 #if defined(PKG_CMBACKTRACE_PLATFORM_M0_M0PLUS)
     #define CMB_CPU_PLATFORM_TYPE      CMB_CPU_ARM_CORTEX_M0
@@ -61,14 +64,19 @@ extern void cmb_flash_log_println(const char *fmt, ...);
 #else
     #error "You must select a CPU platform on menuconfig"
 #endif /* PKG_CMBACKTRACE_PLATFORM_M0_M0PLUS */
+
 /* enable dump stack information */
 #if defined(PKG_CMBACKTRACE_DUMP_STACK)
     #define CMB_USING_DUMP_STACK_INFO
 #endif
+
 /* language of print information */
 #if defined(PKG_CMBACKTRACE_PRINT_ENGLISH)
     #define CMB_PRINT_LANGUAGE         CMB_PRINT_LANGUAGE_ENGLISH
 #elif defined(PKG_CMBACKTRACE_PRINT_CHINESE)
     #define CMB_PRINT_LANGUAGE         CMB_PRINT_LANGUAGE_CHINESE
+#elif defined(PKG_CMBACKTRACE_PRINT_CHINESE_UTF8)
+    #define CMB_PRINT_LANGUAGE         CMB_PRINT_LANGUAGE_CHINESE_UTF8
 #endif /* PKG_CMBACKTRACE_PRINT_ENGLISH */
+
 #endif /* _CMB_CFG_H_ */

+ 13 - 12
cmb_def.h

@@ -36,27 +36,28 @@
 /* library software version number */
 #define CMB_SW_VERSION                "1.4.0"
 
-#define CMB_CPU_ARM_CORTEX_M0          0
-#define CMB_CPU_ARM_CORTEX_M3          1
-#define CMB_CPU_ARM_CORTEX_M4          2
-#define CMB_CPU_ARM_CORTEX_M7          3
+#define CMB_CPU_ARM_CORTEX_M0             0
+#define CMB_CPU_ARM_CORTEX_M3             1
+#define CMB_CPU_ARM_CORTEX_M4             2
+#define CMB_CPU_ARM_CORTEX_M7             3
 
-#define CMB_OS_PLATFORM_RTT            0
-#define CMB_OS_PLATFORM_UCOSII         1
-#define CMB_OS_PLATFORM_UCOSIII        2
-#define CMB_OS_PLATFORM_FREERTOS       3
+#define CMB_OS_PLATFORM_RTT               0
+#define CMB_OS_PLATFORM_UCOSII            1
+#define CMB_OS_PLATFORM_UCOSIII           2
+#define CMB_OS_PLATFORM_FREERTOS          3
 
-#define CMB_PRINT_LANGUAGE_ENGLISH     0
-#define CMB_PRINT_LANGUAGE_CHINESE     1
+#define CMB_PRINT_LANGUAGE_ENGLISH        0
+#define CMB_PRINT_LANGUAGE_CHINESE        1
+#define CMB_PRINT_LANGUAGE_CHINESE_UTF8   2
 
 /* name max length, default size: 32 */
 #ifndef CMB_NAME_MAX
-#define CMB_NAME_MAX                   32
+#define CMB_NAME_MAX                      32
 #endif
 
 /* print information language, default is English */
 #ifndef CMB_PRINT_LANGUAGE
-#define CMB_PRINT_LANGUAGE             CMB_PRINT_LANGUAGE_ENGLISH
+#define CMB_PRINT_LANGUAGE                CMB_PRINT_LANGUAGE_ENGLISH
 #endif