Debugger+Server+User+Guide (En US)
Debugger+Server+User+Guide (En US)
14 Public
XuanTie DebugServer
User Guide
Revision 5.14
Security Pubilc
XuanTie Debugger Server User Guide-V5.14 Public
Copyright © 2024 Hangzhou C-SKY MicroSystems Co., Ltd. All rights reserved.
This document is the property of Hangzhou C-SKY MicroSystems Co., Ltd. and its affiliates
("C-SKY"). This document may only be distributed to: (i) a C-SKY party having a legitimate
business need for the information contained herein, or (ii) a non-C-SKY party having a legitimate
business need for the information contained herein. No license, expressed or implied, under any
patent, copyright or trade secret right is granted or implied by the conveyance of this document.
No part of this document may be reproduced, transmitted, transcribed, stored in a retrieval
system, translated into any language or computer language, in any form or by any means,
electronic, mechanical, magnetic, optical, chemical, manual, or otherwise without the prior
written permission of Hangzhou C-SKY MicroSystems Co., Ltd.
Notice
The purchased products, services and features are stipulated by the contract made between
C-SKY and the customer. All or part of the products, services and features described in this
document may not be within the purchase scope or the usage scope. Unless otherwise specified
in the contract, all statements, information, and recommendations in this document are provided
"AS IS" without warranties, guarantees or representations of any kind, either express or implied.
Contents
1. Introduction ............................................................................................................. 1
8. Multi-core debugging............................................................................................ 64
6. Confirm the user information and installation directory on the page that
appears and click Next to start the installation. .............................................. 7
Figure 11-8 Dialog box for specifying whether to update the driver...................... 9
Figure 8-11-25 View threads by running "info thread" in XuanTie GDB ............ 72
Figure 8-11-29 Switch a thread of XuanTie GDB and set the PC value of CPU 0
to 0x10000 .................................................................................................... 75
1. Introduction
This user guide describes the features of XuanTie DebugServer (XUANTIE DebugServer).
This software supports Windows and Linux platforms. Therefore, the descriptions are divided by
platform.
1.1. Terms
Term Description
DDC A direct download channel. Such a channel can significantly
accelerate data download.
XUANTIE This software is a proxy debug server program.
DebugServer
ICE An in-circuit emulator. In this document, CKLink is used as an
example of an ICE.
XUANTIE DebugServer receives a primitive debug command sent by XuanTie GDB and
then sends a command to the hardware debug API (HAD) based on the Joint Test Access Group
(JTAG) protocol. Then, XUANTIE DebugServer controls the execution of debug commands,
obtains debug data, and returns the debug data to XuanTie GDB. XuanTie GDB communicates
with XUANTIE DebugServer in socket mode. XuanTie GDB and XUANTIE DebugServer can
run on different hosts. XUANTIE DebugServer communicates with the target machine via ICE
based on the JTAG protocol.
The ICE driver is packaged in the installation package of XUANTIE DebugServer. When
you install XUANTIE DebugServer, select ICE Driver. The driver file will be copied to the system
directory during installation of XUANTIE DebugServer. After you plug in an ICE device,
Windows automatically installs the driver for the ICE.
Obtain the installation package from the Open Chip Community (OCC) platform of XuanTie
at https://occ.XuanTie.cn/community/download_detail?id=616215132330000384 or from
Customer Service. The installation package includes the compressed
XuanTie-DebugServer-windows*.zip file for Windows systems and two
XuanTie-DebugSever-linux-*.sh files for 32-bit and 64-bit Linux systems.
2. Read through the license agreement of THServer and click Yes to continue.
3. Enter a user name and a company name, select applicable users, and click Next.
5. Select the components you want to install. Main App is XUANTIE DebugServer, ICE Driver is
the ICE device driver, and Tutorial is the user manual. We recommend that you select all and click
Next.
6. Confirm the user information and installation directory on the page that appears and click Next to
7. If an ICE driver is already installed on your PC, a message is displayed to ask whether you want
to update the driver. We recommend that you select Yes, so that your ICE driver will be updated to
the latest.
Figure 11-8 Dialog box for specifying whether to update the driver
9. Wait until the installation of XUANTIE DebugServer is complete and then click Finish.
1. If you selected ICE Driver in Section 2.1.2 "Install XUANTIE DebugServer," the driver file
will be copied to the system directory during installation of XUANTIE DebugServer.
2. Reconnect your ICE to the PC. You can view that the device name similar to CKLink-Lite or
CKLink Pro shown in the following image in the Device Manager window on your PC.
XUANTIE DebugServer can run in Windows 2000 and later and require that the input and
output devices be equipped with USB ports. XUANTIE DebugServer can be used with all
versions of XuanTie GDB.
2.3.1.Operating parameters
[-local-semi/-ls]
option to implement
semihosting in
XUANTIE
【-local-semi/-ls】
DebugServer.
add the
-local-semi/-ls
option in Windows,
supported.
This part illustrates common input examples. XUANTIE DebugServer is an application. The
following input examples are for your reference:
• XUANTIE DebugServer
This command is equivalent to XUANTIE DebugServer –setclk 12M –port 1025. The
default option is used.
Sets the number of the socket port to 1111 and the frequency of the hardware ICE to 13
MHz.
XUANTIE DebugServer Console Edition allows you to run scripts. Scripts are divided into
JTAG scripts and GPIO scripts. A JTAG script can perform direct operations on a JTAG scan
chain register. You can customize a combination of JTAG operations to access a specified HAD
register and manage other hardware. A GPIO script can control the outputs of JTAG pin levels of
an ICE and obtain JTAG pin levels of an ICE. You can generate custom waveforms by using the
script. You can generate waveforms required for the pins or read the level state of JTAG pins.
The following sections describe the usages of the two types of scripts in detail.
XUANTIE DebugServer allows you to read and write the HAD register by executing A
JTAG script.
1. No special requirements are set for the file extension. The file name can be a relative path.
(1) Multiple JTAG operations can be described in the script. Each operation unit must use [JTAGx]
as a keyword, where x represents a number. Note that [JTAGx] must be capitalized and the
numbers must be consecutive. If inconsecutive numbers are used, the script will not be executed.
(3) The IR length and the DR length must be a multiple of 8 bits in versions earlier than V5.14.2.
In V5.14.2 and later, non-8-bit aligned values are supported. Here, the IR length and the DR
length can be n-byte aligned.
(4) The content in bytes must be in hexadecimal, with or without the prefix 0x.
(5) The bytes are written into JTAG DR in order and read from the DR in order.
3. Script examples
[JTAG0]
IR=8, 0x8
DR=R, 32
[JTAG1]
IR=8, 0x8E
DR=R, 16
[JTAG2]
IR=8, 0x8E
XUANTIE DebugServer allows you to use a GPIO script to control the outputs of JTAG pin
levels and generate waveforms required for the pins. In addition, you can use a GPIO script to
read the level state of JTAG pins.
1. The XuanTie GPIO script is represented by the [THEAD_ICE_GPIO] field. Only a script file
2. No special requirements are set for the file extension. The file name can be a relative path.
(1) The script takes behavioral parsing and execution as a unit. Each line is parsed and
executed once. One line may contain multiple statements separated with commas (,).
The last statement must not be followed by a comma. Otherwise, a syntax error occurs.
(2) Multiple statements in the same line can be used to perform operations on the same bit
of the same register. A latter statement overwrites a former statement. For example, if
TDI=1, TMS=1, NRST=0, and TDI=0 exist in the same line, the final parsing and
(3) In the assignment statement for a single pin, such as TMS=1, the value must be 0 or 1.
Otherwise, a syntax error occurs. Values starting with 0x are deemed as hexadecimal.
(4) During the execution of the script, the initial level of each JTAG pin is 0. In this
operation, no assignment is performed on the pin. Therefore, the level of the pin remains
(5) The default value of the GPIO_OE register is 0x3f. That is, each JTAG pin corresponds
to the output mode. You can assign a value to the GPIO_OE register to change the
input/output mode of the pin. After the GPIO_OE register is assigned a value, the value
takes effect until the next time a value is assigned to the GPIO_OE register.
(6) The script supports repeat loops, whose syntax is REPT=x......ENDR. Nested loops are
supported. REPT and ENDR must be used in pairs; otherwise, a syntax error occurs.
The equal sign (=) that follows REPT cannot be omitted. The number of loops is
indicated by x and cannot be less than 0; otherwise, a syntax error occurs. The REPT
statement and the ENDR statement must be on separate lines; otherwise, a syntax error
occurs.
(7) The PRINT statement is used to read the value of the GPIO_IN register and must
(8) The content of the script must start with START and end with END. Otherwise, a syntax
error occurs.
⚫ Control statements used to control the input/output directions of each pin. For example,
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
20
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
GPIO_OE=0x1f is supported.
⚫ Assignment statements used to control the output of a single pin. For example, the
statement TMS=1 is used to assign the value 1 to the bit that corresponds to the TMS pin
in the GPIO_OUT register.
⚫ One-time assignment statements for all pins. For example, the statement
GPIO_OUT=0x1d is used to assign the value to the GPIO_OUT register.
⚫ PRINT=GPIO_IN statement, which is used to read and print the value of the GPIO_IN
register.
⚫ REPT and ENDR statements, that is, repeat loops. The statement REPT=x, where x is
the number of loops, is used to repeat the statement between REPT and ENDR x times.
Note: In the script, the output assignment statement such as TMS=1 and the input print
statement PRINT=GPIO_IN only read data from and write data to the GPIO_OUT and
GPIO_IN registers in the ICE. JTAG pins set bits only during operations on the GPIO_OE
register. For example, when GPIO_OE[3] for a TMS pin is 1, which indicates the output
mode, the value of GPIO_OUT[3] is reflected on the TMS pin. Similarly, when GPIO_OE[3]
is 0, which indicates the input mode, the value of GPIO_IN[3] that is read by using the
PRINT=GPIO_IN statement is the real level of the TMS pin. Otherwise, the value is invalid.
5.Script examples
[THEAD_ICE_GPIO]
START
GPIO_OE = 0x1f
TDI=1,TMS=1,NRST=0, TDI =0
GPIO_OE = 0x13
REPT = 10
TMS =0
TMS = 1
ENDR
TRST=1
#GPIO_CTRL=0x1d
END
To execute a script in XUANTIE DebugServer Console Edition, use the [-scr filename]
parameter among the operating parameters of XUANTIE DebugServer (see Section 2.3.1).
To execute a script in XUANTIE DebugServer UI Edition, click the icon in the menu
bar toolbar (see Section 2.4.2).
2.3.3.How it works
1. Steps
⚫ If you need to modify an operating parameter, you can press "CTRL+C" to cancel the
connection. The current directory is the installation directory. You need only to enter the
command for running the parameters that you need to run, such as "DebugServerConsole.exe
-port 1028".
1. Use the XuanTie toolchain to generate the XuanTie elf program named a.out.
⚫ If you use CDK or CDS, see the user documentation for the development environment.
2. Operating UI
3. Note
(1) During the running of XUANTIE DebugServer, if a message that indicates "ICE Upgrade"
appears, click Yes to upgrade the firmware. After the upgrade is complete, you need to unplug and
re-plug the ICE and connect XUANTIE DebugServer to the ICE.
(2) When the target board is multi-core, XUANTIE DebugServer enables multiple consecutive
ports based on the serial number of the CPU in the structure, to connect to XuanTie GDB. The
first port number is specified by users and is 1025 by default.
2.4.1.Main UI
(Stop)
Flash Setting Configures the algorithm file used for No shortcut keys
flash programming, flash breakpoints, and
simulated breakpoints.
Verbose Setting Sets the outputs of log information for No shortcut keys
XUANTIE DebugServer:
CKLINK_LITE_V2: cklink_lite.hex
CKLINK_PRO_V1: cklink_v1.iic
CKLINK_PRO_V2: cklink_pro.iic
By default, the startup file is the default.ini file in the directory where XUANTIE
DebugServer is located. The following content describes the file content:
[TARGET] tags:
⚫ PRESETCDI=2/5; // Sets the operating mode of the target board after XUANTIE
DebugServer is connected to the ICE. The value 2/5 indicates 2 lines or 5 lines.
⚫ RESETWAIT=50; // Sets the delay for waiting for a reset operation to complete.
⚫ SAMPLINGTYPE= ; // Sets the sampling type. The value PCFIFO-HOST indicates the host
and the value PCFIFO-LINK indicates CKLink.
⚫ ENTERDEBUGTIME=; // Sets the timeout period for initiating synchronization to make the
CPU enter the debug mode.
[SOCKETSERVER]
2.4.4.Common features
In addition to using an existing configuration file, you can manually specify configurations.
Choose Setting->Target Setting to open the Target Setting dialog box.
⚫ Debug Arch Select: selects debug architecture. Valid values: XuanTie HAD, RISCV DM, and
AUTO.
⚫ ICE Vendor Select: selects an ICE vendor. The default value is CK-Link.
⚫ ICE Setting: sets the information about an ICE that you want to use as a connection target,
including the ICE frequency and MTCR delay.
⚫ NReset Delay: sets an NReset delay to ensure that the ICE can generate stable hardware reset
(NReset) signals. The unit is 10 us. The default value is 1 ms.
⚫ TReset Delay: sets a TReset delay to ensure that the ICE can generate stable reset signals to
reset the HAD state machine. The unit is 10 us. The default value is 1.1 ms.
⚫ Reset Wait: sets a delay to ensure that the reset process of the target board lasts to the end
after the target board receives a reset signal. The default value is 50 ms.
⚫ Enable TRST: specifies whether to execute TRST when executing Reset Target.
Choose Target Setting->Socket Setting. The Socket Server Setting dialog box appears, as
shown in the following figure. Enter the port number. The default value is 1025.
Select the upgrade file that corresponds to your ICE. The upgrade file must be consistent with the
box type of the ICE. The following correspondences are for your reference:
CKLINK_LITE_V2: cklink_lite.hex
CKLINK_PRO_V1: cklink_v1.iic
CKLINK_PRO_V2: cklink_pro.iic
When the current Debug Arch is XuanTie HAD, perform the following steps:
Choose Tools->HAD/DM Register. The Had Register Operator dialog box appears. You can
read data from and write data to the HAD register.
Read operation:
Select a HAD register to read from the Select Register drop-down box. The Value field
automatically displays the value of this register.
Write operation:
Select the HAD register to write data to from the Select Register drop-down box. In the Value
field, enter the desired value and then click Set.
When the current Debug Arch is RISC-V DM, perform the following steps:
Choose Tools->HAD/DM Register. The Debug Module Register Operator dialog box appears.
You can read data from and write data to the DM register.
In the Select Register field, select a DM register and click Read or Write as needed. If the
DM registers you selected from the Select Register drop-down box does not contain the register
that you want to manage, you can select "Select DM Register by NUM" and specify the number.
Then, click Read or Write as needed.
2.4.5.How it works
1. Steps
1. Use the XuanTie toolchain to generate the XuanTie elf program named a.out.
command line of XuanTie GDB. For example, type target remote 172.16.28.158:1025.
⚫ If you use CDK or CDS, see the user documentation for the development environment.
2. Operating UI
3. Note
(1) During the running of XUANTIE DebugServer, if a message that indicates "ICE Upgrade"
appears, click Yes to upgrade the firmware. After the upgrade is complete, you need to unplug and
re-plug the ICE and connect XUANTIE DebugServer to the ICE.
2. Increase execution permissions for the installation package by running the chmod+x command.
4. When the message "Do you agree to install the DebugServer[yes/no]" appears, type "yes".
5. When the message "Set full installing path:" appears, set the installation path.
(1) Install XUANTIE DebugServer to a user-specified directory: Enter the absolute installation
path. During installation, the message "This software will be installed to the path: (User-specified
path)? [yes/no/cancel]:" appears. After you confirm that the path is correct, type "yes" and press
"Enter". At this time, the installation package starts being installed. After the installation is
complete, the following message appears:
"Done!
path/XuanTie_DebugServer".)
(2) Install XUANTIE DebugServer to the default path: Press "Enter". The message "This software
will be installed to the default path: (/usr/bin/)?[yes/no/cancel]:" appears. Type "yes". The software
will be installed to the default path "/usr/bin/". After the installation is complete, the following
message appears:
"Done!
The XUANTIE DebugServer can run on most Linux platforms such as Ubuntu. Input and
output devices must be equipped with a USB port. The XUANTIE DebugServer can be used with
all versions of XuanTie GDB.
The operating parameters are the same as those described in Section 2.3.1 "Operating
parameters."
The JTAG script configuration feature is the same as that described in Section 2.3.2 "Script
configuration feature of XUANTIE DebugServer."
1. Steps
1. Use the XuanTie toolchain to generate the XuanTie elf program named a.out.
(1) How to use XuanTie GDB is similar to how to use GNU GDB.
⚫ If you use CDK or CDS, see the user documentation for the development environment.
2. Operating UI: The operating UI is the same as that described in Section 2.3.3 "How it works"
for XUANTIE DebugServer Console Edition for Windows.
3. Note
(1) Before you run XUANTIE DebugServer, check the /etc/hosts file to see whether the host IP
and host name already exist. If no, add them in the first line.
(2) During the running of XUANTIE DebugServer, if a message that indicates "ICE Upgrade"
appears, click Yes to upgrade the firmware. After the upgrade is complete, you need to unplug and
re-plug the ICE and connect XUANTIE DebugServer to the ICE.
4. Semihosting feature
Semihosting is a debugging method that replaces the input and output of a device with the input
and output of the host during debugging. For example, the input and output devices of the host,
such as the keyboard, disk, and screen can be used as the input and output of the target board.
Semihosting can reduce the dependence on hardware devices during development. You need only
to connect to the target board by using a debugging method.
1.open
2.close
3.read
4.write
5.lseek
6.rename
7.unlink
8.stat
9.fstat
10.gettimeofday
11.isatty
12.system
To use the semihosting feature of XuanTie 800 series CPUs, perform the following steps:
1. Write a bare XuanTie program that contains file operations or inputs and outputs.
2. When you compile a project, add the compilation option "-lsemi" to the compiler. The
toolchain must be V3.8.x or later.
3. Use XUANTIE DebugServer to download and debug the program. XUANTIE DebugServer
must be V5.2.0 or later.
4. Run the program. Semihosting operations involved in the program will be implemented by
XuanTie GDB. For example, the output of printf is displayed on the UI of XuanTie GDB and
the fopen command can be used to open a file in the host where XuanTie GDB is located.
To use the semihosting feature of RISC-V CPUs, perform the following steps:
2. To compile code by using Toolchain V2.2.0 and later, add --specs=semihost.specs to the link
option.
4. Debug the code by using XuanTie GDB. Semihosting requests that appear in elf will be
processed by XUANTIE DebugServer.
Note:
1. XuanTie GDB does not support semihosting requests from RISC-V CPUs. Only XUANTIE
DebugServer can process these requests.
2. When you add the -local-semi/-ls option in Windows, isatty and system operations are not
supported.
To use this feature, perform the following steps, where the CK802 with LDCC is used as an
example:
1. Write a bare XuanTie program and implement fputc. The following sample code is for your
reference.
*pata = ch;
return 0;
2. Use the XuanTie ELF toolchain to compile the code and generate an ELF file.
4. Connect XuanTie GDB to XUANTIE DebugServer and run the program at full speed.
set mem-access Modifies the current memory access method set mem-access progbuf
progbuf/abscmd/s of XUANTIE DebugServer when the set mem-access abscmd
ysbus current architecture is RISC-V DM. set mem-access sysbus
set Sets whether the memory access method of
virtual-mem-acces XUANTIE DebugServer is consistent with
s on/off the current program. Valid values: on: The
memory access method is consistent with
the program. off: The address that
XUANTIE DebugServer uses to read data
from and write data to the memory is a
physical address. The default value is on.
set Sets the maximum bit width of memory data set mem-access-max-mode
mem-access-max- to be accessed by XUANTIE DebugServer auto
mode at a time. The value auto specifies to use the set mem-access-max-mode
auto/dword/word/ maximum bit width supported by the debug dword
hword/byte architecture. If the bit width you specify is set mem-access-max-mode
greater than the maximum bit width word
supported by the current debug architecture, set mem-access-max-mode
the maximum bit width supported by the hword
debug architecture is used. set mem-access-max-mode
byte
For example, for E906, the maximum bit
width that the debugging architecture
supports at a single time of access is per
word. If the bit width is set to word, when a
large chunk of memory is accessed, the
word-aligned part is first accessed per word.
In the non-word-aligned part, the
hword-aligned part is accessed per hword
and the remaining part is accessed per byte.
This feature is provided only in XUANTIE DebugServer Console Edition. After you start
XUANTIE DebugServer Console Edition, you can run the preceding commands to perform the
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
46
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
Registers in the XuanTie HAD debug architecture: (You can view the registers by running
pad-reg-list.)
HAD registers: hid, htcr, mbca, mbcb, pcfifo, baba, babb, bama, bamb, cpuscr, bypass, hcr,
hsr, ehsr, wbbr, psr, pc, ir, csr, dccdata, ldccdata, ddcaddr, ddcdata, bsel, hcdi, cpusel, cpust, and
hacr
Registers in the RISC-V DM debug architecture: (You can view the registers by running p
dm-reg-list.)
Registers in the DM V0.13 architecture: data0, data1, data2, data3, data4, data5, data6, data7,
data8, data9, data10, data11, dmcontrol, dmstatus, hartinfo, haltsum1, hawindowsel, hawindow,
abstractcs, command, abstractauto, confstrptr0, confstrptr1, confstrptr2, confstrptr3, nextdm,
progbuf0, progbuf1, progbuf2, progbuf3, progbuf4, progbuf5, progbuf6, progbuf7, progbuf8,
progbuf9, progbuf10, progbuf11, progbuf12, progbuf13, progbuf14, progbuf15, authdata,
haltsum2, haltsum3, sbaddress3, sbcs, sbaddress0, sbaddress1, sbaddress2, sbdata0, sbdata1,
sbdata2, sbdata3, and haltsum0 In XuanTie, itr, customcs, customcmd, and compid registers are
also supported.
CPU registers: To view the list of CPU registers, check the register descriptions in the
tdescriptions folder in the installation directory of XUANTIE DebugServer.
7.1. Introduction
XuanTie GDB implements a set of extended mechanism that uses XML files to describe
to-be-debugged registers. This feature is based on XuanTie GDB's support for describing
registers by using XML files. XuanTie GDB builds internal register operation requirements
based on the register name, quantity, register group, and other information described in XML
files. This mechanism allows you to use an XML file to describe the information of a target
register in the specified UI or command lines.
7.2.1.Writing rules
XuanTie GDB requires that a description file comply with the following rules:
◆ The description file must comply with the rules for XML files.
◆ In the XML file, target is the root element with the version attribute.
This attribute is 1.0 by default.
◆ The target element contains the architecture and feature elements at the
same level.
◆ The architecture element indicates the system architecture described
by the file. Valid values: arm, mips, and csky.
◆ The feature element has a name attribute. The name attribute indicates
the division of registers.
◆ The main element contained by the feature element is the reg element.
The reg element contains name (register name), bitsize (bit width),
regnum (internal serial number of XuanTie GDB), type (data type),
group (group to which the register belongs), save-restore (internal
attribute of XuanTie GDB), and other attributes. Among these
attributes, the name and bitesize attributes are required and the other
attributes are optional.
◆ The feature element also contains vector, struct, union, and flags
elements. These elements are extensions to the description of the target
register type and are described in the appendix.
XuanTie GDB supplements the following rules on the basis of the preceding rules:
⚫ The target element has the version attribute. This attribute is "1.0" by
default. XuanTie-GDB supports "1.0" only.
⚫ The value of the architecture element must be set to csky.
⚫ The name attribute of the feature element is org.gnu.csky.abiv1.xxx or
org.gnu.csky.abiv2.xxx.
⚫ In each feature element, the first reg element must contain the regnum
attribute. If the regnum attribute in a subsequent reg element is a
number following the value of the previous regnum attribute, this reg
element can contain no regnum attributes. The value of this regnum
attribute increases by 1 based on the value of the regnum attribute in
the previous reg element. If the regnum attribute in the subsequent reg
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
48
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
1. "org.gnu.csky.abiv2.gpr"
2. "org.gnu.csky.abiv2.fpu"
3. "org.gnu.csky.abiv2.cr"
4. "org.gnu.csky.abiv2.fvcr"
5. "org.gnu.csky.abiv2.mmu"
6. "org.gnu.csky.abiv2.tee"
7. "org.gnu.csky.abiv2.fpu2"
8. "org.gnu.csky.abiv2.bank0"
9. "org.gnu.csky.abiv2.bank1"
10. "org.gnu.csky.abiv2.bank2"
11. "org.gnu.csky.abiv2.bank3"
12. "org.gnu.csky.abiv2.bank4"
13. "org.gnu.csky.abiv2.bank5"
14. "org.gnu.csky.abiv2.bank6"
15. "org.gnu.csky.abiv2.bank7"
16. "org.gnu.csky.abiv2.bank8"
17. "org.gnu.csky.abiv2.bank9"
18. "org.gnu.csky.abiv2.bank10"
19. "org.gnu.csky.abiv2.bank11"
20. "org.gnu.csky.abiv2.bank12"
21. "org.gnu.csky.abiv2.bank13"
22. "org.gnu.csky.abiv2.bank14"
23. "org.gnu.csky.abiv2.bank15"
24. "org.gnu.csky.abiv2.bank16"
25. "org.gnu.csky.abiv2.bank17"
26. "org.gnu.csky.abiv2.bank18"
27. "org.gnu.csky.abiv2.bank19"
28. "org.gnu.csky.abiv2.bank20"
29. "org.gnu.csky.abiv2.bank21"
30. "org.gnu.csky.abiv2.bank22"
31. "org.gnu.csky.abiv2.bank23"
32. "org.gnu.csky.abiv2.bank24"
33. "org.gnu.csky.abiv2.bank25"
34. "org.gnu.csky.abiv2.bank26"
35. "org.gnu.csky.abiv2.bank27"
36. "org.gnu.csky.abiv2.bank28"
37. "org.gnu.csky.abiv2.bank29"
38. "org.gnu.csky.abiv2.bank30"
39. "org.gnu.csky.abiv2.bank31"
40. "org.gnu.csky.linux"
XuanTie ABI V2 GDB has the following additional requirements for register names:
first.
7.2.2.Sample description
The following code is a sample XML file that XuanTie uses to describe a
register:
<?xml version=”1.0”?>
<target version=”1.0”>
<architecture>csky</architecture>
<feature name=”org.gnu.csky.abiv1.gpr”>
</feature>
<feature name=”org.gnu.XuanTie.pseudo”>
</feature>
</target>
⚫ In the XML file, target is the root element with the version attribute. This
attribute is 1.0 by default.
⚫ The architecture element indicates that this file describes the XuanTie
architecture.
⚫ The name attribute of the feature element is set to org.gnu.csky.abiv1.gpr.
The value indicates that the feature element describes a GPR of ABI V1 in
the XuanTie architecture.
⚫ For the first register, the name is r0, the bit width is 32, the internal serial
number in XuanTie GDB is 0, the data type is uint32, and this register
belongs to Register Group gpr.
⚫ For the second register, the name is r1, the bit width is 32, and the internal
serial number in XuanTie GDB is 1.
⚫ For the third register, the name is r2, the bit width is 32, and the internal
serial number in XuanTie GDB is 2.
⚫ The name attribute of the second feature element is set to
org.gnu.csky.pseudo. The value indicates that the feature element functions
as a specific feature that describes a pseudo register.
⚫ For the first register in the second feature element, the name is r01, the bit
width is 64, the data type is uint64, and the serial numbers of the register
are 0 and 1.
Register numbers used in the XML file, that is, the values of the regnum attribute, are
the values of the Serial number in XuanTie GDB column in Table 11-9 Serial numbers of
ABI V1 registers and Table 11-10 Serial numbers of ABI V2 registers. The following two
tables list register numbers that are supported and expected to be supported. Register
names are not all listed. After XuanTie-GDB supports XML, register names can be
modified as required.
◆ MMUs
The following table lists the serial numbers of registers.
◆ Cr_Bank0
◆ Cr_Bank1
◆ Cr_Bank3
◆ Cr_Bank15
The following table lists the serial numbers of registers.
Prof-soft-general 140~143
Prof-cr 144~157
Prof-arch 160~174
Prof-exten 176~188
Bank1 189~220
Bank3 221~252
All registers in Bank15 253~275
except the MMU
Bank2 276~307
Bank4 308~339
Bank5 340~371
Bank6 372~403
Bank7 404~435
Bank8 436~467
Bank9 468~499
Bank10 500~531
Bank11 532~563
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
55
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
Bank12 564~595
Bank13 596~627
Bank14 628~659
Bank16 660~691
Bank17 692~723
Bank18 724~755
Bank19 756~787
Bank20 788~819
Bank21 820~851
Bank22 852~883
Bank23 884~915
Bank24 916~947
Bank25 948~979
Bank26 980~1011
Bank27 1012~1043
Bank28 1044~1075
Bank29 1076~1107
Bank30 1108~1139
Bank31 1140~1171
Cr16~cr31 1172~1187
In the XuanTie TEE (secure) programming model, the same register has a copy in both the
TEE and REE worlds. To read data from and write data to these registers, you need to switch
between the worlds or map the registers. For more information, see the manuals related to
XuanTie TEE. XuanTie GDB and the xml files of XUANTIE DebugServer help users view
register information of the current world and the other world in either world. XuanTie GDB must
be V3.10.0 and later and XUANTIE DebugServer must be V4.5.0 and later. XUANTIE
DebugServer helps switch between the worlds and read registers in the current world.
1. The description of a TEE register is provided in a pseudo register. Therefore, the rules for
describing TEE registers must meet all the rules related to pseudo registers in Section7.2.1.
2. A TEE register uses the "env" attribute to indicate whether the register is a TEE or REE
register. The attribute can only be set to "ree" or "tee".
3. Use the "regs" attribute to indicate the serial numbers of physical registers that correspond
to the registers.
4. Set the values of bytesize and type based on the actual attributes.
7.2.3.3. Examples
The following content is a sample register description file, with CK810T being an example. You
can refer to the file in the tdescriptions folder in the installation directory of XUANTIE
DebugServer V5.4.0 and later.
<?xml version="1.0"?>
<target>
<architecture>csky</architecture>
<feature name="org.gnu.csky.abiv2.gpr">
</feature>
<feature name="org.gnu.csky.abiv2.cr">
</feature>
<feature name="org.gnu.csky.abiv2.tee">
</feature>
<feature name="org.gnu.csky.pseudo">
</feature>
</target>
As described in the preceding XML file, the psr that you view in XuanTie GDB is the psr of the
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
59
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
current world, the t_psr is the psr of the secure world, and the nt_psr is the psr of the non-secure
world. In other words, psr may be the same as t_psr or nt_psr, depending on the current world.
XUANTIE DebugServer UI Edition allows you to specify an XML file in the startup
configuration file default.ini and specify an XML file in the UI.
After you modify the path to the XML file in the UI, a message appears when you
close XUANTIE DebugServer, asking you whether you are sure to modify the
default configuration. If you click Yes, the current relevant configurations of
XUANTIE DebugServer are saved as a configuration file.
In the UI edition:
A shortcut icon is added to the toolbar to select an XML file, as shown in the
following figure.
After you click either the preceding option or icon, the Target Description File
dialog box appears, where you can select an XML file.
Click Browse, select a local XML file that describes the target, and click OK.
In Windows environments:
4) Click "OK". Start the shortcut and connect XuanTie GDB to XUANTIE
DebugServer for debugging.
In Linux environments:
8. Multi-core debugging
8.1. Introduction
In other words, when one core enters or exits the debug mode, you can choose to send this
signal to other cores. Other cores can choose to respond or not to respond to this signal and enter
or exit the debug mode. The following figure shows the hardware model.
Core0
dbg_ent_0/dbg_exit_0
HAD
EVENT_OUTEN
EVENT_INEN
EVENT_INEN
CK860MP
XuanTie has also implemented the ETM module for RISC-V multi-core C910MP. The
implementation and debugging method are the same as those of XuanTie C860MP.
In the multi-core debugging framework, XUANTIE DebugServer supports two debug modes:
multi-core single-port debugging and multi-core multi-port debugging. The following sections
describe the two debugging modes.
Hardware requirements
2. One XuanTie ICE CKLINK_PRO_V2 box with supporting FFC and USB cables
3. PC running in the Windows system with MinGW or running in the Linux system
Software requirements:
In this mode, XUANTIE DebugServer provides only one service port to connect to XuanTie
GDB. After you connect XuanTie GDB to XUANTIE DebugServer by running "target remote
ip:port", XUANTIE DebugServer encapsulates the information about multiple cores into thread
information and sends the information to XuanTie GDB. You can view and debug multiple CPUs
by using the thread command on XuanTie GDB.
In this mode, multiple CPUs send debug signals to each other and respond to the debug
signals of other cores. In other words, when one CPU enters or exits the debug mode, other CPUs
also enter or exit the debug mode at the same time.
8.3.1.Procedure
1. Power on the development board, connect to the ICE, and connect the USB cable from the
ICE to the PC.
2. Run XUANTIE DebugServer. The following figures show the outputs in different editions.
(2) In this case, the output on the console edition for Linux and Windows is the same as that
on the UI edition for Windows.
Figure 8-11-20 Output on XUANTIE DebugServer Console Edition after first connection to
C860MP that is powered on soon (Same output for Windows and Linux)
Then, XUANTIE DebugServer prints the CPUID information of CPU 0, but fails to print the
CPUID information of CPU 1. This error message is normal, because all cores except CPU 0 are
in the reset state after C860MP is powered on for the first time. The JTAG state machine cannot
obtain the information about CPU 1 and therefore the information about CPU 1 cannot be printed.
(2) In the command line of XuanTie GDB, type "target remote ip:port". This command is
the connection command shown on the UI of XUANTIE DebugServer.
(3) After XUANTIE DebugServer is connected, type the following command line to wake
up CPU 1: set $cr29 = 3. For the description of cr29, see the user manual of C860MP.
At this time, XUANTIE DebugServer prints the CPUID information of CPU 0 and CPU
1.
(2) Perform the following steps on XUANTIE DebugServer Console Edition for Windows
or Linux:
C860MP in the multi-core single-port mode (Same output for Windows and Linux)
At this time, XUANTIE DebugServer prints the CPUID information of CPU 0 and CPU
1.
(2) In the command line of XuanTie GDB, type "target remote ip:port". This command is
Document Version 5.14 Copyright© Hangzhou C-SKY
MicroSystems Co., LTD All Rights
71
Reserved.
XuanTie Debugger Server User Guide-V5.14 Public
(3) In the command line of XuanTie GDB, type "info threads". The following figure shows
the output.
As shown in the preceding figure, XuanTie GDB displays Thread 1 and Thread 2.
Thread 1 corresponds to CPU 0, and Thread 2 corresponds to CPU 1.
8.3.2.Thread-based operations
After you perform the steps described in Section 8.3.1, threads of XuanTie GDB correspond
to CPUs on a one-to-one basis. You can perform operations as needed.
1. View the register information of CPU 1 by typing the following command in the
command line of XuanTie GDB:
(2) info registers (XuanTie GDB displays the information about registers such as the GPR,
PC, and PSR of CPU 1.)
Figure 8-11-26 Switch a thread of XuanTie GDB to view register information of CPU 1
(2) info registers (XuanTie GDB displays the information about registers such as the GPR,
PC, and PSR of CPU 0.)
Figure 8-11-27 Switch a thread of XuanTie GDB to view register information of CPU 0
(1) If Thread 1 is active, type "Thread 1" again to switch to Thread 1. The thread number is
the serial number of the CPU plus 1. You can type "thread" or "info threads" in the
XuanTie GDB command line to display the current threads in XuanTie GDB.
In the printed information, the lines starting with an asterisk (*) is the current thread.
Figure 8-11-29 Switch a thread of XuanTie GDB and set the PC value of CPU 0 to 0x10000
4. During all viewing and modification operations, you need to check the registers of the
specified CPU. Before you set the registers and check the backtrace and memory, you need to
check whether threads that correspond to the cores are correct.
5. Run the program: In this mode, multiple cores respond to debug signals from each
other. In other words, when you type step i, step, next, or continue in the command line of
XuanTie GDB to run the program, the command is sent to the current CPU. However, when
a core exists the debug mode, the debug signal will be responded to by other cores.
(1) When you type si in the command line, all CPU cores execute the si command.
(2) When you type step or continue in the command line, the CPU that corresponds to the
current thread exits the debug mode, and other CPUs also exit the debug mode at the
same time. When one of CPUs enters the debug mode due to a breakpoint or other
reasons, other CPUs are pulled into the debug mode by the CPU that first enters the
debug mode. After XuanTie GDB obtains the message that indicates the CPU enters the
debug mode, XuanTie GDB prints the relevant information and switches the current
thread to the thread that corresponds to the CPU that first enters the debug mode.
6. Set a breakpoint
(3) To make a specified CPU stop at a breakpoint, add thread information when you set the
breakpoint. For example, type the following command:
This command means that when Thread 2, which corresponds to CPU 1, hits the
breakpoint, XuanTie GDB stops.
In this mode, XUANTIE DebugServer provides one service port for each CPU to connect to
XuanTie GDB. CPUs are divided by port. After you connect XuanTie GDB to XUANTIE
DebugServer by running "target remote ip:port", the CPU that corresponds to the port is specified.
You can view the correspondence between the CPU and the port on XUANTIE DebugServer.
In this mode, multiple CPUs do not send debug signals to each other or respond to the debug
signals of other cores. In other words, a debugged core is independent. When one CPU enters or
exits the debug mode, other CPUs can still keep operating. You can deem that you are debugging
multiple development boards, only that the multiple development boards share the same memory.
8.4.1.Procedure
② Find the default.ini file in the directory where the XUANTIE DebugServer
program is located, and change "MULTICORETHREADS=TRUE" to
"MULTICORETHREADS=FALSE. Then, start XUANTIE DebugServer again.
Figure 8-11-32 UIs for modifying default.ini to set the -no-multicore-threads mode
(2) Perform the following steps on XUANTIE DebugServer Console Edition for Windows
or Linux:
Figure 8-11-34 Output on XUANTIE DebugServer Console Edition after connection to C860MP in the
(1) The connection commands used to connect to CPU 0 and CPU 1 are already displayed
on the UI of XUANTIE DebugServer. The IP addresses of the CPUs are the same. The
port numbers are different and therefore are used for differentiation.
(2) When XuanTie GDB is debugging, XuanTie GDB is debugging a single core. This
feature is the same as single-core debugging. You need only to know that all the cores
are sharing the same memory.
The flash programming principles of XUANTIE DebugServer is consistent with those of the
CDK.
As shown in the figure above, the debugger uses the flash algorithm file in the RAM area to erase
and burn the flash or ROM area. For details, see chapters 5.2, 5.3, and 5.4 in the following link:
https://occ.XuanTie.cn/development/series/video?spm=a2cl5.25410618.0.0.4a53180f137C4G&id
=3864775351511420928&type=kind&softPlatformType=4#sticky
Since the hardware scene cannot be destroyed when XUANTIE DebugServer downloads and sets
flash breakpoints, you need to know:
1. Registers that will be destroyed by the algorithm file. The registers include GPRS, PC, and the
control register containing the interrupt enable control bit. These registers have no requirements
on the XUANTIE algorithm file.
2. Memories that will be destroyed by the algorithm file. The memories include the flash
algorithm program code execution memory and stack memory. The code execution memory can
be obtained, but the stack memory requires that the version of the algorithm file be greater than or
equal to 6.
It is required that the algorithm file use the CDK template and the version be greater than or equal
to 6. Basic requirements are as follows:
The functions related to flash operations are implemented in the command line of XUANTIE
DebugServer. The commands integrated into XUANTIE DebugServer are as follows:
• flash
• flash info
• flash erase
• flash program
• flash dump
• flashbp-clear
flash: is used to specify the flash algorithm file. The parameter is as follows:
flash info: is used to view information about the current flash algorithm file. No parameters are
involved.
flash program: is used to perform flash programming. The parameters are as follows:
• -al/--algorithm file: specifies the flash algorithm file used for flash programming. By
default, the flash algorithm file specified when XUANTIE DebugServer is started or the
algorithm file specified by flash -al is used.
• -f/--file: specifies the file to be flashed.
• -b/--binary: If a .bin file is to be flashed, this parameter needs to be specified.
• -a/--address ADDR: If a .bin file is to be flashed, this parameter specifies the starting
address of flash programming.
• -v/--verify: checks whether the flash programming is successful.
flash erase: is used to erase the flash. The parameters are as follows:
• -al/--algorithm file: specifies the flash algorithm file used for erasing. By default, the
flash algorithm file specified when XUANTIE DebugServer is started or the algorithm
file specified by flash -al is used.
• -c/--chip: specifies chip erasing.
• -a/--address ADDR without -c/--chip: specifies the starting address of erasing and writing
when chip erasing is not performed.
• -s/--size LENGTH without -c/--chip: specifies the length of erasing when chip erasing is
not performed.
flash dump: is used to dump the flash content to a file. The parameters are as follows:
• -al/--algorithm file: specifies the flash algorithm file used for dumping. By default, the
flash algorithm file specified when XUANTIE DebugServer is started or the algorithm
file specified by flash -al is used.
• -o/--output: specifies the name of the file to which the flash content is dumped.
• -b/--binary: indicates that the dumped file is a .bin file.
• -h/--hex: indicates that the dumped file is a .hex file.
• -a/--address ADDR: specifies the starting address of dumping.
• -s/--size LENGTH: specifies the length of dumping.
flashbp-clear: is used to clear the flash breakpoints that have been inserted or that are not deleted
in the flash memory. In the debugging process, instruction simulation will be performed to speed
up the process, or the flash breakpoints will be deleted only at the appropriate time to reduce the
number of operations on the flash. In this way, flash breakpoints that have been inserted or that are
not deleted still exist in the current flash memory in the debugging process. This command will
delete these breakpoints and restore the original values in the flash.
EXAMPLE:
flash info
flash erase -c
• Software breakpoints
• Hardware breakpoints
• Data observation points
Software breakpoints: The instruction set of the CPU contains a breakpoint instruction. When the
instruction is executed on the CPU, a debugging exception is generated, and the CPU enters the
debug mode. In this case, the CPU stops running. With the characteristics of this instruction, the
debugger replaces the original instruction at the breakpoint location through the load or store
Hardware breakpoints: The CPU contains an address comparator unit. When a hardware
breakpoint is set, the address PC of the configuration comparator is compared with the breakpoint
address. If the address PC matches the breakpoint address, the CPU enters the debug mode and the
hardware breakpoint takes effect. Since the comparator occupies a large number of resources, the
number of hardware breakpoint comparators in the MCU is limited.
Data observation points: The data address comparator in the CPU is similar to the hardware
breakpoint comparator. The observation point comparator compares the load or store address and
the data observation point address. When the addresses are matched, the CPU enters the debug
mode and the hardware breakpoint takes effect. Generally speaking, the data address comparator is
the same unit as the address comparator on the hardware.
In the MCU field, codes are stored in the flash. When a software breakpoint is made to codes, the
instruction code is rewritten through the load or store instruction because the software breakpoint
is used. Since codes are stored on the flash, the instruction code cannot be rewritten through the
load or store instruction. In this case, only hardware breakpoints can be used. However, due to the
limitation of the number of hardware breakpoints, the debugging work of developers is limited.
To solve the proceeding problems, flash breakpoints are introduced. Similar to software
breakpoints, flash breakpoints also use the breakpoint instruction to enable the CPU to enter the
debug mode. The difference is that software breakpoints use the load or store instruction to rewrite
the instruction code, while flash breakpoints erase the flash to rewrite the instruction code.
9.2.1.Working principles
As mentioned above, the flash breakpoint provides a method to rewrite the instruction code by
erasing the flash. Therefore, XUANTIE DebugServer will record the breakpoint information used
by the user. When a new breakpoint needs to be inserted, XUANTIE DebugServer erases and
burns the flash, and replaces the original instruction with the bkpt/ebreak instruction. For more
information about flash programming principles, see 9.1Flash programming principles.
When the user needs to execute a command at the breakpoint, XUANTIE DebugServer integrates
the simulation execution unit to simulate some of the instructions. In case some instructions
cannot be simulated, the instruction codes will be written in the sp position and executed by the
CPU.
9.2.2.Efficiency of breakpoints
In the debugging process, the flash breakpoints need to perform erasing and writing operations on
the on-chip flash, resulting in increased time cost when compared with software breakpoints. To
reduce the number of operations on the flash, a series of optimizations are made in XUANTIE
DebugServer, including but not limited to the combined use of hardware breakpoints and
instruction simulation.
To ensure data consistency, XUANTIE DebugServer saves the memory area used by the algorithm
file before burning flash breakpoints. To improve efficiency, we recommend that the code size and
data size of the flash algorithm file be as small as possible.
Multiple Vendor directories are stored in the links directory in the installation directory. Each
directory stores the link library file of a customer. The library file is required to provide some
interfaces for porting so that XUANTIE DebugServer can complete debugging.
For porting interfaces, see Table 11-11 Link porting interface list. Details can also be found in
Include/link.hof the sample program.
DebugServer tool, and the operations are different in the Linux and Windows systems.
In the Linux system, a Makefile compiling project is provided. The dependency tools are Make,
GCC, and G++.
In the Windows system, a VS project is provided. The dependency tool is Virtual Studio.
Open the project, we can see some operations in the source file. The operations include:
Version Restart
upgrade XUANTIE
failure DebugServer
and connect it
to the ICE.
When an ICE
upgrade
prompt
appears, select
'y'. After the
upgrade is
successful,
unplug and
then replug the
ICE, and
reconnect
XUANTIE
DebugServer
to the ICE.
Debug The debug architecture is automatically detected when the server is connected. For the
architecture If the architecture is not detected, the "-arch" parameter needs to be specified. console
connection version
issue XUANTIE
DebugServer,
add the startup
parameter
"-arch riscv".
For the UI
version
XUANTIE
DebugServer,
choose
Setting >
Target Setting
and select
RISCV DM
for Debug
Arch Select.