Firmware updating method, device, apparatus and storage medium
By using a differential data packet update method and a security verification mechanism, the problems of low efficiency and insufficient reliability in firmware updates for embedded devices are solved, achieving efficient and secure firmware updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN ASCHIP TECH CO LTD
- Filing Date
- 2026-02-26
- Publication Date
- 2026-05-29
AI Technical Summary
Existing embedded device firmware updates suffer from low efficiency, insufficient reliability and security, and high maintenance costs, especially in large-scale device scenarios, and are susceptible to network conditions and security threats.
The differential data packet update method is adopted. The transmission mode is selected according to the firmware update command type. The differential data packets are received and synthesized by combining local and remote communication interfaces, and security is ensured by digital signature and device whitelist verification.
It improves the efficiency and reliability of firmware updates, reduces operation and maintenance costs, enhances network adaptability and security, and prevents firmware tampering and device damage.
Smart Images

Figure CN122111481A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data transmission technology, and in particular to a firmware update method, apparatus, device, and storage medium. Background Technology
[0002] In the field of embedded device firmware updates, IAP (In-Application Programming) and OTA (Over-The-Air) have long been in a state of "separate applications" without forming an efficient collaborative mechanism. Traditional IAP technology mostly relies on wired transmission (such as the USART interface), only supports local firmware writing, and upgrade operations are limited by physical distance, resulting in extremely high maintenance costs in large-scale equipment scenarios such as industrial IoT. Although its transmission process adopts a fragmentation mechanism, it lacks the ability to resume interrupted transmissions. Once communication is interrupted, a complete retransmission is required, which is inefficient.
[0003] While existing OTA (Over-The-Air) technology enables wireless upgrades, it suffers from significant drawbacks: First, upgrades involve large data transfers, typically using a full firmware push mode. In narrowband networks like LoRa or scenarios sensitive to 4G tariffs, this not only results in lengthy upgrades but also incurs high communication costs. Second, protocol compatibility is poor, often relying on a single fixed protocol (such as MQTT or HTTP), unable to dynamically adjust based on the bandwidth and latency characteristics of different network types like Wi-Fi, 4G, 5G, and LoRa. This makes transmission interruptions prone to occur during network switching or signal instability. Third, security is weak, with most relying solely on simple cyclic redundancy check (CRC) and lacking digital signatures and transmission encryption mechanisms. Firmware is easily tampered with or hijacked, and there is a risk of version downgrade attacks. Furthermore, devices are often in an "unavailable" state during existing system upgrades. If the upgrade fails (e.g., due to firmware corruption or power outage), the device can become unusable and unable to return to normal operation.
[0004] Therefore, there is an urgent need for a firmware update method that can not only improve the efficiency of firmware updates, but also enhance the reliability and security of firmware updates. Summary of the Invention
[0005] The main objective of this invention is to provide a firmware update method, apparatus, device, and storage medium, which aims to solve the technical problems of low efficiency, insufficient reliability, and inadequate security in existing firmware updates.
[0006] To achieve the above objectives, the present invention provides a firmware update method, the method comprising the following steps: Receive firmware update instructions, including local update instructions or remote update instructions; Based on the type of the firmware update instruction, the corresponding transmission mode is determined, and a differential data packet is obtained through the transmission mode. The differential data packet includes the difference information between the target firmware and the current firmware. Firmware synthesis is performed based on the current firmware and the differential data packet to obtain the target firmware, and the target firmware is written to a preset backup storage area; The target firmware in the preset backup storage area is subjected to integrity verification, and after the verification is passed, the system is switched to the preset backup storage area to start running.
[0007] Optionally, the step of determining the corresponding transmission mode based on the type of the firmware update instruction and obtaining differential data packets through the transmission mode includes: When the firmware update command is a local update command, the local communication interface is activated, and differential data packets are received through the local communication interface in a preset fragmentation manner. When the firmware update command is a remote update command, the current network environment parameters are detected, a target transmission protocol is selected from multiple transmission protocols based on the current network environment parameters, and differential data packets are received through the target transmission protocol.
[0008] Optionally, the step of detecting current network environment parameters and selecting a target transmission protocol from multiple transmission protocols based on the current network environment parameters when the firmware update command is a remote update command includes: When the firmware update command is a remote update command, the current network environment parameters are detected, including the current network bandwidth, latency, and packet loss rate. Based on the bandwidth, the latency, and the packet loss rate, the comprehensive adaptation score of each transmission protocol is determined according to the preset protocol evaluation rules. The transmission protocol with the highest overall adaptation score is selected as the target transmission protocol.
[0009] Optionally, the step of activating the local communication interface and receiving differential data packets in a preset fragmentation manner through the local communication interface when the firmware update command is a local update command includes: When the firmware update command is a local update command, the local communication interface is activated, and a response signal is returned to the sending end of the firmware update command; Receive firmware metadata frames sent by the sending end, the firmware metadata frames including firmware capacity information and fragmentation configuration parameters; Based on the fragmentation configuration parameters, a fragmentation reception strategy is determined. Data fragments corresponding to differential data packets are received one by one according to the fragmentation reception strategy. After each data fragment is received, a reception confirmation signal is returned to the sending end. A preset delay interval is set between the reception of adjacent data fragments until the reception of the differential data packets is completed.
[0010] Optionally, before the step of writing the target firmware to the preset backup storage area, the method further includes: The differential data packets are subjected to source legitimacy verification, which includes digital signature verification and device whitelist verification. After the source legitimacy verification is passed, the step of writing the target firmware to the preset backup storage area is performed.
[0011] Optionally, the step of performing integrity verification on the target firmware in the preset backup storage area, and switching to the preset backup storage area for startup and operation after the verification passes, includes: Perform integrity verification on the target firmware in the preset backup storage area and obtain the verification result; When the verification result indicates that the verification is successful, the status flag of the preset backup storage area is updated to mark the preset backup storage area as an active state; In response to a device restart command, the device starts running from the preset backup storage area in the pending activation state, based on the status flag of the preset backup storage area.
[0012] Optionally, before the step of receiving the firmware update instruction, the method further includes: Receive a group update instruction sent by a remote management platform, wherein the group update instruction includes the target device group identifier and update task parameters; Based on the target device group identifier, confirm whether the device belongs to the target update group, and if it is confirmed to belong, execute the step of receiving firmware update instructions.
[0013] Furthermore, to achieve the above objectives, the present invention also proposes a firmware update device, the device comprising: The instruction receiving module is used to receive firmware update instructions, which include local update instructions or remote update instructions; The data acquisition module is used to determine the corresponding transmission mode according to the type of the firmware update instruction, and to acquire differential data packets through the transmission mode. The differential data packets include the difference information between the target firmware and the current firmware. The firmware synthesis module is used to synthesize firmware based on the current firmware and the differential data packet to obtain the target firmware, and write the target firmware into a preset backup storage area; The firmware verification module is used to perform integrity verification on the target firmware in the preset backup storage area, and switch to the preset backup storage area to start running after the verification is passed.
[0014] Furthermore, to achieve the above objectives, the present invention also proposes a firmware update device, the device comprising: a memory, a processor, and a firmware update program stored in the memory and executable on the processor, the firmware update program being configured to implement the steps of the firmware update method as described above.
[0015] Furthermore, to achieve the above objectives, the present invention also proposes a storage medium storing a firmware update program, wherein the firmware update program, when executed by a processor, implements the steps of the firmware update method as described above.
[0016] This invention discloses a method for receiving firmware update instructions, including local update instructions or remote update instructions; determining the corresponding transmission mode based on the type of firmware update instruction, and obtaining differential data packets through the transmission mode, the differential data packets including difference information between the target firmware and the current firmware; synthesizing firmware based on the current firmware and the differential data packets to obtain the target firmware, and writing the target firmware into a preset backup storage area; performing integrity verification on the target firmware in the preset backup storage area, and switching to the preset backup storage area for startup after successful verification. Because this invention adapts the corresponding transmission mode according to the type of firmware update instruction and obtains differential data packets, then writes the target firmware into the preset backup storage area, performs integrity verification on the target firmware in the preset backup storage area, and switches to the preset backup storage area for startup after successful verification, compared with the prior art, this invention not only improves the efficiency of firmware updates but also enhances the reliability and security of firmware updates. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the first embodiment of the firmware update method of the present invention; Figure 2 This is a flowchart illustrating the second embodiment of the firmware update method of the present invention; Figure 3 This is a flowchart illustrating the third embodiment of the firmware update method of the present invention; Figure 4 This is a structural block diagram of the first embodiment of the firmware update device of the present invention; Figure 5 This is a schematic diagram of the structure of the firmware update device for the hardware operating environment involved in the embodiments of the present invention.
[0018] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0019] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0020] This invention provides a firmware update method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the firmware update method of the present invention.
[0021] In this embodiment, the firmware update method includes steps S10 to S40: Step S10: Receive firmware update instructions, which include local update instructions or remote update instructions.
[0022] It should be noted that the execution subject of this embodiment can be an embedded device that performs firmware updates and has data processing, network communication, and program execution functions, or an electronic device (such as a firmware update device) capable of performing the above functions. The following uses a system containing a firmware update device (hereinafter referred to as the system) as an example to illustrate this embodiment and the following embodiments.
[0023] It should be understood that a firmware update instruction can refer to a control signal or command frame that triggers the device to initiate the firmware update process.
[0024] Furthermore, local update commands can refer to firmware update commands triggered through physical wired interfaces (such as USART2, USB, CAN, etc.), typically issued by a directly connected local host (host computer). For example, the "app update" command sent by the host computer via USART2 is a local update command.
[0025] Remote update commands can refer to firmware update commands received via wireless networks (such as Wi-Fi, 4G / 5G, LoRa, etc.) and issued by cloud servers or remote management platforms. For example, OTA upgrade commands sent from the cloud to a group of devices are remote update commands.
[0026] Step S20: Determine the corresponding transmission mode according to the type of the firmware update instruction, and obtain the differential data packet through the transmission mode. The differential data packet includes the difference information between the target firmware and the current firmware.
[0027] Understandably, firmware update commands fall into two categories: local update commands and remote update commands. The transmission mode refers to a predefined combination of communication links and data transmission strategies used to receive differential data packets, designed to accommodate different types of firmware update commands.
[0028] It should be noted that when the firmware update command is a local update command, the local communication interface is activated, and differential data packets are received through the local communication interface in a preset fragmentation manner; when the firmware update command is a remote update command, the current network environment parameters are detected, a target transmission protocol is selected from multiple transmission protocols based on the current network environment parameters, and differential data packets are received through the target transmission protocol.
[0029] For example, in response to a local update command, the device's local communication interface (such as USART2) can be activated, and differential data packet reception can be performed using a preset fragmentation method (such as 256 bytes / fragment, with delayed transmission) and an acknowledgment protocol (such as the 0x79 acknowledgment command). This transmission mode emphasizes compatibility with the hardware debugging environment and transmission reliability.
[0030] For example, in response to a remote update command, the system's OTA module is activated. By monitoring current network environment parameters (bandwidth, latency, packet loss rate) in real time, it dynamically selects the optimal transmission protocol from the multi-protocol adaptive stack, i.e., the target transmission protocol (such as MQTT, CoAP, HTTP / 2). It can also be used in conjunction with a breakpoint resume mechanism for differential data packet reception. This transmission mode emphasizes the ability to adapt to different network conditions.
[0031] It needs to be explained that the breakpoint resume mechanism refers to a data transmission guarantee strategy that, when receiving differential data packets through the transmission mode corresponding to the remote update command, if the transmission is interrupted due to abnormal conditions such as network fluctuations, connection timeouts, or device power failures, the transmission can continue from the breakpoint when the connection is re-established, rather than starting all over again.
[0032] In a specific implementation, during the process of receiving differential data packets through the target transmission protocol, the transmission offset of the successfully received data can be recorded in real time. When a network transmission interruption is detected and the connection is re-established, a resume request is sent to the sending end. The resume request carries the transmission offset to instruct the sending end to continue transmitting differential data packets from the data position corresponding to the transmission offset.
[0033] It should be noted that the two transmission modes corresponding to the aforementioned local update command and remote update command can be automatically switched by the system's IAP-OTA collaborative control module according to the type of firmware update command, achieving seamless linkage between wired and wireless upgrades.
[0034] It should be noted that differential data packets refer to data packets generated by the cloud-based differential upgrade engine based on the differences between the target firmware and the current firmware of the device. They are not complete firmware images and may include changed data blocks (i.e. binary fragments that have changed or been added to the target firmware compared to the current firmware), location information (i.e. the write address or offset of each changed data block in the target firmware), and control information (i.e. metadata such as differential algorithm identifier, firmware version number, and checksum).
[0035] In its implementation, after receiving the differential data packet, the device's local differential upgrade engine (based on the BsDiff optimization algorithm) combines the unchanged parts of the current firmware with data block replacement and splicing to reconstruct the complete target firmware locally. Compared to transmitting the full firmware, differential data packets can save more than 90% of transmission bandwidth, making them particularly suitable for narrowband networks or cost-sensitive scenarios.
[0036] It should be noted that when the firmware update command is a remote update command, the step of detecting the current network environment parameters and selecting a target transmission protocol from multiple transmission protocols based on the current network environment parameters includes: when the firmware update command is a remote update command, detecting the current network environment parameters, which include the current network bandwidth, latency, and packet loss rate; determining the comprehensive adaptation score of each transmission protocol according to the bandwidth, latency, and packet loss rate and a preset protocol evaluation rule; and selecting the transmission protocol with the highest comprehensive adaptation score as the target transmission protocol.
[0037] It should be understood that the overall adaptation score can refer to a quantitative value used to characterize the overall adaptability of a specific communication protocol in the currently detected network environment. This score is the output of preset protocol evaluation rules, and its value directly reflects the expected effect of selecting the protocol for data transmission. The higher the score, the better the transmission stability, efficiency, and reliability of the protocol under the current network conditions, and the more likely it should be given priority.
[0038] It should be explained that the preset protocol evaluation rule can refer to a pre-defined computational logic or decision-making strategy used to quantitatively evaluate the adaptability of different communication transmission protocols in the current network environment. The core purpose of this rule is to transform abstract network conditions (such as bandwidth, latency, and packet loss severity) into comparable quantitative indicators, thereby providing an objective basis for protocol selection.
[0039] In a practical implementation, the preset protocol evaluation rules can be embodied as a weighted scoring algorithm. That is, a corresponding scoring function is assigned to each network environment parameter (such as bandwidth, latency, and packet loss rate), mapping the original measurement value to a score (e.g., higher bandwidth, higher score; lower latency, higher score; lower packet loss rate, higher score). Furthermore, a weighting coefficient is assigned to each parameter (e.g., bandwidth weight 40%, latency weight 30%, packet loss rate weight 30%). Finally, a weighted summation method is used to calculate the comprehensive adaptation score of a protocol in this network environment. The comprehensive adaptation score = bandwidth score × 0.4 + latency score × 0.3 + packet loss rate score × 0.3. The protocol with the highest score is activated as the target transmission protocol. For example, a LoRa network with a bandwidth score of 10, a latency score of 3, and a packet loss rate score of 5 has a comprehensive score of 10 × 0.4 + 3 × 0.3 + 5 × 0.3 = 6.4, which is higher than MQTT's 4.2. Therefore, the CoAP protocol is preferentially selected as the target transmission protocol.
[0040] It should be noted that when the firmware update command is a local update command, the step of activating the local communication interface and receiving differential data packets through the local communication interface in a preset fragmentation manner includes: when the firmware update command is a local update command, activating the local communication interface and returning an acknowledgment signal to the sending end of the firmware update command; receiving the firmware metadata frame sent by the sending end, the firmware metadata frame including firmware capacity information and fragmentation configuration parameters; determining a fragmentation reception strategy based on the fragmentation configuration parameters, receiving data fragments corresponding to the differential data packets one by one according to the fragmentation reception strategy, returning a reception acknowledgment signal to the sending end after each data fragment is received, and setting a preset delay interval between the reception of adjacent data fragments until the reception of the differential data packets is completed.
[0041] Understandably, a local communication interface refers to the hardware port and its driver software on a device used for wired data exchange with external devices (such as host computers, debuggers, industrial control computers, etc.) that are directly connected locally. Its function is to establish a physical point-to-point communication link, independent of wireless network infrastructure. Examples include Universal Synchronous / Asynchronous Receiver / Transmitter (USART, such as the USART2 interface), Universal Serial Bus (USB), or Controller Area Network (CAN) interfaces, used to establish a wired physical connection between the device and a local host computer for data exchange.
[0042] It should be understood that an acknowledgment signal can be a specific confirmation code or status frame returned by the device to the sender after receiving a legitimate instruction or data. Its function is to notify the sender that the instruction has been correctly received and parsed, that the device is ready to receive subsequent data, or that a piece of data has been successfully written, thereby achieving reliable communication based on a handshake mechanism.
[0043] For example, an acknowledgment signal can be a specific hexadecimal byte 0x79 (corresponding to the ASCII character 'y') used to report the status of the current operation to the host computer. 0x79 typically indicates that the instruction has been successfully received and accepted (ACK), and the device can continue processing subsequent data. Other codes can be used to represent different states, such as busy or error.
[0044] It should be noted that a firmware metadata frame can be a special data packet sent by the sending end (such as a host computer) to the receiving end (such as an embedded device) before the actual transmission of firmware data. This data packet does not contain the firmware's code content itself, but carries descriptive information describing the attributes and transmission rules of the firmware file to be transmitted, allowing the receiving end to prepare for reception. Firmware capacity information can refer to the total byte size of the differential data packets or the complete firmware file to be transmitted. Based on this, the device can pre-allocate sufficient storage buffers and determine whether the data has been received completely. Fragmentation configuration parameters can refer to the specific rules used by the sending end to segment the firmware data during this transmission, such as how many bytes each data block contains. In addition, it may also include fragment sequence number encoding rules, etc.
[0045] It should be understood that a fragmented reception strategy refers to a set of specific and ordered data reception rules formulated by an embedded device based on the fragmentation configuration parameters parsed from the firmware metadata frame and combined with its own processing capabilities. These rules determine how the device requests or receives data from the sender, how it handles reception gaps, and how it acknowledges data. For example, when the fragmentation configuration parameter is 256 bytes, the fragmented reception strategy is as follows: receive data in 256-byte blocks one by one; after successfully writing each data block, return an acknowledgment signal (e.g., 0x79) to request the next fragment; and, to ensure sufficient time for the hardware to complete the erase and write operations, a preset delay interval (e.g., 50 milliseconds) is forcibly inserted between the reception of two consecutive data fragments until all fragments have been received.
[0046] Step S30: Based on the current firmware and the differential data packet, perform firmware synthesis to obtain the target firmware, and write the target firmware into the preset backup storage area.
[0047] It should be noted that the step of synthesizing the target firmware based on the current firmware and the differential data packet may include: parsing the differential data packet to extract the changed data blocks carried therein and the position information of each changed data block in the target firmware; copying the unchanged data blocks from the current firmware except for the positions corresponding to the changed data blocks; and combining and splicing the changed data blocks and unchanged data blocks according to the position information to reconstruct and generate the target firmware. For example, the current firmware V1.0 contains fragments (A)(B)(C)(D), and after upgrading to the target firmware V1.1, the fragments become (A)(X)(C)(Y). The differential data packet only contains (X)(Y) and position information. By replacing the corresponding fragments during synthesis, the complete firmware can be restored to obtain the target firmware.
[0048] Understandably, to ensure firmware integrity, CRC32 verification can be used after firmware synthesis to ensure firmware integrity. If the verification fails, a request is made to retransmit the differential data packets.
[0049] It should be explained that the preset backup storage area can refer to one or more dedicated storage spaces in the non-volatile memory (such as Flash) of an embedded device, which are pre-allocated and independent of the storage area of the currently running firmware.
[0050] It should be noted that the preset backup storage area is physically isolated from the storage area of the currently running firmware (hereinafter referred to as the "current running area"), and the two do not overlap. For example, the Flash can be divided into area A (current running area) and area B (preset backup storage area), each occupying 512KB. Logically, the two are distinguished and managed through partition status flags (such as the byte stored at address 0x0800F000). The flags can indicate whether the partition is in a "running", "awaiting activation (writable)", or "abnormal" state.
[0051] The core function of the preset backup storage area is to carry new firmware (target firmware) to enable rolling updates and fault rollback. During normal operation, the device boots from the "current running area"; when a firmware upgrade is performed, the newly synthesized target firmware is written to the idle "preset backup storage area", while the original "current running area" continues to run the old firmware, ensuring that the device remains available during the upgrade writing process and does not interrupt services.
[0052] In a specific implementation, the step of writing the target firmware to the preset backup storage area may include: determining the preset backup storage area that is currently in an idle state as the target writing area; writing the target firmware piece by piece to the target writing area, and updating the status flag of the target writing area in real time during the writing process; after all the target firmware has been written, updating the status flag of the target writing area to the pending activation state, so that it can be identified by the boot loader and started first when the device is restarted.
[0053] Step S40: Perform integrity verification on the target firmware in the preset backup storage area, and switch to the preset backup storage area to start running after the verification is passed.
[0054] To ensure the stability and security of the device during the upgrade process, in a specific implementation, the target firmware in the preset backup storage area can be subjected to integrity verification (e.g., CRC32 verification) to obtain the verification result; when the verification result indicates that the verification is successful, the status flag bit of the preset backup storage area is updated to mark the preset backup storage area as a pending activation state; in response to the device restart command, the device is started from the preset backup storage area in the pending activation state based on the status flag bit of the preset backup storage area.
[0055] It should be noted that once the target firmware written to the preset backup storage area has passed integrity verification and is confirmed to be bootable, the role of this "preset backup storage area" will switch to the new "current running area," and the device will boot from here next time. The original "current running area" will then become a new, idle "preset backup storage area" for the next upgrade. This role-swapping mechanism achieves seamless switching and backup protection between the A / B dual systems.
[0056] If the firmware written to the "preset backup storage area" fails to boot (e.g., detected by boot timeout detection), the device will automatically roll back to another partition (i.e., the original "current running area") to boot, and mark the failed boot "preset backup storage area" as "abnormal," while simultaneously uploading the fault log via OTA. This effectively prevents the device from becoming bricked due to upgrade failure.
[0057] This embodiment discloses receiving firmware update instructions, including local update instructions or remote update instructions; determining the corresponding transmission mode according to the type of firmware update instruction, and obtaining differential data packets through the transmission mode, the differential data packets including difference information between the target firmware and the current firmware; synthesizing firmware based on the current firmware and the differential data packets to obtain the target firmware, and writing the target firmware into a preset backup storage area; performing integrity verification on the target firmware in the preset backup storage area, and switching to the preset backup storage area for startup after successful verification. Because this embodiment adapts the corresponding transmission mode according to the type of firmware update instruction and obtains differential data packets, then writes the target firmware into the preset backup storage area, performs integrity verification on the target firmware in the preset backup storage area, and switches to the preset backup storage area for startup after successful verification, compared with the prior art, this embodiment not only improves the efficiency of firmware updates but also enhances the reliability and security of firmware updates.
[0058] refer to Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the firmware update method of the present invention.
[0059] Based on the first embodiment described above, in this embodiment, before step S30, steps S301 to S302 are further included: Step S301: Perform source legitimacy verification on the differential data packet, which includes digital signature verification and device whitelist verification.
[0060] Step S302: After the source legitimacy verification is passed, the step of writing the target firmware into the preset backup storage area is executed.
[0061] It should be explained that digital signature verification is a data integrity verification and source authentication technology based on asymmetric encryption algorithms. In this embodiment, it specifically means: After generating the differential data packet, the firmware publisher (such as a cloud server) uses its private key to encrypt the hash value of the firmware data, generating a digital signature, and sends this signature along with the differential data packet. The embedded device pre-stores a public key paired with the private key. After receiving the differential data packet, the device uses the public key to decrypt the digital signature, obtaining a digest value A; simultaneously, the device performs the same hash operation on the received differential data packet itself, obtaining a digest value B. Verification can be achieved by comparing whether digest value A and digest value B are consistent.
[0062] It should be understood that only the publisher holding the legitimate private key can generate a signature that can be correctly decrypted by the public key, thus proving that the data comes from a trusted publisher. If the data is tampered with during transmission, the digest value B calculated locally by the device will inevitably be inconsistent with the decrypted digest value A, and the verification will fail.
[0063] It's important to explain that device whitelist verification is an access control technology based on device identity. In this solution and embodiment, it specifically means: a "whitelist" is pre-configured or dynamically updated in the embedded device's storage area. This list records all legitimate device identifiers (such as device ID, MAC address, serial number, etc.) allowed to perform firmware update operations. When a firmware update command or differential data packet is received, the device first extracts its own device identifier and compares it with the whitelist. Only if the device's identifier exists in the whitelist is the subsequent firmware synthesis and writing process allowed to continue; if it is not in the list, the update request is directly rejected.
[0064] Furthermore, to ensure data is not intercepted during transmission, data can be encrypted using TLS / DTLS protocols at the data transmission layer to prevent interception. Additionally, to prevent malicious downgrade attacks, an anti-downgrade mechanism can be added through version number verification, allowing upgrades only to higher firmware versions to prevent malicious downgrade attacks.
[0065] This embodiment discloses a method for verifying the source legitimacy of the differential data packets. This verification includes digital signature verification and device whitelist verification. After the source legitimacy verification passes, the step of writing the target firmware to a preset backup storage area is executed. Because this embodiment performs digital signature verification and device whitelist verification on the differential data packets, and then executes the step of writing the target firmware to a preset backup storage area after successful verification, compared to existing technologies, this embodiment effectively prevents firmware tampering and hijacking, reducing security risks in device upgrade scenarios.
[0066] refer to Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the firmware update method of the present invention.
[0067] Based on the above embodiments, in this embodiment, before step S10, steps S101~S102 are further included: Step S101: Receive a group update instruction sent by the remote management platform. The group update instruction includes the target device group identifier and update task parameters.
[0068] Step S102: Confirm whether the device belongs to the target update group based on the target device group identifier, and execute the step of receiving firmware update instruction if it is confirmed to belong to the target update group.
[0069] It should be understood that a group update command can refer to a unified command sent by a remote management platform (such as a cloud server or operations and maintenance center) to multiple target devices at once to initiate a firmware upgrade task. Unlike traditional "unicast" commands, it is a "multicast" or "broadcast" form of control command, enabling efficient management of batch devices.
[0070] Understandably, by using group update commands, maintenance personnel no longer need to send upgrade commands to hundreds or thousands of devices one by one. They only need to operate once in the cloud to initiate an upgrade for all devices in a specific group, which greatly simplifies the operation process and saves time and manpower costs.
[0071] It should be noted that the target device group identifier can be an identity tag included in the group update command, used to uniquely identify the range of devices to which the command is intended. For example, it can be a group ID (such as "Group_ID_123"), representing all groups with ID 123; or it can be a combination of device types, models, or geographical locations. After receiving the command, the device compares its own attributes with this identifier to determine whether it belongs to the designated upgrade target.
[0072] It should be understood that the target device group identifier allows upgrade tasks to be precisely assigned to a specific set of devices. Whether grouped by model, region, batch, or custom rules, it ensures the accurate delivery of upgrade instructions and avoids interference with irrelevant devices.
[0073] Update task parameters refer to the dataset carried in the group update command, which defines the specific content of this upgrade task. This may include, but is not limited to: the target firmware version number, the firmware download address (URL), the hash value of the differential upgrade package, the upgrade strategy (such as forced upgrade or silent upgrade), and the upgrade execution time window. These parameters provide the necessary configuration information for the device to perform specific upgrade actions.
[0074] It should be understood that updating task parameters provides personalized configurations for each group upgrade. For example, different upgrade time windows can be set (such as early morning) to avoid peak business hours, or different upgrade strategies can be set for different groups, thereby achieving highly flexible and controllable remote maintenance, and thus enhancing the flexibility and controllability of upgrade tasks.
[0075] Understandably, compared to each device independently polling or requesting upgrade tasks from the server, issuing a group command at once can significantly reduce the signaling interaction pressure on the server side, while also making more efficient use of network resources and avoiding network congestion caused by a large number of devices making simultaneous requests.
[0076] In a specific implementation, it may also include reporting the current update progress and device status information to the remote management platform according to a preset reporting cycle during the firmware update process; receiving an abnormal alarm instruction generated by the remote management platform based on the device status information, the abnormal alarm instruction including an abnormal type identifier and suggested handling measures; and executing the corresponding abnormal handling process according to the abnormal type identifier, the abnormal handling process including one or more of retransmission request, protocol switching or rollback recovery.
[0077] This embodiment discloses receiving a group update command sent by a remote management platform. The group update command includes a target device group identifier and update task parameters. It then confirms whether the device belongs to the target update group based on the target device group identifier, and executes the step of receiving the firmware update command upon confirmation. Because this embodiment receives the group update command sent by the remote management platform, confirms whether the device belongs to the target update group based on the target device group identifier, and executes the step of receiving the firmware update command upon confirmation, compared to existing technologies, this embodiment not only improves the efficiency of large-scale operation and maintenance but also enhances the flexibility and controllability of upgrade tasks.
[0078] Furthermore, embodiments of the present invention also propose a storage medium storing a firmware update program, wherein the firmware update program, when executed by a processor, implements the steps of the firmware update method described above.
[0079] Reference Figure 4 , Figure 4 This is a structural block diagram of the first embodiment of the firmware update device of the present invention.
[0080] like Figure 4 As shown, the firmware update device proposed in this embodiment of the invention includes: an instruction receiving module 501, a data acquisition module 502, a firmware synthesis module 503, and a firmware verification module 504.
[0081] The instruction receiving module 501 is used to receive firmware update instructions, which include local update instructions or remote update instructions.
[0082] The data acquisition module 502 is used to determine the corresponding transmission mode according to the type of the firmware update instruction, and to acquire differential data packets through the transmission mode. The differential data packets include difference information between the target firmware and the current firmware.
[0083] The firmware synthesis module 503 is used to synthesize firmware based on the current firmware and the differential data packet to obtain the target firmware, and write the target firmware into a preset backup storage area.
[0084] The firmware verification module 504 is used to perform integrity verification on the target firmware in the preset backup storage area, and switch to the preset backup storage area to start running after the verification is passed.
[0085] The data acquisition module 502 is further configured to activate the local communication interface when the firmware update instruction is a local update instruction, and receive differential data packets through the local communication interface in a preset fragmentation manner; when the firmware update instruction is a remote update instruction, detect the current network environment parameters, select a target transmission protocol from multiple transmission protocols based on the current network environment parameters, and receive differential data packets through the target transmission protocol.
[0086] The data acquisition module 502 is further configured to detect current network environment parameters when the firmware update command is a remote update command, the current network environment parameters including the current network bandwidth, latency and packet loss rate; determine the comprehensive adaptation score of each transmission protocol according to the bandwidth, latency and packet loss rate and a preset protocol evaluation rule; and select the transmission protocol with the highest comprehensive adaptation score as the target transmission protocol.
[0087] The data acquisition module 502 is further configured to: activate the local communication interface and return an acknowledgment signal to the sending end of the firmware update instruction when the firmware update instruction is a local update instruction; receive the firmware metadata frame sent by the sending end, the firmware metadata frame including firmware capacity information and fragmentation configuration parameters; determine a fragmentation reception strategy based on the fragmentation configuration parameters; receive data fragments corresponding to the differential data packets one by one according to the fragmentation reception strategy; return a reception acknowledgment signal to the sending end after each data fragment is received; and set a preset delay interval between the reception of adjacent data fragments until the reception of the differential data packets is completed.
[0088] The firmware verification module 504 is further configured to perform integrity verification on the target firmware in the preset backup storage area and obtain a verification result; when the verification result indicates that the verification is successful, update the status flag bit of the preset backup storage area to mark the preset backup storage area as a pending activation state; and in response to a device restart command, start running from the preset backup storage area in the pending activation state based on the status flag bit of the preset backup storage area.
[0089] This device embodiment discloses receiving firmware update instructions, including local update instructions or remote update instructions; determining the corresponding transmission mode according to the type of firmware update instruction, and obtaining differential data packets through the transmission mode, the differential data packets including difference information between the target firmware and the current firmware; synthesizing firmware based on the current firmware and the differential data packets to obtain the target firmware, and writing the target firmware into a preset backup storage area; performing integrity verification on the target firmware in the preset backup storage area, and switching to the preset backup storage area for startup after successful verification. Because this device embodiment adapts the corresponding transmission mode according to the type of firmware update instruction and obtains differential data packets, then writes the target firmware into the preset backup storage area, performs integrity verification on the target firmware in the preset backup storage area, and switches to the preset backup storage area for startup after successful verification, compared with the prior art, this device embodiment not only improves the efficiency of firmware updates but also enhances the reliability and security of firmware updates.
[0090] Based on the first embodiment of the firmware update device of the present invention described above, a second embodiment of the firmware update device of the present invention is proposed.
[0091] In this embodiment, the firmware synthesis module 503 is further configured to perform source legitimacy verification on the differential data packet, the source legitimacy verification including digital signature verification and device whitelist verification; after the source legitimacy verification is passed, the step of writing the target firmware into the preset backup storage area is executed.
[0092] Other embodiments or specific implementations of the firmware update device of the present invention can be found in the above-described method embodiments, and will not be repeated here.
[0093] This application provides a firmware update device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the firmware update method in Embodiment 1 above.
[0094] The following is for reference. Figure 5The diagram illustrates a structural schematic suitable for implementing the firmware update device in the embodiments of this application. The firmware update device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The firmware update device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0095] like Figure 5 As shown, the firmware update device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in the read-only memory 1002 or a program loaded from the storage device 1003 into the random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the firmware update device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the firmware update device to communicate wirelessly or wiredly with other devices to exchange data. While the figure shows firmware update devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0096] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0097] The firmware update device provided in this application, employing the firmware update method described in the above embodiments, can solve the technical problems of low efficiency, insufficient reliability, and inadequate security in existing firmware updates. Compared with the prior art, the beneficial effects of the firmware update device provided in this application are the same as those of the firmware update method provided in the above embodiments, and other technical features of this firmware update device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0098] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0099] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0100] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0101] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0102] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0103] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the protection scope of the present invention.
Claims
1. A firmware update method, characterized in that, The method includes: Receive firmware update instructions, including local update instructions or remote update instructions; Based on the type of the firmware update instruction, the corresponding transmission mode is determined, and a differential data packet is obtained through the transmission mode. The differential data packet includes the difference information between the target firmware and the current firmware. Firmware synthesis is performed based on the current firmware and the differential data packet to obtain the target firmware, and the target firmware is written to a preset backup storage area; The target firmware in the preset backup storage area is subjected to integrity verification, and after the verification is passed, the system is switched to the preset backup storage area to start running.
2. The firmware update method as described in claim 1, characterized in that, The step of determining the corresponding transmission mode based on the type of the firmware update instruction and obtaining differential data packets through the transmission mode includes: When the firmware update command is a local update command, the local communication interface is activated, and differential data packets are received through the local communication interface in a preset fragmentation manner. When the firmware update command is a remote update command, the current network environment parameters are detected, a target transmission protocol is selected from multiple transmission protocols based on the current network environment parameters, and differential data packets are received through the target transmission protocol.
3. The firmware update method as described in claim 2, characterized in that, When the firmware update command is a remote update command, the step of detecting the current network environment parameters and selecting a target transmission protocol from multiple transmission protocols based on the current network environment parameters includes: When the firmware update command is a remote update command, the current network environment parameters are detected, including the current network bandwidth, latency, and packet loss rate. Based on the bandwidth, the latency, and the packet loss rate, the comprehensive adaptation score of each transmission protocol is determined according to the preset protocol evaluation rules. The transmission protocol with the highest overall adaptation score is selected as the target transmission protocol.
4. The firmware update method as described in claim 2, characterized in that, The step of activating the local communication interface and receiving differential data packets in a preset fragmentation manner through the local communication interface when the firmware update command is a local update command includes: When the firmware update command is a local update command, the local communication interface is activated, and a response signal is returned to the sending end of the firmware update command; Receive firmware metadata frames sent by the sending end, the firmware metadata frames including firmware capacity information and fragmentation configuration parameters; Based on the fragmentation configuration parameters, a fragmentation reception strategy is determined. Data fragments corresponding to differential data packets are received one by one according to the fragmentation reception strategy. After each data fragment is received, a reception confirmation signal is returned to the sending end. A preset delay interval is set between the reception of adjacent data fragments until the reception of the differential data packets is completed.
5. The firmware update method as described in claim 1, characterized in that, Before the step of writing the target firmware to the preset backup storage area, the method further includes: The differential data packets are subjected to source legitimacy verification, which includes digital signature verification and device whitelist verification. After the source legitimacy verification is passed, the step of writing the target firmware to the preset backup storage area is performed.
6. The firmware update method as described in claim 1, characterized in that, The step of performing integrity verification on the target firmware in the preset backup storage area, and switching to the preset backup storage area for startup after the verification is successful, includes: Perform integrity verification on the target firmware in the preset backup storage area and obtain the verification result; When the verification result indicates that the verification is successful, the status flag of the preset backup storage area is updated to mark the preset backup storage area as an active state; In response to a device restart command, the device starts running from the preset backup storage area in the pending activation state, based on the status flag of the preset backup storage area.
7. The firmware update method as described in claim 1, characterized in that, Before the step of receiving the firmware update instruction, the method further includes: Receive a group update instruction sent by a remote management platform, wherein the group update instruction includes the target device group identifier and update task parameters; Based on the target device group identifier, confirm whether the device belongs to the target update group, and if it is confirmed to belong, execute the step of receiving firmware update instructions.
8. A firmware update device, characterized in that, The device includes: The instruction receiving module is used to receive firmware update instructions, which include local update instructions or remote update instructions; The data acquisition module is used to determine the corresponding transmission mode according to the type of the firmware update instruction, and to acquire differential data packets through the transmission mode. The differential data packets include the difference information between the target firmware and the current firmware. The firmware synthesis module is used to synthesize firmware based on the current firmware and the differential data packet to obtain the target firmware, and write the target firmware into a preset backup storage area; The firmware verification module is used to perform integrity verification on the target firmware in the preset backup storage area, and switch to the preset backup storage area to start running after the verification is passed.
9. A firmware update device, characterized in that, The device includes: a memory, a processor, and a firmware update program stored on the memory and executable on the processor, the firmware update program being configured to implement the steps of the firmware update method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a firmware update program, which, when executed by a processor, implements the steps of the firmware update method as described in any one of claims 1 to 7.