[Trace32] Essentials of Trace32

4 minute read

Introduction

Trace32 is a powerful debugging tool.
It requires a separate license and connects via a debug interface, most commonly JTAG.
This is a personal reference post summarizing basic commands.
It will be updated continuously on the Trace32 Quick Start Guide page.
For OS awareness, please refer to the Trace32 OS Awareness page.

Getting Started

To use Trace32 (abbreviated as T32), you must first install the debugging software.
However, due to the high cost of licenses, setup in a general environment is challenging.
This guide assumes that the basic software and license are already prepared.

Device Connection

Connect the target board to T32.
Ensure the target board is powered off to protect both the debugger and the board.
Carefully identify pin 1 of the debug interface (usually JTAG) and make the connection.

You can monitor the debugger’s status via the Power Debugger interface LEDs:

' POWER
' SELECT
' EMULATE

POWER : Lights up when the power is on.
SELECT : Flashes on power-up; stays on while PowerView is running.
EMULATE : Lights up when the target is running.

Start by running t32m[core].exe or t32start.exe to select the core.

PowerView

Option 1: Configure target information.
Go to [CPU] -> [System Setting] -> … and configure JTAG clock, multicore, and other settings as needed, then select “UP” in the Mode menu.

Option 2: Use a pre-written script for the target board.
Load a .cmm script via [File] -> [Edit script].
Execute using Do or Debug -> over.
Scripts can also be loaded via the command line.
You can use pedit {cmm script} or pedit * .
As mentioned later, using pedit * opens a file browser.

Option 3: Be cautious when using T32 in environments with Watchdogs (e.g., Linux kernel).
If the system hits a breakpoint in T32, the Watchdog might automatically reset the device to prevent it from hanging.
This will cause the connection with T32 to drop.

Refer to the datasheet to disable the WDT, or for Linux, remove the relevant CONFIG and rebuild the kernel.

Additionally, in multicore environments, there might be mechanisms monitoring the IDLE states between different cores.
In this case, set the CPU configuration to MPCore and include information for each core in the T32 script.

Commands

Enter commands at the command prompt (B::).
Commands are case-insensitive, though they may vary between software versions.
Use the Tab key for auto-completion to find the correct command if there are differences.

Basic

reset

B:: sys.d
B:: reset


Go

B:: g

Enters the running state. Register dumps are not available during this time.

Break

B:: b

Enters the break state. You can inspect register values in this state.

Data

B:: Data.{Set/dump/...} {class}:{address} /{option} ..

This command is used to check register values at specific addresses.
The ‘class’ determines the address attributes.
For example, the following classes exist:

a: Represents a physical address.
d: Recognizes as a data type.
s: Secure access.
ns: Non-secure access.
spr: Accesses via architecture-encoded addresses.


Load elf

B:: Data.LOAD.ELF {target_elf_path} /{option}

This command loads symbols.
You can use ‘*’ instead of target_elf_path to manually select a file.
After execution, view the symbols via [View] -> [Symbol Table] in PowerView.
Similar to cmm scripts or symbol files, using * when loading files opens a file explorer.
You can then select the file directly using the explorer.

Translate Path

B:: sYmbol.sourcePATH.translate "{invalid part}" "{correct part}"

The source paths in the loaded file might sometimes be unknown to the local system.
Use this to replace an invalid path segment with the correct local path.

OS awareness

For OS awareness, particularly Linux, please refer to the Linux awareness page.

CMM Scripts

Use the following command to write a cmm script:

B:: pedit main.cmm


Or to import an existing script (using file explorer):

B:: pedit *


Some script examples (for reference)

/* data dump */
data.dump R(PC) // data dump in PC addr
data.dump apb:0x... // access memory addr directly
data.dump ahb:0x... // access memory addr directly
data.dump a:0x... // access memory addr directly
data.dump a:0x... /quad // access memory addr directly

/* mmu */
mmu.list.pt R(x3) // check virtual_addr to physical_addr
mmu.dump.pt R(x3) // how to table walking


segmentation fault:
./elf_name
...
...
...> syncro exception
     (almost permission) or page fault
     segmentation fault -> exit
                        ` break point

GUI:
Linux -> process -> Debug New Process
elf_name (main) break
-> load elf

CLI:
B:: symbol.browse.symbol
Filter: fault (__do_fault) select
(or Functions that must be called before panic)

view register: peripherals -> ID... (first)
(check esr)
B:: break.list
B:: frame.view


Use cmm script with arguments
-----------------------------
entry &core &arg2 &arg3

path + c:\ // "do" search pwd default, path +: add search path

if ("&core"=="CA65")
(
  do tcn100x_ca65e.cmm
  if (&arg2!="")
  (
    do tcn100x_ca65e.cmm &arg2
  )
)
if ("&core"=="CM7")
(
  do tcn100x_cm7.cmm &arg2
  if (&arg3!="")
  (
    do tcn100x_cm7.cmm &arg3
  )
)
ENDDO
-----------------------------

Add button on the toolbar
(B:: menu.reprogram toolbar.men)
-------------------------
ADD
TOOLBAR
(
  TOOLITEM "setting CM7 core 0" "c0,B" "do main.cmm CM7 0"
  SEPARATOR
  TOOLITEM "setting CM7 core 0" "c1,B" "do main.cmm CM7 1"
  SEPARATOR
  TOOLITEM "setting CM7 core 0" "c2,B" "do main.cmm CM7 2"
  SEPARATOR
  TOOLITEM "setting CM7 core 0" "c3,B" "do main.cmm CM7 3"
  SEPARATOR
)
-------------------------


system-settings.cmm for TOOLBAR
-------------------------------

B::

path + C:\

menu.reprogram c:\toolbar.men

ENDDO
-------------------------------

save C:\T32\system-settings.cmm
&
search <help>
how to edit & use system-settings.cmm


[Guide <help>]
help -> find
find: // view example
find index: // view defines

Leave a comment