From b1c5648c176e46f4135d24d782e89bed7960c27d Mon Sep 17 00:00:00 2001 From: "snickersun@163.com" Date: Fri, 7 Jun 2024 13:29:37 +0000 Subject: [PATCH] Merge #240 into sdk602patch0521 from refs/changes/240/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from snickersun@163.com * refs/changes/240/head: (2 commits squashed) - 给exc_info等dumpfile的文件名添加时间戳 - Merge branch 'sdk602patch0521' of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 Signed-off-by: snickersun@163.com Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/240 --- .../chips/brandy/dfx/zdiag_adapt_sdt.c | 8 ++++++-- .../chips/brandy/exception/exception_riscv.c | 15 +++++++++++---- .../utils/dfx/preserve/private/preserve.c | 17 +++++++++++++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c b/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c index ea74ec417..42b0f1607 100755 --- a/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c +++ b/code/sdk/middleware/chips/brandy/dfx/zdiag_adapt_sdt.c @@ -56,7 +56,7 @@ typedef struct diag_msg_para { } diag_msg_para_t; #if defined(SAVE_EXC_INFO) && (CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES) -static const char *g_bt_exc_info_path = "/user/exc/bt_exc_info.bin"; +static const char *g_bt_exc_info_path = "/user/exc/bt_exc_info_%d.bin"; #endif oam_cmd_handle_callback g_diag_debug_proc = NULL; uint8_t g_recv_msg_step = SDT_MSG_STEP_HEAD; @@ -267,7 +267,11 @@ static bool zdiag_adapt_sdt_short_msg_report(uint8_t *data, uint32_t data_len) } else if (om_msg_header->func_type == OM_MSG_TYPE_LAST) { zdiag_adapt_sdt_om_last_parse(data, (uint16_t)data_len, ¶); #if defined(SAVE_EXC_INFO) && (CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES) - if (exc_info_write(g_bt_exc_info_path, 0, para.buf, (uint32_t)para.buf_size) < 0) { + uint32_t timestamp = get_local_timestamp(); + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, g_bt_exc_info_path, timestamp); + if (exc_info_write(str, 0, para.buf, (uint32_t)para.buf_size) < 0) { dfx_log_err("exc_info_write error.\r\n"); } #endif diff --git a/code/sdk/middleware/chips/brandy/exception/exception_riscv.c b/code/sdk/middleware/chips/brandy/exception/exception_riscv.c index 0a0e6d102..d5d4119a4 100755 --- a/code/sdk/middleware/chips/brandy/exception/exception_riscv.c +++ b/code/sdk/middleware/chips/brandy/exception/exception_riscv.c @@ -131,7 +131,7 @@ static const uint8_t g_xregs_map[] = { 6, 5, 4, 19, 18, 17, 16 }; #if CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_YES -static const char *g_exc_info_path = "/user/exc/exc_info.bin"; +static const char *g_exc_info_path = "/user/exc/exc_info_%d.bin"; #endif #endif @@ -803,8 +803,11 @@ errcode_t emmc_exc_info_write(void) osal_kfree(exc_info_buffer); return ERRCODE_SUCC; } - - int32_t ret = exc_info_write(g_exc_info_path, 0, (const uint8_t *)exc_info_buffer, ONE_SECTOR_SIZE); + uint32_t timestamp = get_local_timestamp(); + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, g_exc_info_path, timestamp); + int32_t ret = exc_info_write(str, 0, (const uint8_t *)exc_info_buffer, ONE_SECTOR_SIZE); if (ret < 0) { osal_kfree(exc_info_buffer); return ERRCODE_FAIL; @@ -829,7 +832,11 @@ static errcode_t exc_info_write_local(exc_info_save_t *exc_info_save, uint32_t e #ifdef CFG_DRIVERS_NANDFLASH nand_driver_init(SPEED_SLOW); set_trans_type(TRANS_BY_CPU_SINGLE_LINE); - ret = exc_info_write(g_exc_info_path, 0, (const uint8_t *)exc_info_save, exc_size); + uint32_t timestamp = get_local_timestamp(); + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, g_exc_info_path, timestamp); + ret = exc_info_write(str, 0, (const uint8_t *)exc_info_save, exc_size); dump_all_to_file(); #endif #ifdef CFG_DRIVERS_MMC diff --git a/code/sdk/middleware/utils/dfx/preserve/private/preserve.c b/code/sdk/middleware/utils/dfx/preserve/private/preserve.c index e26b6d8e8..6325d425d 100755 --- a/code/sdk/middleware/utils/dfx/preserve/private/preserve.c +++ b/code/sdk/middleware/utils/dfx/preserve/private/preserve.c @@ -113,16 +113,25 @@ void save_preserve_file_to_nand(void) void save_btram_file_to_nand(void) { - const char *btram_info_path = "/user/exc/bt_ram_info.bin"; + const char *btram_info_path = "/user/exc/bt_ram_info_%d.bin"; + uint32_t timestamp = get_local_timestamp(); + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, btram_info_path, timestamp); + int32_t ret = - exc_info_write(btram_info_path, 0, (uint8_t *)BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH); + exc_info_write(str, 0, (uint8_t *)BT_RAM_ORIGIN_APP_MAPPING, BT_RAM_ORIGIN_APP_MAPPING_LENGTH); printf("save_btram_file_to_nand ret:%d.\r\n", ret); } void save_btrace_file_to_nand(void) { - const char *btrace_info_path = "/user/exc/btrace_info.bin"; - int32_t ret = exc_info_write(btrace_info_path, 0, (uint8_t *)BTRACE_ADDR_EXEC, BTRACE_ADDR_EXEC_LEN); + const char *btrace_info_path = "/user/exc/btrace_info_%d.bin"; + uint32_t timestamp = get_local_timestamp(); + char *str = (char *)malloc(200); + memset_s(str, 200, 0, 200); + sprintf(str, btrace_info_path, timestamp); + int32_t ret = exc_info_write(str, 0, (uint8_t *)BTRACE_ADDR_EXEC, BTRACE_ADDR_EXEC_LEN); printf("save_btrace_file_to_nand ret:%d.\r\n", ret); } #endif -- 2.17.1