A method for implementing an extensible debugging tool with encryption function

By introducing FLASH download algorithm and a variety of encryption algorithms into the chip debugging tool, the problems of insufficient ease of use, versatility and scalability of existing tools are solved, and encryption protection of chip data and flexible option byte operation are achieved.

CN118484177BActive Publication Date: 2025-02-18SHANGHAI XINBIDA MICROELECTRONICS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410761367.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2025-02-18
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

Existing chip debugging tools are not easy to use, versatile, and scalable, and lack the ability to protect data encryption.

Method used

Provides an implementation method of debugging tool with extensible encryption function. It directly operates option bytes through FLASH download algorithm, supports multiple Linker protocols and chips, integrates multiple encryption algorithms, users can choose encryption algorithms and keys, and Encrypt and decrypt data when downloading and reading.

Benefits of technology

It achieves better scalability and ease of use, supports a variety of chips and Linker, provides user-friendly options byte display and data encryption protection, and improves the versatility and security of debugging tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118484177B_ABST
    Figure CN118484177B_ABST
Patent Text Reader

Abstract

The present invention discloses an implementation method of an expandable debugging tool with encryption function, which writes option bytes into FLASH through a FLASH download algorithm; parses the option bytes (OPB for short), and displays the content of the option bytes item by item according to the configuration of different users by reading the OPB configuration file; encrypts the data written into the memory and decrypts the data read from the memory. This debugging tool implementation method is based on a universal debugger that provides a complete GUI interface, can be independently installed, and supports multiple chips and linkers. It directly operates the option bytes through a FLASH download algorithm. This method can use the Flash download algorithm to download option bytes, treat option bytes and ordinary data in the same way, and adopt the same processing method. The writing method of option bytes can be standardized, and this method has better scalability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of chip debugging, and in particular to a method for realizing an expandable debugging tool with encryption function. Background Art

[0002] For access to the memory in the chip, such as burning and downloading embedded programs, communication between the upper and lower computers is usually required, and debugging tools are needed to debug the completed chip. The current status of chip debugging tool software is as follows:

[0003] JFlash: An independently installable application software that can access SRAM and Flash. However, this application has requirements for connectors and can only use JLINK.

[0004] Keil: An integrated development environment (IDE) for embedded programming. Chip debugging and memory access are sub-functions of Keil and cannot be independent. It supports multiple connectors. It supports Flash access of multiple chips by reading Pack. Keil debugging functions are scattered in different function tab interfaces, which is relatively cumbersome to use.

[0005] STM32CubeProgrammer: An application software that can be installed independently. This software supports a limited number of chip series and only supports the manufacturer's own chips.

[0006] PyOcd: A Python library that can be installed independently. It has no interface support and needs to be used through the command line. It also supports other chips by importing the PACK package.

[0007] OpenOcd: Can be used to install applications independently. No interface support, need to be used through the command line.

[0008] Existing on-chip debuggers all have one or more of the following deficiencies:

[0009] (1) Insufficient usability. Some existing software requires users to manually enter command lines, which is inconvenient to use. Some provide insufficient GUIs and are not flexible enough to provide the functions required by on-chip debuggers.

[0010] (2) Lack of versatility. Some existing tools have limited linker support, some have limited chips support, and some are specific to fixed IDEs.

[0011] (3) Insufficient scalability. It does not support displaying multiple types of customized option byte formats.

[0012] (4) Lack of support for data encryption protection. Summary of the invention

[0013] The purpose of the present invention is to provide an implementation method of an expandable debugging tool with encryption function in view of the problems existing in the prior art, which has the functions of debugging chips, reading and writing memory and registers in chips, supporting multiple Linker protocols, and supporting multiple chips of different specifications and styles.

[0014] To achieve the above object, the technical solution adopted by the present invention is:

[0015] A method for implementing an expandable debugging tool with encryption function, writing option bytes into FLASH through a FLASH download algorithm;

[0016] Parse the option bytes and display the content of the option bytes item by item according to the configuration of different users by reading the OPB configuration file;

[0017] Encrypts data written to memory and decrypts data read from memory.

[0018] The method for implementing an expandable debugging tool with encryption function of the present invention is based on a universal debugger that provides a complete GUI interface, can be installed independently, and supports multiple chips and linkers. The method directly operates option bytes through a FLASH download algorithm. The method can use the Flash download algorithm to download option bytes, treat option bytes and ordinary data in the same way, and adopt the same processing method. The writing method of option bytes can be standardized, and this method has better scalability.

[0019] By reading the configuration file in XML format, the content of the option bytes is displayed item by item according to the configuration of different users, rather than displaying all the binary contents of the option bytes according to a whole Flash area, which is convenient for users to use and does not require users to interpret the option bytes according to the definition of the option bytes.

[0020] A variety of encryption algorithms are integrated into the debugging tool. The user can select the encryption algorithm when downloading data (if the encryption algorithm selected is based on key confidentiality, the user also needs to enter the key). The on-chip debugger will encrypt the data before downloading, and then write the ciphertext into the chip memory such as FLASH or SRAM. Conversely, if the encryption algorithm is selected when reading the memory, the debugging tool of the present invention will decrypt the data in the memory and then display it to the user.

[0021] Preferably, the operation process of the FLASH download algorithm is as follows:

[0022] The CPU enters debug mode;

[0023] Download the download algorithm into RAM;

[0024] Execute the "Init" function;

[0025] Execute the "EraseSector" function to erase pages in a loop;

[0026] Write the page to be written into RAM, execute the "ProgrammePage" function to write the page in RAM into FLASH, if the data is not written, return and repeat the process;

[0027] If the data is written, the "Uninit" function is executed.

[0028] Preferably, the steps of writing the option bytes are as follows:

[0029] Check the size of the option bytes to see if the size exceeds the size of one page;

[0030] The option bytes are written into the FLASH according to the page size; the option bytes (OPB for short) are some special control data used to indicate whether some operations can be performed on the FLASH, and the OPB configuration file is a configuration file customized and used in the present invention for more friendly parsing and modification of the OPB;

[0031] If there are pages that are completely used, then all the pages that are completely used are erased; and then the option bytes are written into the erased pages;

[0032] If there are pages that are partially used, the contents of the partially used pages are read into the host computer memory, modified in the memory, and then the modified page contents containing the option bytes are written to the FLASH.

[0033] Preferably, the reading and writing process of the option bytes is as follows:

[0034] Import OPB configuration file;

[0035] Read the content of OPB area;

[0036] Parse the OPB area content and display it in the software interface in the form of a list;

[0037] Whether the user has modified the content of the OPB area, if so, the user clicks Save and executes the FLASH download algorithm instruction to write the input into FLASH; if not, the process is skipped directly.

[0038] Preferably, each configuration item is defined in the OPB configuration file, including at least the name, description, start address and content size information of each item, and the corresponding OPB item is extracted according to the defined start address and content size information and displayed in the software interface.

[0039] Preferably, during the process of downloading the file, the encryption process is as follows:

[0040] The user selects the chip model and creates a project;

[0041] Establish a communication channel between the upper computer and the lower computer;

[0042] The user opens the file;

[0043] The file contents are displayed in the software interface;

[0044] Set the download configuration in the software interface, including at least whether to encrypt, the data to be encrypted, the encryption algorithm and the key;

[0045] If encryption is required, the selected data will be encrypted, if not, it will be skipped;

[0046] Write the data to be written into FLASH.

[0047] Preferably, the process of encrypting and writing user data is as follows:

[0048] The user selects the encryption algorithm, the data block to be encrypted and enters the encryption key;

[0049] When a user writes data to the on-chip memory (referring to the memory within the chip or the on-chip memory), the data that the user wants to write is encrypted, and then the ciphertext is written to the memory;

[0050] If the user does not select an encryption algorithm, the original data is written directly to the memory;

[0051] The process of decrypting and reading user data is as follows:

[0052] The user selects the encryption algorithm, the data block to be decrypted and enters the decryption key;

[0053] When the user reads data to the interface for display, the data to be read by the user is decrypted and then the plain text is displayed on the tool interface;

[0054] If the user does not select an encryption algorithm, the original data will be directly read and displayed in the software interface.

[0055] Furthermore, the software architecture of the debugging tool includes the following:

[0056] The View layer is responsible for the display of the UI, including the custom module, widget module, and designer module; the custom module is a custom function module, the widget module contains various specific forms, and the designer module is a UI file for various interface layout designs;

[0057] Model layer, including data objects that support interface display data, other required data structures, software settings and project settings information records;

[0058] The Adapter layer is an intermediate layer that isolates the software layer through interface conversion;

[0059] The Core layer is the centralized implementation level of core functions, including the Probe module, Target module, CoreSight module, Protocol module and Algo module; the Target module defines the key information of various chips, including the FLASH download algorithm, and the Algo module has built-in multiple encryption algorithms; the Probe module implements communication support for several simulators; the CoreSight module defines the software abstraction of the CoreSight component; the Protocol module implements communication protocols such as SWD and JTAG;

[0060] The Infrastructure layer provides common capabilities, including log printing and resource management.

[0061] Furthermore, the upper computer is connected to the lower computer through various linkers, and then the chip memory and registers can be read and written by operating the debugging tool software;

[0062] The host computer has an on-chip debugger, which provides a GUI (Graphical User Interface or GUI for short) for users to perform chip debugging operations, including memory read and write operations, file downloads, option byte read and write, and data encryption and decryption;

[0063] The lower computer at least includes a chip board or an FPGA board.

[0064] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. The implementation method of the debugging tool with an expandable encryption function of the present invention is based on providing a universal debugger with a complete GUI interface, which can be independently installed and supports multiple chips and linkers. The method directly operates the option bytes through the FLASH download algorithm. The method can use the Flash download algorithm to download the option bytes, treat the option bytes and ordinary data in the same way, and use the same processing method to normalize the writing method of the option bytes. This method has better scalability; 2. The user can conveniently perform operations such as accessing the memory in the chip through the GUI, and in particular, a humanized display of the option bytes is provided, which reflects the ease of use of the present method; 3. The present method has good versatility, can support multiple linkers and chips, and pre-sets multiple linkers and chips; 4. The present method supports humanized display of the content of the option byte area according to certain configuration rules. Different OPB definitions of different manufacturers will only lead to different configuration files, which will not affect the debugging tool of the present invention; and it supports directly writing the option bytes through the FLASH download algorithm. Supports loading and importing new FLASH download algorithm files to support new chips; supports adding support for new Linkers through secondary development; 5. This method can also write ciphertext to the memory after encryption, and can also decrypt the encrypted content in the memory and display it. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 A schematic diagram of on-chip debugging of an implementation method of a debugging tool with an expandable encryption function according to the present invention;

[0066] Figure 2 It is a schematic diagram of the operation flow of the FLASH download algorithm of the present invention;

[0067] Figure 3 Schematic diagram of the reading and writing process of the option bytes of the present invention;

[0068] Figure 4 It is a schematic diagram of the encryption process during the downloading process of the present invention;

[0069] Figure 5 A schematic diagram of the software architecture of an implementation method of an extensible debugging tool with encryption function according to the present invention;

[0070] Figure 6 A software GUI schematic diagram (default display interface) of the implementation method of the debugging tool with an extensible encryption function of the present invention;

[0071] Figure 7 A software GUI schematic diagram (operation configuration display interface) of the implementation method of the debugging tool with an expandable encryption function of the present invention;

[0072] Figure 8 It is a schematic diagram of the display format of OPB in the implementation method of the debugging tool with an expandable encryption function of the present invention;

[0073] Fig. 9 This is an example of the OPB configuration file in the code of the present invention. DETAILED DESCRIPTION

[0074] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings 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.

[0075] like Figure 1 As shown, the complete use of the debugging tool with an expandable encryption function of the present invention is demonstrated. The upper computer is connected to the lower computer through a variety of linkers, and then the chip memory and registers are read and written by operating the debugging tool software;

[0076] The host computer, as desktop software running on the PC, provides a GUI for users to perform chip debugging operations, including memory (SRAM, FLASH and registers, etc.) read and write operations, file download, option byte read and write, and data encryption functions;

[0077] Among them, the data file can be a common file format in the embedded programming process, such as hex file, axf file, bin file, etc.; FLASH download algorithm file, the software reads the file content, and completes the FLASH download data by executing the download algorithm instruction; OPB configuration file, through the content defined in the XML file, can parse the name, description, starting address, content and content size of each item of OPB.

[0078] The linker is a basic component in the embedded development process, which is used to connect the host computer and the slave computer and provide functions such as protocol conversion. The present invention defines a unified abstract interface for protocols such as DAPLINK and JLINK, and abstracts interfaces such as open, close, connect, disconnect, reset, read_dp, write_dp, read_ap and write_ap. Different linkers are encoded to implement a unified interface, so as to support multiple linkers.

[0079] The lower computer includes at least a chip board or an FPGA board. For a chip board, the chip has been packaged and integrated into a development board, and the development board exposes communication interfaces such as USB and JTAG. For an FPGA board, when there is no finished chip, the functional logic of the chip can be simulated by programming.

[0080] The chip function interface can also be abstracted, and support for multiple chips can also be achieved through polymorphism. The differences between different chips are mainly reflected in memory mapping, download algorithms, etc., which can all be parameterized. Therefore, not only can multiple chips be supported in advance during coding, but also multiple chips can be supported through import, which has better scalability and flexibility.

[0081] This debugging tool can import the FLASH download algorithm by importing the algorithm file, or directly hard-code the FLASH download algorithm into the code and directly build it into the tool software.

[0082] like Figure 2 As shown, the operation process of the FLASH download algorithm in the implementation method of the debugging tool with an extensible encryption function of the present invention is as follows:

[0083] The on-chip debugger puts the CPU into debug mode;

[0084] Download the download algorithm into RAM;

[0085] Execute the "Init" function;

[0086] Execute the "EraseSector" function to erase pages in a loop;

[0087] Write the page to be written into RAM, execute the "ProgrammePage" function to write the page in RAM into FLASH, if the data is not written, return and repeat the process;

[0088] If the data is written, the "Uninit" function is executed.

[0089] Option bytes are generally stored in a special location of FLASH, such as the beginning of the address space. The content of the option bytes is some special configuration of FLASH. The steps of writing option bytes are as follows:

[0090] Check the size of the option byte to see if it exceeds 2K (the size of a page, generally the page size is 2K, but some FLASH page sizes are not 2K);

[0091] Writing the option bytes into FLASH according to the page size;

[0092] If there are pages that are completely used, then all the pages that are completely used are erased; and then the option bytes are written into the erased pages;

[0093] If there are pages that are partially used, the contents of the partially used pages are read into the host computer memory, modified in the memory, and then the modified page contents containing the option bytes are written to the FLASH.

[0094] The method for implementing an expandable debugging tool with encryption function of the present invention is based on a universal debugger that provides a complete GUI interface, can be installed independently, and supports multiple chips and linkers. The method directly operates option bytes through a FLASH download algorithm. Different from the method of indirectly operating option bytes on the FLASH by reading and writing registers, the method can use the Flash download algorithm to download option bytes, treat option bytes and ordinary data in the same way, and adopt the same processing method, so that the reading and writing methods of option bytes and ordinary data can be unified, and this method has better scalability.

[0095] None of the existing debugging tools provide user-friendly parsing of option bytes. When reading the content of option bytes, the content of the entire FLASH page where the option bytes are located is directly displayed. If the user wants to understand the configuration meaning of the option bytes, he needs to interpret them manually. Figure 3 As shown, the reading and writing process of option bytes in this method is shown:

[0096] Step 1: Import the OPB configuration file;

[0097] Step 2: Read the content of OPB area;

[0098] Step 3: Parse the content of the OPB area and display it in the software interface in the form of a list;

[0099] Step 4: Check whether the user has modified the content of the OPB area. If so, execute Step 5: The user clicks Save and further executes Step 6: Execute the FLASH download algorithm instruction to write the input into FLASH; if not, skip the process of Steps 5 and 6 directly.

[0100] Preferably, each configuration item is defined in the OPB configuration file, such as Fig. 9 As shown, at least the name, description, start address and content size information of each item are included. According to the defined start address and content size information, the corresponding OPB item is extracted and displayed in the software interface.

[0101] Steps 1 and 3 can load the definition information of the option bytes, and display the content and meaning of the option bytes in a more user-friendly way in a list display, which helps users directly understand the configuration meaning of the option bytes. This approach can support parsing option bytes from different manufacturers. Different chip manufacturers provide their own definition files, and this debugging tool parses according to the definition. Step 6 can treat OPB and ordinary data the same way, and write option bytes more directly.

[0102] OPB configuration files (definition files) can be Figure 1 The OPB display configuration file introduced in the article is essentially an XML file. This method defines the format of the OPB configuration file. Fig. 9 This is described and shown in the code in . Importing Fig. 9 After the configuration file shown in the code is loaded, the on-chip debugging tool can parse the content of the OPB area according to the configuration, and clearly display the value and meaning of each part in the form of a list, which is convenient for users to use. It avoids the shortcomings of directly displaying the content of the entire OPB area and letting users interpret it by themselves. Different manufacturers have different OPB definitions and configuration files, but they do not affect the software's parsing of the OPB area.

[0103] OPB is a FLASH storage area with a specific function in the chip. The size and functional meaning of this area are artificially defined. Therefore, different chip manufacturers can design their own OPB area. The size of OPB of different manufacturers may be different, and the meaning of the content in the OPB area may also be different. For example, assuming that the OPB area of ​​manufacturer 1 and manufacturer 2 are both 2 bytes, and the content of this area is 0000000100000000, the existing debugging tools can support the display of the entire FLASH area, that is, 0000000100000000, but the meaning of the content of this area needs to be interpreted manually, which is not user-friendly. Then manufacturer 1 stipulates that the first byte is a read protection function. When the value is 1, read protection is turned on; the second byte is write protection. When the value is 1, it means that write protection is turned on. But manufacturer 2 may be just the opposite. The first byte is write protection and the second byte is read protection. This method defines a unified configuration file format (what is the meaning of a sub-area from a certain starting address to a certain ending address). In view of the difference in OPB definitions between manufacturer 1 and manufacturer 2, two configuration files can be written (describe the meaning of the first byte and the second byte respectively. The configuration file of manufacturer 1 indicates that the first byte is read protection and the second is write protection, while the configuration file of manufacturer 2 is the opposite). The debugging tool described in this method can parse the configuration file and display each area division of OPB. The interface display is as follows: Figure 8 As shown. Of course, you can also edit Figure 8The interface shown modifies the content of the area that the user needs to modify. For example, modifying the read protection value can control whether to enable the read protection function.

[0104] like Figure 4 As shown, the process of downloading files in the present method is shown, during which an encryption process may occur.

[0105] Step 1: The user selects the chip model and creates a project;

[0106] Step 2: Establish a communication channel between the upper computer and the lower computer;

[0107] Step 3: The user opens a file, such as a .bin file;

[0108] Step 4: The file contents are displayed in the software interface;

[0109] Step 5: Set the download configuration in the software interface, including at least whether to encrypt, the data to be encrypted, the encryption algorithm and the key, etc.;

[0110] Step 6: If encryption is required, execute step 7: encrypt the selected data. If not, jump;

[0111] Step 8: Write the data to be written into FLASH.

[0112] Step 1 shows the support for multiple chips. This method integrates multiple encryption algorithms, and users can choose to encrypt their own data. In the encryption function, users can select the encryption algorithm to be used, and can also select the file area to be encrypted (it can be the entire file or part of the file).

[0113] In most cases, the files downloaded by the debugging tool are compiled program files (such as hex, axf, FLM files, etc.) or data files (such as bin files). Regardless of the type of file, the debugging tool processes it as a binary file, that is, no matter what the content of the file is, it must be a binary code sequence such as 0101. Take a program file (hex format, file extension is hex) as an example. If the amount of code written by the user is large, the compiled hex file will also be large. Generally speaking, the encryption and decryption process is a computationally intensive and time-consuming process. If the entire file is encrypted, it may be very time-consuming. However, the user may really want to protect a part of his program, which may be a key algorithm or other extremely valuable program. In this case, there is no need to encrypt the entire file. You can encrypt the location where the key code is located. From this, two processing methods are naturally derived: encrypting the entire file or encrypting part of the file.

[0114] Assume that a hex file is 128KB, which contains the instructions and some other information of the compiled user program. The file contains the compiled result of a key algorithm. The user can know the location of the key algorithm in the hex file after compilation, assuming it is from byte 101 to byte 110. The user can specify that only the content from byte 101 to byte 110 in the file is encrypted by specifying the start and end offsets (that is, 101 and 110), and the rest can be written to FLASH as is. This can protect the key content and not waste too much time, thus ensuring the speed of downloading files.

[0115] This method implements common traditional encryption algorithms and modern encryption algorithms and integrates them into the debugging tool. Traditional encryption algorithms include encryption algorithms based on algorithm confidentiality such as Caesar encryption. Symmetric encryption algorithms include national encryption (sm2, sm3, sm4), DES (Data Encryption Standard), 3DES (Triple DES), AES (Advanced Encryption Standard), Blowfish, IDEA, RC4 (Rivest Cipher 4), RC5 and RC6. Asymmetric encryption algorithms include RSA, ECC, EL Gamal, DSA and Diffie-Hellman.

[0116] This debugging tool customizes and encapsulates an encryption algorithm library. The algorithm library defines a unified abstract interface through the strategy mode, and different encryption algorithms implement this interface. It makes full use of the polymorphic characteristics of Python, an object-oriented language, to make the encryption algorithm library easy to expand, maintain, test, and have low coupling.

[0117] The process of encrypting and writing user data is as follows:

[0118] (1) The user selects the encryption algorithm, the data block to be encrypted, and enters the encryption key;

[0119] (2) When the user writes data to the on-chip memory, the data to be written by the user is encrypted and then the ciphertext is written into the memory;

[0120] (3) If the user does not select an encryption algorithm, the original data is written directly into the memory;

[0121] The process of decrypting and reading user data is as follows:

[0122] (1) The user selects the encryption algorithm, the data block to be decrypted, and enters the decryption key, etc.

[0123] (2) When the user reads data to the interface display, the data to be read by the user is decrypted and then the plain text is displayed on the tool interface;

[0124] (3) If the user does not select an encryption algorithm, the original data will be directly read and displayed on the software interface.

[0125] like Figure 5 As shown, this method also provides a software architecture. It includes the following contents:

[0126] The View layer is responsible for the display of the UI, including the custom module, widget module, and designer module. The custom module is a custom function module, the widget module contains various specific forms, and the designer module is a UI file for various interface layout designs. The UI layout and content display are shown in Figure 6 and 7 ;

[0127] Model layer, including data objects that support interface display data, other required data structures, software settings and project settings information records;

[0128] The Adapter layer is an intermediate layer that plays the role of software interface conversion and software layer isolation;

[0129] The Core layer is the centralized implementation level of core functions, including the Probe module, Target module, CoreSight module, Protocol module and Algo module; the Probe module uses polymorphic characteristics to implement a variety of simulators, such as DAPLINK, JLINK, etc.; the Target module defines key information of a variety of chips, such as the FLASH download algorithm, etc.; the CoreSight module implements the communication information and register access protocol required by the ARM specification, etc.; the Algo module has a variety of encryption algorithms built in, which are implemented in a polymorphic way for expansion;

[0130] The Infrastructure layer provides general capabilities, including log printing and resource (multi-language files, images, etc.) management.

[0131] This software is a chip debugging tool that provides all debugging functions. For example, it can put the chip into debugging mode by setting special registers in the chip, realize program suspension, single-step execution and current status acquisition, support kernel register reading and writing, support software breakpoints and hardware breakpoints, support chip memory access and access protection, etc.

[0132] The functions implemented by the software are all provided in the form of GUI, and the interface reflects the functions provided by the debugging tool. Figure 6 and Figure 7 The software interface is implemented based on the QWidget library of PyQt, and the business logic code is implemented in Python.

[0133] When the user clicks the button to download the file, the View layer will collect the parameters required for the file download function (need to be provided by the user) and perform preliminary parameter verification. If the parameters entered by the user are illegal, a prompt will be displayed directly on the interface. Then the file content stored in the Model layer and the parameters entered by the user will be passed to the Adapter layer. The Adapter layer acts as an intermediary and will do some verification and processing before handing it over to the Core layer to execute the file download task. During this process, it is possible to perform functions such as printing logs at any time, and such functions will be provided in the Infrastructure layer.

[0134] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for implementing an extensible debugging tool with encryption function, characterized in that: Write the option bytes into FLASH through the FLASH download algorithm; Parse the option bytes and display the content of the option bytes item by item according to the configuration of different users by reading the OPB configuration file; Encrypting data written to the memory and decrypting data read from the memory; The software architecture of the debugging tool includes the following: The View layer is responsible for the display of the UI, including the custom module, widget module, and designer module; the custom module is a custom function module, the widget module contains various specific forms, and the designer module is a UI file for various interface layout designs; Model layer, including data objects that support interface display data, other required data structures, software settings and project settings information records; The Adapter layer is an intermediate layer that isolates the software layer through interface conversion; The Core layer is the centralized implementation level of core functions, including the Probe module, Target module, CoreSight module, Protocol module and Algo module; the Target module defines the key information of various chips, including the FLASH download algorithm, and the Algo module has built-in multiple encryption algorithms; the Probe module implements communication support for the emulator; the CoreSight module defines the software abstraction of the CoreSight component; the Protocol module implements the communication protocol of SWD and JTAG; The Infrastructure layer provides common capabilities, including log printing and resource management.

2. The method for implementing an expandable debugging tool with encryption function according to claim 1, characterized in that: The operation process of the FLASH download algorithm is as follows: The CPU enters debug mode; Download the download algorithm into RAM; Execute the "Init" function; Execute the "EraseSector" function to erase pages in a loop; Write the page to be written into RAM, execute the "ProgrammePage" function to write the page in RAM into FLASH, if the data is not written, return and repeat the process; If the data is written, the "Uninit" function is executed.

3. The method for implementing an expandable debugging tool with encryption function according to claim 1, characterized in that: The steps for writing option bytes are as follows: Check the size of the option bytes to see if the size exceeds the size of one page; Writing the option bytes into FLASH according to the page size; If there are pages that are completely used, then all the pages that are completely used are erased; and then the option bytes are written into the erased pages; If there are pages that are partially used, the contents of the partially used pages are read into the host computer memory, modified in the memory, and then the modified page contents containing the option bytes are written to the FLASH.

4. The method for implementing an expandable debugging tool with encryption function according to claim 1, characterized in that: The reading and writing process of the option bytes is as follows: Import OPB configuration file; Read the content of OPB area; Parse the OPB area content and display it in the software interface in the form of a list; Whether the user has modified the content of the OPB area, if so, the user clicks Save and executes the FLASH download algorithm instruction to write the input into FLASH; if not, the process is skipped directly.

5. The method for implementing an expandable debugging tool with encryption function according to claim 4, characterized in that: Each configuration item is defined in the OPB configuration file, including at least the name, description, start address and content size information of each item. The corresponding OPB item is extracted according to the defined start address and content size information and displayed in the software interface.

6. The method for implementing an expandable debugging tool with encryption function according to claim 1, characterized in that: During the download process, the encryption process is as follows: The user selects the chip model and creates a project; Establish a communication channel between the upper computer and the lower computer; The user opens the file; The file contents are displayed in the software interface; Set the download configuration in the software interface, including at least whether to encrypt, the data to be encrypted, the encryption algorithm and the key; If encryption is required, the selected data will be encrypted, if not, it will be skipped; Write the data to be written into FLASH.

7. The method for implementing an expandable debugging tool with encryption function according to claim 1 or 6, characterized in that: The process of encrypting and writing user data is as follows: The user selects the encryption algorithm, the data block to be encrypted and enters the encryption key; When the user writes data to the on-chip memory, the data to be written by the user is encrypted, and then the ciphertext is written into the memory; If the user does not select an encryption algorithm, the original data is written directly to the memory; The process of decrypting and reading user data is as follows: The user selects the encryption algorithm, the data block to be decrypted and enters the decryption key; When the user reads data to the interface for display, the data to be read by the user is decrypted and then the plain text is displayed on the tool interface; If the user does not select an encryption algorithm, the original data will be directly read and displayed in the software interface.

8. The method for implementing an expandable debugging tool with encryption function according to claim 1, characterized in that: The upper computer is connected to the lower computer through various linkers, and then the chip memory and registers are read and written by operating the debugging tool software; The host computer has an on-chip debugger, which provides a GUI for users to perform chip debugging operations, including memory read and write operations, file downloads, option byte read and write, and data encryption and decryption; The lower computer at least includes a chip board or an FPGA board.

Citation Information

Patent Citations

  • Embedded Flash controller supporting encrypted storage

    CN113220498A