TRACE32 debugging skills

Source: Internet
Author: User
1. debug step l connect the TRACE32-ICD and target board, be sure not to live plugging JTAG, easy to damage TRACE32 or target board, and then turn on the TRACE32-ICD and target board power. L enable the debugging software TRACE32l to set the CPU type and status. You can run the following command or menu: sys. resetsys. CPUARM7TDMI; set the CPU

1. debug step l connect the TRACE32-ICD and target board, be sure not to live plugging JTAG, easy to damage TRACE32 or target board, and then turn on the TRACE32-ICD and target board power. L enable the debugging software TRACE32 l to set the CPU type and status. You can run the following command or menu: sys. reset sys. CPU ARM7TDMI; set the CPU here.

1. debugging steps

L connect the TRACE32-ICD and target board, note that do not live plugging JTAG, easy to damage TRACE32 or target board, and then turn on the TRACE32-ICD and target board power.

L enable the debugging software TRACE32

L set the CPU type and status. You can run the following command or menu:

Sys. reset

Sys. CPU ARM7TDMI; set the CPU type here

Sys. up; start debugging. If it is normal, the status is system. ready; otherwise, an error is reported. Check whether the CPU settings are correct and whether the TRACE32 and target board connections and power supply are normal.

After debugging is started properly, you can download the compiled files (such as. elf and. binary) to RAM or FLASH for debugging.

L download the compilation file. The command is as follows:

Data. load. elf E:/source/test. elf/path e:/source

Here, the/PATH option is used to specify the source code PATH. During debugging, the TRACE can find the source code. Here, the TRACE will be based on. the starting address of the target code contained in the elf file is loaded to the corresponding address of RAM. You can also specify the address to be loaded to RAM, but it must be consistent with the setting during compilation, otherwise, the program cannot run normally.

Note: TRACE can also burn the compilation target file to flash for debugging. You need to use flash burning commands, which will not be detailed here.

L then you can set the breakpoint for debugging, such:

Break. set 0x0c008000

TRACE32 has two types of breakpoints: hardware breakpoint (in FLASH) and software breakpoint (in RAM). Hardware breakpoint requires CPU support, for example, supports up to two hardware breakpoints. If you use a soft breakpoint, you can only use one hardware breakpoint. If you do not have a soft breakpoint, you can set more than one hardware breakpoint.

Note: In TRACE32, if you want to use a hardware breakpoint, you must first set the FLASH memory ing range. the following command:

Map. bonchip 0x0000 -- 0 xfffff; the specific range is set according to the range of the target board FLASH.

L the breakpoint can be properly debugged.

2. Source Code debugging

When compiling the source code, compile it into the target file (which can be in axf/elf format) of the debug version (with the-g option), and use TRACE32 to directly debug the source code. TRACE32 supports almost all compiler compilation files. For specific formats, see the help of TRACE32. Axf, elf, and other compilation files are also called symbol files, that is, the source code symbol table (functions, variables, etc.) is saved in the file for debugging, however, the symbol table only plays a positioning role and requires the source code. Otherwise, only compilation-level debugging is required. TRACE32 supports disassembly of machine codes into assembly languages for debugging, in addition, the target file is not required. TRACE32 can automatically read the machine code from FLASH/RAM and decompile it into assembly code.

Use the data. load command to download the symbol table file (. elf, etc.) to the target machine and specify the source code path for code debugging.

Data. load. elf E:/source/test. elf/path e:/source

3. Dead-end location method

When debugging a product, the device crashes. The following problems may occur during the debugging process, so you can easily use TRACE to check the problem; however, if the device is running normally (without JTAG debugging) or the device crashes, it is difficult to locate the problem. You can use the TRACE32 attach function to debug the problem as follows:

L connect the problematic machine to the TRACE32-ICD (connect to the JTAG, the test machine needs to reserve the JTAG port first), then enable TRACE32, set the CPU type, use sys. the attach command can connect TRACE32 to the problematic machine. After a normal connection, the system status changes to running or up.

L you can perform assembly-level debugging directly.

L but under normal circumstances, assembly-level debugging is difficult to locate the problem, the need for source code-level debugging, can be carried out according to the following operations: first the TRACE32-ICD and the same problem machine of the same type of machine connection, then put the symbol table file (. elf files) download (through data. load command) to the good machine, and then unplug the JTAG line from the good machine, connect to the problem machine; and then use sys. the attach command connects TRACE32 to the file machine so that source code-level debugging can be performed.

If you don't want to be so troublesome, you can also do this, connect to the TRACE32-ICD and problem machine, open the TRACE32 software, then the system state is "system down", and then through the "data. load command to download the symbol table file (. because the system status is down, TRACE32 will prompt that the unsigned table file has not been downloaded successfully, because it is not downloaded to the RAM of the faulty machine, however, the symbol table file has been downloaded to TRACE32 and then passed sys. the attach command associates TRACE32 with the problematic machine so that source code-level debugging can be performed.


The following describes how to use trace32 to debug the kernel.

First, let's talk about the hardware connection. Make sure that your trace32 is connected to the JTAG port of arm11.

Open the trace32 command window and set the cpu, as shown in:

Go to the settings page and set it as follows:

Enter the command "cd Z:/out/target/product/msm7627_surf/obj/KERNEL_OBJ" and "d. load. elf vmlinux/nocode" in sequence, as shown in:

Open the symbol table and find the function you want to debug, as shown in:

After the breakpoint is set, you need to perform the following settings,

Click go to open the breakpoint, for example:

It can be seen that the breakpoint has been entered, but how does one display the corresponding c code for a bunch of compilation? Use "symbol. sourcepath. setrecursedir z:/kernel" to add a path,

Finally, we see the correct code as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.