6 Trace32¶
6.1 Using Trace32 to recover Hcpu crash scene¶
1,参照章节5.8 Dump内存方法 Dump内存方法,Dump the memory and the compiled axf file into the same directory
D
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
3)还有一种方法,Manually recover directly from the hardfault scene, refer to section 6.6 Trace32 manual crash scene recovery method
6.2 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.3 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.4 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。