JTAG (Joint Test Action Group) connection management method and device, equipment and storage medium
By updating the firmware to enable and disable the JTAG interception function, the debugging difficulties caused by permanent disabling of JTAG is solved, improving the flexibility of JTAG connections and ensuring the security of device data.
Patent Information
- Application Number
- CN202411173005.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-15
AI Technical Summary
In the prior art, the permanent disabling of JTAG results in the inability to debug when the device runs abnormally, lacks flexibility and cannot recover.
The first version of firmware enables the JTAG interception function, and uses the controller to monitor the access of the JTAG emulator in real time to perform connection interception; the second version of firmware disables the interception function, allowing the JTAG emulator to debug the equipment and adopts non-public encrypted storage.
It realizes the flexibility of JTAG connection and device data security, allowing debugging through the JTAG emulator when the device fails, avoiding external intrusion.
Smart Images

Figure CN118964210A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a JTAG connection management method, device, equipment and storage medium. Background Art
[0002] Generally, during the product development stage of electronic equipment, JTAG (Joint Test Action Group) is required for firmware burning and debugging (debug, programmers can read the debugging module integrated in the electronic equipment through JTAG, and the debugging module allows programmers to debug the software in the embedded system). However, after the device leaves the factory, in order to prevent the firmware from being tampered with by the outside, JTAG access is usually not allowed. In the prior art, JTAG is disabled by removing the JTAG pins in the device, permanently disabling the JTAG pins, etc. However, when the device runs abnormally and needs to be analyzed and debugged, JTAG needs to be re-enabled. If the disabling of JTAG is permanent and irreversible, it will cause subsequent abnormal operation of the device and debugging will no longer be possible. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a JTAG connection management method, apparatus, device and storage medium, which can improve the flexibility of JTAG connection and ensure the security of device data. The specific scheme is as follows:
[0004] On the one hand, the present application discloses a JTAG connection management method, comprising:
[0005] Refreshing the target device with the first version firmware to enable the JTAG interception function of the target device;
[0006] Monitoring in real time whether a JTAG emulator access occurs through a controller of the target device, and if so, executing JTAG connection interception through the controller;
[0007] The target device is refreshed with the second version firmware to disable the JTAG interception function of the target device so as to debug the target device with the JTAG emulator.
[0008] Optionally, monitoring in real time whether a JTAG emulator is connected by a controller of the target device, and if so, executing JTAG connection interception by the controller, including:
[0009] Monitor the JCOMP pin of JTAG through the controller of the target device to see if a low level occurs;
[0010] If a low level occurs, it is determined that a JTAG emulator is connected, and the JTAG connection interception is performed by the controller.
[0011] Optionally, monitoring whether a JCOMP pin of JTAG appears at a low level by the controller of the target device includes:
[0012] The level of the target IO pin is monitored by the controller of the target device; the target IO pin is connected to the JCOMP pin, and the level of the target IO pin is consistent with the level of the JCOMP pin.
[0013] Optionally, the time taken by the controller to respond to an interrupt intercepted by the JTAG connection is less than the time taken by the JTAG emulator from the occurrence of a low level at the target pin to the first sending of data.
[0014] Optionally, the second version firmware is stored in a private encrypted manner.
[0015] Optionally, perform JTAG connection interception, including:
[0016] Disable debugging on the target device.
[0017] Optionally, perform JTAG connection interception, including:
[0018] Disable the clock signal inversion of the JTAG emulator;
[0019] Or, disable the TMS signal output of the JTAG emulator;
[0020] Or, disable data transfer from the JTAG emulator.
[0021] In a second aspect, the present application discloses a JTAG connection management device, comprising:
[0022] An interception function enabling module, used to refresh the target device through the first version firmware to enable the JTAG interception function of the target device;
[0023] A connection interception module, used to monitor in real time whether a JTAG emulator access occurs through a controller of the target device, and if so, perform JTAG connection interception through the controller;
[0024] The interception function disabling module is used to refresh the target device through the second version firmware to disable the JTAG interception function of the target device so as to debug the target device through the JTAG emulator.
[0025] In a third aspect, the present application discloses an electronic device, comprising:
[0026] Memory, used to store computer programs;
[0027] The processor is used to execute the computer program to implement the aforementioned JTAG connection management method.
[0028] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program implements the aforementioned JTAG connection management method when executed by a processor.
[0029] In the present application, the target device is refreshed by the first version of the firmware to enable the JTAG interception function of the target device; the controller of the target device monitors in real time whether a JTAG emulator is connected, and if so, the JTAG connection interception is executed by the controller; the target device is refreshed by the second version of the firmware to disable the JTAG interception function of the target device, so that the target device can be debugged by the JTAG emulator. It can be seen that the JTAG interception function of the target device is disabled by the second version of the firmware, so that the target device can be debugged by the JTAG emulator, and the JTAG interception function of the target device is enabled by the first version of the firmware. After enabling, the controller monitors in real time and intercepts the JTAG connection when the JTAG emulator is connected to ensure that the device is not invaded by the outside; that is, the enabling and disabling of JTAG is realized by updating the firmware, which improves the flexibility of the JTAG connection and ensures the data security of the device. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0031] Figure 1 A flow chart of a JTAG connection management method provided by this application;
[0032] Figure 2 This is the pin output timing diagram after JTAG connection;
[0033] Figure 3 A specific JTAG connection management timing diagram provided for this application;
[0034] Figure 4 A schematic diagram of the structure of a JTAG connection management device provided by this application;
[0035] Figure 5 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] In the prior art, JTAG is disabled by removing the JTAG pins in the device or permanently disabling the JTAG pins. However, when the device runs abnormally and needs to be analyzed and debugged, JTAG needs to be re-enabled. If the disabling of JTAG is permanent and irreversible, it will cause subsequent abnormal operation of the device and make it impossible to debug. In order to solve the above technical problems, this application proposes a JTAG connection management method, which can enable and disable JTAG by updating the firmware, improve the flexibility of JTAG connection, and ensure the data security of the device.
[0038] The present application embodiment discloses a JTAG connection management method, see Figure 1 As shown, the method may include the following steps:
[0039] Step S11: Refresh the target device with the first version firmware to enable the JTAG interception function of the target device.
[0040] In this embodiment, the target device is refreshed through the first version firmware to enable the JTAG interception function of the target device. That is, the above-mentioned first version firmware is used to enable the JTAG interception function; it should be noted that the firmware corresponding to different devices is different, and the manufacturer needs to set it according to the actual situation. It is understandable that during the product development stage, JTAG access is required for function debugging and product development. After leaving the factory, JTAG access is no longer allowed to ensure product safety. Therefore, it is usually updated with the first version firmware before the device leaves the factory, so that the device has the JTAG interception function after leaving the factory, and can intercept malicious attacks connected through JTAG, thereby ensuring the security of device data.
[0041] Step S12: monitoring in real time whether a JTAG emulator is connected through the controller of the target device, and if so, executing JTAG connection interception through the controller.
[0042] After the connection function is enabled, the controller of the target device monitors in real time whether a JTAG emulator is currently connected to the target device. If so, the controller performs JTAG connection interception. In other words, after the interception function is enabled, the JTAG emulator that wants to connect will be intercepted. The above controller can be a microcontroller unit (MCU).
[0043] In some embodiments, whether a JTAG emulator is accessed is monitored in real time by the controller of the target device. If so, JTAG connection interception is executed by the controller, which may include: monitoring whether a low level appears on the JCOMP pin of the JTAG through the controller of the target device; if a low level appears, it is determined that a JTAG emulator is accessed, and JTAG connection interception is executed by the controller.
[0044] First, a brief introduction to the JTAG emulator is given. The JTAG emulator includes TCK (Test Clock Input) pin, TMS (Test Mode Selection Input) pin, TDI (Test Data Input) pin, TDO (Test Data Output) pin, etc. Among them, TCK provides an independent, basic clock signal for the operation of TAP (Test Access Port), and all TAP operations are driven by this clock signal. The TMS signal is valid on the rising edge of TCK. The TMS signal is used to control the transition of the TAP state machine. Through the TMS signal, the TAP can be controlled to switch between different states. TDI is the interface for data input. All data to be input into a specific register is input serially one bit at a time through the TDI interface (driven by TCK). TDO is the interface for data output. All data to be output from a specific register is output serially one bit at a time through the TDO interface (driven by TCK).
[0045] In actual use, when the JTAG emulator tries to access the MCU, the JTAG emulator will first pull down the JCOMP pin to reset the debug module of the chip device, and then send data to the device through the TMS and TCK pins, for example Figure 2 That is to say, the JTAG emulator will definitely pull down the JCOMP pin before transmitting data. Therefore, in this embodiment, the controller monitors whether the JCOMP pin of the JTAG is at a low level. If a low level is present, it can be considered that the JTAG emulator is connected. The controller further performs JTAG connection interception before the JTAG emulator performs actual data transmission to prevent the JTAG from being accessed and ensure that the chip is protected from being invaded.
[0046] The time taken by the controller to respond to the interrupt intercepted by the JTAG connection is less than the time taken by the JTAG emulator from the low level at the target pin to the first data transmission. That is, it takes a period of time from the initiation of interception to the actual response. The prerequisite for being able to intercept before data transmission is that the time taken by the JTAG connection to respond to the interrupt intercepted by the controller is less than the time taken by the JTAG emulator from the low level at the target pin to the first data transmission. Figure 3 As shown in the figure, the time from when the JCOMP pin is pulled low to when the JTAG emulator sends the first data is t1, which is fixed and usually 263us. After actual testing, the time t2 from when the JCOMP pin is pulled low to when the MCU responds to the interrupt is only 653ns (main frequency 300MHz). Therefore, before the JTAG emulator sends data, it can be detected and intercepted.
[0047] In some embodiments, monitoring whether the JCOMP pin of JTAG is at a low level through the controller of the target device may include: monitoring the level of the target IO pin through the controller of the target device; the target IO pin is connected to the JCOMP pin, and the level of the target IO pin is consistent with the level of the JCOMP pin. It is understandable that since the level of the JCOMP pin cannot be read directly, a common pin (such as an IO (input and output) pin) is connected to the JCOMP pin, and the common pin is configured as an input module, and an interrupt is triggered on the pull-up and falling edges; thus, when the JTAG emulator attempts to access the MCU and pulls down the JCOMP pin, the input interrupt of the common pin will be triggered, and the controller can perform corresponding interception actions in the interrupt function.
[0048] The execution of the JTAG connection interception may specifically include: disabling the debugging function of the target device, that is, processing the target device to prevent the device from being invaded by the JTAG emulator by disabling the debugging function of the target device.
[0049] In some embodiments, the execution of JTAG connection interception may also include: prohibiting the clock signal of the JTAG emulator from flipping; or prohibiting the TMS signal output of the JTAG emulator; or prohibiting the data transmission of the JTAG emulator. That is, for the JTAG emulator, by disabling the clock signal or input data, JTAG is blocked from sending data to the device. Of course, in addition to the above method, any method that can achieve connection interception is acceptable, and this embodiment does not limit it.
[0050] Step S13: Refresh the target device with the second version firmware to disable the JTAG interception function of the target device so as to debug the target device with the JTAG emulator.
[0051] When a device fails and needs repair, the manufacturer can refresh the target device through the second version of the firmware to disable the JTAG interception function of the target device. After deactivation, the target device can be debugged through the JTAG emulator. It can be seen that the second version of the firmware is used to disable the JTAG interception function. Therefore, the second version of the firmware is encrypted and stored privately and is only used by the manufacturer during maintenance, so that others can use it maliciously.
[0052] By adopting JTAG insertion detection, when there is a JTAG insertion, the software can choose to block / allow access. This allows flexible settings, such as allowing JTAG access during the product development stage, and not allowing JTAG access by updating the firmware during the product delivery stage. The firmware update method has fewer restrictions than the commonly used method of disabling JTAG, and can be more flexible and adapt to more scenarios.
[0053] As can be seen from the above, in this embodiment, the target device is refreshed through the first version of the firmware to enable the JTAG interception function of the target device; the controller of the target device monitors in real time whether a JTAG emulator is connected, and if so, the JTAG connection interception is executed through the controller; the target device is refreshed through the second version of the firmware to disable the JTAG interception function of the target device, so that the target device can be debugged through the JTAG emulator. It can be seen that the JTAG interception function of the target device is disabled through the second version of the firmware, so that the target device can be debugged through the JTAG emulator, and the JTAG interception function of the target device is enabled through the first version of the firmware. After the activation, the controller monitors in real time and performs JTAG connection interception when the JTAG emulator is connected to ensure that the device is not invaded by the outside; that is, the enabling and disabling of JTAG is realized by updating the firmware, which improves the flexibility of the JTAG connection and ensures the data security of the device.
[0054] Correspondingly, the embodiment of the present application also discloses a JTAG connection management device, see Figure 4 As shown, the device comprises:
[0055] The interception function enabling module 11 is used to refresh the target device through the first version firmware to enable the JTAG interception function of the target device;
[0056] A connection interception module 12, used for monitoring in real time whether a JTAG emulator access occurs through the controller of the target device, and if so, performing JTAG connection interception through the controller;
[0057] The interception function disabling module 13 is used to refresh the target device through the second version firmware to disable the JTAG interception function of the target device so as to debug the target device through the JTAG emulator.
[0058] As can be seen from the above, in this embodiment, the target device is refreshed through the first version of the firmware to enable the JTAG interception function of the target device; the controller of the target device monitors in real time whether a JTAG emulator is connected, and if so, the JTAG connection interception is executed through the controller; the target device is refreshed through the second version of the firmware to disable the JTAG interception function of the target device, so that the target device can be debugged through the JTAG emulator. It can be seen that the JTAG interception function of the target device is disabled through the second version of the firmware, so that the target device can be debugged through the JTAG emulator, and the JTAG interception function of the target device is enabled through the first version of the firmware. After the activation, the controller monitors in real time and performs JTAG connection interception when the JTAG emulator is connected to ensure that the device is not invaded by the outside; that is, the enabling and disabling of JTAG is realized by updating the firmware, which improves the flexibility of the JTAG connection and ensures the data security of the device.
[0059] In some specific embodiments, the connection interception module 12 may specifically include:
[0060] A level monitoring unit, used for monitoring whether a JCOMP pin of JTAG appears at a low level through a controller of the target device;
[0061] The interception execution unit is used to determine that a JTAG emulator is connected if a low level occurs, and to execute JTAG connection interception through the controller.
[0062] In some specific embodiments, the level monitoring unit may specifically include:
[0063] The IO pin level monitoring unit is used to monitor the level of the target IO pin through the controller of the target device; the target IO pin is connected to the JCOMP pin, and the level of the target IO pin is consistent with the level of the JCOMP pin.
[0064] In some specific embodiments, the time taken by the controller to respond to the interrupt intercepted by the JTAG connection is less than the time taken by the JTAG emulator from the occurrence of a low level at the target pin to the first transmission of data.
[0065] In some specific embodiments, the second version of the firmware may be stored in a non-public encrypted manner.
[0066] In some specific embodiments, the connection interception module 12 may specifically include:
[0067] The debugging disabling unit is used to disable the debugging function of the target device.
[0068] In some specific embodiments, the connection interception module 12 may specifically include:
[0069] The signal inversion prohibition unit is used to prohibit the clock signal inversion of the JTAG emulator;
[0070] or, a signal output disabling unit, used for disabling the TMS signal output of the JTAG emulator;
[0071] Or, a data transfer prohibition unit is used to prohibit data transfer of the JTAG emulator.
[0072] Furthermore, the present application also discloses an electronic device, see Figure 5 As shown, the contents in the drawings should not be considered as any limitation on the scope of use of the present application.
[0073] Figure 5 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the JTAG connection management method disclosed in any of the aforementioned embodiments.
[0074] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0075] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222, and data 223 including a first version of firmware, etc. The storage method can be temporary storage or permanent storage.
[0076] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the JTAG connection management method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0077] Furthermore, an embodiment of the present application also discloses a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the JTAG connection management method disclosed in any of the aforementioned embodiments are implemented.
[0078] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0079] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0080] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0081] The JTAG connection management method, device, equipment and storage medium provided by the present invention are introduced in detail above. The principle and implementation mode of the present invention are explained by using specific examples in this article. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A JTAG connection management method, characterized in that: include: Refreshing the target device with the first version firmware to enable the JTAG interception function of the target device; Monitoring in real time whether a JTAG emulator access occurs through a controller of the target device, and if so, executing JTAG connection interception through the controller; The target device is refreshed with the second version firmware to disable the JTAG interception function of the target device so as to debug the target device with the JTAG emulator.
2. The JTAG connection management method according to claim 1, characterized in that: The controller of the target device monitors in real time whether a JTAG emulator is connected. If so, the controller performs JTAG connection interception, including: Monitor the JCOMP pin of JTAG through the controller of the target device to see if a low level occurs; If a low level occurs, it is determined that a JTAG emulator is connected, and the JTAG connection interception is performed by the controller.
3. The JTAG connection management method according to claim 2, characterized in that: Monitoring, by the controller of the target device, whether a JCOMP pin of the JTAG is at a low level includes: The level of the target IO pin is monitored by the controller of the target device; the target IO pin is connected to the JCOMP pin, and the level of the target IO pin is consistent with the level of the JCOMP pin.
4. The JTAG connection management method according to claim 1, characterized in that: The time taken by the controller to respond to the interrupt intercepted by the JTAG connection is less than the time taken by the JTAG emulator from the occurrence of a low level at the target pin to the first sending of data.
5. The JTAG connection management method according to claim 1, characterized in that: The second version of the firmware is stored in a private encrypted manner.
6. The JTAG connection management method according to claim 1, characterized in that: Perform JTAG connection interception, including: Disable debugging on the target device.
7. The JTAG connection management method according to any one of claims 1 to 5, characterized in that: Perform JTAG connection interception, including: Disable the clock signal inversion of the JTAG emulator; Or, disable the TMS signal output of the JTAG emulator; Or, disable data transfer from the JTAG emulator.
8. A JTAG connection management device, characterized in that: include: An interception function enabling module, used to refresh the target device through the first version firmware to enable the JTAG interception function of the target device; A connection interception module, used to monitor in real time whether a JTAG emulator access occurs through a controller of the target device, and if so, perform JTAG connection interception through the controller; The interception function disabling module is used to refresh the target device through the second version firmware to disable the JTAG interception function of the target device so as to debug the target device through the JTAG emulator.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the JTAG connection management method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein when the computer programs are executed by a processor, the JTAG connection management method according to any one of claims 1 to 7 is implemented.
