各位大佬好, 打扰了,最近尝试 zynq7020 上使用 rt-thread, 发现了一个奇怪的问题, 在启用文件系统后, shell 线程触发了异常, 通过 map 文件定位到是在调用 strcat 时出现了问题。串口打印并未发现参数有误。尝试用一个自定义的 strcat 替换掉 strcat, 就可以正常运行了。请问哪位大佬知道可能是什么原因? 谢谢
报错:
initialize init_th:0 done
initialize finsh_system_init:0 done
running on cpu 0
data abort:Execption:
r00:0x00000005 r01:0x7f7f8000 r02:0x0011a9f1 r03:0x0000003e
r04:0x0011a9f0 r05:0xdeadbeef r06:0xdeadbeef r07:0xdeadbeef
r08:0xdeadbeef r09:0xdeadbeef r10:0xdeadbeef
fp :0x0011de04 ip :0x01010101
sp :0x0011ddf8 lr :0x0010efe0 pc :0x0010f008
cpsr:0x80000013
thread pri status sp stack size max used left tick error
tshell 20 running 0x00000040 0x00001000 13% 0x0000000a 000
test 20 suspend 0x000000a4 0x00000400 16% 0x00000004 000
ulog_async 30 ready 0x00000044 0x00000400 06% 0x00000014 000
tidle0 31 ready 0x00000040 0x00000200 12% 0x00000020 000
init 10 close 0x0000007c 0x00000800 15% 0x00000010 000
shutdown...
(0) assertion failed at function:rt_hw_cpu_shutdown, line number:38
尝试替换 strcat, 并打印 strcat 的位置:
diff --git a/rt-thread/components/finsh/shell.c b/rt-thread/components/finsh/shell.c
index 61f0b95..2b6f8f5 100644
--- a/rt-thread/components/finsh/shell.c
+++ b/rt-thread/components/finsh/shell.c
[url=home.php?mod=space&uid=1999721]@@[/url] -101,6 +101,18 @@ int finsh_set_prompt(const char * prompt)
#include <dfs_posix.h>
#endif /* RT_USING_DFS */
+char *t_strcat(char * dest, const char * src)
+{
char *tmp = dest;
while (*dest)
dest++;
while ((*dest++ = *src++) != '\0')
;
return tmp;
+}
const char *finsh_get_prompt(void)
{
#define _MSH_PROMPT "msh "
@@ -131,7 +143,8 @@ const char *finsh_get_prompt(void)
getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
#endif
initialize init_th:0 done
initialize finsh_system_init:0 done
running on cpu 0
str_cat: 0011556d
msh />
地址与map文件中一致
.text.strcat 0x0011556c 0x40 d:/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb/fpu\libc.a(lib_a-strcat.o)
0x0011556c strcat
更多回帖