6 Trace32¶
6.1 Trace32下载和配置方法¶
1. 下载Trace32
可以直接在Lauterbach公司的官网下载,如下图:
版本选择ARM版本的simarm.zip,免费版本在线调试和Script长度有限制,SiFli的全系列MCU目前只用到了离线调试功能;
Lauterbach公司的离线调试工具下载地址:
Simulator for ARM/CORTEX/XSCALE
simarm.zip [[使用方法](#Mark_Using Trace32 to recover Hcpu crash scene)]
2. 配置方法
打开安装说明文件SiFli-SDK\tools\crash_dump_analyser\INSTALL.md
# Installation Guide
- Download simarm from the link below: https://www2.lauterbach.com/download/simarm.zip
- Extract all files in `simarm.zip` to `simarm` folder, `simarm` folder should be in `crash_dump_analyser` folder
- Replace t32.cmm and t32.men in `simarm` folder with the ones in `patch` folder
下载的压缩包解压到SiFli-SDK\tools\crash_dump_analyser\
目录内,再把此目录的patch
的内容复制到刚解压的simarm
目录内,如下图:
3. Trace32运行方法
该软件免安装,鼠标双击simarm
目录内t32marm.exe
可执行文件,就可以打开Trace32
6.2 Using Trace32 to recover Hcpu crash scene¶
1,参照章节5.8 Dump内存方法 Dump内存方法,Dump the memory and the compiled axf file into the same directory
2,Run t32marm.exe located in the sdk directory \tools\crash_dump_analyser\simarm<br>
3,Check Hcpu crash, click the HA button (HCPU assertion),If some bins are missing (e.g., some dumps do not have PSRAM2), you can uncheck them。
Click the “run_next_step” button to load
After successful loading, the scene information shown in the figure below will be displayed,
4,在save的内存相关bin都成功的情况下,The relationship between memory and related addresses will be established, refer to the Memory address space in each chip manual,If the scene is not recovered, check whether the dumped bins are normal,Check whether the PC and other registers in log.txt are correctly read,In specific cases, such as when psram is not ready, you can modify the corresponding dump script,比如:sf32lb52x.jlink内的dump内容来添加或者减少需要dump的地址空间。
5,You can switch the displayed window in the Window menu
The heapAllocation window shows the allocation of all heap pools in the system,包括system heap以及memheap_pool:
system heap: pool used by rt_malloc and lv_mem_alloc
Each memheap_pool: pool created using rt_memheap_init, allocated and freed using rt_memheap_alloc and rt_memheap_free
The meaning of fields in the allocation information list is:
BLOCK_ADDR: The starting address of the allocated memory block, including management items
BLOCK_SIZE: The size of the requested memory, excluding the length of management items
USED: Whether it is allocated, 1 means allocated, 0 means not allocated
TICK: Application time, in OS ticks, i.e., 1ms
RETURN ADDR: Applicant address
6,No display of exception stack processing
After completing the previous steps, sometimes the crash scene stack will not be displayed, possibly because the dump content was not saved or saved abnormally,可以尝试以下3种办法:
1)Load the scene stack from the Jlink halt log information The HR (HCPU Registers) button is used to restore CPU registers that did not reach the exception handler After clicking the button, select the exported log.txt file, which will backfill the 16 HCPU registers into trace32
2)From the 16 registers printed in the log, backfill them into the register window of trace32
#提示:ARM内核中,寄存器对应关系如下:
SP <-> R13
LR <-> R14
PC <-> R15
3)还有一种方法,直接从hardfault的现场手动恢复,参考Trace32手动恢复死机现场方法
4)在hardfaulRT_ERROR_HW_EXCEPTION
死机的情况下,要特别留意出问题的PC汇编指令,要考虑为什么出现异常地址,异常指令,如下图:
6.3 Using Trace32 to recover Lcpu crash scene¶
Similar to HCPU scene recovery, select the LA button and follow the prompts。 需要注意的是LCPU has additional rom axf synchronous loading, which can be checked as needed。
6.4 Trace32 common commands¶
1, Menu: View->List Soure, bring up the source code window, or command L 10063c or l 0x10063c, you can view the code where the PC pointer is 0x10063c。
2, Menu: VarT->View, or command: v.v *, bring up the variable window, you can search for variables, functions, supports * wildcard,如如下图:
3, Menu: CPU->CPU Registers, or command: r, bring up the register window, modify register values。
4, Menu: View->Dump…, or command: data.dump, bring up the memory address window, for example, enter 0x200c0000 in the input box to view the memory at 0x200c0000,或者命令:data.dump 0x200c0000查看0x200c0000内存。
5,Menu: View->StackFrame with locals, or command: frame /locals /caller, view the call stack and local variables。
6, You can execute the scripts under tools\crash_dump_analyser\script\ with commands,如下图:
show_app_pages.cmm
show_heap.cmm
show_heap_lcpu.cmm
show_heap2.cmm
show_isr_history.cmm
show_reg.cmm
show_rt_memheap.cmm
show_running_app.cmm
show_switch_history.cmm
show_tasks.cmm
show_timer.cmm
switch_task.cmm
switch_to.cmm
对应命令:
do show_tasks
#Display all threads, showing running status, stack addresses, and priority,如下图:
do switch_to 0x200A2F7C
#You can switch to other threads with commands, as shown below, switch to the TP thread:
do show_switch_history
#You can view thread switching history。
do show_timer
#You can view the usage of timers。
7,Method to forcibly convert memory address to structure:
结构体 struct rt_pm _pm;
Conversion command: (struct rt_pm *)0x101fa2b9
如下图:
8,Method to forcibly convert memory address to uint8, uint16, etc. variables:
(uint16_t *)0x101fa2b9
6.5 Trace32Project path relocation¶
1,When trace32 recovers dumped memory files on different computers, the following situation may occur where only assembly is displayed and C language cannot be displayed:
The reason is that the path of the dump memory project executed by save_ram_a0.bat is inconsistent with the location of your trace32 reproduction path project。
2,We can solve this problem by relocating the project path,如下图:
Select the project path where the corresponding c file is located. After selecting this file, all project paths are relocated,如下图:
3,The relocated trace32 interface is as follows: Except for the code in lib, all can display C language code。