Debugging method and system for heterogeneous multi-core processor
By creating shared storage areas and function reference relationships between the master and slave cores of heterogeneous multi-core processors, combined with the terminal tool tshell, the real-time, complexity and flexibility of heterogeneous multi-core processor debugging in the prior art is solved, and a low-cost and high-flexible debugging method is realized.
Patent Information
- Application Number
- CN202411981200.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-11
AI Technical Summary
The prior art is difficult to realize real-time debugging when debugging heterogeneous multi-core processors, and the hardware design is complex and cost-effective and has poor flexibility.
By creating a shared storage area between the master and slave core, the management module divides and maps the memory space, and communications between the master and slave core through the correspondence between the function prototype and the function pointer, the terminal tool tshell is used to debug the analysis of the command and the output of the execution result.
Real-time debugging of heterogeneous multi-core processors is realized, reducing the complexity and cost of hardware design and improving debugging flexibility.
Smart Images

Figure CN119806934A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of embedded debugging technology, and in particular to a debugging method and system for a heterogeneous multi-core processor. Background Art
[0002] With the rapid development of information technology, embedded systems are increasingly used in many fields, from smart home devices to industrial automation control systems, from automotive electronic systems to aerospace equipment, etc. The complexity and importance of embedded software are constantly increasing. Especially as heterogeneous multi-core processor architecture gradually becomes the mainstream, the development of embedded software faces unprecedented challenges.
[0003] In the prior art, the design of high-performance processors is basically a heterogeneous parallel architecture, with general-purpose CPUs and special-purpose processors integrated in different proportions. Based on the embedded software development, testing, and certain faults that occur during the operation of this type of processor, the application is debugged without power failure. One method is to use a special debugger gdb, attach to the thread to be debugged, and then obtain the current variable values and stack call relationship information in the process space. Since gdb needs to interrupt the program running and has memory occupancy and other overheads, this method is not suitable for systems running in real time. Another method is to use an emulator to track the process of program execution through a special hardware instrument to view the values of variables and registers. This type of solution requires planning JTAG pins in advance to reserve hardware resources. This not only increases the complexity and cost of hardware design, but also in some systems where the hardware layout has been completed and the corresponding resources have not been reserved, this method cannot be implemented, which seriously limits its scope of application and flexibility.
[0004] How to solve the above technical problems is the subject faced by the present invention. Summary of the invention
[0005] In order to solve the deficiencies of the prior art, the present invention provides a debugging method and system for a heterogeneous multi-core processor that can be debugged in real time, has low hardware design complexity and cost, and high flexibility.
[0006] The technical solution adopted by the present invention to solve its technical problem is:
[0007] In one aspect, the present invention provides a debugging method for a heterogeneous multi-core processor, comprising the following steps:
[0008] S1, start the master core and slave core, complete the initialization operation, and create a shared storage area;
[0009] The master core performs hardware initialization, including setting the clock frequency, initializing registers, configuring the interrupt vector table, etc., and loads necessary kernel modules and drivers to create an execution environment for subsequent tasks; the slave core completes its own hardware self-test and basic software environment initialization, such as initializing local memory and setting the default working mode, etc.
[0010] The shared storage area management module divides a specific area in the addressable memory space of the master core and the slave core as the shared storage area, and performs necessary memory mapping and access permission settings to ensure that both the master core and the slave core can perform safe and efficient read and write operations on the area.
[0011] S2. Create a corresponding relationship between the function prototype and the function pointer in the slave core and send it to the shared storage area;
[0012] S3, the main core obtains the correspondence between the function prototype and the function pointer from the shared storage area;
[0013] S4. The terminal tool tshell sends a debugging command to the master core, which parses the command and sends it to the slave core.
[0014] S5, the slave core determines whether to execute, and if so, returns the execution result to the master core;
[0015] S6. The main core sends the execution result to the terminal tool.
[0016] Preferably, the step S1 further comprises: the main core is started in user mode, and after the main core and the slave core are started, the main core creates a localshellin task and a remoteshellout task, and the slave core creates a coshelltask task;
[0017] The localshellin task is used to process the main core and terminal tool data and parse the debugging command; the remoteshellout task is used to process the information sent from the core; and the coshelltask task is used to receive the command sent by the main core.
[0018] Preferably, in step S2, a corresponding relationship between a function prototype and a function pointer is created by registering a function through a dynamic command;
[0019] The structure of the dynamic command registration function includes a cmd command name, a function pointer, an explanation of the cmd command, and the number of parameters corresponding to the cmd command.
[0020] Preferably, the step S4 is specifically:
[0021] When the user enters a debugging command in the terminal tool tshell, the terminal tool tshell packages the debugging command according to the pre-defined communication protocol format and writes the debugging command to the socket port. The master core obtains and parses the debugging command through the localshellin task, finds the function pointer corresponding to the debugging command, and sends the function pointer and related command parameters to the slave core.
[0022] Preferably, the step S5 is specifically:
[0023] After receiving the function pointer and related command parameters from the core, check whether the function pointer has been registered locally. If it has been registered, execute the corresponding function and return the execution result to the main core; if it has not been registered, exit.
[0024] If it has been registered, the slave core calls the corresponding execution function through the function pointer and passes the parameters sent by the master core to the execution function; the execution function operates and obtains data from the relevant resources of the slave core according to the requirements of the command, such as reading specific register values, querying data structures in memory, executing specific algorithms, etc.; after the execution function is completed, the execution result is packaged according to a pre-defined data format and returned to the master core through the communication interface between the master core and the slave core.
[0025] Preferably, the step S6 is specifically:
[0026] The main core outputs the execution result to the terminal tool tshell through the remoteshellout task, and the terminal tool tshell writes the execution result to the socket port and displays the execution result.
[0027] On the other hand, the present invention provides a debugging system for a heterogeneous multi-core processor, including a command registration module, a shared storage area management module and a terminal tool tshell;
[0028] The command registration module is used to create a corresponding relationship between a function prototype and a function pointer;
[0029] The shared storage area management module is used for creating, initializing, allocating and reclaiming the shared storage area; when the system is started, the size and address range of the shared storage area are reasonably divided according to the requirements of the master core and the slave core;
[0030] The terminal tool tshell is used to perform real-time debugging and management on the main core process.
[0031] Preferably, the terminal tool tshell creates a pseudo terminal as a standard I / O during the initialization phase, and configures the input and output properties of the pseudo terminal through system calls, such as setting character encoding, baud rate, etc. A socket port is created as the input and output direction of the terminal tool tshell, and the TCP or UDP protocol is used to establish a communication connection and transmit data.
[0032] The beneficial effects of the present invention are: real-time debugging, low complexity and cost of hardware design, and high flexibility. The slave core dynamically registers the debugging function as a shell command through the function API, avoiding the problem of reserving hardware resources when using an emulator for debugging in the prior art, and the design is simple and low in cost. The master core system can debug the slave core conveniently and quickly through the terminal tool tshell to perform real-time debugging and management of the slave core system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a diagram of the method steps of the present invention.
[0034] Figure 2 It is a system block diagram of the present invention.
[0035] Figure 3 It is a schematic diagram of data transmission direction of the present invention. DETAILED DESCRIPTION
[0036] In order to clearly illustrate the technical features of this solution, this solution is described below through specific implementation methods.
[0037] See also Figure 1 , Figure 3 As shown, this embodiment provides a debugging method for a heterogeneous multi-core processor, comprising the following steps:
[0038] S1, start the master core and slave core, complete the initialization operation, and create a shared storage area;
[0039] The master core performs hardware initialization, including setting the clock frequency, initializing registers, configuring the interrupt vector table, etc., and loads necessary kernel modules and drivers to create an execution environment for subsequent tasks; the slave core completes its own hardware self-test and basic software environment initialization, such as initializing local memory and setting the default working mode, etc.
[0040] The shared storage area management module divides a specific area in the addressable memory space of the master core and the slave core as the shared storage area, and performs necessary memory mapping and access permission settings to ensure that both the master core and the slave core can perform safe and efficient read and write operations on the area.
[0041] S2. Create a corresponding relationship between the function prototype and the function pointer in the slave core and send it to the shared storage area;
[0042] S3, the main core obtains the correspondence between the function prototype and the function pointer from the shared storage area;
[0043] S4. The terminal tool tshell sends a debugging command to the master core, which parses the command and sends it to the slave core.
[0044] S5, the slave core determines whether to execute, and if so, returns the execution result to the master core;
[0045] S6. The main core sends the execution result to the terminal tool.
[0046] Step S1 also includes that the main core is started in user mode, and after the main core and the slave core are started, the main core creates a localshellin task and a remoteshellout task, and the slave core creates a coshelltask task;
[0047] The localshellin task is used to process the main core and terminal tool data and parse debugging commands; the remoteshellout task is used to process the information sent from the core; and the coshelltask task is used to receive commands sent by the main core.
[0048] In step S2, a corresponding relationship between a function prototype and a function pointer is created by registering a function through a dynamic command;
[0049] The structure of the dynamic command registration function includes the cmd command name, function pointer, explanation of the cmd command and the number of parameters corresponding to the cmd command.
[0050] Step S4 is specifically as follows:
[0051] When the user enters a debugging command in the terminal tool tshell, the terminal tool tshell packages the debugging command according to the pre-defined communication protocol format and writes the debugging command to the socket port. The master core obtains and parses the debugging command through the localshellin task, finds the function pointer corresponding to the debugging command, and sends the function pointer and related command parameters to the slave core.
[0052] Step S5 is specifically as follows:
[0053] After receiving the function pointer and related command parameters from the core, check whether the function pointer has been registered locally. If it has been registered, execute the corresponding function and return the execution result to the main core; if it has not been registered, exit.
[0054] If it has been registered, the slave core calls the corresponding execution function through the function pointer and passes the parameters sent by the master core to the execution function; the execution function operates and obtains data from the relevant resources of the slave core according to the requirements of the command, such as reading specific register values, querying data structures in memory, executing specific algorithms, etc.; after the execution function is completed, the execution result is packaged according to a pre-defined data format and returned to the master core through the communication interface between the master core and the slave core.
[0055] Step S6 is specifically as follows:
[0056] The main core outputs the execution result to the terminal tool tshell through the remoteshellout task, and the terminal tool tshell writes the execution result to the socket port and displays the execution result.
[0057] See also Figure 2 As shown, the present invention also provides a debugging system for a heterogeneous multi-core processor, including a command registration module, a shared storage area management module and a terminal tool tshell;
[0058] The command registration module is used to create the correspondence between function prototypes and function pointers;
[0059] The shared storage area management module is used to create, initialize, allocate and recycle the shared storage area. When the system starts, the size and address range of the shared storage area are reasonably divided according to the needs of the master core and the slave core.
[0060] The terminal tool tshell is used to perform real-time debugging and management of the main core process.
[0061] During the initialization phase, the terminal tool tshell creates a pseudo terminal as standard I / O and configures the input and output properties of the pseudo terminal through system calls, such as setting character encoding, baud rate, etc. A socket port is created as the input and output direction of the terminal tool tshell, and TCP or UDP protocol is used to establish a communication connection and transmit data.
[0062] Technical features not described in the present invention can be achieved through or by adopting existing technologies and will not be described in detail here. Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions or substitutions made by ordinary technicians in this technical field within the essential scope of the present invention should also fall within the scope of protection of the present invention.
Claims
1. A debugging method for a heterogeneous multi-core processor, characterized in that: The following steps are involved: S1, start the master core and slave core, complete the initialization operation, and create a shared storage area; S2. Create a corresponding relationship between the function prototype and the function pointer in the slave core and send it to the shared storage area; S3, the main core obtains the correspondence between the function prototype and the function pointer from the shared storage area; S4. The terminal tool tshell sends a debugging command to the master core, which parses the command and sends it to the slave core. S5, the slave core determines whether to execute, and if so, returns the execution result to the master core; S6. The main core sends the execution result to the terminal tool.
2. The debugging method for a heterogeneous multi-core processor according to claim 1, characterized in that: The step S1 also includes that the main core is started in user mode, and after the main core and the slave core are started, the main core creates a localshellin task and a remoteshellout task, and the slave core creates a coshelltask task; The localshellin task is used to process the main core and terminal tool data and parse the debugging commands; the remoteshellout task is used to process the information sent from the core; and the coshelltask task is used to receive the commands sent by the main core.
3. The debugging method for a heterogeneous multi-core processor according to claim 1, characterized in that: In the step S2, a corresponding relationship between a function prototype and a function pointer is created by registering a function through a dynamic command; The structure of the dynamic command registration function includes a cmd command name, a function pointer, an explanation of the cmd command, and the number of parameters corresponding to the cmd command.
4. The debugging method for a heterogeneous multi-core processor according to claim 1, characterized in that: The step S4 is specifically as follows: The terminal tool tshell writes the debugging command to the socket port. The master core obtains and parses the debugging command through the localshellin task, finds the function pointer corresponding to the debugging command, and sends the function pointer and related command parameters to the slave core.
5. The debugging method for a heterogeneous multi-core processor according to claim 1, characterized in that: The step S5 is specifically as follows: After receiving the function pointer and related command parameters from the core, check whether the debug command has been registered locally. If it has been registered, execute the corresponding function and return the execution result to the main core; If not registered, log out.
6. The debugging method for a heterogeneous multi-core processor according to claim 1, characterized in that: The step S6 is specifically as follows: The main core outputs the execution result to the terminal tool tshell through the remoteshellout task, and the terminal tool tshell writes the execution result to the socket port and displays the execution result.
7. A debugging system for a heterogeneous multi-core processor, characterized in that: Includes command registration module, shared storage area management module and terminal tool tshell; The command registration module is used to create a corresponding relationship between a function prototype and a function pointer; the shared storage area management module is used to create, initialize, allocate and recycle a shared storage area; and the terminal tool tshell is used to perform real-time debugging management on the main core process.
8. The debugging method and system of heterogeneous multi-core processor according to claim 7, characterized in that: During the initialization phase, the terminal tool tshell creates a pseudo terminal as a standard I / O and a socket port as the input and output direction of the terminal tool tshell.