mirror of
https://github.com/armink/CmBacktrace.git
synced 2025-01-08 20:16:17 +08:00
【增加】主栈检查功能。
Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
parent
8bbd42533c
commit
9b1158bf12
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2018 Armink (armink.ztl@gmail.com)
|
||||
Copyright (c) 2016-2019 Armink (armink.ztl@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
40
README.md
40
README.md
@ -1,6 +1,6 @@
|
||||
# CmBacktrace: ARM Cortex-M 系列 MCU 错误追踪库
|
||||
|
||||
[![GitHub release](https://img.shields.io/github/release/armink/CmBacktrace.svg)](https://github.com/armink/CmBacktrace/releases/latest) [![GitHub commits](https://img.shields.io/github/commits-since/armink/CmBacktrace/1.2.0.svg)](https://github.com/armink/CmBacktrace/compare/1.0.0...master) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/armink/CmBacktrace/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/armink/CmBacktrace.svg)](https://github.com/armink/CmBacktrace/releases/latest) [![GitHub commits](https://img.shields.io/github/commits-since/armink/CmBacktrace/1.3.0.svg)](https://github.com/armink/CmBacktrace/compare/1.0.0...master) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/armink/CmBacktrace/master/LICENSE)
|
||||
|
||||
## 0、CmBacktrace 是什么
|
||||
|
||||
@ -176,6 +176,44 @@ void cm_backtrace_fault(uint32_t fault_handler_lr, uint32_t fault_handler_sp)
|
||||
- 1、注释/删除其他文件中定义的 `HardFault_Handler` 函数,仅保留 cmb_fault.s 中的;
|
||||
- 2、将 cmb_fault.s 移除工程,手动添加 `cm_backtrace_fault` 函数至现有的故障处理函数,但需要注意的是,务必 **保证该函数数入参的准备性** ,否则可能会导致故障诊断功能及堆栈打印功能无法正常运行。所以如果是新手,不推荐第二种解决方法。
|
||||
|
||||
#### 2.5.4 初始化时提示无法获取主栈(main stack)信息
|
||||
|
||||
在 `cmd_def.h` 中有定义默认的主栈配置,大致如下:
|
||||
|
||||
```c
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
/* C stack block name, default is STACK */
|
||||
#ifndef CMB_CSTACK_BLOCK_NAME
|
||||
#define CMB_CSTACK_BLOCK_NAME STACK
|
||||
#endif
|
||||
...
|
||||
#elif defined(__ICCARM__)
|
||||
/* C stack block name, default is 'CSTACK' */
|
||||
#ifndef CMB_CSTACK_BLOCK_NAME
|
||||
#define CMB_CSTACK_BLOCK_NAME "CSTACK"
|
||||
#endif
|
||||
...
|
||||
#elif defined(__GNUC__)
|
||||
/* C stack block start address, defined on linker script file, default is _sstack */
|
||||
#ifndef CMB_CSTACK_BLOCK_START
|
||||
#define CMB_CSTACK_BLOCK_START _sstack
|
||||
#endif
|
||||
/* C stack block end address, defined on linker script file, default is _estack */
|
||||
#ifndef CMB_CSTACK_BLOCK_END
|
||||
#define CMB_CSTACK_BLOCK_END _estack
|
||||
#endif
|
||||
...
|
||||
#else
|
||||
```
|
||||
|
||||
比如在 Keil-MDK 编译器下会默认选择 `STACK` 作为主栈 block 的名称,但在一些特殊平台下,项目的主栈 block 名称可能不叫 `STACK`,导致 CmBacktrace 无法获取到正确的主栈信息,所以在初始化时会有如上的错误提示信息。
|
||||
|
||||
解决这个问题一般有两个思路
|
||||
|
||||
- 1、在 `cmb_cfg.h` 中重新定义主栈的信息,此时 CmBacktrace 会优先使用 `cmb_cfg.h` 中的配置信息;
|
||||
- 2、修改项目配置,如果是 Keil-MDK ,则在启动文件的开头位置,将主栈的名称修改为默认的 `STACK` ,其他编译器一般很少出现该问题。
|
||||
|
||||
### 2.6 许可
|
||||
|
||||
采用 MIT 开源协议,细节请阅读项目中的 LICENSE 文件内容。
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of the CmBacktrace Library.
|
||||
*
|
||||
* Copyright (c) 2016-2017, Armink, <armink.ztl@gmail.com>
|
||||
* Copyright (c) 2016-2019, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -62,6 +62,7 @@
|
||||
#endif
|
||||
|
||||
enum {
|
||||
PRINT_MAIN_STACK_CFG_ERROR,
|
||||
PRINT_FIRMWARE_INFO,
|
||||
PRINT_ASSERT_ON_THREAD,
|
||||
PRINT_ASSERT_ON_HANDLER,
|
||||
@ -103,6 +104,7 @@ 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",
|
||||
@ -141,6 +143,7 @@ static const char * const print_info[] = {
|
||||
[PRINT_MMAR] = "The memory management fault occurred address is %08x",
|
||||
[PRINT_BFAR] = "The bus fault occurred address is %08x",
|
||||
#elif (CMB_PRINT_LANGUAGE == CMB_PRINT_LANGUAGE_CHINESE)
|
||||
[PRINT_MAIN_STACK_CFG_ERROR] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
[PRINT_FIRMWARE_INFO] = "<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>%s<><73>Ӳ<EFBFBD><D3B2><EFBFBD>汾<EFBFBD>ţ<EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD>ţ<EFBFBD>%s",
|
||||
[PRINT_ASSERT_ON_THREAD] = "<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>(%s)<29>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
[PRINT_ASSERT_ON_HANDLER] = "<EFBFBD><EFBFBD><EFBFBD>жϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
@ -229,6 +232,11 @@ void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, cons
|
||||
#error "not supported compiler"
|
||||
#endif
|
||||
|
||||
if (main_stack_size == 0) {
|
||||
cmb_println(print_info[PRINT_MAIN_STACK_CFG_ERROR]);
|
||||
return;
|
||||
}
|
||||
|
||||
init_ok = true;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of the CmBacktrace Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
* Copyright (c) 2016-2019, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -34,7 +34,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/* library software version number */
|
||||
#define CMB_SW_VERSION "1.2.1"
|
||||
#define CMB_SW_VERSION "1.3.0"
|
||||
|
||||
#define CMB_CPU_ARM_CORTEX_M0 0
|
||||
#define CMB_CPU_ARM_CORTEX_M3 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user