加入 CmBacktrace-v1.4.1 辅助定位 hard Fault
This commit is contained in:
parent
bde51765d0
commit
15e84bec95
24
.config
24
.config
@ -328,7 +328,7 @@ CONFIG_ULOG_OUTPUT_LVL_D=y
|
||||
CONFIG_ULOG_OUTPUT_LVL=7
|
||||
# CONFIG_ULOG_USING_ISR_LOG is not set
|
||||
CONFIG_ULOG_ASSERT_ENABLE=y
|
||||
CONFIG_ULOG_LINE_BUF_SIZE=128
|
||||
CONFIG_ULOG_LINE_BUF_SIZE=256
|
||||
# CONFIG_ULOG_USING_ASYNC_OUTPUT is not set
|
||||
|
||||
#
|
||||
@ -574,7 +574,27 @@ CONFIG_PKG_CJSON_VER="v1.7.15"
|
||||
#
|
||||
# tools packages
|
||||
#
|
||||
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||
CONFIG_PKG_USING_CMBACKTRACE=y
|
||||
# CONFIG_PKG_CMBACKTRACE_PLATFORM_M0_M0PLUS is not set
|
||||
# CONFIG_PKG_CMBACKTRACE_PLATFORM_M3 is not set
|
||||
CONFIG_PKG_CMBACKTRACE_PLATFORM_M4=y
|
||||
# CONFIG_PKG_CMBACKTRACE_PLATFORM_M7 is not set
|
||||
# CONFIG_PKG_CMBACKTRACE_PLATFORM_M33 is not set
|
||||
# CONFIG_PKG_CMBACKTRACE_PLATFORM_NOT_SELECTED is not set
|
||||
CONFIG_PKG_CMBACKTRACE_DUMP_STACK=y
|
||||
# CONFIG_PKG_CMBACKTRACE_PRINT_ENGLISH is not set
|
||||
# CONFIG_PKG_CMBACKTRACE_PRINT_CHINESE is not set
|
||||
CONFIG_PKG_CMBACKTRACE_PRINT_CHINESE_UTF8=y
|
||||
# CONFIG_CMB_USING_FAL_FLASH_LOG is not set
|
||||
CONFIG_PKG_CMBACKTRACE_PATH="/packages/tools/CmBacktrace"
|
||||
CONFIG_PKG_USING_CMBACKTRACE_V10401=y
|
||||
# CONFIG_PKG_USING_CMBACKTRACE_V10400 is not set
|
||||
# CONFIG_PKG_USING_CMBACKTRACE_V10300 is not set
|
||||
# CONFIG_PKG_USING_CMBACKTRACE_V10202 is not set
|
||||
# CONFIG_PKG_USING_CMBACKTRACE_V10200 is not set
|
||||
# CONFIG_PKG_USING_CMBACKTRACE_LATEST_VERSION is not set
|
||||
CONFIG_PKG_CMBACKTRACE_VER="v1.4.1"
|
||||
CONFIG_PKG_CMBACKTRACE_VER_NUM=0x10401
|
||||
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define LOG_LVL LOG_LVL_DBG
|
||||
#include <ulog.h>
|
||||
#include <board.h>
|
||||
|
||||
#include <ttmsg/ttmsg.h>
|
||||
//#define LED_HEART GET_PIN(E,3)
|
||||
//#ifndef ETH_RESET_PIN
|
||||
//#define ETH_RESET_PIN GET_PIN(E, 7)//71
|
||||
@ -22,7 +22,30 @@
|
||||
////#define RESET_LB GET_PIN(E, 1)
|
||||
////#define RESET_UB GET_PIN(E, 0)
|
||||
////#define RESET_CE GET_PIN(G, 10)
|
||||
|
||||
///
|
||||
//static rt_uint8_t d[35][200] = { };
|
||||
//static rt_uint8_t s[35] = { };
|
||||
static size_t leng = 0;
|
||||
void pfdemo(void)
|
||||
{
|
||||
// #define cmb_println(...) rt_kprintf(__VA_ARGS__);rt_kprintf("\r\n");
|
||||
// char *f = "1023_05_19_15_29_59_254.txt";
|
||||
char *f = "2023_05_19_15_29_59_255.txt";
|
||||
static rt_uint8_t d[10][200] = { };
|
||||
static rt_uint8_t s[10] = { };
|
||||
rt_uint8_t len = 0;
|
||||
LOG_D("%p--%p",d,s);
|
||||
LOG_I("pack %s ...",f);
|
||||
len = pack_File(f, 0, d, s);
|
||||
rt_kprintf("len is %d\n", len);
|
||||
if (len)
|
||||
{
|
||||
LOG_HEX("pkdata:",27,d[0],s[0]);
|
||||
LOG_D("%p--%p",d,s);
|
||||
LOG_D("%d--%d--%02X",len,s[0],d[0][0]);
|
||||
LOG_I("Done.");
|
||||
}
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@ -37,8 +60,23 @@ int main(void)
|
||||
rt_pin_mode(ETH_RESET_PIN, PIN_MODE_OUTPUT);
|
||||
|
||||
// rt_pin_write(ETH_RESET_PIN, PIN_LOW);//关闭ETH
|
||||
|
||||
|
||||
// rt_thread_mdelay(10000);
|
||||
// pfdemo();
|
||||
char *f = "2023_05_19_15_29_59_255.txt";
|
||||
static rt_uint8_t d[35][200] = { };
|
||||
static rt_uint8_t s[35] = { };
|
||||
size_t len = 0;
|
||||
LOG_D("%p--%p",d,s);
|
||||
LOG_I("pack %s ...",f);
|
||||
// len = pack_File(f, 0, d, s);
|
||||
rt_kprintf("len is %d\n", len);
|
||||
if (len)
|
||||
{
|
||||
LOG_HEX("pkdata:",27,d[0],s[0]);
|
||||
LOG_D("%p--%p",d,s);
|
||||
LOG_D("%d--%d--%02X",len,s[0],d[0][0]);
|
||||
LOG_I("Done.");
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
/* 拉低PIN脚 */
|
||||
@ -56,3 +94,24 @@ int main(void)
|
||||
}
|
||||
//fastlz_test -c demo.bin f.bin
|
||||
|
||||
void pp(int argc, char **argv)
|
||||
{
|
||||
// if (argc == 2)
|
||||
{
|
||||
/* 创建线程 */
|
||||
rt_thread_t thread = rt_thread_create("pmsg2", pfdemo, RT_NULL, 1024 * 10, 25, 10);
|
||||
/* 创建成功则启动线程 */
|
||||
if (thread != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(thread);
|
||||
// rt_kprintf("done");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("thread 'pmsg' create failure.");
|
||||
return RT_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MSH_CMD_EXPORT(pp, 打包文件。);
|
||||
|
@ -81,7 +81,7 @@ static size_t split(const char *str, const char *deli, char (*out)[STR_LEN_MAX])
|
||||
token = strtok_r(buf, delim, &saveptr);
|
||||
while (token)
|
||||
{
|
||||
LOG_D("---%s---",token);
|
||||
// LOG_D("---%s---",token);
|
||||
rst[idx++] = token;
|
||||
token = strtok_r(NULL, delim, &saveptr);
|
||||
}
|
||||
@ -112,11 +112,11 @@ static size_t getID(const char *str, unsigned char *out)
|
||||
size_t len = split(str, "/", id);
|
||||
|
||||
// 分割后缀
|
||||
LOG_D("file is %s",id[len-1]);
|
||||
// LOG_D("file is %s",id[len-1]);
|
||||
len = split(id[len - 1], ".", id);
|
||||
|
||||
// 分割时间
|
||||
LOG_D("file name is %s",id[0]);
|
||||
// LOG_D("file name is %s",id[0]);
|
||||
len = split(id[0], "_", id);
|
||||
|
||||
unsigned char tmp[len];
|
||||
@ -208,16 +208,17 @@ rt_uint8_t packMsg(MSG *p_msg, rt_uint8_t *din, rt_uint8_t len, rt_uint8_t *dout
|
||||
* @param {rt_uint8_t} *dout 打包后数据
|
||||
* @return {*} 打包后数据总长度
|
||||
*/
|
||||
size_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t (*dout)[200], rt_uint8_t *arrlen)
|
||||
rt_uint8_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t (*dout)[200], rt_uint8_t *arrlen)
|
||||
{
|
||||
if (!(w > 0)) // 无效长度
|
||||
{
|
||||
w = len;
|
||||
}
|
||||
rt_uint8_t row = (len / w) + (len % w > 0 ? 1 : 0);
|
||||
static rt_uint8_t row = 0;
|
||||
row = (len / w) + (len % w > 0 ? 1 : 0);
|
||||
// rt_uint8_t packdata[row][200]; // 打包后数据
|
||||
rt_uint8_t tlen[row]; // 打包后数据各维长度
|
||||
rt_uint8_t index = 0;
|
||||
static rt_uint8_t index = 0;
|
||||
|
||||
// rt_uint8_t in[len];
|
||||
// memcpy(in,din,len);
|
||||
@ -228,14 +229,14 @@ size_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t
|
||||
size_t tmplen = len - var; // 当前待打包数据的长度
|
||||
tmplen = tmplen > w ? w : tmplen; // 判断最后一包数据的长度
|
||||
cfg->fcurpiece[0] = index+1;
|
||||
size_t col = packMsg(cfg, din+var, tmplen, dout[index]);
|
||||
tlen[index] = col;
|
||||
rt_uint8_t col = packMsg(cfg, din+var, tmplen, dout[index]);
|
||||
arrlen[index] = col;
|
||||
index++;
|
||||
LOG_D("index/row-var-tmplen");
|
||||
LOG_D("%5d/%3d-%3d-%6d",index,row,var,tmplen);
|
||||
// LOG_D("index/row-var-tmplen");
|
||||
// LOG_D("%5d/%3d-%3d-%6d",index,row,var,tmplen);
|
||||
LOG_HEX("per msg",27,dout[index-1],col);
|
||||
LOG_D("--------");
|
||||
LOG_D("addr is %d",din);
|
||||
// LOG_D("addr is %d",din);
|
||||
rt_thread_mdelay(100);
|
||||
}
|
||||
|
||||
@ -243,7 +244,7 @@ size_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t
|
||||
// {
|
||||
// memcpy(dout[i], packdata[i], tlen[i]);
|
||||
// }
|
||||
memcpy(arrlen, tlen, row);
|
||||
// memcpy(arrlen, tlen, row);
|
||||
// LOG_D("--addr is %d",din);
|
||||
return row;
|
||||
}
|
||||
@ -266,7 +267,7 @@ for (size_t var = 0; var < s; ++ var) {
|
||||
rt_memcpy(buf+var, din+var, 1);
|
||||
}
|
||||
LOG_HEX("buf",16,buf,100);
|
||||
LOG_D("addr is %d",din);
|
||||
// LOG_D("addr is %d",din);
|
||||
if (buf) {
|
||||
rt_free(buf);
|
||||
}
|
||||
@ -283,12 +284,13 @@ LOG_HEX("buf",16,buf,100);
|
||||
* @param arrlen 打包后二维数组各维数组的长度
|
||||
* @return
|
||||
*/
|
||||
size_t pack_File(const char *fin, rt_uint8_t flag, char (*dout)[200], char *arrLen)
|
||||
rt_uint8_t pack_File(const char *fin, rt_uint8_t flag, const rt_uint8_t (*dout)[200], rt_uint8_t *arrLen)
|
||||
{
|
||||
MSG cfg;
|
||||
rt_memset(&cfg, 0, sizeof(MSG)); // 分配空间
|
||||
rt_uint8_t rst = packInit(&cfg, fin, flag);
|
||||
if (rst!= RT_EOK) {
|
||||
rt_uint8_t rst = packInit(&cfg, fin, flag);
|
||||
if (rst != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -297,7 +299,7 @@ size_t pack_File(const char *fin, rt_uint8_t flag, char (*dout)[200], char *arrL
|
||||
static size_t file_size = 0;
|
||||
// rt_uint8_t *buffer = RT_NULL;
|
||||
size_t flen = 150; // 每包数据初始长度,最大不超过 FRAME_DATA_LEN_MAX
|
||||
size_t len = 0;
|
||||
rt_uint8_t len = 0;
|
||||
|
||||
fd_in = open(fin, O_RDONLY, 0);
|
||||
if (fd_in < 0)
|
||||
@ -310,13 +312,13 @@ size_t pack_File(const char *fin, rt_uint8_t flag, char (*dout)[200], char *arrL
|
||||
file_size = lseek(fd_in, 0, SEEK_END);
|
||||
LOG_I("file size is %d bytes.",file_size);
|
||||
lseek(fd_in, 0, SEEK_SET);
|
||||
rt_uint8_t *buffer = rt_malloc(file_size);
|
||||
static rt_uint8_t *buffer = RT_NULL;
|
||||
buffer = rt_malloc(file_size);
|
||||
if (buffer == RT_NULL) {
|
||||
LOG_E("No memory for read %s.",fin);
|
||||
return 0;
|
||||
}
|
||||
// rt_uint8_t buffer[file_size];
|
||||
rt_memset(buffer, 0x00, file_size);
|
||||
|
||||
read(fd_in, buffer, file_size);
|
||||
close(fd_in);
|
||||
// 粗略调整每包大小
|
||||
@ -339,18 +341,17 @@ size_t pack_File(const char *fin, rt_uint8_t flag, char (*dout)[200], char *arrL
|
||||
}
|
||||
LOG_I("len of data per pack is %d Bytes.",flen);
|
||||
LOG_I("cnt of packages is %d",(file_size / flen) + (file_size % flen > 0 ? 1 : 0));
|
||||
// LOG_HEX("BEFORE:",16,buffer,file_size);
|
||||
LOG_D("1-addr is %p",buffer);
|
||||
|
||||
// len = packMsgs(&cfg, buffer, file_size, flen, dout, arrLen);
|
||||
// arrLen[0]= packMsg(&cfg, buffer, flen, dout[0]);
|
||||
// len=1;
|
||||
|
||||
len = packMsgs(&cfg, buffer, file_size, flen, dout, arrLen);
|
||||
LOG_D("2-addr is %p",buffer);
|
||||
// len = demo(buffer);
|
||||
|
||||
LOG_D("len is %d",len);
|
||||
LOG_I("file size is %d bytes.",file_size);
|
||||
// LOG_HEX("AFTER:",16,buffer,file_size);
|
||||
LOG_D("addr is %p",buffer);
|
||||
// len = 10;
|
||||
// rt_memset(arrLen, 100, len);
|
||||
// for (size_t var = 0; var < len; ++var)
|
||||
// {
|
||||
// rt_memset(dout[var], 0xab, arrLen[var]);
|
||||
// }
|
||||
|
||||
|
||||
if (fd_in >= 0)
|
||||
@ -364,22 +365,113 @@ size_t pack_File(const char *fin, rt_uint8_t flag, char (*dout)[200], char *arrL
|
||||
rt_free(buffer);
|
||||
LOG_D("free buf done.");
|
||||
}
|
||||
LOG_D("%p--%p",dout,arrLen);
|
||||
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pf_thread_entry(void* parameter)
|
||||
{
|
||||
|
||||
static char d[40][200];
|
||||
static char s[40];
|
||||
char *f = (char *) parameter;
|
||||
rt_uint8_t d[50][200];
|
||||
rt_uint8_t s[50];
|
||||
size_t len = pack_File(f, 0, d, s);
|
||||
// static char d[5][200];
|
||||
// static char s[5];
|
||||
// rt_memset(s, 0xab, 5);
|
||||
// for (size_t var = 0; var < 5; ++var) {
|
||||
// rt_memset(d[var], 0xab, 200);
|
||||
// }
|
||||
rt_uint8_t len = 0;
|
||||
// len = pack_File(f, 0, d, s);
|
||||
|
||||
if (1)
|
||||
{
|
||||
MSG cfg;
|
||||
rt_memset(&cfg, 0, sizeof(MSG)); // 分配空间
|
||||
rt_uint8_t rst = packInit(&cfg, f, 0);
|
||||
if (rst != RT_EOK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd_in = -1; //, fd_out = -1;
|
||||
|
||||
static size_t file_size = 0;
|
||||
// rt_uint8_t *buffer = RT_NULL;
|
||||
size_t flen = 150; // 每包数据初始长度,最大不超过 FRAME_DATA_LEN_MAX
|
||||
// rt_uint8_t len = 0;
|
||||
|
||||
fd_in = open(f, O_RDONLY, 0);
|
||||
if (fd_in < 0)
|
||||
{
|
||||
LOG_E("open the input file : %s error!\n", f);
|
||||
close(fd_in);
|
||||
return len;
|
||||
}
|
||||
|
||||
file_size = lseek(fd_in, 0, SEEK_END);
|
||||
LOG_I("file size is %d bytes.", file_size);
|
||||
lseek(fd_in, 0, SEEK_SET);
|
||||
static rt_uint8_t *buffer = RT_NULL;
|
||||
buffer = rt_malloc(file_size);
|
||||
if (buffer == RT_NULL)
|
||||
{
|
||||
LOG_E("No memory for read %s.", f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
read(fd_in, buffer, file_size);
|
||||
close(fd_in);
|
||||
// 粗略调整每包大小
|
||||
if (file_size > FRAME_DATA_LEN_MAX)
|
||||
{
|
||||
while (file_size % flen < flen / 1.2 && flen < FRAME_DATA_LEN_MAX) // 阈值约83%
|
||||
{
|
||||
flen += 1;
|
||||
}
|
||||
if (file_size % flen < flen / 1.2)
|
||||
{ // 到达限制仍不符合要求
|
||||
flen = 150;
|
||||
while (file_size % flen < flen / 2.5 && flen < FRAME_DATA_LEN_MAX) // 调整阈值为40%
|
||||
{
|
||||
flen += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flen = file_size;
|
||||
}
|
||||
// s[0] = packMsg(&cfg, buffer, flen, d[0]);
|
||||
len = packMsgs(&cfg, buffer, file_size, flen, d, s);
|
||||
if (fd_in >= 0)
|
||||
{
|
||||
close(fd_in);
|
||||
}
|
||||
|
||||
if (buffer != RT_NULL)
|
||||
{
|
||||
LOG_D("try to free buf.");
|
||||
rt_free(buffer);
|
||||
LOG_D("free buf done.");
|
||||
}
|
||||
}
|
||||
|
||||
rt_kprintf("len is %d\n", len);
|
||||
if (len)
|
||||
{
|
||||
// LOG_HEX("pkdata:",27,d[0],s[0]);
|
||||
// LOG_D("%d",s[0]);
|
||||
LOG_I("Done.");
|
||||
}
|
||||
LOG_HEX("s",27,s,len);
|
||||
// for (size_t var = 0; var < len; ++var) {
|
||||
// LOG_HEX("d",27,d[var],s[var]);
|
||||
// }
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
void pmsg(int argc, char **argv)
|
||||
@ -390,7 +482,7 @@ void pmsg(int argc, char **argv)
|
||||
strcpy(c, argv[1]);
|
||||
|
||||
/* 创建线程 */
|
||||
rt_thread_t thread = rt_thread_create("pmsg", pf_thread_entry, (void *) c, 1024 * 30, 25, 10);
|
||||
rt_thread_t thread = rt_thread_create("pmsg", pf_thread_entry, (void *) c, 1024 * 4, 25, 10);
|
||||
/* 创建成功则启动线程 */
|
||||
if (thread != RT_NULL)
|
||||
{
|
||||
|
@ -95,8 +95,9 @@ typedef struct{
|
||||
rt_uint8_t fdata[];//当前分片数据,为待发数据
|
||||
|
||||
}MSG;
|
||||
rt_uint8_t pack_File(const char *fin, rt_uint8_t flag, const rt_uint8_t (*dout)[200], rt_uint8_t *arrLen);
|
||||
|
||||
//rt_uint8_t packMsg(MSG *p_msg, rt_uint8_t *din, rt_uint8_t len, rt_uint8_t *dout);
|
||||
//rt_uint8_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t (*dout)[500], rt_uint8_t *arrlen);
|
||||
|
||||
|
||||
#endif /* APPLICATIONS_TTMSG_TTMSG_H_ */
|
||||
|
@ -9,6 +9,11 @@
|
||||
"ver": "v1.7.15",
|
||||
"name": "CJSON"
|
||||
},
|
||||
{
|
||||
"path": "/packages/tools/CmBacktrace",
|
||||
"ver": "v1.4.1",
|
||||
"name": "CMBACKTRACE"
|
||||
},
|
||||
{
|
||||
"path": "/packages/misc/fastlz",
|
||||
"ver": "v1.0.1",
|
||||
|
@ -195,7 +195,7 @@
|
||||
#define ULOG_OUTPUT_LVL_D
|
||||
#define ULOG_OUTPUT_LVL 7
|
||||
#define ULOG_ASSERT_ENABLE
|
||||
#define ULOG_LINE_BUF_SIZE 128
|
||||
#define ULOG_LINE_BUF_SIZE 256
|
||||
|
||||
/* log format */
|
||||
|
||||
@ -268,6 +268,12 @@
|
||||
|
||||
/* tools packages */
|
||||
|
||||
#define PKG_USING_CMBACKTRACE
|
||||
#define PKG_CMBACKTRACE_PLATFORM_M4
|
||||
#define PKG_CMBACKTRACE_DUMP_STACK
|
||||
#define PKG_CMBACKTRACE_PRINT_CHINESE_UTF8
|
||||
#define PKG_USING_CMBACKTRACE_V10401
|
||||
#define PKG_CMBACKTRACE_VER_NUM 0x10401
|
||||
/* end of tools packages */
|
||||
|
||||
/* system packages */
|
||||
|
Loading…
Reference in New Issue
Block a user