Differential upgrading method based on single chip microcomputer

By using cyclic redundancy check value to verify the differential upgrade package in the differential upgrade method of microcontroller, the problem of difficult to guarantee the integrity and correctness of the new software after the upgrade is solved, and the reliability and flexibility of software upgrades are achieved.

CN119718392APending Publication Date: 2025-03-28TIANJIN LISHEN SPECIAL POWER SUPPLY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411703369.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing differential upgrade method cannot determine the integrity and correctness of the new upgraded software, which has led to the integrity and correctness of the new upgraded software being a question worthy of attention.

Method used

By using cyclic redundancy check values ​​during the upgrade process, the complete upgrade file is restored through the differential algorithm, and then the restored complete upgrade package is checked to ensure the integrity and correctness of the new software after the upgrade.

Benefits of technology

It realizes verification of the integrity and correctness of the upgraded new software, ensures the reliability of software upgrades, and supports breakpoint continuous transmission and version rollback functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718392A_ABST
    Figure CN119718392A_ABST
Patent Text Reader

Abstract

The invention provides a differential upgrading method based on a single-chip microcomputer, and the method comprises the steps: verifying the integrity of a transmitted differential upgrading package through a cyclic redundancy verification value according to an upgrading protocol; restoring the complete upgrade file through a differential algorithm, and performing correctness verification on the restored complete upgrade package through a cyclic redundancy verification value carried in the differential upgrade package; and when the verification is passed, the upgrade package is placed in the backup upgrade area of the single-chip microcomputer, and upgrade is completed. The upgrade package adopted by the method carries the differential upgrade package and also carries the new version software cyclic redundancy check value for verifying the new version software, so that the new version software can be obtained after the differential upgrade package and the old version software are fused, the new version software check file is used for verifying the new version software mirror image, and the verification efficiency of the new version software is improved. Therefore, the integrity and correctness of the new version software obtained by upgrading are verified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of software upgrade, and in particular to a differential upgrade method based on a single chip microcomputer. Background Art

[0002] At present, in order to increase and improve the functions or problems of the software in products (such as lithium-ion batteries and BMS control equipment), it is necessary to upgrade the software in the products from time to time. Usually, there are two ways to upgrade: full package upgrade and differential upgrade. Among them, differential upgrade has attracted widespread attention in terms of improving upgrade speed and success rate because of its small upgrade package.

[0003] The principle of differential upgrade is to separate the difference between the source version and the target version into an upgrade package, and then merge the difference with the source version into a new version through a restoration algorithm on the device side. The differential upgrade method can not only save the internal space of the MCU itself, but also reduce the upgrade time and power consumption (Wifi or NB IoT products can also reduce the traffic required for the upgrade).

[0004] However, the current differential upgrade method cannot determine the integrity and correctness of the new software after the upgrade. Based on this problem, restoring the integrity and correctness of the new software after the upgrade becomes an issue worthy of attention. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a differential upgrade method based on a single chip microcomputer.

[0006] In order to solve the above technical problems, the technical solution of the present invention is:

[0007] A differential upgrade method based on a single-chip microcomputer verifies the integrity of a transmitted differential upgrade package through a cyclic redundancy check value according to an upgrade protocol; restores the complete upgrade file through a differential algorithm, and verifies the correctness of the restored complete upgrade package through the cyclic redundancy check value carried in the differential upgrade package; when the verification passes, the upgrade package is placed in a backup upgrade area of ​​the single-chip microcomputer to complete the upgrade.

[0008] Preferably, the above-mentioned differential upgrade method based on single chip microcomputer has the following specific steps:

[0009] (1) Using the cyclic redundancy check value of the differential upgrade package carried in the communication protocol, verifying the differential upgrade package;

[0010] (2) When the verification passes, the differential upgrade package and the source version software are merged to calculate the cyclic redundancy check value, and then verified with the cyclic redundancy check value carried in the differential upgrade package: if they are consistent, the new version software verification value is the cyclic redundancy (CRC) check value of the new version software, thereby ensuring the integrity and correctness of the differential upgrade package; if the upgrade is forced to stop due to abnormal power failure, communication failure, etc., the breakpoint resumption and version rollback functions are implemented according to different situations (the external storage medium records the status of each stage of the upgrade).

[0011] Preferably, in the above-mentioned differential upgrade method based on the single-chip microcomputer, the differential upgrade package is produced by separating the difference parts of the firmware between the new and old versions by the upper computer; the single-chip microcomputer end accepts the differential upgrade package, and through the differential recovery algorithm, merges the new and old versions according to the data flags in the differential package to become a new firmware to complete the upgrade.

[0012] Preferably, in the above-mentioned differential upgrade method based on the single-chip microcomputer, the host computer adopts the differential algorithm bsd if+1 zma to generate a differential upgrade package, and the single-chip microcomputer also adopts the algorithm to restore the complete upgrade file.

[0013] Preferably, the above-mentioned differential upgrade method based on single-chip microcomputer further includes placing the differential upgrade package into the backup upgrade area and then placing the original program code into an external storage medium to prevent problems from occurring during the upgrade process or requiring a version rollback function.

[0014] Beneficial effects:

[0015] The differential upgrade method based on the single-chip microcomputer saves the storage space of the single-chip microcomputer itself, reduces the upgrade time and the required power consumption, and more importantly, ensures the integrity and correctness of the upgraded new software by differentiating the upgrade package. In addition to the differential upgrade package, the adopted upgrade package also carries the new version software cyclic redundancy check value used to verify the new version software, so that the differential upgrade package can be merged with the old version software to obtain the new version software, and the new version software image is verified using the new version software verification file, thereby realizing the verification of the integrity and correctness of the upgraded new version software.

[0016] The single chip microcomputer-based differential upgrade method sorts old files and new files based on the BSD i ff method, compares the difference files and the newly added files, and then forms a compressed package with the difference files and the newly added files, and verifies the integrity and correctness of the upgraded new software through the cyclic redundancy check value of the differential upgrade package and the cyclic redundancy check value of the restored complete file.

[0017] Use the cyclic redundancy check value of the differential upgrade package carried in the communication protocol to verify the differential upgrade package; when the verification passes, merge the differential upgrade package and the original version software to calculate the cyclic redundancy check value, and verify it with the cyclic redundancy check value carried in the differential upgrade package. If they are consistent, the new version software verification value is the cyclic redundancy (CRC) check value of the new version software, thereby ensuring the integrity and correctness of the differential upgrade package; if the upgrade is forced to stop (abnormal power failure, communication failure, etc.) during the upgrade process, according to different situations (storage medium records the status of each stage of the upgrade), breakpoint resumption, version rollback and other functions can be realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A schematic diagram of the generation principle of the differential upgrade package provided in an embodiment of the present application.

[0019] Figure 2 A schematic diagram of a differential upgrade package generation method provided in an embodiment of the present application.

[0020] Figure 3 This is a differential restoration schematic diagram of the single-chip microcomputer differential upgrade package provided in an embodiment of the present application.

[0021] Figure 4 A schematic diagram of breakpoint-resume transmission of a single-chip microcomputer differential upgrade package provided in an embodiment of the present application.

[0022] Figure 5 A schematic diagram of version rollback of a single-chip microcomputer differential upgrade package provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] The following is a detailed description of a single chip microcomputer-based differential upgrade method and its implementation method of the present invention in conjunction with the embodiments and drawings.

[0024] Example 1

[0025] like Figure 1 and Figure 2 As shown, based on the differences between the new version of the software and the old version of the software, a differential upgrade package is generated. The specific generation steps are as follows:

[0026] (1) Compare the new version of the software with the old version of the software. When the new version of the software and the old version of the software have the same part, record the current address and compare them step by step. When there is a difference of more than 8 bytes, it is regarded as a new file, and the previous and next addresses are recorded. Continue to compare and record the difference until the end of the new version of the software. The above differences are combined into a differential package, that is, the data carried in the differential package is the data representing the difference between the new version of the software and the old version of the software.

[0027] (2) The upgrade communication used is 485 communication. The PC or other device is connected to the upgrade target through the serial port. The new version of the software differential upgrade package is generated and transmitted to the upgrade target through 485 communication. The communication format is as follows: Figure 3 When the upgrade target is in the process of starting the upgrade, upgrading, and upgrading results, different message forms will be fed back, and the feedback form is shown in Table 1, so as to understand the upgrade situation.

[0028] Table 1 Differential upgrade package format

[0029]

[0030] (3) After the upgrade package is downloaded, Figure 4 As shown, restore the new version of the software in the following way:

[0031] The difference data of the new and old firmware binary files of the upgrade package is obtained by comparing the new firmware and the old firmware by the binary difference tool bsd i ff. In the process of making the differential upgrade package, the first 64 bytes of the differential package include the CRC check, length and other information of the old / new version software. When restoring the differential upgrade package, the address of the file header offset by these 64 bytes is the starting position of the new version software. After merging the difference part with the old version software, calculate the CRC check value. Compare the CRC check value with the CRC in the differential upgrade package, and the correctness check of the new version software is completed if they are the same. Extract the old version software and put it into the upgrade backup area, and write the new version software into the internal Flash of the MCU to complete the upgrade process.

[0032] When the upgrade is interrupted, depending on the abnormal situation, you can use functions such as breakpoint resumption and version rollback to ensure that the upgrade process can be completed.

[0033] like Figure 4 As shown, the implementation of the breakpoint resume function mainly depends on the storage medium. Each step in the upgrade process is recorded in the storage medium. When the upgrade process is interrupted, the microcontroller will record the upgrade process before the interruption occurs. When the upgrade is started again later, the microcontroller will actively report it as a breakpoint resume process.

[0034] like Figure 5 As shown, when upgrading to a new version of the software, the old version of the software will be stored in the backup upgrade area; therefore, when the new version of the software does not meet the customer's current usage requirements due to functions or other factors, a version rollback instruction can be sent to roll the new software back to the old version, without having to spend a long time upgrading.

[0035] The various function modules related to the upgrade (differential upgrade, upgrade backup, breakpoint resume, version rollback) can be integrated into one processing program, or each module can exist separately, or multiple modules can be integrated into one program. If the function is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium and embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0036] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. The construction steps of the structure of the present invention are not in any particular order. Improvements and modifications such as structural transformation carried out by technicians in this technical field based on the method of the present invention or on the basis of the method are deemed to be within the scope of protection of the present invention.

Claims

1. A differential upgrade method based on a single chip microcomputer, characterized in that: According to the upgrade protocol, the integrity of the transmitted differential upgrade package is verified by the cyclic redundancy check value; the complete upgrade file is restored by the differential algorithm, and the correctness of the restored complete upgrade package is verified by the cyclic redundancy check value carried in the differential upgrade package; when the verification passes, the upgrade package is placed in the backup upgrade area of ​​the microcontroller to complete the upgrade.

2. The differential upgrade method based on single chip microcomputer according to claim 1 is characterized in that: The specific steps are as follows: (1) Using the cyclic redundancy check value of the differential upgrade package carried in the communication protocol, verifying the differential upgrade package; (2) When the verification passes, the differential upgrade package and the source version software are merged to calculate the cyclic redundancy check value, and the cyclic redundancy check value carried in the differential upgrade package is verified: if they are consistent, the new version software verification value is the cyclic redundancy check value of the new version software; If the upgrade is forced to stop during the upgrade process, perform breakpoint resumption or version rollback.

3. The differential upgrade method based on single chip microcomputer according to claim 1 or 2, characterized in that: The differential upgrade package is produced by separating the difference between the new and old versions of the firmware on the host computer; the single-chip microcomputer receives the differential upgrade package, and through the differential recovery algorithm, merges the new and old versions according to the data flags in the differential package to form a new firmware to complete the upgrade.

4. The differential upgrade method based on single chip microcomputer according to claim 3 is characterized in that: The host computer uses the differential algorithm bsdiff+lzma to generate a differential upgrade package, and the microcontroller also uses the algorithm to restore the complete upgrade file.

5. The differential upgrade method based on single chip microcomputer according to claim 1 or 2, characterized in that: It also includes placing the differential upgrade package into the backup upgrade area and placing the original program code into an external storage medium to prevent problems from occurring during the upgrade process or requiring a version rollback function.