DSP Debugging
Preparation
Before debugging the DSP, ensure the following installations are complete:
Install the xt-ocd tool: Refer to Install Debug Plugin. xt-ocd supports DSP debugging using J-Link debugger via SWD protocol.
Install J-Link driver: The version we use is V6.44. Newer versions should also work but have not been tested.
Connect DSP to J-Link
The default installation path for Xtensa OCD Daemon is: C:\Program Files (x86)\Tensilica\Xtensa OCD Daemon 14.08.
Replace the
topology.xmlfile in the following path with the code below:Windows:
C:Program Files (x86)TensilicaXtensa OCD Daemon 14.08topology.xmlLinux:
/opt/Tensilica/xocd-14.08/topology.xml
You need to modify the usbser value according to your J-Link serial number:
<configuration> <controller id='Controller0' module='jlink' usbser='XXXXXX' type='swd' speed='4000000' locking='1'/> <driver id='XtensaDriver0' dap='1' xdm-offset='0x80000000' module='xtensa' step-intr='mask,stepover,setps' /> <chain controller='Controller0'> <tap id='TAP0' irwidth='5' /> </chain> <system module='jtag'> <component id='Component0' tap='TAP0' config='trax' /> </system> <device id='Xtensa0' component='Component0' driver='XtensaDriver0' ap-sel='3'/> <application id='GDBStub' module='gdbstub' port='20000'> <target device='Xtensa0' /> </application> </configuration>
Find the usbser value through J-Link Commander:
Debugging Methods
When using Xplorer to debug the DSP core, it is recommended to first erase the entire Flash, then download only the KM4/KR4 firmware. During debugging startup, the DSP firmware will be loaded directly into PSRAM via J-Link.
Click Debug Configurations…
Select Xtensa On Chip Debug, then create a new debug configuration. Check the Use XOCD Manager option and click the Connect button. After refreshing the OCD Version, select the 14.08 version.
Topology File should select the
C:Program Files (x86)TensilicaXtensa OCD Daemon 14.08topology.xmledited in the previous section. Connection Type should be SWD.
Select core0, set Download binary to Always. Then click Apply and Debug.
By default, the DSP core will stop at the first line of the main function. To check memory values, it is recommended to use Bounded Memory and manually refresh the memory table when memory values change.
Open a command prompt window and navigate to the directory
C:\Program Files (x86)\Tensilica\Xtensa OCD Daemon 14.08Run
xt-ocd -c topology.xml
Note
Some warning messages are normal and can be ignored. If XDM driver initialization fails, you may need to initialize and start the DSP core before debugging.
In the path
<dsp_sdk>\project (or auto_ws)\project_dsp\bin\HIFI5_PROD_1123_asic_UPG\Release, there is aproject_dspfile.Copy it to the directory
C:\usr\xtensa\XtDevTools\install\tools\RI-2021.8 -win32\XtensaTools\bin.Open a command prompt window and navigate to the directory
C:\usr\xtensa\XtDevTools\install\tools\RI-2021.8-win32\XtensaTools\bin.The CMD commands for CALL0 ABI are as follows:
xt-gdb --xtensa-core=HIFI5_PROD_1123_asic_UPG project_dsp target remote localhost:20000 reset load
You can now proceed with normal debugging. For debugging commands, refer to: Xtensa Documentation.
Debugging Tips
If you cannot connect to the debug port, it may be because the SWD port is disabled (SWD port is used as a regular GPIO). You need to enable the SWD function for the GPIO.
Generate DSP disassembly and map files: Build Debug Files.
For convenience in Linux environment, you can add the following paths to PATH:
/opt/Tensilica/xocd-14.08 /opt/xtensa/XtDevTools/install/tools/RI-2021.8-linux/XtensaTools/bin
If you use
auto_build.shinstead of Xplorer to build the project, you can find the project_dsp elf file at:<dsp_sdk>/auto_ws/project_dsp/bin/<configuration_name>/ReleaseFor more debugging guides, please refer to Xtensa Documentation.
xt-ocd Debugging Issues
Problem Description: When debugging in Linux Xplorer, a Cannot Find OCD Daemons error occurs.
Cause Analysis: The xt-ocd version or path is not configured correctly.
Solution: Add a line after # [XOCDInstallations] in the file /opt/xtensa/Xplorer-9.0.18/utils/xocdm9.0.18.3000/xocdm.ini:
14.08=/opt/Tensilica/xocd-14.08