CN115344434B - Patching method and device, electronic equipment and storage medium - Google Patents

Patching method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115344434B
CN115344434B CN202211279827.1A CN202211279827A CN115344434B CN 115344434 B CN115344434 B CN 115344434B CN 202211279827 A CN202211279827 A CN 202211279827A CN 115344434 B CN115344434 B CN 115344434B
Authority
CN
China
Prior art keywords
patch
address
security chip
stored
backup
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211279827.1A
Other languages
Chinese (zh)
Other versions
CN115344434A (en
Inventor
王馨
杨玲
刘静亚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ziguang Tongxin Microelectronics Co Ltd
Original Assignee
Ziguang Tongxin Microelectronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ziguang Tongxin Microelectronics Co Ltd filed Critical Ziguang Tongxin Microelectronics Co Ltd
Priority to CN202211279827.1A priority Critical patent/CN115344434B/en
Publication of CN115344434A publication Critical patent/CN115344434A/en
Application granted granted Critical
Publication of CN115344434B publication Critical patent/CN115344434B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates

Abstract

The application relates to the technical field of patches and discloses a method for patching, which comprises the following steps: acquiring a patch address of an installed patch of a security chip; comparing the patch address with a preset first address and a preset second address respectively, and determining a backup patch according to a comparison result; the first address and the second address are both memory addresses within the secure chip for storing the patch. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching. The application also discloses a patching device, electronic equipment and a storage medium.

Description

Patching method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of patch technologies, and for example, to a method and an apparatus for patching, an electronic device, and a storage medium.
Background
Currently, there is a technical need for patching, whether for a system or a chip. In the patching process, there may be situations where patching fails, such as: chinese patent document No. CN102156651A discloses: the client cannot meet the requirement of the patch installation condition due to some technical reasons, so that the patch cannot be installed.
However, in case of failure of patching, the original function may not be used normally. For example: chinese patent publication No. CN101931944A discloses: because the online upgraded version is the running version in the mobile phone, the original data can be deleted when new data is written in the flash memory, which causes some functions to be abnormal because the original data is inconsistent with the updated data.
Various problems still occur after the safety chip leaves the factory, and at the moment, the safety chip needs to be patched so that the safety chip can be normally and safely used. In the related art, when a security chip is patched, an installed patch in the security chip is erased, and then a new patch is directly downloaded to the security chip, so as to directly patch the security chip. However, in the process of patching the security chip, a situation of failure in patching may occur, so that the original functions of the security chip cannot be used normally.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview nor is intended to identify key/critical elements or to delineate the scope of such embodiments but rather as a prelude to the more detailed description that is presented later.
The embodiment of the disclosure provides a patching method and device, electronic equipment and a storage medium, so that a security chip can be recovered under the condition of failure in patching.
In some embodiments, the method for patching includes: acquiring a patch address of an installed patch of a security chip; respectively comparing the patch address with a preset first address and a preset second address, and determining a backup patch according to a comparison result; the first address and the second address are both storage addresses within the security chip for storing patches.
In some embodiments, the means for patching comprises: an obtaining module configured to obtain a patch address of an installed patch of a security chip; the comparison module is configured to compare the patch address with a preset first address and a preset second address respectively, and determine a backup patch according to a comparison result; the first address and the second address are both storage addresses within the security chip for storing patches.
In some embodiments, the electronic device comprises a processor and a memory storing program instructions, the processor being configured to, when executing the program instructions, perform the method for patching described above.
In some embodiments, the storage medium stores program instructions that, when executed, perform the above-described method for patching.
The method and the device for patching, the electronic equipment and the storage medium provided by the embodiment of the disclosure can realize the following technical effects: by obtaining the patch address of the installed patch of the security chip. And comparing the patch address with a preset first address and a preset second address respectively, and determining a backup patch according to a comparison result. The first address and the second address are both memory addresses within the secure chip for storing the patch. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the application.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the accompanying drawings and not in limitation thereof, in which elements having the same reference numeral designations are shown as like elements and not in limitation thereof, and wherein:
fig. 1 is a schematic diagram of a first method for patching provided by an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a second method for patching provided by embodiments of the present disclosure;
FIG. 3 is a schematic diagram of a third method for patching provided by an embodiment of the disclosure;
FIG. 4 is a schematic diagram of a fourth method for patching provided by the embodiments of the present disclosure;
FIG. 5 is a schematic diagram of an apparatus for patching provided by the embodiments of the present disclosure;
fig. 6 is a schematic diagram of an electronic device provided by an embodiment of the disclosure.
Detailed Description
So that the manner in which the features and elements of the disclosed embodiments can be understood in detail, a more particular description of the disclosed embodiments, briefly summarized above, may be had by reference to the embodiments, some of which are illustrated in the appended drawings. In the following description of the technology, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the disclosed embodiments. However, one or more embodiments may be practiced without these details. In other instances, well-known structures and devices may be shown in simplified form in order to simplify the drawing.
The terms "first," "second," and the like in the description and in the claims, and the above-described drawings of embodiments of the present disclosure, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the present disclosure described herein may be made. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions.
The term "plurality" means two or more unless otherwise specified.
In the embodiment of the present disclosure, the character "/" indicates that the preceding and following objects are in an or relationship. For example, A/B represents: a or B.
The term "and/or" is an associative relationship that describes objects, meaning that three relationships may exist. For example, a and/or B, represents: a or B, or A and B.
The term "correspond" may refer to an association or binding relationship, and a corresponds to B refers to an association or binding relationship between a and B.
The security chip provided by the embodiment of the disclosure is provided with two patch areas with the same size. The patch area is a storage area in the security chip for storing the patch. The first address is the address of one of the patch areas and the second address is the address of the other patch area. The size is the same, i.e. the storage capacity is the same. Therefore, when the security chip is upgraded, one patch area can be selected as a backup area of the installed patch, and the other patch area can be used as an upgrading area of the patch to be installed. In the process of patching the security chip, even if patching failure or patch writing failure occurs, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
In some embodiments, the patch area is for storing patch data, the patch data including: the patch code corresponding to the patch, a 2-byte patch version number, and a 4-byte CRC (Cyclic Redundancy Check) Check value.
With reference to fig. 1, an embodiment of the present disclosure provides a method for patching, including:
step S101, the electronic equipment acquires a patch address of an installed patch of the security chip.
Step S102, the electronic equipment respectively compares the patch address with a preset first address and a preset second address, and determines a backup patch according to the comparison result; the first address and the second address are both memory addresses within the secure chip for storing the patch.
By adopting the method for patching provided by the embodiment of the disclosure, the patch address of the installed patch of the security chip is obtained. And comparing the patch address with a preset first address and a preset second address respectively, and determining a backup patch according to a comparison result. The first address and the second address are both memory addresses within the secure chip for storing the patch. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
In some embodiments, the stored patch is used as the installed patch after the patch operation is performed on the security chip by using the stored patch. The patch address of the installed patch is the address to be installed of the stored patch. And storing the patch address of the installed patch in a preset address of the security chip. Obtaining a patch address of an installed patch of the security chip, that is, obtaining a patch address of the installed patch at a preset address of the security chip.
Optionally, determining the backup patch according to the comparison result includes: under the condition that the patch address is the same as the first address, determining the patch stored at the first address as a backup patch; in the case where the patch address is the same as the second address, the patch stored at the second address is determined as a backup patch. The first address and the second address are different storage addresses of the security chip. In this way, by comparing the patch address with the first address and the second address, it is possible to determine at which memory address the installed patch that is being executed by the security chip is stored, and determine the installed patch that is being executed and stored in the memory address as the backup patch. So that the function of the security chip can be restored by using the backup patch under the condition of failure in patching or failure in writing the patch.
Optionally, determining a backup patch according to the comparison result, further comprising: under the condition that the patch address, the first address and the second address are different, acquiring an installed patch; the installed patch is stored to the first address or the second address, and the installed patch is determined to be a backup patch. Therefore, under the condition that the patch address, the first address and the second address are different, the patch needs to be stored in the patch area first, so that the backup patch can be determined during subsequent patching.
Optionally, after determining the backup patch according to the comparison result, the method further includes: obtaining a patch to be installed; and determining the storage address of the non-stored backup patch as the address to be installed, and storing the patch to be installed to the address to be installed. Therefore, the installed patch used by the security chip can be reserved when the patch to be installed is stored in the storage address where the backup patch is not stored, and the security chip can be recovered by using the backup patch even if the patching fails or the patch writing fails when a new patch is patched for the security chip.
Further, determining a storage address where the backup patch is not stored as an address to be installed includes: and determining the second address as the address to be installed under the condition that the storage address corresponding to the backup patch is the first address. And determining the first address as the address to be installed under the condition that the storage address corresponding to the backup patch is the second address.
With reference to fig. 2, a second method for patching is provided in an embodiment of the present disclosure, which includes:
in step S201, the electronic device obtains a patch address of an installed patch of the security chip.
Step S202, the electronic equipment compares the patch address with a preset first address and a preset second address respectively, and determines a backup patch according to the comparison result; the first address and the second address are both memory addresses within the secure chip for storing the patch.
In step S203, the electronic device obtains a patch to be installed.
Step S204, the electronic device determines the storage address where the backup patch is not stored as the address to be installed, and stores the patch to be installed to the address to be installed.
By adopting the method for patching provided by the embodiment of the disclosure, the patch address of the installed patch of the security chip is obtained. And comparing the patch address with a preset first address and a preset second address respectively, and determining a backup patch according to a comparison result. And obtaining a patch to be installed. And determining the storage address where the backup patch is not stored as the address to be installed, and storing the patch to be installed to the address to be installed. Thus, two addresses for storing patches are set in the security chip, and the backup patches are predetermined. And then storing the patch to be installed to the address to be installed, wherein the backup patch cannot be covered by the patch to be installed. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
Further, before storing the patch to be installed to the address to be installed, the method further includes: and erasing the patch data stored in the address to be installed. Wherein the patch data includes: the corresponding patch code of the patch, the version number of the patch of 2 bytes and the CRC check value of 4 bytes. In this way, the security chip may perform a plurality of patching operations, so that the first address and the second address both store patches. And the patch data stored in the address to be installed is erased, so that a new patch can be conveniently downloaded to the address to be installed, and the new patch and the old patch can not conflict.
Further, storing the patch to be installed to the address to be installed includes: calculating a first CRC value of a patch to be installed; and comparing the first CRC value with a preset verification value, and storing the patch to be installed to the address to be installed under the condition that the first CRC value is consistent with the preset verification value. In this way, cyclic redundancy checks can be used to detect or check for errors that may occur after data transmission or storage. Whether errors occur in the data transmission process can be detected by comparing the first CRC check value with a preset verification value, and therefore the correctness of the patch to be installed is guaranteed.
Optionally, after storing the patch to be installed to the address to be installed, the method further includes: verifying whether the stored patch is complete; the stored patch is a to-be-installed patch stored in the to-be-installed address; and under the condition that the stored patch is complete, the stored patch is utilized to carry out patching operation on the security chip. Therefore, the safe chip can be patched by using the stored patch under the condition that the stored patch is complete, so that the safe chip can smoothly complete patching operation.
With reference to fig. 3, a third method for patching is provided in an embodiment of the present disclosure, including:
in step S301, the electronic device obtains a patch address of an installed patch of the security chip.
Step S302, the electronic device compares the patch address with a preset first address and a preset second address, and determines a backup patch according to the comparison result.
Step S303, the electronic device obtains a patch to be installed.
Step S304, the electronic device determines the storage address where the backup patch is not stored as the address to be installed, and stores the patch to be installed to the address to be installed.
Step S305, the electronic equipment verifies whether the stored patch is complete; the stored patch is a to-be-installed patch stored in the to-be-installed address.
Step S306, when the stored patch is complete, the electronic device performs a patching operation on the security chip by using the stored patch.
By adopting the method for patching provided by the embodiment of the disclosure, the patch address of the installed patch of the security chip is obtained. And acquiring the patch address of the installed patch of the security chip. The electronic device obtains a patch to be installed. And determining the storage address where the backup patch is not stored as the address to be installed, and storing the patch to be installed to the address to be installed. Verifying whether the stored patch is complete; the stored patch is a to-be-installed patch stored in the to-be-installed address. And under the condition that the stored patch is complete, performing patching operation on the security chip by using the stored patch. Thus, two addresses for storing patches are set in the security chip, and the backup patches are predetermined. And storing the patch to be installed to the address to be installed. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching. Meanwhile, under the condition that the stored patch is complete, the stored patch is utilized to patch the security chip, so that the security chip can smoothly complete the patching operation.
Further, verifying whether the stored patch is complete includes: acquiring a patch version number of a stored patch; comparing the patch version number with a preset expected version number to obtain a first comparison result; calculating a second CRC value of the stored patch, and comparing the second CRC value with a preset verification value to obtain a second comparison result; and determining whether the stored patch is complete according to the first comparison result and the second comparison result. In this way, comparing the patch version number with a preset expected version number can determine whether the stored patch is the patch version that the user wishes to download. Meanwhile, the second CRC value is compared with a preset verification value, and whether the stored patch has a problem in the storage process can be determined. Whether the stored patch is complete or not is determined through the two comparison results, and the safe chip can complete the patching operation smoothly.
In some embodiments, a desired version number is input to the secure chip in response to a user version number input instruction. The desired version number is obtained from the secure chip.
Further, determining whether the stored patch is complete according to the first comparison result and the second comparison result includes: determining that the stored patch is complete under the condition that the first comparison result is that the patch version number is consistent with a preset expected version number and the second comparison result is that the second CRC check value is consistent with a preset verification value; otherwise, the stored patch is determined to be incomplete.
With reference to fig. 4, a fourth method for patching is provided in an embodiment of the present disclosure, including:
in step S401, the electronic device obtains a patch address of an installed patch of the secure chip, and then performs step S402.
Step S402, the electronic equipment determines whether the patch address is consistent with a preset first address, and if the patch address is consistent with the preset first address, the step S403 is executed; in the case where the patch address does not coincide with the preset first address, step S404 is performed.
In step S403, the electronic device determines the patch stored at the first address as a backup patch, and then performs step S406.
Step S404, the electronic device determines whether the patch address is consistent with the preset second address, and if the patch address is consistent with the preset second address, the electronic device executes step S405; in the case where the patch address does not coincide with the preset second address, step S414 is performed.
In step S405, the electronic device determines the patch stored at the second address as a backup patch, and then performs step S406.
Step S406, the electronic equipment acquires a patch to be installed; calculating a first CRC value of a patch to be installed; then, step S407 is executed.
Step S407, the electronic device determines whether the first CRC check value is consistent with a preset verification value; executing step S408 if the first CRC check value is consistent with the preset verification value; in the case where the first CRC check value does not coincide with the preset verification value, step S415 is performed.
Step S408, the electronic equipment stores the patch to be installed to the address to be installed; then, step S409 is performed.
Step S409, the electronic equipment acquires the patch version number of the stored patch; the stored patch is a to-be-installed patch stored in the to-be-installed address; then, step S410 is performed.
Step S410, the electronic equipment determines whether the patch version number is consistent with a preset expected version number; executing step S411 if the patch version number is consistent with the preset expected version number; in the case where the patch version number does not coincide with the preset desired version number, step S415 is performed.
Step S411, the electronic equipment calculates a second CRC check value of the stored patch; then, step S412 is performed.
Step S412, the electronic device determines whether the second CRC check value is consistent with a preset verification value; in case the second CRC check value is identical to the preset verification value, performing step S413; in the case where the second CRC check value does not coincide with the preset verification value, step S415 is performed.
In step S413, the electronic device performs a patching operation on the security chip by using the stored patch.
In step S414, the electronic device obtains the installed patch and stores the installed patch to the first address or the second address.
In step S415, the flow ends.
By adopting the method for patching provided by the embodiment of the disclosure, the backup patch is determined, and the patch to be installed is stored in the address to be installed. And verifying the patch to be installed, and performing patching operation on the security chip by using the patch to be installed under the condition of successful verification. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
Optionally, after the patch operation is performed on the security chip by using the stored patch, the method further includes: and determining whether the function of the security chip is normal according to a preset judgment flow, and performing patching operation on the security chip by using the backup patch under the condition that the function of the security chip is abnormal.
Optionally, after the patch operation is performed on the security chip by using the stored patch, the method further includes: and updating the patch address of the installed patch of the security chip.
Optionally, updating the patch address of the installed patch of the security chip includes: and determining whether the function of the security chip is normal according to a preset judgment flow, and updating the patch address of the installed patch of the security chip under the condition that the function of the security chip is normal.
In some embodiments, updating the patch address of the installed patch of the secure chip includes: and acquiring the storage address of the stored patch, and replacing the patch address of the installed patch with the storage address.
In some embodiments, the patch address of the installed patch is not stored at the preset address of the secure chip, i.e. the patch is first patched for the secure chip. And storing the patch to be installed acquired by the electronic equipment to the first address or the second address, and performing patching operation on the security chip by using the stored patch.
In some embodiments, updating the upgraded function B is referred to as B'. Patch A includes B'. After the secure chip finishes patching A, when the secure chip runs to the function B, the secure chip directly points to B ' in the patch A and executes B ', so that the function B is replaced by the B '.
In some embodiments, since there is only one patch package in use in the security chip, there may be one or more updated and upgraded functions in one patch package, so as to patch a plurality of places in the security chip that need to be patched.
As shown in fig. 5, an apparatus for patching according to an embodiment of the present disclosure includes an obtaining module 501 and a comparing module 502. An obtaining module 501 configured to obtain a patch address of an installed patch of a secure chip. A comparing module 502 configured to compare the patch address with a preset first address and a preset second address respectively, and determine a backup patch according to the comparison result. The first address and the second address are both memory addresses within the secure chip for storing the patch.
By adopting the device for patching provided by the embodiment of the disclosure, the patch address of the installed patch of the security chip is obtained through the obtaining module. The comparison module compares the patch address with a preset first address and a preset second address respectively, and determines a backup patch according to a comparison result. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
As shown in fig. 6, an embodiment of the present disclosure provides an electronic device including a processor (processor) 600 and a memory (memory) 601. Optionally, the apparatus may also include a Communication Interface 602 and a bus 603. The processor 600, the communication interface 602, and the memory 601 may communicate with each other via a bus 603. The communication interface 602 may be used for information transfer. The processor 600 may call logic instructions in the memory 601 to perform the method for patching of the above-described embodiments.
Optionally, the electronic device is a computer or a server.
By adopting the electronic device provided by the embodiment of the disclosure, the patch address of the installed patch of the security chip is obtained. And comparing the patch address with a preset first address and a preset second address respectively, and determining a backup patch according to a comparison result. The first address and the second address are both memory addresses within the secure chip for storing the patch. Thus, two addresses for storing patches are set in the security chip, and backup patches are predetermined. When a new patch is applied to the security chip, even if the patch application fails or the patch writing fails, the security chip can be recovered by using the backup patch. Therefore, the safety chip can be recovered conveniently under the condition of failure in patching.
In addition, the logic instructions in the memory 601 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as a stand-alone product.
The memory 601 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, such as program instructions/modules corresponding to the methods in the embodiments of the present disclosure. The processor 600 executes functional applications and data processing, i.e. implements the method for patching in the above embodiments, by executing program instructions/modules stored in the memory 601.
The memory 601 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. In addition, the memory 601 may include a high speed random access memory, and may also include a non-volatile memory.
Embodiments of the present disclosure provide a computer-readable storage medium storing computer-executable instructions configured to perform the above-described method for patching.
Embodiments of the present disclosure provide a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the above-described method for patching.
The computer-readable storage medium described above may be a transitory computer-readable storage medium or a non-transitory computer-readable storage medium.
The technical solution of the embodiments of the present disclosure may be embodied in the form of a software product, where the computer software product is stored in a storage medium and includes one or more instructions to enable a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method of the embodiments of the present disclosure. And the aforementioned storage medium may be a non-transitory storage medium comprising: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes, and may also be a transient storage medium.
The above description and drawings sufficiently illustrate embodiments of the disclosure to enable those skilled in the art to practice them. Other embodiments may incorporate structural, logical, electrical, process, and other changes. The examples merely typify possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in or substituted for those of others. Furthermore, the words used in the specification are words of description only and are not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this application is meant to encompass any and all possible combinations of one or more of the associated listed. Furthermore, the terms "comprises" and/or "comprising," when used in this application, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Without further limitation, an element defined by the phrase "comprising a" \8230; "does not exclude the presence of additional like elements in a process, method or apparatus comprising the element. In this document, each embodiment may be described with emphasis on differences from other embodiments, and the same and similar parts between the respective embodiments may be referred to each other. For methods, products, etc. of the embodiment disclosures, reference may be made to the description of the method section for relevance if it corresponds to the method section of the embodiment disclosure.
Those of skill in the art would appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software may depend upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments. It can be clearly understood by the skilled person that, for convenience and brevity of description, the specific working processes of the system, the apparatus and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, apparatuses, etc.) may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units may be merely a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form. The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to implement the present embodiment. In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than disclosed in the description, and sometimes there is no specific order between the different operations or steps. For example, two sequential operations or steps may in fact be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. Each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Claims (7)

1. A method for patching, comprising:
acquiring a patch address of an installed patch of a security chip;
respectively comparing the patch address with a preset first address and a preset second address, and determining a backup patch according to a comparison result; the first address and the second address are both storage addresses used for storing patches in the security chip;
after determining the backup patch according to the comparison result, the method further comprises the following steps: obtaining a patch to be installed; determining a storage address where the backup patch is not stored as an address to be installed, and storing the patch to be installed to the address to be installed;
storing the patch to be installed to the address to be installed, including: calculating a first CRC value of the patch to be installed; comparing the first CRC value with a preset verification value, and storing the patch to be installed to the address to be installed under the condition that the first CRC value is consistent with the preset verification value;
after storing the patch to be installed to the address to be installed, the method further comprises the following steps: verifying whether the stored patch is complete; the stored patch is a to-be-installed patch stored in the to-be-installed address; under the condition that the stored patch is complete, utilizing the stored patch to perform patching operation on the security chip;
after the patch operation is carried out on the security chip by utilizing the stored patch, the method further comprises the following steps: determining whether the function of the security chip is normal according to a preset judgment flow, and performing patching operation on the security chip by using a backup patch under the condition that the function of the security chip is abnormal;
the security chip is provided with two patch areas with the same size; the patch area is a storage area used for storing patches in the security chip; the first address is the address of one patch area, and the second address is the address of the other patch area; the patch area is used for storing patch data, and the patch data comprises: the corresponding patch code of the patch, the version number of the patch of 2 bytes and the CRC check value of 4 bytes.
2. The method of claim 1, wherein determining a backup patch based on the comparison comprises:
under the condition that the patch address is the same as the first address, determining a patch stored at the first address as a backup patch;
and under the condition that the patch address is the same as the second address, determining a patch stored at the second address as a backup patch.
3. The method of claim 1, wherein verifying whether the stored patch is complete comprises:
acquiring a patch version number of the stored patch;
comparing the patch version number with a preset expected version number to obtain a first comparison result;
calculating a second CRC value of the stored patch, and comparing the second CRC value with a preset verification value to obtain a second comparison result;
and determining whether the stored patch is complete according to the first comparison result and the second comparison result.
4. The method of claim 1, wherein after the patching operation of the security chip by using the stored patch, further comprising:
and updating the patch address of the installed patch of the security chip.
5. An apparatus for patching, comprising:
an obtaining module configured to obtain a patch address of an installed patch of a security chip;
the comparison module is configured to compare the patch address with a preset first address and a preset second address respectively, and determine a backup patch according to a comparison result; the first address and the second address are both storage addresses used for storing patches in the security chip;
after determining the backup patch according to the comparison result, the method further comprises the following steps: obtaining a patch to be installed; determining a storage address where the backup patch is not stored as an address to be installed, and storing the patch to be installed to the address to be installed;
storing the patch to be installed to the address to be installed, including: calculating a first CRC value of the patch to be installed; comparing the first CRC value with a preset verification value, and storing the patch to be installed to the address to be installed under the condition that the first CRC value is consistent with the preset verification value;
after storing the patch to be installed to the address to be installed, the method further comprises the following steps: verifying whether the stored patch is complete; the stored patch is a to-be-installed patch stored in the to-be-installed address; under the condition that the stored patch is complete, utilizing the stored patch to carry out patching operation on the security chip;
after the patch operation is carried out on the security chip by utilizing the stored patch, the method further comprises the following steps: determining whether the function of the security chip is normal according to a preset judgment flow, and performing patching operation on the security chip by using a backup patch under the condition that the function of the security chip is abnormal;
the security chip is provided with two patch areas with the same size; the patch area is a storage area used for storing patches in the security chip; the first address is the address of one patch area, and the second address is the address of the other patch area; the patch area is used for storing patch data, and the patch data comprises: the corresponding patch code of the patch, the version number of the patch of 2 bytes and the CRC check value of 4 bytes.
6. An electronic device comprising a processor and a memory storing program instructions, wherein the processor is configured to perform the method for patching according to any one of claims 1 to 4 when executing the program instructions.
7. A storage medium storing program instructions which, when executed, perform a method for patching according to any of claims 1 to 4.
CN202211279827.1A 2022-10-19 2022-10-19 Patching method and device, electronic equipment and storage medium Active CN115344434B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211279827.1A CN115344434B (en) 2022-10-19 2022-10-19 Patching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211279827.1A CN115344434B (en) 2022-10-19 2022-10-19 Patching method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115344434A CN115344434A (en) 2022-11-15
CN115344434B true CN115344434B (en) 2023-03-24

Family

ID=83956987

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211279827.1A Active CN115344434B (en) 2022-10-19 2022-10-19 Patching method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115344434B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115543403B (en) * 2022-11-29 2023-03-21 紫光同芯微电子有限公司 System upgrading method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113312270A (en) * 2021-06-25 2021-08-27 展讯通信(上海)有限公司 ROM code repairing method and device, readable storage medium and terminal

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8291407B2 (en) * 2002-06-12 2012-10-16 Symantec Corporation Systems and methods for patching computer programs
CN100407638C (en) * 2004-04-14 2008-07-30 华为技术有限公司 Method for software upgrading and withdrawing
CN108572792B (en) * 2017-06-13 2021-06-11 北京金山云网络技术有限公司 Data storage method and device, electronic equipment and computer readable storage medium
US11237928B2 (en) * 2019-12-02 2022-02-01 Advanced Micro Devices, Inc. Method for a reliability, availability, and serviceability-conscious huge page support
CN111562934B (en) * 2020-04-03 2023-08-11 深圳震有科技股份有限公司 Software system upgrading method based on hot patch, terminal and storage medium
CN115184764A (en) * 2021-04-02 2022-10-14 湖北芯擎科技有限公司 Chip testing method and device, electronic equipment and storage medium
CN113885926A (en) * 2021-09-10 2022-01-04 北京中电华大电子设计有限责任公司 Operating system online upgrading method based on security chip

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113312270A (en) * 2021-06-25 2021-08-27 展讯通信(上海)有限公司 ROM code repairing method and device, readable storage medium and terminal

Also Published As

Publication number Publication date
CN115344434A (en) 2022-11-15

Similar Documents

Publication Publication Date Title
CN109408153B (en) Software starting method and software upgrading method
US10162625B2 (en) Vehicle control storage methods and systems
CN109032632B (en) FOTA upgrading method, wireless communication terminal and storage medium
CN106020865A (en) System upgrading method and device
EP2076056A1 (en) Management method for intelligent terminal system and intelligent terminal
CN106775610B (en) Electronic equipment starting method and electronic equipment
CN107783776B (en) Processing method and device of firmware upgrade package and electronic equipment
CN109240731B (en) Safe upgrading method and system for TBox
KR101369251B1 (en) Apparatus, method, terminal and system for recovery protection of system files
CN115344434B (en) Patching method and device, electronic equipment and storage medium
CN111625295A (en) Embedded system starting method, device, equipment and storage medium
CN106201640A (en) A kind of method and device of BootLoader program of upgrading
CN107003876A (en) Firmware updates
CN110209420A (en) A kind of method and device updating bootstrap loader
CN114116305A (en) BIOS firmware recovery method, system, terminal and storage medium based on PFR
CN110597662B (en) Backup data automatic verification method and device, user equipment and storage medium
CN105550071A (en) System file upgrading and detecting method and communication device
CN108920962B (en) Firmware downloading and signing checking method, firmware publishing method, mobile terminal and server
CN111221553A (en) Firmware upgrading method and device
CN109375953B (en) Operating system starting method and device
CN113885907A (en) Firmware upgrading system and method
CN116820528A (en) Firmware version upgrading method and device, chip and electronic equipment
CN115827069A (en) Starting control method, system and device for server mainboard
CN115220796A (en) Secure boot device
CN115202690A (en) Method and device for firmware upgrading, air conditioner and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant