A firmware storage method, firmware reading method, device, chip processor and storage medium

By setting configuration areas, operation areas and backup areas in the chip, and realizing key generation, compression encryption and data erasing functions in the chip processor, the problem of chip firmware being easily cracked is solved, and the chip's efficient anti-cracking and development and debugging convenience is achieved.

CN114327518BActive Publication Date: 2025-03-11GUANGZHOU SIRUI SEMICON CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111666580.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-03-11
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

The existing chip cracking method is implemented by copying the program firmware in the chip, which makes the chip's firmware easy to be cracked and cannot effectively prevent the chip from being cracked.

Method used

By setting the configuration area, operation area and backup area in the chip, and automatically randomly generating keys, compression encryption operations and data erasing functions in the chip processor, we ensure that the firmware files are automatically erased in the running area and cannot be read by external devices, thereby preventing the chip from being cracked.

Benefits of technology

Effectively prevent the chip from being cracked, ensure the security of firmware files, and allow developers to debug through wired connections, which facilitates firmware function verification and debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114327518B_ABST
    Figure CN114327518B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention provide a firmware storage method, a firmware reading method, a device, a chip processor and a storage medium, and relate to the field of chip technology. Applied to a chip processor, the chip includes a configuration area, an operation area and a backup area. The chip processor performs a read or write operation on the configuration area, the operation area and the backup area, and the configuration area is prohibited from being read by an external device. The method includes: when the chip is connected to a burning tool for communication, erasing the data stored in the operation area, and obtaining the original firmware burned by the burning tool. Automatically randomly generate a key and store the key in the configuration area. Based on the key and the compression algorithm built into the chip processor, perform compression and encryption operations on the original firmware to obtain a compressed file. The original firmware is stored in the operation area, and the compressed file is stored in the backup area. In this way, by setting the chip processor, the backup area and the operation area to store the firmware, the problem of the chip being cracked can be effectively prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip technology, and in particular to a firmware storage method, a firmware reading method, a device, a chip processor and a storage medium. Background Art

[0002] Microcontroller Unit (MCU), also known as single chip microcomputer or single chip microcomputer, is a chip-level computer that appropriately reduces the frequency and specifications of the central chip processor (CPU) and integrates peripheral interfaces such as memory and counters to provide different combination controls for different applications. As chips are increasingly used in industrial control, communications, the Internet of Things and other fields, chip cracking has also attracted the attention of developers.

[0003] Existing chip cracking usually involves copying the program firmware in the chip and obtaining the original code of the program firmware through methods such as disassembly, thereby achieving chip cracking. Summary of the invention

[0004] The purpose of the present invention includes, for example, providing a firmware storage method that can prevent a chip from being cracked.

[0005] The embodiments of the present invention can be implemented as follows:

[0006] In a first aspect, an embodiment of the present invention provides a firmware storage method, which is applied to a chip processor, wherein the chip includes a configuration area, a running area, and a backup area, and the chip processor performs a read or write operation on the configuration area, the running area, and the backup area, and the configuration area is prohibited from being read by an external device, and the method includes:

[0007] When the chip is in communication connection with the burning tool, the data stored in the running area is erased to obtain the original firmware burned by the burning tool;

[0008] Automatically randomly generate a key and store the key in the configuration area;

[0009] Based on the key and the compression algorithm built into the chip processor, a compression and encryption operation is performed on the original firmware to obtain a compressed file;

[0010] storing the original firmware in the running area;

[0011] The compressed file is stored in the backup area.

[0012] Furthermore, there are multiple compression algorithms, and the step of performing compression and encryption operations on the original firmware based on the key and the compression algorithm built into the chip processor to obtain a compressed file includes:

[0013] Randomly selecting two or more compression algorithms from the multiple compression algorithms, and randomly combining the two or more compression algorithms to obtain a target compression algorithm;

[0014] According to the key and the target compression algorithm, a compression encryption operation is performed on the original firmware to obtain a compressed file.

[0015] Furthermore, the chip processor stores a plurality of encryption algorithms; the step of performing compression and encryption operations on the original firmware according to the key and the target compression algorithm to obtain a compressed file includes:

[0016] Randomly selecting two or more encryption algorithms from the multiple encryption algorithms, and randomly combining the two or more encryption algorithms to obtain a target encryption algorithm;

[0017] According to the key and the target encryption algorithm, an encryption operation is performed on the original firmware that has completed the compression operation to obtain the compressed file.

[0018] Furthermore, the method further comprises:

[0019] Obtaining the length and checksum of the original firmware from the burning tool;

[0020] The length and the check code are stored in the backup area.

[0021] Furthermore, after the step of storing the compressed file in the backup area, the method further comprises:

[0022] If a debugging instruction is received, debugging is performed according to the received debugging instruction to ensure that the functions of the original firmware can be successfully implemented on the chip; after the debugging is completed, erasing the data stored in the running area;

[0023] If no debugging instruction is received, the data stored in the running area is erased.

[0024] In a second aspect, an embodiment of the present invention provides a firmware reading method, wherein the chip includes a configuration area, a running area, and a backup area, the chip processor performs a read or write operation on the configuration area, the running area, and the backup area, and the configuration area is prohibited from being read by an external device, and the method includes:

[0025] When the chip is not in communication connection with an external device and the data in the operation area is erased, acquiring the key stored in the configuration area and the compressed file stored in the backup area;

[0026] Decompressing and decrypting the compressed file according to the key and the compression algorithm built into the chip processor to obtain a firmware file;

[0027] The firmware file is stored in the running area.

[0028] Further, after the step of storing the firmware file in the running area, the method further includes:

[0029] Obtain the length and check code stored in the backup area;

[0030] Calculating the length and checksum of the firmware file;

[0031] If the calculated length is consistent with the obtained length, and the calculated check code is consistent with the obtained check code, then the firmware file is complete and the firmware file is executed.

[0032] In a third aspect, an embodiment of the present invention provides a firmware storage device, wherein the chip includes a configuration area, a running area, and a backup area, the chip processor performs a read or write operation on the configuration area, the running area, and the backup area, and the configuration area is prohibited from being read by an external device, and the device includes:

[0033] A detection module, used to detect whether there is a burning tool communicating with the chip;

[0034] A communication module, used for obtaining the original firmware burned by the burning tool; storing the original firmware in the running area; and storing the compressed file in the backup area;

[0035] The processing module is used to erase the data stored in the running area; automatically generate a key randomly and store the key in the configuration area; based on the key and the compression algorithm built into the chip processor, perform compression and encryption operations on the original firmware to obtain a compressed file.

[0036] In a fourth aspect, an embodiment of the present invention provides a chip processor, comprising: a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the method described in any one of the first aspects is implemented.

[0037] In a fifth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method as described in any one of the first aspects are executed.

[0038] The beneficial effects of the embodiments of the present invention include, for example: placing the firmware file in the running area, and automatically erasing the data in the running area as long as it is connected to the external device for communication, so as to prevent the firmware in the running area from being copied by crackers to crack the chip. In addition, the chip processor is prohibited from being accessed by external devices, further preventing crackers from indirectly obtaining the firmware file through the instructions processed by the chip to crack the chip. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 A schematic diagram of the structure of a chip processor provided by an embodiment of the present invention.

[0041] Figure 2 One of the flowchart diagrams of a firmware storage method provided by an embodiment of the present invention.

[0042] Figure 3 A schematic diagram of the structure of a storage space of a chip provided by an embodiment of the present invention.

[0043] Figure 4 The second flowchart of a firmware storage method provided by an embodiment of the present invention.

[0044] Figure 5 A third flowchart of a firmware storage method provided by an embodiment of the present invention.

[0045] Figure 6 A fourth flowchart of a firmware storage method provided in an embodiment of the present invention.

[0046] Figure 7 One of the flowchart diagrams of a firmware reading method provided by an embodiment of the present invention.

[0047] Figure 8 The second flowchart of a firmware reading method provided by an embodiment of the present invention.

[0048] Fig. 9 A schematic diagram of functional modules of a firmware storage device provided by an embodiment of the present invention.

[0049] Icon: 100 - chip processor; 110 - communication unit; 120 - memory; 130 - processor;

[0050] 200 - firmware storage device; 210 - detection module; 220 - communication module; 230 - processing module. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions 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 part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0052] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. 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.

[0053] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0054] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0055] In order to protect the firmware and prevent the chip from being cracked, the prior art usually adopts the following two methods.

[0056] The first method is to encrypt the firmware data and save it in the flash memory (Flash). After the chip is powered on, the firmware data is decrypted and saved in the random access memory (RAM), and then the program generated by the firmware is executed. After the power is turned off, the data stored in the RAM will be automatically cleared. In this way, the cracker can only obtain the encrypted firmware file stored in the Flash, thereby preventing the chip from being cracked. However, since RAM is more expensive than Flash, and the chip has certain requirements for RAM space when running, the chip development cost is high.

[0057] Another way is to use wireless communication to burn the firmware to prevent crackers from obtaining firmware data. However, wireless communication will affect the speed of data or command transmission, and the accuracy of transmission will also be affected, making it difficult for developers to debug the firmware.

[0058] Based on this, please refer to Figure 1, is a schematic diagram of a chip processor 100 according to an embodiment of the present invention. The chip processor 100 includes a memory 120 , a processor 130 and a communication unit 110 .

[0059] The memory 120, the processor 130 and the communication unit 110 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. At least one of the firmware storage method and the firmware reading method can be stored in the memory 120 in the form of software or firmware (Firmware) or a software function module solidified in the operating system (OS) of the chip processor 100. The processor 130 is used to execute the executable module stored in the memory 120.

[0060] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the processor 130 executes the program after receiving an execution instruction. The communication unit 110 is used to communicate with an external device, a backup area, and a running area.

[0061] The processor 130 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0062] Based on the existing technology, the chip is cracked by copying the firmware in the chip. Figure 2This is one of the flowcharts of a firmware storage method provided by an embodiment of the present invention. Figure 2 As shown, it is applied to a chip processor, the chip includes a configuration area, a running area and a backup area, the chip processor performs a read or write operation on the configuration area, the running area and the backup area, and the configuration area is prohibited from being read by an external device. The method includes:

[0063] Step S101: When the chip is in communication with the burning tool, the data stored in the running area is erased.

[0064] Step S102: Obtain the original firmware burned by the burning tool.

[0065] Step S103: Automatically generate a key at random and store the key in the configuration area.

[0066] Step S104: Based on the key and the compression algorithm built into the chip processor, a compression encryption operation is performed on the original firmware to obtain a compressed file.

[0067] Step S105: store the original firmware in the running area, and store the compressed file in the backup area.

[0068] The chip is set with three storage spaces related to storage operations, namely configuration area, operation area, and backup area, to prevent the chip from being cracked. The specific settings to prevent the chip from being cracked are as follows:

[0069] All burning and storage operations are controlled and executed by the chip processor, such as encryption, compression, etc., and the configuration area is set to be prohibited from being read by external devices to prevent crackers from obtaining keys through the chip and indirectly obtaining firmware files to crack the chip.

[0070] The original firmware is stored in the running area. When it is detected that the chip is connected to an external device, the data in the running area will be automatically erased to prevent the original firmware from being obtained by the cracker and the chip from being cracked.

[0071] The compressed files are stored in the backup area so that the original firmware stored in the running area can be restored even if it is erased. The backup area stores compressed files, and the related encryption and compression algorithms are also determined by the built-in chip processor, so that even if the cracker obtains the compressed files, he cannot successfully perform the decryption and decompression operations, and thus cannot obtain the original firmware, that is, it is impossible to achieve chip cracking by disassembly and other methods.

[0072] Based on the above three settings, it is impossible for crackers to crack the chip.

[0073] Through the above settings, while preventing the chip from being cracked, the use of wired connection communication for debugging makes it convenient for developers to perform debugging work.

[0074] In one implementation, Figure 3 As shown, the programs and data in the configuration area, backup area, and running area can be placed in a flash memory (Flash) to reduce development costs. The chip processor can read or write the programs and data stored in the configuration area, backup area, and running area to achieve corresponding functions.

[0075] The configuration area stores programs used by the chip processor to control the operation of the chip system, such as programs for saving chip system configuration, programs for communicating with the burning tool, programs for compressing and encrypting the original firmware, and programs for supporting user debugging.

[0076] In one implementation, the configuration area is set to prohibit external devices from reading it, which can effectively prevent crackers from obtaining the program running on the chip system and sending relevant instructions to the running area or backup area to indirectly obtain the firmware file, that is, cracking the chip.

[0077] In one implementation, the operation area is provided with read protection. After the read protection is provided, after power-on or reset, the external device will not be able to read the content of the operation area.

[0078] It should be explained that the method embodiments of the present invention can be applied to various types of chips, such as MCU chips, FPGA chips, DSP chips, etc.

[0079] Continue reading Figure 2 In one implementation, after step S105 is completed, it indicates that the original firmware is burned. After the original firmware is burned, a new firmware flag can be set on the chip processor to record whether there is a new firmware and whether the data in the running area is erased, so as to facilitate the judgment of whether the firmware reading method needs to be executed later.

[0080] After burning the firmware file, developers may need to debug the firmware to make sure that the firmware functions can be implemented on the chip. Figure 4 A second flowchart of a firmware storage method provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, step S105 may be followed by:

[0081] Step S201: If a debugging instruction is received, debugging is performed according to the received debugging instruction to ensure that the functions of the original firmware can be successfully implemented on the chip.

[0082] Step S202: After debugging is completed, erase the data stored in the running area.

[0083] Step S203: If no debugging instruction is received, the data stored in the running area is erased.

[0084] In one implementation, after the burning is completed, the chip continues to maintain a communication connection state with the burning tool. In the case that the chip is not reset or powered on again, it enters the debugging mode according to the debugging instruction received from the developer. After entering the debugging mode, the developer can debug the firmware to ensure that the functions of the firmware can be implemented on the chip.

[0085] To further increase the difficulty of cracking, the chip processor is also equipped with a variety of compression algorithms. Figure 5 The third flowchart of a firmware storage method provided by an embodiment of the present invention. Figure 5 As shown, the specific implementation of step S104 can be as follows:

[0086] Step S104a: arbitrarily select two or more compression algorithms from a plurality of compression algorithms, and randomly combine the two or more compression algorithms to obtain a target compression algorithm.

[0087] Step S104b: perform compression and encryption operations on the original firmware according to the key and the target compression algorithm to obtain a compressed file.

[0088] In one implementation, the use of a compression algorithm is similar to the use of an encryption algorithm. The compression algorithm may use an existing compression algorithm, such as a Huffman compression algorithm, a lossless compression algorithm, etc., and may also be set according to actual application requirements.

[0089] For example, the principle of the compression algorithm can be that the original data {aabbbcccccaaa}, a total of 13 data, can be converted into {a2b3c5a3} to indicate that the data is composed of 2 a's, 3 b's, 5 c's, and 3 a's, and after compression it becomes 8 data.

[0090] For another example, the principle of the compression algorithm may be to compress the obtained n*n array set in a diagonal manner, that is, the data above the diagonal line may be deleted to reduce the amount of data.

[0091] In one implementation, a compression algorithm may be randomly selected. Alternatively, two or more compression algorithms may be randomly selected and randomly combined, that is, the order in which the compression algorithms are executed is not required, so as to increase the difficulty of cracking. For example, in the first method, the first compression algorithm, the second compression algorithm, and the third compression algorithm are selected, and the target compression algorithm obtained may be to first execute the third compression algorithm on the file, then execute the second compression algorithm on the file, and finally execute the first compression algorithm on the file.

[0092] In one implementation, the compression algorithm used and the order in which compression is performed using the compression algorithm can be recorded, so that when the compressed file is subsequently decompressed, the decompression operation can be performed in sequence in the reverse order of the compression algorithm arrangement order to obtain the firmware file.

[0093] In one implementation, the encryption operation may be performed first and then the compression operation, or the compression operation may be performed first and then the encryption operation. The encryption operation may also be performed separately on the compressed files obtained each time using the compression algorithm. For example, in the process of performing the compression operation using the target compression algorithm, a first compressed file and a second compressed file may be obtained. The encryption operation may be performed on the first compressed file to obtain a first encrypted compressed file, and then the compression operation may be performed on the first encrypted compressed file to obtain a second compressed file.

[0094] To further strengthen the protection of firmware data, an encryption algorithm is built into the chip processor to encrypt the compressed file. The specific implementation of step S104b can be as follows:

[0095] From a plurality of encryption algorithms, two or more encryption algorithms are arbitrarily selected, and the two or more encryption algorithms are randomly combined to obtain a target encryption algorithm.

[0096] According to the key and the target encryption algorithm, the encryption operation is performed on the original firmware that has completed the compression operation to obtain a compressed file.

[0097] In one implementation, one encryption algorithm may be randomly selected, or two or more encryption algorithms may be randomly selected and randomly combined, that is, the order in which the encryption algorithms are executed is not required.

[0098] In one implementation, the encryption algorithm can use an existing encryption algorithm to encrypt the firmware file, for example, a homomorphic encryption algorithm, an md5 encryption algorithm, etc. A corresponding encryption algorithm can also be designed according to actual application requirements to prevent cracking from using the existing algorithm to obtain the original firmware file.

[0099] For example, an addition encryption algorithm may be used: y=x+a, where y is the data after encryption, x is the data before encryption, and a is a randomly generated parameter, namely, a key. The subsequent steps are similar and will not be described in detail.

[0100] For another example, an XOR encryption algorithm may be used: y=x^a.

[0101] For another example, a displacement encryption algorithm can be used: y = x < <a。

[0102] In one implementation, in order to increase the difficulty of cracking, the encryption algorithms can be randomly combined to obtain the target encryption algorithm. For example, the target encryption algorithm can be to first execute the above-mentioned XOR encryption algorithm and then execute the above-mentioned displacement encryption algorithm. The key of each algorithm can also be different, which increases the randomness of key generation and further increases the difficulty of cracking.

[0103] To ensure that the firmware file obtained after subsequent decompression is the same as the original firmware file, that is, no firmware data is missing. Figure 6 FIG4 is a flowchart of a firmware storage method provided by an embodiment of the present invention. Figure 6 As shown, the method also includes:

[0104] Step S301: Obtain the length and checksum of the original firmware from the burning tool.

[0105] Step S302: Store the length and check code in the backup area.

[0106] Get the length and checksum of the original firmware from the burning tool, and place them in the backup area. After compressing the file, you can verify the decompressed firmware file by the length and checksum to ensure the integrity of the decompressed firmware file.

[0107] It should be explained that multiple data files are stored in a continuous storage space. When obtaining a data file, it is necessary to determine the start and end positions of the data file. There may be errors in the determination of the start or end positions, resulting in incomplete data file acquisition or excessive acquisition of data from other data files.

[0108] In one implementation, the length of the compressed file can be calculated to facilitate the acquisition of the correct compressed file when the firmware reading method is subsequently executed. That is, the length of the compressed file can be calculated, and when a decompression operation is required later, the location of the compressed file can be found in the storage space, and the data of the length of the compressed file can be intercepted from the storage space, thereby improving the speed of obtaining the compressed file and avoiding the situation of obtaining errors, that is, obtaining data other than the compressed file or obtaining an incomplete compressed file.

[0109] After the original firmware is compressed, it needs to be decompressed so that the program corresponding to the firmware can run on the chip. Figure 7 One of the flowcharts of a firmware reading method provided by an embodiment of the present invention is as follows: Figure 7 As shown, a chip processor applied to a chip includes a configuration area, an operation area, and a backup area. The chip processor performs a read or write operation on the configuration area, the operation area, and the backup area. The configuration area is prohibited from being read by an external device. The method includes:

[0110] Step S401: When the chip is not in communication connection with an external device and the data in the running area is erased, the key stored in the configuration area and the compressed file stored in the backup area are obtained.

[0111] Step S402: Decompress and decrypt the compressed file according to the key and the compression algorithm built into the chip processor to obtain a firmware file.

[0112] Step S403: store the firmware file in the running area.

[0113] In one implementation, the firmware flag bit set in the chip processor can be used to determine whether the data in the running area is erased. If not, the firmware file stored in the running area is directly used to implement the firmware function on the chip.

[0114] In one implementation, a target compression algorithm and a compressed file stored in a backup area are obtained, and a decompression operation is performed on the compressed file in the reverse order of the compression algorithms in the target compression algorithm. For example, if the order of the target compression algorithms is a first compression algorithm and a second compression algorithm, the second compression algorithm is first used to decompress the compressed file to obtain a first compressed file, and then the first compression algorithm is used to decompress the first compressed file to finally obtain a firmware file.

[0115] To ensure that the firmware file is complete, Figure 8 The second flowchart of a firmware reading method provided by an embodiment of the present invention is shown in FIG. Figure 8 As shown, after step S403, the method further includes:

[0116] Step S501, obtain the length and check code stored in the backup area.

[0117] Step S502, calculating the length and checksum of the firmware file;

[0118] Step S503: If the calculated length is consistent with the obtained length, and the calculated check code is consistent with the obtained check code, the firmware file is complete and the firmware file is executed.

[0119] Get the length and checksum of the original firmware, calculate the length and checksum of the firmware file, and determine whether the length of the original firmware is consistent with the length of the firmware file, and whether the checksum of the original firmware is consistent with the checksum of the firmware file. If they are consistent, it means that the obtained firmware file is complete, thus ensuring that the firmware file can run normally on the chip.

[0120] In one implementation, the checksum may be calculated in a variety of ways, for example, the checksum of the original firmware and the firmware file may be calculated in an md5 manner.

[0121] Fig. 9 A functional module diagram of a firmware storage device 200 is provided for an embodiment of the present invention. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Fig. 9 As shown, the device includes a detection module 210, a communication module 220 and a processing module 230, which is applied to a chip processor of a chip. The chip includes a configuration area, an operation area and a backup area. The chip processor performs a read or write operation on the configuration area, the operation area and the backup area. The configuration area is prohibited from being read by an external device. The device includes:

[0122] A detection module 210 is used to detect whether there is a communication connection between the burning tool and the chip;

[0123] The communication module 220 is used to obtain the original firmware burned by the burning tool; store the original firmware in the running area; and store the compressed file in the backup area;

[0124] The processing module 230 is used to erase the data stored in the running area; automatically generate a key and store the key in the chip processor; based on the key and the compression algorithm built into the chip processor, perform compression and encryption operations on the original firmware to obtain a compressed file.

[0125] In one implementation, the chip processor further includes a configuration module for configuring the operating environment when the chip is powered on to ensure that the chip starts normally, that is, the program on the chip can run.

[0126] In one implementation, the processing module 230 is also used to obtain the firmware flag bit after each power-on or hardware reset of the chip to determine whether the above firmware reading method needs to be executed.

[0127] In one implementation, the operation area is restricted by the chip processor and has read protection. After the burning is completed, the external device cannot perform a read operation on the operation area.

[0128] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0129] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0130] An embodiment of the present invention further provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method embodiment are executed.

[0131] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0132] In summary, the embodiments of the present invention provide a firmware storage method, a firmware reading method, a device, a chip processor, and a storage medium. The firmware file is placed in the operation area, and as long as it is connected to the external device for communication, the data in the operation area is automatically erased to prevent the firmware in the operation area from being copied by the cracker to crack the chip. In addition, the chip processor is prohibited from being accessed by external devices to further prevent the cracker from indirectly obtaining the firmware file through the instructions processed by the chip to crack the chip.

[0133] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A firmware storage method, characterized in that: Applied to a chip processor, the chip includes a configuration area, a running area and a backup area, the chip processor performs a read or write operation on the configuration area, the running area and the backup area, the configuration area is prohibited from being read by an external device, and the configuration area stores a compression encryption and decompression and decryption program of the original firmware; the method includes: When the chip is in communication connection with the burning tool, the data stored in the running area is erased to obtain the original firmware burned by the burning tool; Automatically randomly generate a key and store the key in the configuration area; Running the compression encryption and decompression and decryption program, based on the key and the compression algorithm built into the chip processor, performing compression encryption operations on the original firmware to obtain a compressed file; storing the original firmware in the running area; storing the compressed file in the backup area; When it is detected that the chip is connected to an external device, erasing the data stored in the operation area; If a debugging instruction is received, debugging is performed according to the received debugging instruction to ensure that the functions of the original firmware can be successfully implemented on the chip; after the debugging is completed, the data stored in the running area is erased; if no debugging instruction is received, the data stored in the running area is erased.

2. The method according to claim 1, characterized in that There are multiple compression algorithms. The step of performing compression and encryption operations on the original firmware based on the key and the compression algorithm built into the chip processor to obtain a compressed file includes: Randomly selecting two or more compression algorithms from the multiple compression algorithms, and randomly combining the two or more compression algorithms to obtain a target compression algorithm; According to the key and the target compression algorithm, a compression encryption operation is performed on the original firmware to obtain a compressed file.

3. The method according to claim 2, characterized in that The chip processor stores a plurality of encryption algorithms, and the step of performing compression and encryption operations on the original firmware according to the key and the target compression algorithm to obtain a compressed file includes: Randomly selecting two or more encryption algorithms from the multiple encryption algorithms, and randomly combining the two or more encryption algorithms to obtain a target encryption algorithm; According to the key and the target encryption algorithm, an encryption operation is performed on the original firmware that has completed the compression operation to obtain the compressed file.

4. The method according to claim 1, characterized in that The method further comprises: Obtaining the length and checksum of the original firmware from the burning tool; The length and the check code are stored in the backup area.

5. A firmware reading method, characterized in that: Applied to a chip processor, the chip includes a configuration area, a running area and a backup area, the chip processor performs a read or write operation on the configuration area, the running area and the backup area, the configuration area is prohibited from being read by an external device, and the configuration area stores a compression encryption and decompression and decryption program of the original firmware; the method includes: When the chip is not in communication connection with an external device and the data in the operation area is erased, acquiring the key stored in the configuration area and the compressed file stored in the backup area; Run the compression and encryption and decompression and decryption programs, and decompress and decrypt the compressed file according to the key and the compression algorithm built into the chip processor to obtain a firmware file; Storing the firmware file in the running area; When it is detected that the chip is connected to an external device, erasing the data stored in the operation area; If a debugging instruction is received, debugging is performed according to the received debugging instruction to ensure that the functions of the original firmware can be successfully implemented on the chip; after the debugging is completed, the data stored in the running area is erased; if no debugging instruction is received, the data stored in the running area is erased.

6. The method according to claim 5, characterized in that After the step of storing the firmware file in the running area, the method further comprises: Obtain the length and check code stored in the backup area; Calculating the length and checksum of the firmware file; If the calculated length is consistent with the obtained length, and the calculated check code is consistent with the obtained check code, then the firmware file is complete and the firmware file is executed.

7. A firmware storage device, characterized in that: The chip includes a configuration area, a running area, and a backup area. The chip processor performs a read or write operation on the configuration area, the running area, and the backup area. The configuration area is prohibited from being read by an external device. The configuration area stores a compression encryption and decompression and decryption program of the original firmware. The device includes: A detection module, used to detect whether there is a burning tool communicating with the chip; A communication module, used for obtaining the original firmware burned by the burning tool; storing the original firmware in the running area; and storing the compressed file in the backup area; A processing module, used to erase the data stored in the running area; automatically generate a key randomly, and store the key in the configuration area; run the compression encryption and decompression and decryption program, and perform compression encryption operations on the original firmware based on the key and the compression algorithm built into the chip processor to obtain a compressed file; The processing module is further configured to erase the data stored in the operation area when it is detected that the chip is connected to an external device; The processing module is also used to perform debugging according to the received debugging instructions if a debugging instruction is received to ensure that the functions of the original firmware can be successfully implemented on the chip; after the debugging is completed, erase the data stored in the running area; if no debugging instruction is received, erase the data stored in the running area.

8. A chip processor, characterized in that: include: A memory, a processor, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the method according to any one of claims 1 to 4 is implemented.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are executed.

Citation Information

Patent Citations

  • Code protection method for chip

    CN111475815A

  • Embedded device firmware security upgrading method and system, terminal and storage medium

    CN111596938A

  • BMC firmware protection method, system and device and readable storage medium

    CN113626803A