Firmware upgrading method and system
By adopting compression and decompression technology in firmware upgrades, combining cyclic redundancy verification code and block encoding, the problem of large storage space and time consumption in firmware upgrades is solved, the device version management is simplified, and the efficiency of firmware upgrades is improved.
Patent Information
- Application Number
- CN202411266774.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-27
AI Technical Summary
In the existing firmware upgrade methods, full upgrades take up a large storage space and take a long time. Differential upgrades require differential firmware to be made separately for different device versions, which is complex in management.
The upgraded firmware is compressed in the upper computer and uploaded to the cloud server. The target device downloads and decompresses from the cloud server and updates the original firmware. It uses cyclic redundancy verification code and block compression coding technology, including LZ77 and Huffman encoding , simplify differential firmware management.
It reduces the storage space and transfer time of firmware on the device, avoids the complexity of making differential firmware for different device versions, and improves the management efficiency of firmware upgrades.
Smart Images

Figure CN119201192A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a firmware upgrade method and system. Background Art
[0002] Firmware is software in an embedded system. Usually, a device is provided with a boot and multiple applications, wherein the boot and an application in the device are a firmware in the device. Firmware upgrade usually refers to the application upgrade in the firmware in the device.
[0003] In the prior art, there are two main types of firmware upgrade methods. The first type of upgrade method is full upgrade. Specifically, in this method, the device side obtains the upgrade firmware from the host computer, and then puts the upgrade firmware in the code running area to start running. The second type of upgrade method is differential upgrade. Specifically, in this method, the difference between the upgrade firmware and the original firmware is first compared, and differential firmware is made according to the difference. After the device side obtains the differential firmware from the host computer, the device side restores the upgrade firmware according to the differential firmware and the original firmware, and then puts the upgrade firmware in the code running area to start running.
[0004] For the full upgrade method, since the complete upgrade firmware needs to be downloaded to the memory on the device side, it will take up more storage space on the device side. In addition, since the upgrade firmware file is large, it takes a lot of file transfer and writing time.
[0005] For the differential upgrade method, since the versions of the original firmware running in different devices are different, for example, the version of the original firmware running in some devices is version 1.1, and the version of the original firmware running in some devices is version 1.2, if you want to upgrade the firmware version in the device to version 2.0, you need to make different differential firmware for the versions of the original firmware running in different devices, which is inconvenient to manage the firmware. Summary of the invention
[0006] In view of this, the purpose of this application is to provide a firmware upgrade method and system, so as to reduce the storage space occupied by the upgraded firmware in the device and reduce the transmission time of the upgraded firmware file, while eliminating the need to produce differential firmware for different versions of the original firmware, so as to avoid confusion in the upgraded firmware.
[0007] In a first aspect, an embodiment of the present application provides a firmware upgrade method, comprising:
[0008] In the host computer, the upgrade firmware file is compressed to obtain a compressed firmware file, and the compressed firmware file is uploaded to the cloud server;
[0009] The target device downloads the compressed firmware file from the cloud server, and decompresses the compressed firmware file to obtain a decompressed upgrade firmware file;
[0010] The target device uses the decompressed upgrade firmware file to update the original firmware file in the target device.
[0011] In combination with the first aspect, the embodiment of the present application provides a first possible implementation of the first aspect, wherein compressing the upgrade firmware file to obtain a compressed firmware file includes:
[0012] Convert the file format of the upgrade firmware file into the file format of an executable file;
[0013] Calculate a first checksum value of a cyclic redundancy check code function of the upgraded firmware file after format conversion;
[0014] The upgraded firmware file after format conversion is compressed and encoded in blocks to obtain an initial compressed firmware file;
[0015] The upgraded firmware information is added to the initial compressed firmware file to obtain the compressed firmware file; the upgraded firmware information includes the first check value.
[0016] In combination with the first possible implementation of the first aspect, the embodiment of the present application provides a second possible implementation of the first aspect, wherein the step of performing block compression encoding on the upgraded firmware file after format conversion to obtain an initial compressed firmware file includes:
[0017] Reading a first portion of the upgrade firmware file of a preset file size from the unencoded portion of the upgrade firmware file after format conversion, encoding the first portion of the upgrade firmware file in sequence, and obtaining an encoded first portion of the compressed firmware file corresponding to the first portion of the upgrade firmware file;
[0018] Determine whether the upgrade firmware file is encoded;
[0019] If the upgrade firmware file has not been encoded, continue to execute the step of reading the first part of the upgrade firmware file with a preset file size from the unencoded part of the upgrade firmware file after format conversion and subsequent steps;
[0020] If the encoding of the upgrade firmware file is completed, the first part of the compressed firmware files corresponding to each of the first part of the upgrade firmware files are spliced according to the arrangement order of each of the first part of the upgrade firmware files in the upgrade firmware file to obtain an initial compressed firmware file.
[0021] In combination with the second possible implementation of the first aspect, the embodiment of the present application provides a third possible implementation of the first aspect, wherein the encoding of the first part of the upgrade firmware file in sequence to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file includes:
[0022] The first part of the upgrade firmware file is sequentially encoded with a first code and a second code to obtain a first part of the compressed firmware file corresponding to the first part of the upgrade firmware file.
[0023] In combination with the third possible implementation of the first aspect, the embodiment of the present application provides a fourth possible implementation of the first aspect, wherein the first encoding is LZ77 encoding, and the second encoding is Huffman encoding.
[0024] In combination with the fourth possible implementation of the first aspect, the embodiment of the present application provides a fifth possible implementation of the first aspect, wherein the target device downloads the compressed firmware file from the cloud server, including:
[0025] The compressed firmware file is obtained from the cloud server through the IAP interface program in the target device, so as to download the compressed firmware file to the storage space of the internal memory of the target device.
[0026] In combination with the fifth possible implementation of the first aspect, the embodiment of the present application provides a sixth possible implementation of the first aspect, wherein the decompressing the compressed firmware file to obtain the decompressed upgrade firmware file includes:
[0027] For the undecompressed part of the compressed firmware file, the Boot in the target device reads the second part of the compressed firmware file of a preset file size from the storage space of the internal memory, and sequentially performs Huffman decoding and LZ77 decoding on the second part of the compressed firmware file in the Boot to obtain the decoded second part of the upgrade firmware file corresponding to the second part of the compressed firmware file;
[0028] Determine in Boot whether the compressed firmware file is decoded;
[0029] If the compressed firmware file is not decoded, continue to execute the steps of reading the second part of the compressed firmware file of the preset file size from the storage space of the internal memory by the Boot in the target device for the undecompressed part of the compressed firmware file and subsequent steps;
[0030] If the compressed firmware file is decoded, the second part upgrade firmware files corresponding to each second part compressed firmware file are spliced according to the arrangement order of the second part compressed firmware files in the compressed firmware file to obtain the decompressed upgrade firmware file.
[0031] In combination with the first possible implementation of the first aspect, the embodiment of the present application provides a seventh possible implementation of the first aspect, wherein the target device uses the decompressed upgrade firmware file to update the original firmware file in the target device, including:
[0032] The target device calculates a second check value of a cyclic redundancy check code function of the decompressed upgrade firmware file;
[0033] Determining whether the second verification value is the same as the first verification value;
[0034] If the second check value is the same as the first check value, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
[0035] In a second aspect, an embodiment of the present application further provides a firmware upgrade system, the system comprising a target device and a host computer;
[0036] The host computer is used to compress the upgrade firmware file to obtain a compressed firmware file, so as to upload the compressed firmware file to the cloud server;
[0037] The target device is used to download the compressed firmware file from the cloud server, decompress the compressed firmware file to obtain the decompressed upgrade firmware file; and use the decompressed upgrade firmware file to update the original firmware file in the target device.
[0038] In combination with the second aspect, the embodiment of the present application provides a first possible implementation of the second aspect, wherein the host computer, when used to compress the upgrade firmware file to obtain the compressed firmware file, is specifically used to:
[0039] Convert the file format of the upgrade firmware file into the file format of an executable file;
[0040] Calculate a first checksum value of a cyclic redundancy check code function of the upgraded firmware file after format conversion;
[0041] The upgraded firmware file after format conversion is compressed and encoded in blocks to obtain an initial compressed firmware file;
[0042] The upgraded firmware information is added to the initial compressed firmware file to obtain the compressed firmware file; the upgraded firmware information includes the first check value.
[0043] In combination with the first possible implementation of the second aspect, the embodiment of the present application provides a second possible implementation of the second aspect, wherein the host computer is used to perform block compression encoding on the upgraded firmware file after the format conversion to obtain the initial compressed firmware file, specifically used to:
[0044] Reading a first portion of the upgrade firmware file of a preset file size from the unencoded portion of the upgrade firmware file after format conversion, encoding the first portion of the upgrade firmware file in sequence, and obtaining an encoded first portion of the compressed firmware file corresponding to the first portion of the upgrade firmware file;
[0045] Determine whether the upgrade firmware file is encoded;
[0046] If the upgrade firmware file has not been encoded, continue to execute the step of reading the first part of the upgrade firmware file with a preset file size from the unencoded part of the upgrade firmware file after format conversion and subsequent steps;
[0047] If the encoding of the upgrade firmware file is completed, the first part of the compressed firmware files corresponding to each of the first part of the upgrade firmware files are spliced according to the arrangement order of each of the first part of the upgrade firmware files in the upgrade firmware file to obtain an initial compressed firmware file.
[0048] In combination with the second possible implementation of the second aspect, the embodiment of the present application provides a third possible implementation of the second aspect, wherein the host computer is used to encode the first part of the upgrade firmware file in sequence to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file, specifically used to:
[0049] The first part of the upgrade firmware file is sequentially encoded with a first code and a second code to obtain a first part of the compressed firmware file corresponding to the first part of the upgrade firmware file.
[0050] In combination with the third possible implementation of the second aspect, the embodiment of the present application provides a fourth possible implementation of the second aspect, wherein the first encoding is LZ77 encoding, and the second encoding is Huffman encoding.
[0051] In combination with the fourth possible implementation of the second aspect, the embodiment of the present application provides a fifth possible implementation of the second aspect, wherein the target device, when used to download the compressed firmware file from the cloud server, is specifically used to:
[0052] The compressed firmware file is obtained from the cloud server through the IAP interface program in the target device, so as to download the compressed firmware file to the storage space of the internal memory of the target device.
[0053] In combination with the fifth possible implementation of the second aspect, the embodiment of the present application provides a sixth possible implementation of the second aspect, wherein the target device, when used to decompress the compressed firmware file to obtain the decompressed upgrade firmware file, is specifically used to:
[0054] For the undecompressed part of the compressed firmware file, the Boot in the target device reads the second part of the compressed firmware file of a preset file size from the storage space of the internal memory, and sequentially performs Huffman decoding and LZ77 decoding on the second part of the compressed firmware file in the Boot to obtain the decoded second part of the upgrade firmware file corresponding to the second part of the compressed firmware file;
[0055] Determine in Boot whether the compressed firmware file is decoded;
[0056] If the compressed firmware file is not decoded, continue to execute the steps of reading the second part of the compressed firmware file of the preset file size from the storage space of the internal memory by the Boot in the target device for the undecompressed part of the compressed firmware file and subsequent steps;
[0057] If the compressed firmware file is decoded, the second part upgrade firmware files corresponding to each second part compressed firmware file are spliced according to the arrangement order of the second part compressed firmware files in the compressed firmware file to obtain the decompressed upgrade firmware file.
[0058] In combination with the first possible implementation of the second aspect, the embodiment of the present application provides a seventh possible implementation of the second aspect, wherein, when the target device is used to update the original firmware file in the target device using the decompressed upgrade firmware file, it is specifically used to:
[0059] Calculate a second check value of a cyclic redundancy check code function of the decompressed upgrade firmware file;
[0060] Determining whether the second verification value is the same as the first verification value;
[0061] If the second check value is the same as the first check value, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
[0062] The embodiment of the present application provides a firmware upgrade method and system. Compared with the full upgrade method, the upgrade method of this embodiment first compresses the upgrade firmware file to obtain a compressed firmware file. Since the file size of the compressed firmware file is smaller than the file size of the upgrade firmware file, when the target device downloads the compressed firmware file to the target device, less storage space is occupied in the target device. At the same time, the time required for the target device to download the compressed firmware file from the cloud server is also shortened compared to the time to download the upgrade firmware file. Furthermore, compared with the differential upgrade method, the upgrade method in this embodiment uses the upgrade firmware file to completely replace the original firmware file in the target device. Therefore, there is no need to consider the version of the original firmware file, and there is no need to produce different differential firmware for different versions of the original firmware files, which is conducive to avoiding confusion in the upgrade firmware.
[0063] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application 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 paying creative work.
[0065] Figure 1 A flowchart of a firmware upgrade method provided in an embodiment of the present application is shown;
[0066] Figure 2 A schematic diagram of the structure of a firmware upgrade system provided in an embodiment of the present application is shown;
[0067] Figure 3 A schematic diagram of compressing an upgrade firmware file provided in an embodiment of the present application is shown;
[0068] Figure 4 A schematic diagram of decompressing a compressed firmware file provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0069] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0070] Considering that the full upgrade method requires more storage space on the device side and consumes a lot of file transfer and writing time, the differential upgrade method requires different differential firmware to be produced for the versions of the original firmware running in different devices, which is not convenient for firmware management. Based on this, the embodiments of the present application provide a firmware upgrade method and system, which are described below through embodiments.
[0071] To facilitate understanding of this embodiment, a firmware upgrade method disclosed in the embodiment of this application is first described in detail. Figure 1 As shown, the following steps S101-S103 are included:
[0072] S101: In the host computer, compress the upgrade firmware file to obtain a compressed firmware file, and upload the compressed firmware file to the cloud server.
[0073] The firmware upgrade method in this embodiment is applied to a firmware upgrade system, such as Figure 2 As shown, the firmware upgrade system includes a host computer and a target device. Wherein, relative to the host computer, the target device is a subordinate device of the host computer.
[0074] In the host computer, the upgrade firmware file is compressed by a firmware compression tool in the host computer to obtain a compressed firmware file. The upgrade firmware file is an upgraded firmware file. Generally, the file size of the upgrade firmware file is larger than the file size of the compressed firmware file. Further, the file size of the upgrade firmware file is larger than twice the file size of the compressed firmware file.
[0075] In a possible implementation, when the host computer executes step S101 to compress the upgrade firmware file to obtain the compressed firmware file, the following steps S1011-S1014 may be specifically performed:
[0076] S1011: Convert the file format of the upgrade firmware file into the file format of an executable file.
[0077] In this embodiment, if Figure 3 As shown, the file format of the upgrade firmware file is .Hex format, and the file format of the executable file is .Bin format.
[0078] S1012: Calculate a first checksum value of a cyclic redundancy check code function of the upgrade firmware file after format conversion.
[0079] In this embodiment, the upgraded firmware file after format conversion refers to an upgraded firmware file in .Bin format. A cyclic redundancy check code function (Crc) is a hash function that generates a short fixed-bit check code based on data such as network data packets or computer files, and is mainly used to detect or verify errors that may occur after data transmission or storage.
[0080] S1013: performing block-by-block compression encoding on the upgraded firmware file after format conversion to obtain an initial compressed firmware file.
[0081] In this embodiment, the first part of the upgrade firmware file of the preset file size is read from the uncoded part of the upgrade firmware file after the format conversion, and the first part of the upgrade firmware file is encoded in turn to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file. It is judged whether the encoding of the upgrade firmware file is completed. If the encoding of the upgrade firmware file is not completed, the step of reading the first part of the upgrade firmware file of the preset file size from the uncoded part of the upgrade firmware file after the format conversion and the subsequent steps are continued. If the encoding of the upgrade firmware file is completed, the first part of the compressed firmware files corresponding to each first part of the upgrade firmware file are spliced according to the arrangement order of each first part of the upgrade firmware file read in the upgrade firmware file to obtain the initial compressed firmware file.
[0082] The preset file size is smaller than the file size of the upgrade firmware file and smaller than the file size of the compressed firmware file. For example, when the file size of the upgrade firmware file is 600kb, the file size of the compressed firmware file may be 420kb, and the preset file size may be 5kb.
[0083] In this embodiment, if Figure 3 As shown, when the steps are executed to sequentially encode the first part of the upgrade firmware file to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file, specifically:
[0084] The first part of the upgrade firmware file is sequentially encoded with a first code and a second code to obtain a first part of the compressed firmware file corresponding to the first part of the upgrade firmware file.
[0085] The first encoding is LZ77 encoding, and the second encoding is Huffman encoding.
[0086] Through the compression method in this embodiment, the compression ratio can reach 70%, that is, when the file size of the upgrade firmware file is 100kb, the file size of the compressed firmware file after compression can reach 70kb.
[0087] S1014: Add upgraded firmware information to the initial compressed firmware file to obtain a compressed firmware file; the upgraded firmware information includes a first check value.
[0088] In this embodiment, the upgrade firmware information specifically includes: a first check value, a file size of the compressed firmware file, a file size of the upgrade firmware file, a version number of the original firmware file, and a device type of the target device.
[0089] In this embodiment, after obtaining the compressed firmware file, as shown in FIG. Figure 2 As shown, upload the compressed firmware file to the cloud server.
[0090] S102: The target device downloads the compressed firmware file from the cloud server, and decompresses the compressed firmware file to obtain the decompressed upgrade firmware file.
[0091] In this embodiment, the compressed firmware file is obtained from the cloud server through the IAP interface program in the target device, so as to download the compressed firmware file to the storage space of the internal memory (MCU FLASH) of the target device.
[0092] In a possible implementation, when executing step S102 to decompress the compressed firmware file to obtain the decompressed upgrade firmware file, the following steps may be specifically performed:
[0093] like Figure 4As shown, for the undecompressed part in the compressed firmware file, the Boot in the target device (BOOT in a computer usually refers to the boot program in the computer startup process) reads the second part of the compressed firmware file of the preset file size from the storage space of the internal memory, and performs Huffman decoding and LZ77 decoding on the second part of the compressed firmware file in Boot in turn to obtain the decoded second part of the upgraded firmware file corresponding to the second part of the compressed firmware file. In Boot, it is judged whether the compressed firmware file is decoded. If the compressed firmware file is not decoded, the steps of reading the second part of the compressed firmware file of the preset file size from the storage space of the internal memory and the subsequent steps for the undecompressed part in the compressed firmware file are continued. If the compressed firmware file is decoded, the second part of the upgraded firmware file corresponding to each second part of the compressed firmware file is spliced according to the arrangement order of the second part of the compressed firmware file in the compressed firmware file to obtain the decompressed upgraded firmware file.
[0094] S103: The target device uses the decompressed upgrade firmware file to update the original firmware file in the target device.
[0095] In this embodiment, the original firmware file is the original firmware file in the target device, and the upgraded firmware file is an upgraded version of the original firmware file. The target device uses the upgraded firmware file to update the original firmware file in the target device, thereby completing the firmware upgrade in the target device.
[0096] In a possible implementation manner, when executing step S103, the following steps S1031-S1033 may be specifically performed:
[0097] S1031: The target device calculates a second check value of a cyclic redundancy check code function of the decompressed upgrade firmware file.
[0098] S1032: Determine whether the second verification value is the same as the first verification value.
[0099] S1033: If the second check value is the same as the first check value, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
[0100] In this embodiment, by determining whether the second verification value is the same as the first verification value, the integrity and accuracy of the decompressed upgrade firmware file in the target device are verified.
[0101] In this embodiment, when determining whether the second check value is the same as the first check value, it is also possible to determine whether the file size of the upgrade firmware file contained in the upgrade firmware information is the same as the file size of the decompressed upgrade firmware file, and whether the file size of the compressed firmware file contained in the upgrade firmware information is the same as the file size of the compressed firmware file downloaded by the target device.
[0102] If the second check value is the same as the first check value, the file size of the upgrade firmware file contained in the upgrade firmware information is the same as the file size of the decompressed upgrade firmware file, and the file size of the compressed firmware file contained in the upgrade firmware information is the same as the file size of the compressed firmware file downloaded by the target device, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
[0103] In this embodiment, when using the decompressed upgrade firmware file to update the original firmware file in the target device, the original firmware file in the target device can be deleted and the decompressed upgrade firmware file can be written into the running space in the target device, thereby completing the firmware upgrade of the firmware file in the target device.
[0104] Based on the same technical concept, the present application also provides a firmware upgrade system, the system comprising a target device and a host computer;
[0105] The host computer is used to compress the upgrade firmware file to obtain a compressed firmware file, so as to upload the compressed firmware file to the cloud server;
[0106] The target device is used to download the compressed firmware file from the cloud server, decompress the compressed firmware file to obtain the decompressed upgrade firmware file; and use the decompressed upgrade firmware file to update the original firmware file in the target device.
[0107] Optionally, when the host computer is used to compress the upgrade firmware file to obtain the compressed firmware file, it is specifically used to:
[0108] Convert the file format of the upgrade firmware file into the file format of an executable file;
[0109] Calculate a first checksum value of a cyclic redundancy check code function of the upgraded firmware file after format conversion;
[0110] The upgraded firmware file after format conversion is compressed and encoded in blocks to obtain an initial compressed firmware file;
[0111] The upgraded firmware information is added to the initial compressed firmware file to obtain the compressed firmware file; the upgraded firmware information includes the first check value.
[0112] Optionally, when the host computer is used to perform block-by-block compression encoding on the upgraded firmware file after format conversion to obtain an initial compressed firmware file, it is specifically used to:
[0113] Reading a first portion of the upgrade firmware file of a preset file size from the unencoded portion of the upgrade firmware file after format conversion, encoding the first portion of the upgrade firmware file in sequence, and obtaining an encoded first portion of the compressed firmware file corresponding to the first portion of the upgrade firmware file;
[0114] Determine whether the upgrade firmware file is encoded;
[0115] If the upgrade firmware file has not been encoded, continue to execute the step of reading the first part of the upgrade firmware file with a preset file size from the unencoded part of the upgrade firmware file after format conversion and subsequent steps;
[0116] If the encoding of the upgrade firmware file is completed, the first part of the compressed firmware files corresponding to each of the first part of the upgrade firmware files are spliced according to the arrangement order of each of the first part of the upgrade firmware files in the upgrade firmware file to obtain an initial compressed firmware file.
[0117] Optionally, when the host computer is used to encode the first part of the upgrade firmware file in sequence to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file, it is specifically used to:
[0118] The first part of the upgrade firmware file is sequentially encoded with a first code and a second code to obtain a first part of the compressed firmware file corresponding to the first part of the upgrade firmware file.
[0119] Optionally, the first encoding is LZ77 encoding, and the second encoding is Huffman encoding.
[0120] Optionally, when the target device is used to download the compressed firmware file from the cloud server, it is specifically used to:
[0121] The compressed firmware file is obtained from the cloud server through the IAP interface program in the target device, so as to download the compressed firmware file to the storage space of the internal memory of the target device.
[0122] Optionally, when the target device is used to decompress the compressed firmware file to obtain the decompressed upgrade firmware file, it is specifically used to:
[0123] For the undecompressed part of the compressed firmware file, the Boot in the target device reads the second part of the compressed firmware file of a preset file size from the storage space of the internal memory, and sequentially performs Huffman decoding and LZ77 decoding on the second part of the compressed firmware file in the Boot to obtain the decoded second part of the upgrade firmware file corresponding to the second part of the compressed firmware file;
[0124] Determine in Boot whether the compressed firmware file is decoded;
[0125] If the compressed firmware file is not decoded, continue to execute the steps of reading the second part of the compressed firmware file of the preset file size from the storage space of the internal memory by the Boot in the target device for the undecompressed part of the compressed firmware file and subsequent steps;
[0126] If the compressed firmware file is decoded, the second part upgrade firmware files corresponding to each second part compressed firmware file are spliced according to the arrangement order of the second part compressed firmware files in the compressed firmware file to obtain the decompressed upgrade firmware file.
[0127] Optionally, when the target device is used to update the original firmware file in the target device using the decompressed upgrade firmware file, the target device is specifically used to:
[0128] Calculate a second check value of a cyclic redundancy check code function of the decompressed upgrade firmware file;
[0129] Determining whether the second verification value is the same as the first verification value;
[0130] If the second check value is the same as the first check value, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0132] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0134] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0135] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. 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.
[0136] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A firmware upgrade method, characterized in that: include: In the host computer, the upgrade firmware file is compressed to obtain a compressed firmware file, and the compressed firmware file is uploaded to the cloud server; The target device downloads the compressed firmware file from the cloud server, and decompresses the compressed firmware file to obtain a decompressed upgrade firmware file; The target device uses the decompressed upgrade firmware file to update the original firmware file in the target device.
2. The method according to claim 1, characterized in that: The step of compressing the upgrade firmware file to obtain a compressed firmware file includes: Convert the file format of the upgrade firmware file into the file format of an executable file; Calculate a first checksum value of a cyclic redundancy check code function of the upgraded firmware file after format conversion; The upgraded firmware file after format conversion is compressed and encoded in blocks to obtain an initial compressed firmware file; The upgraded firmware information is added to the initial compressed firmware file to obtain the compressed firmware file; the upgraded firmware information includes the first check value.
3. The method according to claim 2, characterized in that: The step of performing block-by-block compression encoding on the upgraded firmware file after the format conversion to obtain an initial compressed firmware file includes: Reading a first portion of the upgrade firmware file of a preset file size from the unencoded portion of the upgrade firmware file after format conversion, encoding the first portion of the upgrade firmware file in sequence, and obtaining an encoded first portion of the compressed firmware file corresponding to the first portion of the upgrade firmware file; Determine whether the upgrade firmware file is encoded; If the upgrade firmware file has not been encoded, continue to execute the step of reading the first part of the upgrade firmware file with a preset file size from the unencoded part of the upgrade firmware file after format conversion and subsequent steps; If the encoding of the upgrade firmware file is completed, the first part of the compressed firmware files corresponding to each of the first part of the upgrade firmware files are spliced according to the arrangement order of each of the first part of the upgrade firmware files in the upgrade firmware file to obtain an initial compressed firmware file.
4. The method according to claim 3, characterized in that: The step of sequentially encoding the first part of the upgrade firmware file to obtain the encoded first part of the compressed firmware file corresponding to the first part of the upgrade firmware file includes: The first part of the upgrade firmware file is sequentially encoded with a first code and a second code to obtain a first part of the compressed firmware file corresponding to the first part of the upgrade firmware file.
5. The method according to claim 4, characterized in that: The first encoding is LZ77 encoding, and the second encoding is Huffman encoding.
6. The method according to claim 5, characterized in that: The target device downloads the compressed firmware file from the cloud server, including: The compressed firmware file is obtained from the cloud server through the IAP interface program in the target device, so as to download the compressed firmware file to the storage space of the internal memory of the target device.
7. The method according to claim 6, characterized in that: The decompressing the compressed firmware file to obtain the decompressed upgrade firmware file includes: For the undecompressed part of the compressed firmware file, the Boot in the target device reads the second part of the compressed firmware file of a preset file size from the storage space of the internal memory, and sequentially performs Huffman decoding and LZ77 decoding on the second part of the compressed firmware file in the Boot to obtain the decoded second part of the upgrade firmware file corresponding to the second part of the compressed firmware file; Determine in Boot whether the compressed firmware file is decoded; If the compressed firmware file is not decoded, continue to execute the steps of reading the second part of the compressed firmware file of the preset file size from the storage space of the internal memory by the Boot in the target device for the undecompressed part of the compressed firmware file and subsequent steps; If the compressed firmware file is decoded, the second part upgrade firmware files corresponding to each second part compressed firmware file are spliced according to the arrangement order of the second part compressed firmware files in the compressed firmware file to obtain the decompressed upgrade firmware file.
8. The method according to claim 2, characterized in that: The target device uses the decompressed upgrade firmware file to update the original firmware file in the target device, including: The target device calculates a second check value of a cyclic redundancy check code function of the decompressed upgrade firmware file; Determining whether the second verification value is the same as the first verification value; If the second check value is the same as the first check value, the decompressed upgrade firmware file is used to update the original firmware file in the target device.
9. A firmware upgrade system, characterized in that: The system includes a target device and a host computer; The host computer is used to compress the upgrade firmware file to obtain a compressed firmware file, so as to upload the compressed firmware file to the cloud server; The target device is used to download the compressed firmware file from the cloud server, and decompress the compressed firmware file to obtain a decompressed upgrade firmware file; And the decompressed upgraded firmware file is used to update the original firmware file in the target device.
10. The system according to claim 9, characterized in that: When the host computer is used to compress the upgrade firmware file to obtain the compressed firmware file, it is specifically used to: Convert the file format of the upgrade firmware file into the file format of an executable file; Calculate a first checksum value of a cyclic redundancy check code function of the upgraded firmware file after format conversion; The upgraded firmware file after format conversion is compressed and encoded in blocks to obtain an initial compressed firmware file; Adding the upgraded firmware information to the initial compressed firmware file to obtain the compressed firmware file; The upgrade firmware information includes the first check value.