LOG Tool

Introduction

Trace Tool is an official serial logging tool for the Ameba SoC series developed by Realtek. Through the LOGUART port, it allows developers to send commands to and receive logs from devices in real time.

Compared to generic serial port tools, Trace Tool offers the following advanced functionalities:

  • Multi-core AGG log parsing

    When the LOGUART AGG (aggregation) feature is enabled, Trace Tool demultiplexes the interleaved logs of multiple cores and prepends a per-core tag (for example [KM4] or [CA32]) to each log entry. The demultiplexing is dispatched automatically according to the selected SoC, so simply selecting the connected chip configures the correct per-core tags and the routing of every AGG path.

  • BT log capture

    Automatically captures Bluetooth host (upper-stack) logs and Bluetooth firmware logs to files.

  • Register access

    Reads, writes, and dumps system and Wi-Fi (MAC/BB/RF) registers by address.

  • Scope

    Plots numeric values parsed from specifically formatted logs as live waveforms.

  • Wi-Fi debugging

    Supports access of WiFi-related registers and WiFi debugging.

  • Automation script

    Runs a command script with loops, delays, and pass/fail pattern matching.

Note

If the above advanced features are not required, generic serial port tools can be used as alternatives to Trace Tool.

The UI of Trace Tool is shown below:

../_images/tracetool_ui.png

The main window consists of the following areas:

  • Title bar: Shows the tool version, a connection indicator, and the selected SoC and serial port, for example RTL8720F-(COM13).

  • CHIP selector (top left): Selects the connected SoC. Refer to SoC Selection for details.

  • Menu bar:

    • EDIT: Provides Clear Log and Clear Auto Log, and, under the HISTORY COMMANDS heading, Clear / Save / Load for managing the history command list.

    • OPTION: Provides Global Settings. Refer to Global Settings for details.

    • HELP: Provides Get Script Format, which opens the automation script format reference.

  • Tool keys (top right): AUTO, DBG, and SCOPE. AUTO and DBG open a side panel next to the log; SCOPE shows the scope settings and waveforms in place of the log. Click the key again (or the × button of the side panel) to close it.

  • Log area: Displays the received logs.

  • CMD box: Sends commands to the device. Refer to Send Commands for details.

  • Bottom panel: HISTORY, LOGGING, SERIAL, and TAG FILTER.

  • Status bar: Shows the connection state (CONNECTED / DISCONNECTED), the number of displayed lines (LINES), the latest status message, and the auto-scroll indicator.

Hardware Connection

The hardware connection is illustrated below:

../_images/tracetool_hardware_setup.svg

Software Setup

Trace Tool is available for Windows, macOS, and Linux, with the same functions on all platforms. No additional runtime needs to be installed.

Platform

Environment requirements

Software location

Windows

Windows 10 or above (64-bit)

{SDK}/tools/ameba/TraceTool/AmebaTraceTool.exe

macOS

macOS 11 or above (Apple Silicon or Intel)

{SDK}/tools/ameba/TraceTool/macOS/AmebaTraceTool.app

Linux

x86_64, glibc 2.30 or above (for example, Ubuntu 20.04 or above, Debian 11 or above)

{SDK}/tools/ameba/TraceTool/Linux/AmebaTraceTool

Trace Tool can also be downloaded separately for each platform from the links at the top of this page.

  • macOS: The app is not notarized by Apple, so macOS blocks it the first time it is opened. Right-click AmebaTraceTool.app and select Open, then confirm; or run xattr -dr com.apple.quarantine AmebaTraceTool.app in Terminal. On macOS, use the Command key instead of Ctrl for the keyboard shortcuts in this document (for example, Command+C).

  • Linux: A desktop session (X11 or Wayland) is required. To access serial ports, add the user to the dialout group with sudo usermod -aG dialout $USER, then log out and log in again. If the file lost its executable permission, run chmod +x AmebaTraceTool.

Note

  • Install the driver for the USB-to-UART adapter (for example, PL2303GC) on the host first; otherwise, the host will not be able to recognize the LOGUART port.

  • Download the appropriate driver from the official website of the corresponding USB-to-UART adapter supplier.

SoC Selection

It is recommended to select the connected SoC from the CHIP selector before opening the serial port. The selection is persisted and automatically restored on the next launch.

../_images/tracetool_chip_selection.png

Trace Tool dispatches AGG logs based entirely on the selected SoC. Once the connected SoC is selected, the per-core tags, the TAG FILTER entries, and the routing of each AGG path are configured automatically; no further manual setup is required.

The selected SoC determines:

  • the per-core tag prepended to each log line when LOGUART AGG is enabled;

  • the entries shown in the TAG FILTER panel, which is used to show or hide individual cores;

  • how each AGG path is dispatched: text paths to the log area, and Bluetooth or other binary paths to capture files. Refer to AGG Support for the per-SoC path mapping.

Note

  • Generic is the default selection. When the connected SoC is not selected, or an unrecognized path is received, Trace Tool falls back to the generic core tags [Core0] / [Core1] / [Core2] for text paths so that logs remain visible. Select the actual SoC to obtain the correct per-core tags.

  • For SoCs that do not support the AGG feature, their LOGUART does not insert AGG headers, so no core tags are applied and the TAG FILTER panel is empty when such a SoC is selected.

  • The SoC can also be changed while the serial port is open.

Log Print

Basic Usage

After setting the environment mentioned in Section Hardware Connection, execute the following steps:

  1. Select serial port in the PORT box of the SERIAL panel.

    ../_images/tracetool_port.png
  2. Configure the serial port.

    • BAUD: The default value is 1500000bps. A value that is not in the list can also be typed in.

    • DATA BITS: The default value is 8.

    • PARITY: The default value is “None”.

    • STOP BITS: The default value is 1.

    • ENCODING: The default value is UTF-8, which displays multi-byte characters (such as Chinese) correctly. ASCII is also available.

    These parameters must be consistent with the LOGUART settings on the device side.

    Additionally, a CLOSE ON DOWNLOAD checkbox is provided, when enabled, Trace Tool automatically closes the serial port upon detecting the SoC entering download mode, so that the port can be used by the image download tool.

  3. Click the OPEN button to open the serial port and start to receive the logs from device.

    Log messages will be printed in the log area and the text of OPEN button will be switched to CLOSE. While the port is open, the serial settings are locked, except ENCODING.

  4. To stop receiving the logs, click the CLOSE button to close the serial port.

Note

If the USB-to-UART adapter is unplugged while the port is open, Trace Tool reopens the port automatically once it is plugged in again.

Log View

  • The log area follows the newest logs by default. Scrolling up or selecting text pauses auto-scroll so that the logs can be read; new logs are still received. The indicator at the right of the status bar shows the state, for example Auto-scroll: ON or Auto-scroll: paused, 5 new lines (click to show). Click the indicator, or press Esc in the log area, to resume.

  • Drag over the logs to select text, or Shift + click to extend the selection. A part of a line can be selected as well. Press Ctrl+C to copy the selection.

  • Right-click the log area to open a menu with Copy and Clear Log.

  • Hover over a line that is too long for the window to see its full text in a tooltip.

  • Clear Log only clears the log area; the logs that are being saved to a file are not affected.

Log Saving

To save the logs to local file:

  1. Click START button in LOGGING box, and choose where to save the .txt file. All the received logs will be saved to this file. Click STOP to stop saving.

Note

For segmented logs, click OPTION and Global Settings to set the log size.

  1. Click the OPEN DIR button in LOGGING box to open the folder where the log file are saved.

AGG Support

Trace Tool automatically detects whether the LOGUART AGG (aggregation) feature is enabled and processes logs accordingly.

  • AGG enabled

    The firmware multiplexes the log streams of multiple cores over the single LOGUART pin, tagging every packet with a path number that identifies its source. Trace Tool parses the AGG header of each packet and automatically dispatches it according to the SoC selected in the CHIP selector; no further manual configuration is required.

    Each AGG path carries the following core or stream on each SoC:

    SoC

    Path 1

    Path 2

    Path 3

    Path 4

    Path 5

    RTL8721Dx

    KM4

    KM0

    BT upper stack

    —

    BT FW

    RTL8721F

    KM4TZ

    KM4NS

    BT upper stack

    —

    BT FW

    RTL8720F

    KM4TZ

    KM4NS

    BT upper stack

    SDN

    —

    RTL8720E

    KM4

    KR4

    BT upper stack

    —

    BT FW

    RTL8710E

    KM4

    KR4

    BT upper stack

    —

    BT FW

    RTL8726E

    KM4

    KR4

    BT upper stack

    DSP

    BT FW

    RTL8713E

    KM4

    KR4

    BT upper stack

    DSP

    BT FW

    RTL8730E

    KM4

    KM0

    BT upper stack

    CA32

    BT FW

    RTL8735C

    KM4NP

    CA32

    BT upper stack

    KM0

    BT FW

    Text logs are displayed in the log area, each prepended with the corresponding core tag (for example [KM4] or [CA32]). To show or hide the logs of individual cores, check or uncheck the desired cores in the TAG FILTER panel; the panel is rebuilt to list the cores of the selected SoC each time the CHIP selection changes.

    The other streams (BT upper stack, BT FW, and SDN) are binary and are not displayed in the log area. They are saved to files in the log folder next to the Trace Tool executable, and new files are created each time the serial port is opened:

    • Bluetooth host (upper-stack) logs are saved to a BT_*.bin file.

    • Bluetooth firmware logs are saved to a BT_FW_*.log file.

    • SDN logs are saved to an SDN_*.bin file.

    When LOGUART AGG is enabled, other serial tools may display garbled text because they cannot parse AGG headers.

  • AGG disabled

    • Logs do not include AGG header information.

    • Trace Tool does not prepend core tags to log entries.

    In this case:

    • Log entries may become mixed when multiple cores print simultaneously.

    • Users can use other serial tools to print logs if Bluetooth host and firmware logs are not required.

    Note

    • By default, LOGUART AGG is disabled. To enable it, refer to User Configuration .

    • Temporary log display issues may occur when switching AGG between enabled and disabled states.

Timestamp

Timestamps are prepended to log entries by default. To turn them on or off:

  1. Click the OPTION menu

  2. Select the Global Settings menu item

  3. Check or uncheck the Timestamp checkbox

../_images/tracetool_log.png

Note

Displayed timestamps may lag behind actual log generation times due to processing delays in Trace Tool.

Send Commands

To send commands to the attached device:

  1. Input a command in the command box (CMD).

    ../_images/tracetool_command_box.png

    Note

    Refer to Command Prefix to determine whether a command prefix needs to be added before the command.

  2. Press the Enter key.

The following keys are also available in the command box:

  • Up / Down: Recall the recently sent commands.

  • Ctrl+C: Sends Ctrl+C (0x03) to the device, for example to interrupt a running command.

  • Esc: Sends Esc (0x1B) to the device.

The history command box (HISTORY) records previously sent commands.

  • Click a command to display it in the command box. Hold Ctrl or Shift while clicking to select several commands.

  • Double-click a command to send it to the chip.

  • Click DELETE to remove the selected commands from the list.

  • The history command list can be cleared, saved, or loaded from the EDIT menu, under HISTORY COMMANDS. Loaded commands are appended to the list.

Command Prefix

When multiple cores in different SoC models perform distinct roles, specific command prefixes shall be used to identify core-specific operations.

RTL8721Dx:

Core

Role

Command Prefix

KM4

AP

None

KM0

NP

@

Register Access

Click the DBG key to open the DEBUG panel. The Register Process group is used to read from and write to register values via their addresses.

  • Type: Selects the register type. System accesses system registers, while WiFi MAC / WiFi BB / WiFi RF are for Wi-Fi functionalities, each having a different base address. Select the appropriate option based on your requirements. System is not offered for SoCs that do not support system register access.

  • Address / Offset: The register to access, in hexadecimal. The field is named Address for System and Offset for the Wi-Fi types.

  • Value: The register value, in hexadecimal. Read fills it in; Write writes it to the register.

  • Read / Write: Reads or writes the register value at the specified address.

  • Dump: Bulk-prints a range of registers to the log. Supported only for WiFi MAC / WiFi BB / WiFi RF.

  • Bit Value: Displays the 32 bits of Value. Click a bit to toggle it; the new value is written to the device only when Write is clicked.

../_images/tracetool_register_access.png

Scope Function

The scope function is used to capture specific data from logs and dynamically display waveform patterns.

  1. Click the SCOPE key. The scope settings and waveforms are shown in place of the log.

  2. Enter one or more Y patterns (Y1 to Y6) and enable each Y channel with its checkbox. Each pattern must be different.

  3. Optionally, enter an X pattern. When X is empty, time is used as X.

  4. Set X SAMPLES: the width of the displayed window, in seconds when time is used as X, otherwise in X units. The default value is 100.

  5. Click the RUN button. The button changes to STOP.

../_images/tracetool_scope_setting.png

The waveform of each enabled channel is displayed synchronously, with the minimum (MIN), maximum (MAX), and average (AVG) values and the number of samples (N). Click RESET AVG to restart the statistics.

../_images/tracetool_scope.png

Note

While the scope is running, click START LOGGING to save the captured scope data to a .csv file. Click STOP LOGGING to stop.

Wi-Fi Debug

The WiFi Debug group is located in the DEBUG panel (DBG key).

  • DIG_MARGIN: Set the Wi-Fi DIG margin, available value: [0x00, 0x3c].

  • EDCCA: Set the MAC EDCCA mode, available value: 0/1/9.

  • DBG: Set Wi-Fi RA debug, available value: [0x00, 0xff], and display the average values of CCK FA and OFDM FA over the interval set in every (in seconds, default 5).

  • Power Save: Click Enable or Disable to enable or disable Wi-Fi power saving mode.

../_images/tracetool_wifi_debug.png

Automation Script

Click the AUTO key to open the AUTO SCRIPT panel, which provides support for automatic script execution.

  1. Click the Browse button to choose the script you want to execute. By default, example_script.txt next to the Trace Tool executable is selected.

  2. Open the serial port, then click the Execute button to execute the script. The button changes to Stop, which can be clicked to stop the script.

../_images/tracetool_auto_script_ui.png

The AUTO SCRIPT panel also provides the following helpers:

  • Template: Shows the path of the selected script in the status bar.

  • Edit: Opens the selected script in the default text editor of the system. If the script does not exist, Trace Tool offers to create it.

  • Time Interval: Sets the delay (in milliseconds, default 1000) after each command that has no pass_pattern or fail_pattern.

  • The result list under the buttons shows the result of each command with a timestamp (pass, fail, or timeout). It can be cleared from the EDIT > Clear Auto Log menu.

Note

The script syntax reference can also be opened from the HELP > Get Script Format menu.

The general format of the automatic script:

CMD1
CMD2
CMD3
…
  • Keyword loop can be used to execute commands repeatedly:

    loop=10
    loop_start
       CMD1
       CMD2
       sleep 1000
       …
    loop_end
    

    The keywords and specific rules within the loop are as follows:

    • loop: The number after loop= means loop times.

    • loop_start: Used to mark the beginning of the loop.

    • loop_end: Used to mark the end of the loop.

    • loop_start and loop_end must appear in pairs.

    • sleep: Used to delay some time between commands, and unit is millisecond. sleep 1000 means to delay 1000ms. There should be a blank space between sleep and sleep time.

  • Nested loops are supported, and they can be structured as follows:

    loop=2
    loop_start
       CMD1
       sleep 1000
       loop=3
       loop_start
          CMD2
          sleep 2000
       loop_end
    loop_end
    
  • Catching certain patterns, like pass_pattern or fail_pattern , to indicate that the result of specific CMD execution is supported, the format is as below:

    loop=10
    loop_start
       timeout=1000
       pass_pattern=xxx
       fail_pattern=xxx
       CMD1
       if fail
          break
       fi
       CMD2
       …
    loop_end
    
    • The key words pass_pattern and fail_pattern are only valid for the next command CMD1, used to catch patterns in CMD1 execution. The patterns are regular expressions, and are matched against the logs received after CMD1 is sent.

      When a pattern is detected, the keyword if...fi can be used for subsequent operations. Use if pass, if fail, or if timeout to check the result of the previous command. The commands and keywords between if and fi are executed only when the result matches. break exits the innermost loop.

    • The number following timeout= represents the waiting time for capturing matching characters. If this time is exceeded, capturing will stop. It can be set to different values as needed (unit: milliseconds), with a default value of 5000. The value applies to all subsequent commands until another timeout= is set.

    • The string following pass_pattern= indicates the pass pattern, while fail_pattern= indicates the fail pattern, used to denote the result of the CMD execution.

    When executing a CMD, there are three possible outcomes:

    • Pass: pass_pattern is matched in the CMD execution result within the timeout period.

    • Fail: fail_pattern is matched in the CMD execution result within the timeout period.

    • Timeout: Neither pass_pattern nor fail_pattern is matched in the CMD execution result within the timeout period.

  • Keyword stop ends the script immediately, also from inside a loop.

    For example, the following script reboots the device up to 2 times and stops when the expected log is seen:

    loop=2
    loop_start
       timeout=20000
       pass_pattern=Bringing up secondary CPUs
       fail_pattern=fail
       reboot
       if pass
          break
       fi
    loop_end
    stop
    

Note

For FreeRTOS SDK related applications, please refer to AT CMD documentation to customize automation script.

Caution

  • Only one command is allowed per line.

  • Lines can be indented with TABs or spaces to improve readability.

  • Keywords are case-sensitive and must be written in lowercase.

  • No spaces are allowed before the “=”. The text after pass_pattern= and fail_pattern= is used as it is, including any spaces.

Global Settings

Click OPTION > Global Settings to open the settings dialog. Click OK to apply the changes.

../_images/tracetool_global_settings.png
  • Row Count: The maximum number of log lines kept in the log area (default 1100). The oldest lines are removed when the limit is reached; the log file is not affected.

  • Log Size: The maximum size of each log file, in KB. When it is reached, logging continues in a new file. 0 means no limit.

  • Timestamp: Prepends a timestamp to each log entry. Refer to Timestamp.

  • Dark Mode: Switches between the day and dark appearance. Refer to Dark Mode.

The settings, the serial port configuration, the selected SoC, and the scope configuration are saved in Setting.json next to the Trace Tool executable, and restored on the next launch. On macOS, the folder of the executable is AmebaTraceTool.app/Contents/MacOS.

Dark Mode

Trace Tool uses the day (light) appearance by default. A dark appearance is also available, which is easier on the eyes in a dim environment. To switch to it:

  1. Click OPTION > Global Settings.

  2. Check the Dark Mode checkbox.

  3. Click OK.

The appearance changes immediately, without restarting the tool, and is kept on the next launch. All functions are the same in both modes. Uncheck Dark Mode to return to the day appearance.

../_images/tracetool_dark_mode.png

Troubleshooting

When encountering issues while using Trace Tool, refer to the following common cases:

Port Cannot Be Opened

Issue: Opening the serial port fails, and the status bar shows Open failed: ....

Solution: The port is likely already in use by another process. Close any other terminal application (for example, PuTTY, Tera Term, another Trace Tool instance, Web Flash Tool, or a VS Code serial monitor) that may be holding the port, and then try opening it again.

Serial Port Lost

Issue: The status bar shows Port lost (...); reconnecting... and commands are not sent.

Solution: The USB-to-UART adapter was unplugged or the device was reset. Trace Tool reopens the port automatically once it is available again, and the status bar then shows Reconnected. Check the USB cable if the port does not come back.

Garbled Logs

Issue: Logs are unreadable or contain stray characters.

Solution: Verify that the baud rate, encoding and other configurations match those configured in the device firmware.

BT Logs Are Not Captured

Issue: Bluetooth host or firmware logs are not written to *.bin / *.log files.

Solution:

  • Confirm the connected SoC is selected from the CHIP selector, so that the Bluetooth AGG paths match the SoC. Refer to AGG Support for the per-SoC path mapping.

  • Confirm that LOGUART AGG is enabled in the device firmware. Without AGG, Bluetooth logs cannot be separated from the text logs.

  • The capture files are created in the log folder next to the Trace Tool executable each time the serial port is opened.

Scope Trend Chart Not Updating or Shows Incorrect Values

Issue: In the scope view, a Y channel’s waveform stops updating, plots the wrong value, or never receives any data even though the matching text is visible in the log.

Solution: For each log line, Trace Tool locates the configured X/Y1-Y6 pattern text with a plain substring search, then extracts the first plain base-10 integer (optionally with a leading -) found between that text and the end of the line. The firmware log must follow this format for the value to be captured correctly:

  • Print the pattern text and its value on the same line, with the value right after the pattern text (for example, printf("Temp: %d\n", temp);).

  • Use a plain decimal integer. Hexadecimal (0x1A), floating-point (3.14), or non-numeric payloads are not parsed correctly — Trace Tool extracts only the first run of digits, so 0x1A is read as 0 and 3.14 is read as 3; a line with no digits after the pattern text is silently skipped and the chart is not updated.

  • Make each pattern text an exact, distinctive substring of the log line. Because matching is substring-based, a short or overlapping pattern (for example, one pattern name that is a prefix of another) can match the wrong occurrence.

  • Put each Y metric on its own log line. Trace Tool only evaluates the first configured Y pattern found in a given line; other metrics printed on that same line are ignored for that update.

Settings Reset on Launch

Issue: Trace Tool starts with default settings (COM port, baud rate, selected SoC, etc.) even though the previous session was saved correctly.

Solution: If Setting.json cannot be read (for example, a file written by an older version of Trace Tool), Trace Tool silently falls back to defaults rather than crashing. Delete the Setting.json file next to the Trace Tool executable and relaunch; the file will be regenerated. A saved serial port is restored only if it is present when Trace Tool starts.