根据项目需求,改写了eMBRegHoldingCB
函数,在其中调用了easyflash
的ef_get_env_blob
函数,程序卡死,打印信息如下:
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
开启了CmBacktrace
组件,使用除0错误验证,组件工作正常。
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
md_s_sen 31 suspend 0x000000c0 0x00000200 37% 0x0000000a 000
slave tr 10 suspend 0x000000b8 0x00000200 35% 0x00000005 000
md_s_pol 10 suspend 0x000000e0 0x00000200 69% 0x0000000a 000
tshell 20 suspend 0x00000188 0x00001000 09% 0x0000000a 000
sys_work 23 suspend 0x00000088 0x00000800 06% 0x0000000a 000
mmcsd_de 22 suspend 0x000000b8 0x00000400 62% 0x00000007 000
tidle0 31 ready 0x00000084 0x00000100 57% 0x0000001d 000
timer 4 suspend 0x0000007c 0x00000200 24% 0x00000009 000
main 10 running 0x00000154 0x00000800 44% 0x0000000c 000
Firmware name: CmBacktrace, hardware version: V1.0.0, software version: V0.1.0
Fault on thread main
===== Thread stack information =====
addr: 20004af0 data: 0000001e
addr: 20004af4 data: 00000014
addr: 20004af8 data: 00000000
addr: 20004afc data: 0000000a
addr: 20004b00 data: e000ed14
addr: 20004b04 data: 00000002
addr: 20004b08 data: 20004b10
addr: 20004b0c data: 08001781
addr: 20004b10 data: 00000000
addr: 20004b14 data: 00000000
addr: 20004b18 data: deadbeef
addr: 20004b1c data: 08005419
====================================
=================== Registers information ====================
R0 : 00000000 R1 : 10000000 R2 : 0000000a R3 : 00000000
R12: ffffffff LR : 08005185 PC : 0803587a PSR: 41010000
==============================================================
Usage fault is caused by Indicates a divide by zero has taken place (can be set only if DIV_0_TRP is set)
Show more call stack info by run: addr2line -e CmBacktrace.elf -a -f 0803587a 08005184 08001780
Current system tick: 2309
再次触发eMBRegHoldingCB
,看到如下信息:
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
md_s_sen 31 suspend 0x000000c0 0x00000200 37% 0x00000015 000
slave tr 10 suspend 0x000000b8 0x00000200 35% 0x00000005 000
Firmware name: CmBacktrace, hardware version: V1.0.0, software version: V0.1.0
Fault on thread
Error: Thread stack(00000028) was overflow
===== Thread stack information =====
====================================
Usage fault is caused by attempts to switch to an invalid state (e.g., ARM)
Dump call stack has an error
Current system tick: 14120
虽然打印的线程信息不完全,但这里已经有提示stack(00000028) was overflow
,增加mb_slave_poll
线程的栈空间后,工作正常。
这里线程信息打印不完全也可能是因为栈溢出导致了数据错误,没办法现实完整的信息。
附带在mb_slave_poll
调用ef_get_env_blob
前后的stack size最大使用量:
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
md_s_sen 31 suspend 0x000000c0 0x00000200 37% 0x00000015 000
slave tr 10 suspend 0x000000b8 0x00000200 35% 0x00000005 000
md_s_pol 10 suspend 0x000000e0 0x00001000 08% 0x00000015 000
tshell 20 running 0x00000188 0x00001000 15% 0x00000003 000
sys_work 23 suspend 0x00000088 0x00000800 06% 0x0000000a 000
mmcsd_de 22 suspend 0x000000b8 0x00000400 62% 0x00000007 000
tidle0 31 ready 0x0000005c 0x00000100 57% 0x0000000c 000
timer 4 suspend 0x0000007c 0x00000200 24% 0x00000009 000
main 10 suspend 0x00000144 0x00000800 46% 0x00000003 000
msh />[D/mb.app] haha
ps
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
md_s_sen 31 suspend 0x000000c0 0x00000200 37% 0x00000015 000
slave tr 10 suspend 0x000000b8 0x00000200 39% 0x00000003 000
md_s_pol 10 suspend 0x000000e0 0x00001000 22% 0x0000000c 000
tshell 20 running 0x00000188 0x00001000 15% 0x00000008 000
sys_work 23 suspend 0x00000088 0x00000800 06% 0x0000000a 000
mmcsd_de 22 suspend 0x000000b8 0x00000400 62% 0x00000007 000
tidle0 31 ready 0x0000005c 0x00000100 57% 0x00000017 000
timer 4 suspend 0x0000007c 0x00000200 24% 0x00000009 000
main 10 suspend 0x00000144 0x00000800 46% 0x00000007 000
msh />
从8%提升到了22%,即327Byte提升到了901Byte,之前的512Byte 是远远不够的。