Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let firmware info be optional to save RAM #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions cm_backtrace/cm_backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ static const char * const print_info[] = {
#endif
};

static char fw_name[CMB_NAME_MAX + 1] = {0};
static char hw_ver[CMB_NAME_MAX + 1] = {0};
static char sw_ver[CMB_NAME_MAX + 1] = {0};
#ifdef CMB_NOT_USING_FIRMWARE_INFO
static const char * const fw_name = "x";
#else
static char fw_name[CMB_NAME_MAX + 1] = {0};
static char hw_ver[CMB_NAME_MAX + 1] = {0};
static char sw_ver[CMB_NAME_MAX + 1] = {0};
#endif

static uint32_t main_stack_start_addr = 0;
static size_t main_stack_size = 0;
static uint32_t code_start_addr = 0;
Expand All @@ -143,9 +148,11 @@ static bool on_thread_before_fault = false;
* library initialize
*/
void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, const char *software_ver) {
#ifndef CMB_NOT_USING_FIRMWARE_INFO
strncpy(fw_name, firmware_name, CMB_NAME_MAX);
strncpy(hw_ver, hardware_ver, CMB_NAME_MAX);
strncpy(sw_ver, software_ver, CMB_NAME_MAX);
#endif

#if defined(__ARMCC_VERSION)
main_stack_start_addr = (uint32_t)&CSTACK_BLOCK_START(CMB_CSTACK_BLOCK_NAME);
Expand Down Expand Up @@ -178,7 +185,9 @@ void cm_backtrace_init(const char *firmware_name, const char *hardware_ver, cons
* print firmware information, such as: firmware name, hardware version, software version
*/
void cm_backtrace_firmware_info(void) {
#ifndef CMB_NOT_USING_FIRMWARE_INFO
cmb_println(print_info[PRINT_FIRMWARE_INFO], fw_name, hw_ver, sw_ver);
#endif
}

#ifdef CMB_USING_OS_PLATFORM
Expand Down
2 changes: 2 additions & 0 deletions cm_backtrace/cmb_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
/* #define CMB_USING_DUMP_STACK_INFO */
/* language of print information */
/* #define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH(default) or CMB_PRINT_LANGUAGE_CHINESE or CMB_PRINT_LANGUAGE_CHINESE_UTF8 */
/* disable storing and printing firmware information */
/* #define CMB_NOT_USING_FIRMWARE_INFO */
#endif

#endif /* _CMB_CFG_H_ */