Firmware upgrading method and device, computer equipment, storage medium and program product

By using the longest common subsequence algorithm to determine differential packets on the MCU, transmitting differential packets instead of the entire firmware, solving the problem of firmware upgrades occupying MCU resources, and improving performance and efficiency.

CN119987828APending Publication Date: 2025-05-13镁佳(北京)科技有限公司
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510160130.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The existing firmware upgrade method occupies the MCU's storage space, processing power and communication interface resources, limiting the performance of the MCU when performing other tasks.

Method used

By obtaining the target data and historical data information of the firmware to be upgraded, differential packets are determined using the longest common sub-sequence algorithm, and the differential packets are transmitted instead of the entire firmware, saving storage space.

Benefits of technology

Reduces the storage space occupancy of the MCU, improves the performance of the MCU during the upgrade process, is used to perform other tasks, and improves the upgrade efficiency and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987828A_ABST
    Figure CN119987828A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a firmware upgrading method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: acquiring target data information of firmware to be upgraded; wherein the target data information is information for upgrading the to-be-upgraded firmware; comparing the target data information with historical data information of the firmware to be upgraded, and determining a differential packet; wherein the differential packet is used for indicating different information between the target data information and the historical data information; and upgrading the to-be-upgraded firmware according to the differential package.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a firmware upgrade method, device, computer equipment, storage medium and program product. Background Art

[0002] The current firmware upgrade method is often to burn an IAP program into a microcontroller (MCU, Motor Control Unit), and then use the IAP program to upgrade the received firmware to be upgraded.

[0003] However, the IAP program needs to occupy the MCU's storage space, processing power, communication interface and other resources when running. The occupation of these resources may limit the performance of the MCU when performing other tasks.

[0004] Therefore, how to reduce the occupancy rate of the MCU's storage space during firmware upgrade becomes a problem that needs to be solved. Summary of the invention

[0005] In view of this, the present invention provides a firmware upgrade method, apparatus, computer equipment, storage medium and program product.

[0006] In a first aspect, the present invention provides a firmware upgrade method, the method comprising: obtaining target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded; comparing the target data information with historical data information of the firmware to be upgraded to determine a differential package; wherein the differential package is used to indicate information that is different between the target data information and the historical data information; and upgrading the firmware to be upgraded according to the differential package.

[0007] The firmware upgrade method provided in this embodiment determines the differential package by comparing the target data information with the historical data information of the firmware to be upgraded, that is, determines the information that is different between the target data information and the historical data information, and then transmits the differential package instead of the entire firmware. That is, in the storage space of the MCU, only space needs to be reserved for the differential package instead of the space for the entire firmware, thereby saving storage space, and enabling the MCU to maintain higher performance during the upgrade process for executing other tasks.

[0008] In one possible implementation, the target data information is compared with the historical data information of the firmware to be upgraded to determine the differential package, including: using the longest common subsequence algorithm to determine the difference data between the target data information and the historical data information of the firmware to be upgraded; extracting the difference data from the target data information, and compressing the difference data to obtain compressed data; adding metadata to the compressed data to determine the differential package.

[0009] The firmware upgrade method provided in this embodiment can accurately find the longest common subsequence between two sequences through the longest common subsequence algorithm, thereby effectively determining the difference between them. At the same time, by transmitting only the difference data instead of the entire firmware, the amount of data transmission can be significantly reduced. This not only saves bandwidth resources, but also shortens the time required for the upgrade and improves the upgrade efficiency. In addition, by compressing the difference data and adding metadata to the compressed data to form a differential packet, the integrity and accuracy of the data can be ensured. At the same time, the compression process can also increase the confidentiality of the data to a certain extent, improving the security during the upgrade process.

[0010] In a possible implementation, the method of determining metadata includes: obtaining firmware version information and a hash value; determining an offset and a length of difference data; and determining metadata based on the firmware version information, the offset and the length of the hash value difference data.

[0011] The firmware upgrade method provided in this embodiment can ensure that the correct firmware version is targeted when upgrading or managing by obtaining the version information of the firmware. This avoids upgrade failures or device failures caused by version mismatches. The hash value, as the digital fingerprint of the firmware, can uniquely identify the content of the firmware. By comparing the current hash value of the firmware with the pre-stored hash value, it can be verified whether the firmware has been tampered with or damaged during transmission or storage. This ensures the security and reliability of the firmware. By determining the offset and length of the difference data, the part of the firmware that needs to be updated or modified can be accurately located. This reduces the burden of data transmission and processing and improves upgrade efficiency.

[0012] In a possible implementation, the longest common subsequence algorithm is used to determine the difference data between the target data information and the historical data information of the firmware to be upgraded, including: reading the first firmware file corresponding to the target data information and the second firmware file corresponding to the historical data information into the memory in binary mode respectively; dividing the first firmware file to obtain a first block; dividing the second firmware file to obtain a second block; constructing a two-dimensional matrix based on the first block and the second block; wherein the two-dimensional matrix is ​​used to indicate the length of the longest common subsequence of the first block and the second block; filling the two-dimensional matrix, and determining the difference data based on backtracking processing of the filled two-dimensional data.

[0013] The firmware upgrade method provided in this embodiment can efficiently process the original data by reading the firmware file in binary mode, avoiding the loss of data and format incompatibility problems during the conversion process. In addition, the firmware file is divided into blocks, which can facilitate subsequent processing and analysis. The accuracy and granularity of the segmentation can be adjusted according to actual needs to meet different application scenarios. In addition, by filling a two-dimensional matrix and performing backtracking processing, the difference data in the firmware file can be accurately determined. This method avoids the tedious process of manually comparing and identifying difference data, and improves accuracy and efficiency.

[0014] In a possible implementation, upgrading the firmware to be upgraded according to the differential packet includes: segmenting the differential packet according to a preset size to obtain differential data segments; and transmitting each differential data segment to the firmware to be upgraded in sequence through the serial port to upgrade the firmware to be upgraded.

[0015] The firmware upgrade method provided in this embodiment can reduce the risk of single transmission failure by transmitting differential data segments in segments. If a differential data segment fails to be transmitted, only the segment of data can be retransmitted without retransmitting the entire differential packet, thereby improving the reliability and stability of the upgrade.

[0016] In one possible implementation, before transmitting each differential data segment to the firmware to be upgraded through the serial port in sequence to upgrade the firmware to be upgraded, the method also includes: adding authentication information to each differential data segment respectively; transmitting each differential data segment to the firmware to be upgraded through the serial port in sequence to upgrade the firmware to be upgraded, including: transmitting each differential data segment to the firmware to be upgraded through the serial port in sequence, so that the firmware to be upgraded authenticates the authentication information; wherein, if the authentication is successful, the firmware to be upgraded is upgraded.

[0017] The firmware upgrade method provided in this embodiment can ensure the integrity and authenticity of data during the transmission process by adding authentication information to each differential data segment. After receiving the differential data segment, the firmware to be upgraded will first verify the authentication information, and only the data segment that has been successfully authenticated will be used in the upgrade process. This effectively prevents the data from being tampered with or replaced during the transmission process, thereby improving the security of the upgrade process.

[0018] In a second aspect, the present invention provides a firmware upgrade device, which includes: an acquisition module, used to acquire target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded; a comparison module, used to compare the target data information with the historical data information of the firmware to be upgraded to determine a differential package; wherein the differential package is used to indicate information that is different between the target data information and the historical data information; and an upgrade module, used to upgrade the firmware to be upgraded according to the differential package.

[0019] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the firmware upgrade method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0020] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the firmware upgrade method of the first aspect or any corresponding embodiment thereof.

[0021] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the firmware upgrade method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 is a flowchart of a firmware upgrade method according to an embodiment of the present invention;

[0024] Figure 2 is a structural block diagram of a firmware upgrade device according to an embodiment of the present invention;

[0025] Figure 3 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0027] Based on the relevant technology, it is known that the current firmware upgrade method is often to burn an IAP program into a microcontroller (MCU, Motor Control Unit), and then use the IAP program to upgrade the received firmware to be upgraded.

[0028] However, the IAP program needs to occupy the MCU's storage space, processing power, communication interface and other resources when running. The occupation of these resources may limit the performance of the MCU when performing other tasks.

[0029] Therefore, how to reduce the occupancy rate of the MCU's storage space during firmware upgrade becomes a problem that needs to be solved.

[0030] The present invention provides a firmware upgrade method, which compares target data information with historical data information of a firmware to be upgraded to determine a differential package, that is, to determine the information that is different between the target data information and the historical data information, and then transmits the differential package instead of the entire firmware. That is, in the storage space of the MCU, only space needs to be reserved for the differential package instead of the space for the entire firmware, thereby saving storage space, and enabling the MCU to maintain higher performance during the upgrade process for executing other tasks.

[0031] According to an embodiment of the present invention, a firmware upgrade method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0032] In this embodiment, a firmware upgrade method is provided, which can be used for computer equipment, such as computers, servers, etc. Figure 1 is a flowchart of a firmware upgrade method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0033] Step S101, obtaining target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded.

[0034] The firmware to be upgraded can represent the firmware version that is currently installed in the device but needs to be updated or upgraded. Among them, the firmware to be upgraded can be the firmware to be upgraded of the MCU. MCU is a micro control unit, also known as a single chip microcomputer (SingleChip Microcomputer) or a single chip microcomputer. It appropriately reduces the frequency and specifications of the central processing unit (CPU), and integrates the memory (memory), counter (Timer), USB, A / D conversion, UART, PLC, DMA and other peripheral interfaces, and even LCD drive circuits on a single chip to form a chip-level computer, which can perform different combination controls for different application scenarios.

[0035] The target data information may be the state that the firmware should reach or the information contained in it after the upgrade, usually including new firmware versions, function updates, security patches, etc. Specifically, the complete data packet of the new firmware version can be downloaded or received from a server or a reliable data source, and key information (such as version number, update content, etc.) can be extracted from it as the target data information. For example: There is a smart speaker whose current firmware version is 1.0. The manufacturer has released a new firmware version 1.1, which adds support for a new voice command. In step S101, the speaker needs to download the firmware data packet of version 1.1 from the manufacturer's server and extract the target data information of this version.

[0036] Step S102, comparing the target data information with the historical data information of the firmware to be upgraded to determine a differential packet; wherein the differential packet is used to indicate information that is different between the target data information and the historical data information.

[0037] The historical data information can characterize the status of the current firmware to be upgraded (i.e., the old version of the firmware) or the information contained therein. The differential package can characterize the difference data set obtained by comparing the target data information and the historical data information, which contains the minimum data set required to upgrade the old version of the firmware to the new version. Specifically, a specific algorithm (such as the longest common subsequence algorithm, hash comparison, etc.) can be used to compare the differences between the target data information and the historical data information, and then generate a differential package containing these differences. For example: the speaker will compare the target data information of version 1.1 with the historical data information of version 1.0. Through comparison, it is found that only a part of the code (i.e., the part that supports the new voice command) has changed. Therefore, the differential package will only contain this part of the changed code.

[0038] Step S103: upgrading the firmware to be upgraded according to the differential package.

[0039] The differential packet is transmitted to the device where the firmware to be upgraded is located, and the upgrade operation is performed on the device. Specifically, the difference data in the differential packet can be applied to the old firmware to generate a new firmware version. For example: in the example of a smart speaker, step S103 will involve transmitting the differential packet to the speaker via wireless means such as Wi-Fi or Bluetooth. After receiving the differential packet, the speaker will perform an upgrade operation to upgrade the firmware version 1.0 to version 1.1.

[0040] The firmware upgrade method provided in this embodiment determines the differential package by comparing the target data information with the historical data information of the firmware to be upgraded, that is, determines the information that is different between the target data information and the historical data information, and then transmits the differential package instead of the entire firmware. That is, in the storage space of the MCU, only space needs to be reserved for the differential package instead of the space for the entire firmware, thereby saving storage space, and enabling the MCU to maintain higher performance during the upgrade process for executing other tasks.

[0041] In a possible implementation, the above step S102 includes:

[0042] Step a1: using the longest common subsequence algorithm, determine the difference data between the target data information and the historical data information of the firmware to be upgraded.

[0043] The longest common subsequence algorithm can characterize a problem of finding the longest subsequence among all sequences in a set of sequences (usually two sequences). If a sequence is a subsequence of two or more known sequences and is the longest among all sequences that meet this condition, it is called the longest common subsequence of the known sequences. Specifically, the difference between the target data information determined by the longest common subsequence algorithm and the historical data information of the firmware to be upgraded.

[0044] As an example, the target data information is a string "ABCDEFG", and the historical data information of the firmware to be upgraded is a string "ABCDFGH". Through the longest common subsequence algorithm, it can be determined that their longest common subsequence is "ABCDF", and the difference data is "E" (a unique part in the target data information) and "GH" (a unique part in the historical data information of the firmware to be upgraded. However, in this example, only the difference between the target data and the historical data is considered, so in fact the difference data is "E" and the addition indication of "H", or it can be understood as the absence of "G" and the addition of "EGH", with the addition of "E" being more concerned than "G".

[0045] Step a2, extracting difference data from the target data information, and compressing the difference data to obtain compressed data.

[0046] The difference data is extracted from the target data information, and an appropriate compression algorithm is used to compress the difference data.

[0047] As an example, the extracted difference data may be one or more data blocks, such as "E" in the above example.

[0048] As an example, a compression algorithm such as LZ77 or Huffman coding is used to compress the difference data to obtain compressed data.

[0049] Step a3, adding metadata to the compressed data to determine the differential package.

[0050] Add metadata to the compressed data, such as the compression algorithm type, data size before compression, checksum, etc., and then encapsulate it into a differential packet.

[0051] As an example, the metadata may include: the compression algorithm is LZ77, the data size before compression is 1 byte (ie, the size of "E", not considering the metadata itself), and the checksum is a specific value.

[0052] For example, there is a simple firmware upgrade scenario where the target data information is the new version of the firmware, and the historical data information of the firmware to be upgraded is the old version of the firmware. After determining the difference data between them through the longest common subsequence algorithm, these difference data are extracted and compressed, and then metadata is added to encapsulate them into a differential package. Ultimately, users can upgrade their firmware by downloading and applying this differential package without downloading the entire new version of the firmware, saving time and bandwidth.

[0053] The firmware upgrade method provided in this embodiment can accurately find the longest common subsequence between two sequences through the longest common subsequence algorithm, thereby effectively determining the difference between them. At the same time, by transmitting only the difference data instead of the entire firmware, the amount of data transmission can be significantly reduced. This not only saves bandwidth resources, but also shortens the time required for the upgrade and improves the upgrade efficiency. In addition, by compressing the difference data and adding metadata to the compressed data to form a differential packet, the integrity and accuracy of the data can be ensured. At the same time, the compression process can also increase the confidentiality of the data to a certain extent, improving the security during the upgrade process.

[0054] In a possible implementation, the metadata is determined by:

[0055] Step b1, obtaining the version information and hash value of the firmware.

[0056] The firmware version information can represent a set of data of a specific version of the firmware, including version number, release date, functional changes, etc. The hash value can be used to verify the integrity and security of the data. During the firmware upgrade process, the hash values ​​of the new and old firmware are compared to ensure that the firmware has not been tampered with or damaged. Specifically, the version information can be extracted from the firmware file by reading a specific area within the firmware file or parsing the header information of the firmware file. The hash value of the firmware file can be calculated using a hash algorithm (such as SHA-256).

[0057] Step b2, determining the offset and length of the difference data.

[0058] The offset can represent the distance of a data item relative to the starting position in the data structure. The length can represent the number of bytes or bits occupied by the data item. By comparing the new and old firmware files, the position (offset) and size (length) of the difference data in the firmware file can be determined.

[0059] Step b3, determining metadata according to the firmware version information, the offset and length of the hash value difference data.

[0060] Combine the firmware version information, hash value, offset and length of the difference data into metadata. The metadata may be stored in a specific format, such as XML, JSON, or a custom format. The metadata will be used in the subsequent firmware upgrade process to ensure the correctness and security of the upgrade.

[0061] The firmware upgrade method provided in this embodiment can ensure that the correct firmware version is targeted when upgrading or managing by obtaining the version information of the firmware. This avoids upgrade failures or device failures caused by version mismatches. The hash value, as the digital fingerprint of the firmware, can uniquely identify the content of the firmware. By comparing the current hash value of the firmware with the pre-stored hash value, it can be verified whether the firmware has been tampered with or damaged during transmission or storage. This ensures the security and reliability of the firmware. By determining the offset and length of the difference data, the part of the firmware that needs to be updated or modified can be accurately located. This reduces the burden of data transmission and processing and improves upgrade efficiency.

[0062] In a possible implementation, the above step a1 includes:

[0063] Step a11, reading the first firmware file corresponding to the target data information and the second firmware file corresponding to the historical data information into the memory in binary mode respectively.

[0064] Open the first and second firmware files in binary read mode (usually 'rb' mode, where 'r' means read and 'b' means binary) using the appropriate file open functions or methods. Read the contents of the open files into memory. This typically involves a loop or reading the entire file contents at once, depending on the size of the file and available memory. For larger files, it may be necessary to read in chunks to avoid taking up too much memory at once. Store the read binary data in variables or data structures in memory for subsequent processing. These variables or data structures can be simple byte arrays (such as bytes objects in Python), or more complex custom data structures, depending on the needs of subsequent processing.

[0065] Step a12, splitting the first firmware file to obtain a first block.

[0066] Step a13, split the second firmware file to obtain a second block.

[0067] The size of the segmentation can be determined based on the size of the file, the content structure, or specific processing requirements. Among them, the segmentation strategy may include segmentation by fixed size (such as 1KB, 4KB per block, etc.), segmentation by specific marks or boundaries (such as file header, data segment, file tail, etc.), or segmentation according to other custom rules, etc., which are not specifically limited here and can be implemented by those skilled in the art. According to the determined segmentation strategy, the first firmware file is divided into multiple blocks. Specifically, it can include reading the file content and calculating the starting and ending positions of each block according to the segmentation strategy. Then, the content of each block is extracted and stored in an appropriate location in the memory for subsequent processing.

[0068] Step a14: construct a two-dimensional matrix according to the first block and the second block; wherein the two-dimensional matrix is ​​used to indicate the length of the longest common subsequence of the first block and the second block.

[0069] Specifically, create a two-dimensional matrix dp of size (m+1)x(n+1), where m is the length of the first block and n is the length of the second block. dp[i][j] will represent the length of the longest common subsequence between the first i characters of the first block and the first j characters of the second block. Initialize the first row and first column of the matrix to 0, because the length of the longest common subsequence between the empty string and any string is 0. Use two nested loops to traverse each element of the matrix dp[i][j] (from dp[1][1] to dp[m][n]). For each dp[i][j], check whether the i-1th character of the first block and the j-1th character of the second block are equal: if they are equal, then dp[i][j]=dp[i-1][j-1]+1, because the current character is part of the common subsequence, add the value of the previous dp[i-1][j-1] and add 1. If they are not equal, then dp[i][j] = max(dp[i-1][j], dp[i][j-1]), taking the larger value of the two cases that do not contain the current character. The last element dp[m][n] of the matrix dp is the length of the longest common subsequence of the first block and the second block.

[0070] Step a15, filling the two-dimensional matrix, and determining the difference data by back-tracing the filled two-dimensional data.

[0071] Constructing the LCS matrix is ​​to create a two-dimensional matrix of size [m+1][n+1], where m and n are the lengths of the new and old firmware files respectively. In the matrix, LCS[i][j] represents the longest common subsequence length of the first i bytes of the new firmware file and the first j bytes of the old firmware file. Filling the LCS matrix is ​​to traverse the matrix from the upper left corner and fill it according to the following rules: if the current bytes of the new and old firmware are the same, LCS[i][j] = LCS[i-1][j-1]+1; if they are different, LCS[i][j] = max(LCS[i-1][j], LCS[i][j-1]). Backtracking to find the difference is to backtrack from the lower right corner of the matrix to find the path of the longest common subsequence. During the backtracking process, mark the differences between the new and old firmware files. These are the parts that need to be updated, that is, the difference data.

[0072] The firmware upgrade method provided in this embodiment can efficiently process the original data by reading the firmware file in binary mode, avoiding the loss of data and format incompatibility problems during the conversion process. In addition, the firmware file is divided into blocks, which can facilitate subsequent processing and analysis. The accuracy and granularity of the segmentation can be adjusted according to actual needs to meet different application scenarios. In addition, by filling a two-dimensional matrix and performing backtracking processing, the difference data in the firmware file can be accurately determined. This method avoids the tedious process of manually comparing and identifying difference data, and improves accuracy and efficiency.

[0073] In a possible implementation, the above step S103 includes:

[0074] Step c1, segmenting the differential packet according to a preset size to obtain differential data segments.

[0075] The preset size can represent the size of each segmented packet. The preset size can be P1, P2, etc., which is not specifically limited here. Specifically, read the content of the differential packet, and calculate the number of data segments to be divided according to the preset size. Each data segment can be extracted from the differential packet in sequence in a loop or iteration. Ensure that the last data segment (if the differential packet size is not an integer multiple of the preset size) can also be processed correctly.

[0076] Preferably, in order to be able to reassemble the differential data segments at the receiving end, some marking information may be added before each data segment, such as the sequence number, size, checksum, etc. of the data segment.

[0077] Step c2, transmitting each differential data segment to the firmware to be upgraded in sequence through the serial port, so as to upgrade the firmware to be upgraded.

[0078] Configure the serial port according to the serial port communication specifications (such as baud rate, data bit, stop bit, check bit, etc.) of the firmware device to be upgraded, and use the serial port communication protocol to send each differential data segment to the firmware device in sequence. During the transmission process, communication errors or data loss may occur. Therefore, it is necessary to implement an error detection and retransmission mechanism to ensure that each data segment can reach the firmware device correctly.

[0079] The firmware upgrade method provided in this embodiment can reduce the risk of single transmission failure by transmitting differential data segments in segments. If a differential data segment fails to be transmitted, only the segment of data can be retransmitted without retransmitting the entire differential packet, thereby improving the reliability and stability of the upgrade.

[0080] In a possible implementation, the method further includes:

[0081] Step d1, adding authentication information to each differential data segment.

[0082] When generating a differential packet, the firmware data must be encrypted, and then the new firmware must be differentially analyzed, only the parts that are different from the old firmware must be extracted, and a differential packet must be generated. The differential packet must be segmented by size, and before the firmware data is segmented, each data segment must be added with authentication information, and each data segment must be independently error-checked and error-corrected. The authentication information can represent the information of each segmented packet, such as a unique authentication identifier (ID, etc.).

[0083] Step d2, transmitting each differential data segment to the firmware to be upgraded in sequence through the serial port, so that the firmware to be upgraded authenticates the authentication information; wherein, if the authentication is successful, the firmware to be upgraded is upgraded.

[0084] Before transmitting data, the device needs to send its own device ID and digital signature to the authentication server. The device also needs to verify the identity of the server, use the negotiated key to encrypt the transmitted firmware data, and transmit the differential data segments to the MCU in sequence through the serial port. The flow control of the serial port protocol is used to ensure that data is not lost due to buffer overflow. Each time a data segment is transmitted, the MCU immediately performs checksum verification and digital signature verification. If the check or verification fails, it immediately requests retransmission of the data segment and records the security event.

[0085] The firmware upgrade method provided in this embodiment can ensure the integrity and authenticity of data during the transmission process by adding authentication information to each differential data segment. After receiving the differential data segment, the firmware to be upgraded will first verify the authentication information, and only the data segment that has been successfully authenticated will be used in the upgrade process. This effectively prevents the data from being tampered with or replaced during the transmission process, thereby improving the security of the upgrade process.

[0086] In a specific application scenario, smart home device upgrade: In a smart home system, devices such as smart lights, smart thermostats and smart door locks need to be upgraded with firmware to add new features or fix known problems.

[0087] Preset the address segment of the IAP program in the smart home device to ensure a safe zone. The device connects to the authentication server via Wi-Fi for identity authentication.

[0088] S2. The manufacturer generates a differential package of the new firmware and encrypts it. The differential package is divided into multiple data segments, and authentication information is added to each segment to ensure data integrity and security;

[0089] S3. The device sends the device ID and digital signature to the authentication server, uses the negotiated key to generate a differential package of the new firmware, encrypts it, and divides the differential package into multiple data segments. Each segment is added with authentication information to ensure the integrity and security of the data. At the same time, the device sends the device ID and digital signature to the authentication server, encrypts the differential data using the negotiated key, and transmits it to the device via Wi-Fi. After receiving each data segment, the device immediately performs checksum and digital signature verification. If it fails, it requests retransmission.

[0090] S4. The device decrypts the received differential data, verifies the digital signature and stores it to the preset address. The device's IAP program compiles and runs the new firmware to complete the upgrade.

[0091] In a specific application scenario, industrial control system upgrade: the PLC (programmable logic controller) on an industrial automation production line needs to update its firmware to improve production efficiency.

[0092] D1. Preset the address segment of the IAP program to ensure that there is a security zone. The PLC is connected to the authentication server via industrial Ethernet.

[0093] D2. Generate and encrypt the differential package of the PLC firmware. The differential package is divided into small segments, and authentication information is added to each segment.

[0094] D3, PLC sends the device ID and digital signature to the authentication server, uses a secure communication protocol to transmit encrypted differential data, and performs checksum verification after each data segment is transmitted to ensure data integrity;

[0095] D4. After decrypting and verifying the data, it is stored in the preset address of the PLC. The IAP program starts the new firmware and completes the upgrade process.

[0096] Embodiment 3

[0097] Automotive ECU (Electronic Control Unit) Upgrade: Vehicle manufacturers need to remotely upgrade the vehicle's engine control unit (ECU) firmware to optimize fuel efficiency and emissions.

[0098] The implementation steps are as follows:

[0099] F1. The address segment and security zone of the IAP program are preset in the ECU. The ECU is connected to the vehicle's communication module through the vehicle network (such as CAN bus), and the latter accesses the authentication server through the cellular network.

[0100] F2. Generate a differential package of the ECU firmware, encrypt it, transmit it in segments, and add authentication information to each segment;

[0101] F3. The vehicle sends the device ID and digital signature to the server through the communication module. The encrypted data is transmitted to the vehicle through the cellular network and then to the ECU through the CAN bus. Each data segment is checked and digitally signed after transmission.

[0102] F4. ECU decrypts and verifies the data and stores it to the preset address. The IAP program compiles the new firmware and starts the new code to complete the ECU upgrade.

[0103] The present invention ensures the security of firmware data transmission and storage through encryption processing and digital signature verification, two-way identity authentication of devices and servers, increases the security of the system, reduces the risk of illegal access, uses differential analysis technology to only transmit the difference between the new and old firmware, greatly reduces the amount of data to be transmitted, and thus shortens the upgrade time. At the same time, the segmented transmission method can avoid transmission failure or buffer overflow problems caused by excessive data, improves the reliability and efficiency of transmission, and performs independent error detection and error correction on each data segment to ensure that even if problems occur during the transmission process, they can be quickly discovered and retransmitted to ensure data integrity. Through the flow control of the serial port protocol, the data flow can be effectively managed to prevent data loss or damage, and the problem that serial port communication is easily disturbed in the upgrade method of the comparison file may cause upgrade failure, and the error detection and correction mechanism needs to be considered, which increases the complexity. The probability of data error during transmission is relatively high, and the serial port communication speed is relatively low. Especially when upgrading larger firmware, the upgrade time will be very long, affecting the user experience.

[0104] In this embodiment, a firmware upgrade device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0105] This embodiment provides a firmware upgrade device, such as Figure 2 As shown, it includes: an acquisition module 201, which is used to acquire target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded; a comparison module 202, which is used to compare the target data information with the historical data information of the firmware to be upgraded to determine a differential package; wherein the differential package is used to indicate information that is different between the target data information and the historical data information; and an upgrade module 203, which is used to upgrade the firmware to be upgraded according to the differential package.

[0106] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0107] The firmware upgrade device in this embodiment is presented in the form of a functional unit, where the functional unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0108] The embodiment of the present invention also provides a computer device having the above Figure 2 The firmware upgrade device shown.

[0109] See also Figure 3 , Figure 3 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 3 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.

[0110] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0111] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0112] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0113] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0114] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0115] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0116] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0117] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A firmware upgrade method, characterized in that: The method comprises: Acquire target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded; Comparing the target data information with the historical data information of the firmware to be upgraded to determine a differential packet; wherein the differential packet is used to indicate information that is different between the target data information and the historical data information; The firmware to be upgraded is upgraded according to the differential package.

2. The firmware upgrade method according to claim 1, characterized in that: The step of comparing the target data information with the historical data information of the firmware to be upgraded to determine a differential package includes: Determine the difference data between the target data information and the historical data information of the firmware to be upgraded by using the longest common subsequence algorithm; Extracting the difference data from the target data information, and compressing the difference data to obtain compressed data; Metadata is added to the compressed data to determine a differential packet.

3. The firmware upgrade method according to claim 2, characterized in that: Methods for determining metadata include: Get the firmware version information and hash value; Determining the offset and length of the difference data; The metadata is determined according to the version information of the firmware, the offset and the length of the hash value difference data.

4. The firmware upgrade method according to claim 2, characterized in that: The method of using the longest common subsequence algorithm to determine the difference data between the target data information and the historical data information of the firmware to be upgraded includes: Reading the first firmware file corresponding to the target data information and the second firmware file corresponding to the historical data information into the memory in binary mode respectively; Splitting the first firmware file to obtain a first block; Splitting the second firmware file to obtain a second block; Constructing a two-dimensional matrix according to the first block and the second block; wherein the two-dimensional matrix is ​​used to indicate the length of the longest common subsequence of the first block and the second block; The two-dimensional matrix is ​​filled, and the difference data is determined by back-tracing the filled two-dimensional data.

5. The firmware upgrade method according to claim 1, characterized in that: Upgrading the firmware to be upgraded according to the differential package includes: Segmenting the differential packet according to a preset size to obtain differential data segments; Each differential data segment is sequentially transmitted to the firmware to be upgraded through the serial port, so as to upgrade the firmware to be upgraded.

6. The firmware upgrade method according to claim 5, characterized in that: Before transmitting each differential data segment to the firmware to be upgraded in sequence through the serial port to upgrade the firmware to be upgraded, the method further includes: Adding authentication information to each of the differential data segments; Each differential data segment is transmitted sequentially to the firmware to be upgraded through the serial port to upgrade the firmware to be upgraded, including: Each differential data segment is sequentially transmitted to the firmware to be upgraded through the serial port, so that the firmware to be upgraded authenticates the authentication information; wherein, if the authentication is successful, the firmware to be upgraded is upgraded.

7. A firmware upgrade device, characterized in that: The device comprises: An acquisition module, used to acquire target data information of the firmware to be upgraded; wherein the target data information is information for upgrading the firmware to be upgraded; A comparison module, used to compare the target data information with the historical data information of the firmware to be upgraded, and determine a differential packet; wherein the differential packet is used to indicate information that is different between the target data information and the historical data information; An upgrading module is used to upgrade the firmware to be upgraded according to the differential package.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the firmware upgrade method according to any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the firmware upgrade method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the firmware upgrade method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Firmware updating method, firmware updating device, equipment and storage medium

    CN120335849A

  • Remote upgrading method of equipment, server, equipment side and system

    CN121050755A