TH-1 chip debugging method based on OpenOCD and customized OpenOCD

By customizing OpenOCD tools to debug the TH-1 chip, the problem that existing tools cannot be debugged is solved, efficient chip debugging is achieved, cost reduction and development efficiency is improved.

CN120523658APending Publication Date: 2025-08-22WUXI ADVANCED TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510522856.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-22

AI Technical Summary

Technical Problem

The existing OpenOCD tools cannot effectively debug the TH-1 chip, resulting in inefficiency and inefficiency of debugging tools.

Method used

By customizing OpenOCD tools, configuring debugging parameters suitable for TH-1 chips, establishing a communication environment between the debugging host and TH-1 chips, and connecting through JLink, using customized OpenOCD to send debugging commands to realize online debugging of TH-1 chips.

Benefits of technology

It realizes efficient debugging of the TH-1 chip, reduces debugging costs, improves the work efficiency of hardware developers, and saves time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120523658A_ABST
    Figure CN120523658A_ABST
Patent Text Reader

Abstract

The invention discloses a TH-1 chip debugging method based on an OpenOCD and a customized OpenOCD, and belongs to the technical field of processor on-chip debugging. The method comprises the steps that a communication environment between a debugging host and a TH-1 chip is set up; configuring related parameters adapted to TH-1 chip debugging for the OpenOCD, and operating an OpenOCD program after parameter configuration in a debugging host; and debugging the TH-1 chip based on the debugging host carrying the customized OpenOCD, and obtaining a debugging result. According to the invention, the internal state of the TH-1 chip, such as interruption, operation and reset of a core, can be controlled; a register and a storage space in the TH-1 chip can be accessed; the Flash on the chip can be read and written; the access to the memory space of the chip by using a specific instruction set of the TH-1 chip is supported, and the problem that the OpenOCD open source version does not support the TH-1 chip is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of processor on-chip debugging, and in particular relates to a TH-1 chip debugging method based on OpenOCD and a customized OpenOCD. Background Art

[0002] The current state of embedded chip debugging methods primarily encompasses hardware emulation, software emulation, and online debugging. Hardware emulation: Early chip-level debugging was primarily performed through a dedicated JTAG (Joint Test Action Group) interface. Modern, advanced hardware debuggers support interfaces such as USB-JTAG or SWD (Serial Wire Debug), making debugging equipment more portable. Software emulation: With advances in virtualization technology, programs like GDB (GNU Debugger) can connect to embedded system emulators, such as Keil uVision and IAR Workbench, to simulate a real-world execution environment through a CPU model for testing and debugging code behavior. Online debugging: This method monitors runtime system data in real time through debug interfaces (such as UART and SPI). This method requires no additional hardware resources and is suitable for resource-constrained devices. Furthermore, remote debugging tools are becoming increasingly popular, allowing developers to debug embedded systems on a host computer. Due to the varying internal architectures and interface details of chips from different manufacturers or models, debugging tools designed for one chip may not be suitable for debugging other chips or may be inefficient.

[0003] OpenOCD (Open On-Chip Debugger) focuses on chip-level debugging and programming of embedded target devices. As an open-source debugging tool, it offers powerful flexibility and enables efficient debugging and programming in embedded systems, especially for non-standard or emerging processor architectures. However, OpenOCD currently cannot debug the TH-1 chip. Summary of the Invention

[0004] The present invention aims to provide a TH-1 chip debugging method based on OpenOCD and a customized OpenOCD. OpenOCD is configured according to the debugging requirements of the TH-1 chip, and debugging commands are sent remotely to the TH-1 chip through the customized OpenOCD, thereby realizing the debugging function of the TH-1 chip online.

[0005] To achieve the above object, the present invention is implemented by adopting the following technical solutions:

[0006] In a first aspect, the present invention provides a TH-1 chip debugging method based on OpenOCD, comprising: Build the communication environment between the debugging host and the TH-1 chip; Configure OpenOCD with parameters suitable for TH-1 chip debugging, and run the configured OpenOCD program on the debugging host. Debug the TH-1 chip based on a debugging host equipped with a customized OpenOCD and obtain the debugging results.

[0007] Optionally, establishing a communication environment between the debugging host and the TH-1 chip includes: connecting the debugging host and the TH-1 chip via JLink.

[0008] Optionally, the relevant parameters adapted for debugging the TH-1 chip include: the IR instruction length of the JTAG interface inside the TH-1 chip and the number of cores of the TH-1 chip.

[0009] Optionally, debugging the TH-1 chip based on a debugging host equipped with a customized OpenOCD and obtaining debugging results includes: Send TH-1 chip debugging instructions to the customized OpenOCD through the debugging host; Process and send debugging instructions through customized OpenOCD, and perform corresponding operations on the TH-1 chip according to the debugging instructions; After the debugging operation is completed, the debugging results are fed back to the debugging host through the customized OpenOCD.

[0010] Optionally, the processing and sending of the debugging command by customizing OpenOCD includes: Converting the debugging instructions into an instruction format recognizable by a hardware debugger by customizing OpenOCD; The recognized debugging instructions are converted into an instruction format recognizable by the TH-1 chip through the hardware debugger and sent to the TH-1 chip through the JTAG interface.

[0011] Optionally, the TH-1 chip debugging instructions include: controlling the internal state of the TH-1 chip; accessing registers and storage space inside the TH-1 chip; reading and writing Flash on the TH-1 chip; and supporting access to chip memory space using unique hardware instructions of the TH-1 chip.

[0012] Optionally, performing corresponding operations on the TH-1 chip according to the debugging command includes: Control the processor of the TH-1 chip and access the internal registers and memory space of the TH-1 chip; Get the PC value of the TH-1 chip and read and write the Flash on the TH-1 chip.

[0013] In a second aspect, the present invention provides a customized OpenOCD configured with relevant parameters adapted for TH-1 chip debugging.

[0014] Compared with the existing technology, the present invention has the following beneficial effects: by leveraging the flexibility of OpenOCD as an open source debugging tool and customizing OpenOCD to adapt it to TH-1 chip debugging, the debugging method provided by the customized OpenOCD tool can be used to directly communicate with the TH-1 chip, access the chip status and internal registers, and quickly identify the problem. This greatly reduces the cost of TH-1 debugging, provides great help in solving hardware development problems, improves the work efficiency of hardware developers, and saves a lot of time. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 FIG2 is a flow chart of a TH-1 chip debugging method based on OpenOCD in one embodiment of the present invention;

[0016] Figure 2 FIG2 is a schematic diagram showing the connection relationship between the customized OpenOCD, the debugging host and the TH-1 chip in one embodiment of the present invention;

[0017] Figure 3 Shown is the code structure and configuration information of customizing OpenOCD in one embodiment of the present invention. DETAILED DESCRIPTION

[0018] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.

[0019] Example 1

[0020] This embodiment provides a TH-1 chip debugging method based on OpenOCD, including: Build the communication environment between the debugging host and the TH-1 chip; Configure OpenOCD with parameters suitable for TH-1 chip debugging, and run the configured OpenOCD program on the debugging host. Debug the TH-1 chip based on a debugging host equipped with a customized OpenOCD and obtain the debugging results.

[0021] The OpenOCD code was modified according to the chip's internal architecture and interface, a configuration file was created, and corresponding debugging commands were developed based on the chip's debugging requirements. The customized OpenOCD tool uses an interactive mode that can directly communicate with the target chip. The developed debugging commands are used to debug the TH-1 chip, ensuring that the debugging method can run stably in a Linux environment and reserving an interface for future chip updates.

[0022] Example 2

[0023] Based on Example 1, this example also makes the following design.

[0024] like Figure 1 As shown, this embodiment specifically divides the TH-1 chip debugging method based on OpenOCD into the following steps:

[0025] S101, debug host connected to TH-1 chip.

[0026] like Figure 2 As shown, in step S101 of this embodiment, connecting the debug host to the TH-1 chip refers to connecting the debug host to the TH-1 chip via a hardware debugger such as JLink. A modified OpenOCD that supports the TH-1 chip is installed on the debug host. A USB data cable is used to connect the debug host to the JLink debugger, which is then connected to the TH-1 chip via JTAG, thereby debugging the TH-1 chip.

[0027] S102, configure OpenOCD to debug the TH-1 chip-specific parameters.

[0028] like Figure 3 As shown, OpenOCD is modified and customized according to the TH-1 chip's proprietary parameters. The operation process includes:

[0029] When the TH-1 maintenance software is running on the debugging host, it first classifies and verifies the software command interface and initializes the log. Next, the TH-1 maintenance software parses the provided configuration file, runs the corresponding initialization commands based on the configuration file's contents, initializes JTAG signal transmission, sets the signal frequency, instruction length, debug endpoint, and initializes the target.

[0030] In this embodiment, the OpenOCD source code architecture is studied to identify the parts related to the communication protocol and register structure unique to the TH-1 chip. Debug commands for the TH-1 chip are developed to adapt to the debugging requirements of the TH-1 chip, and an OpenOCD debugging tool adapted to the TH-1 chip is customized.

[0031] Debug commands include:

[0032] Control the internal state of the TH-1 chip, such as core interrupts, operation, and reset;

[0033] Can access registers and storage space inside the TH-1 chip;

[0034] Can read and write the Flash on the chip;

[0035] Supports access to chip memory space using TH-1 chip-specific hardware instructions.

[0036] S103, sending debugging commands to the TH-1 chip through the JTAG interface.

[0037] By customizing OpenOCD to send debug commands to the TH-1 chip, the TH-1's internal registers are manipulated to gain control of the processor, allowing debugging to proceed in an exchanged manner. The user runs the optimized OpenOCD program on the debugging host and uses the J-Link emulator to convert USB to JTAG, sending debug commands to the TH-1 chip in a format that the chip can "read."

[0038] S104: Debug the TH-1 chip according to the debugging command and return the result to the debugging host.

[0039] After the TH-1 maintenance software completes initialization, it enters a loop waiting for command input. Upon receiving a command, it executes the corresponding code to implement the corresponding function. This code is the core of the TH-1 maintenance software. Its process includes: sending JTAG signals from the debug host to the TH-1 chip; the JTAG signal controls the TH-1 chip by manipulating the IR and DR registers through the DMI protocol; and the TH-1 performs corresponding operations based on the control information obtained from the JTAG signal.

[0040] Debugging operations include:

[0041] TH-1 chip status processing: When executing some debug commands, such as accessing registers and reading PC values, the debug host needs to send a halt command to the TH-1 chip to pause the core. When the core needs to continue running, the debug host sends a resume command to the TH-1 chip.

[0042] Access the internal registers of the TH-1 chip;

[0043] Access the TH-1 chip memory space via the SBA (System Bus Access) bus;

[0044] Access to the TH-1 chip memory space is achieved by writing TH-1 chip-specific instructions into the Program Buffer;

[0045] Get the PC value of the TH-1 chip;

[0046] Read and write the Flash on the TH-1 chip;

[0047] Write the contents of the specified file into the memory starting from the specified starting address.

[0048] Example 3

[0049] This embodiment provides a customized OpenOCD configured with relevant parameters suitable for debugging the TH-1 chip.

[0050] Compared to existing technologies, this invention achieves the following benefits: Using the debugging method provided by this custom tool, one can directly communicate with the TH-1 chip, access the chip status and internal registers, and quickly identify the problem. This method significantly reduces the cost of TH-1 debugging, significantly aids in solving hardware development problems, and improves the work efficiency of hardware developers, saving a considerable amount of time.

[0051] After debugging is complete, the debug data is retrieved from the TH-1 chip, converted into JTAG protocol, and returned to the debug host through the hardware debugger. Finally, the results are displayed through a text interface. After debugging is complete, the debug host will release the operation through OpenOCD, clear the signal, and end the entire process.

[0052] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0053] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0054] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0055] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0056] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present invention and the claims, which are all protected by the present invention.

Claims

1. A TH-1 chip debugging method based on OpenOCD, characterized in that: include: Build the communication environment between the debugging host and the TH-1 chip; Configure OpenOCD with parameters suitable for TH-1 chip debugging, and run the configured OpenOCD program on the debugging host. Debug the TH-1 chip based on a debugging host equipped with a customized OpenOCD and obtain the debugging results.

2. The TH-1 chip debugging method based on OpenOCD according to claim 1, characterized in that: The communication environment between the debugging host and the TH-1 chip is established, including: connecting the debugging host and the TH-1 chip through JLink.

3. The TH-1 chip debugging method based on OpenOCD according to claim 1, characterized in that: The relevant parameters adapted for debugging the TH-1 chip include: the IR instruction length of the JTAG interface inside the TH-1 chip and the number of cores possessed by the TH-1 chip.

4. The TH-1 chip debugging method based on OpenOCD according to claim 1, characterized in that: The debugging host equipped with a customized OpenOCD is used to debug the TH-1 chip and obtain the debugging results, including: Send TH-1 chip debugging instructions to the customized OpenOCD through the debugging host; Process and send debugging instructions through customized OpenOCD, and perform corresponding operations on the TH-1 chip according to the debugging instructions; After the debugging operation is completed, the debugging results are fed back to the debugging host through the customized OpenOCD.

5. The TH-1 chip debugging method based on OpenOCD according to claim 4, characterized in that: The processing and sending of debugging commands by customizing OpenOCD includes: Converting the debugging instructions into an instruction format recognizable by a hardware debugger by customizing OpenOCD; The recognized debugging instructions are converted into an instruction format recognizable by the TH-1 chip through the hardware debugger and sent to the TH-1 chip through the JTAG interface.

6. The TH-1 chip debugging method based on OpenOCD according to claim 4, characterized in that: The TH-1 chip debugging instructions include: controlling the internal state of the TH-1 chip; accessing the registers and storage space inside the TH-1 chip; reading and writing the Flash on the TH-1 chip; and supporting the use of the TH-1 chip's unique hardware instructions to access the chip's memory space.

7. The TH-1 chip debugging method based on OpenOCD according to claim 6, characterized in that: The performing corresponding operations on the TH-1 chip according to the debugging command includes: Control the processor of the TH-1 chip and access the internal registers and memory space of the TH-1 chip; Get the PC value of the TH-1 chip and read and write the Flash on the TH-1 chip.

8. A customized OpenOCD, characterized in that: The configuration contains relevant parameters suitable for TH-1 chip debugging.