Upgrading method, system and device for firmware device in embedded system and medium

By combining dual-protocol communication and incremental updates with hardware feature management, the firmware upgrade method solves the problems of low upgrade efficiency and stability of embedded devices in resource-limited scenarios, achieving efficient and reliable firmware upgrades that adapt to different device models and prevent device bricking.

CN122018954APending Publication Date: 2026-05-12STATE NUCLEAR POWER AUTOMATION SYST ENGCO +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
STATE NUCLEAR POWER AUTOMATION SYST ENGCO
Filing Date
2026-02-04
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing firmware upgrade solutions for embedded devices are inefficient in scenarios with limited network bandwidth and scarce storage resources, and lack effective state machine management, which can easily lead to device bricking and insufficient compatibility and adaptability.

Method used

Firmware upgrades are performed using dual-protocol communication (a combination of TCP and UDP protocols). Incremental updates are performed by generating differential data packets. Dynamic management is combined with the hardware characteristics of the storage medium. A dual verification mechanism at the transport layer and hardware layer is constructed, and a state machine is used to manage the upgrade process.

Benefits of technology

It improves the stability and reliability of the upgrade process, reduces network bandwidth and storage resource consumption, adapts to different device models, ensures firmware data integrity, and enables traceability and recovery after interruption, thus avoiding device failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122018954A_ABST
    Figure CN122018954A_ABST
Patent Text Reader

Abstract

The invention provides an upgrading method, system and device for firmware equipment in an embedded system and a medium. The upgrading method is applied to a server side. The server side communicates with the equipment side by adopting dual protocols, and the equipment side is provided with a first protocol communication interface and a second protocol communication interface; the upgrading method comprises the following steps: generating control instruction information; wherein the control instruction information comprises upgrading instruction information and target upgrading package information; and sending the upgrade instruction information to the device end through a first protocol via the first protocol communication interface, and sending the target upgrade package information to the device end through a second protocol via the second protocol communication interface, sending the upgrade instruction information to the equipment end, so that the equipment end adopts the target upgrade package to execute upgrade operation based on the upgrade instruction information; according to the upgrading method provided by the invention, the data transmission efficiency and the control instruction reliability are balanced by adopting the hybrid communication protocol, and the stability of the upgrading process is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing, and in particular to a method, system, device, and medium for upgrading firmware devices in an embedded system. Background Technology

[0002] In the field of firmware upgrade technology for embedded devices, existing solutions mainly face the following limitations:

[0003] First, a full upgrade requires transmitting the complete firmware package, which often leads to excessively long transmission times in industrial applications where network bandwidth is limited, and also consumes a significant amount of device storage space. This characteristic makes it unsuitable for small embedded devices with limited storage resources (such as MCU-based platforms).

[0004] Secondly, traditional incremental upgrade solutions still have several shortcomings: a) Storage management strategies are relatively rigid, usually using a fixed block-based erase / write method, failing to dynamically adjust based on the hardware characteristics of the external Flash (such as the minimum erase unit, block structure, etc.), which can easily lead to wasted storage resources or write failures; b) Communication protocol design is simplistic. If only TCP (Transmission Control Protocol) is used, data transmission efficiency is low; if only UDP (User Datagram Protocol) is used, the reliability of control commands is insufficient, which can easily cause interruptions during the upgrade process; c) The verification mechanism is relatively weak, generally only performing simple verification at the transport layer, lacking the dual protection of the hardware layer (such as real-time readback verification after Flash writing), making it difficult to effectively detect storage media failures.

[0005] In addition, existing upgrade processes generally lack effective state machine management. Once the upgrade is interrupted, the progress cannot be accurately traced, which can easily lead to the device entering a "bricked" state (i.e., unable to start normally).

[0006] Finally, the current solution also has shortcomings in terms of compatibility and adaptability, making it difficult to flexibly adapt to the differences in hardware (such as Flash capacity, network interface performance, etc.) of different embedded devices, thus limiting its scope of application. Summary of the Invention

[0007] The technical problem to be solved by this disclosure is to overcome the defects in the prior art and provide a method, system, device and medium for upgrading firmware devices in an embedded system.

[0008] This disclosure solves the above-mentioned technical problems through the following technical solution:

[0009] According to a first aspect of this disclosure, a method for upgrading firmware devices in an embedded system is provided, the method being applied to a server; the server communicates with the device using dual protocols, the device being provided with a first protocol communication interface and a second protocol communication interface;

[0010] The upgrade method includes:

[0011] Generate control command information; wherein, the control command information includes upgrade command information and target upgrade package information;

[0012] The upgrade instruction information is sent to the device via the first protocol communication interface through the first protocol, and the target upgrade package information is sent to the device via the second protocol communication interface through the second protocol, so that the device performs the upgrade operation based on the upgrade instruction information and the target upgrade package;

[0013] The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

[0014] Optionally, the step of generating control command information includes:

[0015] Generate update package information and obtain the current update package information stored in the device.

[0016] The updated upgrade package information and the first upgrade package difference information of the current upgrade information are compared and used as the target upgrade package information;

[0017] or,

[0018] Generate update and upgrade package information;

[0019] In response to obtaining the reset flag information from the device, the update package is used as the target update package information.

[0020] Optionally, in response to obtaining the breakpoint flag information on the device, the second upgrade package difference information based on the breakpoint flag information and the update upgrade package information is used as the target upgrade package information.

[0021] Optionally, the first protocol includes the TCP protocol;

[0022] And / or,

[0023] The second protocol includes the UDP protocol;

[0024] And / or,

[0025] The upgrade method also includes:

[0026] Acquire and output the real-time status information of the device; wherein the real-time status information includes at least one of the device idle status, device transmission status, and device completion status.

[0027] According to a second aspect of this disclosure, a method for upgrading firmware devices in an embedded system is provided. The method is applied to a device end, which is provided with a first protocol communication interface and a second protocol communication interface.

[0028] The upgrade method includes:

[0029] The system uses the first protocol communication interface to receive upgrade instruction information sent by the server through the first protocol, and uses the second protocol communication interface to receive target upgrade package information sent by the server through the second protocol.

[0030] Wherein, the first protocol is a protocol for transmitting complete data, and the second protocol is a protocol for transmitting data in real time;

[0031] The target upgrade package information is stored sequentially in the initial storage area;

[0032] Based on the upgrade instruction information, the upgrade operation is performed using the target upgrade package information in the initial storage area.

[0033] Optionally, the upgrade instruction information includes a start instruction, a data transmission instruction, and an upgrade completion instruction;

[0034] The target upgrade package information includes package sequence number information, data upgrade information, and verification information;

[0035] The initial storage area includes a fixed data storage module and a differential data storage module;

[0036] In response to the upgrade instruction information being the startup instruction, the step of sequentially storing the target upgrade package information in the initial storage area includes:

[0037] In response to the presence of a reset flag in the initial storage area, the initial storage area is cleared, the update package information is stored in the initial storage area, and a first status information is sent to the server, wherein the first status information is an idle status.

[0038] In response to the presence of a breakpoint flag in the initial storage area, the differential data storage module is cleared, and the second upgrade package differential information is stored in the differential data storage module. The first status information is then sent to the server.

[0039] In response to the absence of the reset flag information and the breakpoint flag information in the initial storage area, the differential data storage module is cleared, and the first upgrade package differential information is stored in the differential data storage module, and the first status information is sent to the server.

[0040] or,

[0041] In response to the upgrade instruction information being the data transmission instruction, the step of completing the upgrade of the device based on the target upgrade package information in the initial storage area includes:

[0042] The data upgrade information in the initial storage area is obtained sequentially according to the package sequence information;

[0043] The different data upgrade information is verified based on a preset verification method, and verification results are generated.

[0044] In response to the successful verification result, the current update progress information is determined based on the packet sequence number information, and the server sends second status information; the second status information is the device transmission status.

[0045] In response to the failure of the verification result, the packet sequence number information corresponding to the failure of the data upgrade information verification is obtained, and the breakpoint flag information, the corresponding packet sequence number information and the second status information are sent to the server.

[0046] or,

[0047] In response to the upgrade instruction information being the upgrade completion instruction, the upgrade method includes:

[0048] The target upgrade package information in the initial storage area is cleared, and a third status information is sent to the server; the third status information is the device completion status.

[0049] According to a third aspect of this disclosure, an upgrade system for firmware devices in an embedded system is provided, the upgrade system being applied to a server; the server communicates with the device using dual protocols, the device being provided with a first protocol communication interface and a second protocol communication interface;

[0050] The upgrade system includes:

[0051] The instruction generation module is used to generate control instruction information; wherein, the control instruction information includes upgrade instruction information and target upgrade package information;

[0052] The instruction transmission module is used to send the upgrade instruction information to the device via the first protocol communication interface through the first protocol, and to send the target upgrade package information to the device via the second protocol communication interface through the second protocol, so that the device can perform an upgrade operation based on the upgrade instruction information and the target upgrade package;

[0053] The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

[0054] Optionally, the instruction generation module is further configured to:

[0055] Generate update package information and obtain the current update package information stored in the device.

[0056] The updated upgrade package information and the first upgrade package difference information of the current upgrade information are compared and used as the target upgrade package information;

[0057] or,

[0058] Generate update and upgrade package information;

[0059] In response to obtaining the reset flag information from the device, the update package is used as the target update package information.

[0060] Optionally, the instruction generation module is further configured to, in response to obtaining the breakpoint flag information from the device, use the second upgrade package difference information based on the breakpoint flag information and the update upgrade package information as the target upgrade package information.

[0061] Optionally, the first protocol includes the TCP protocol;

[0062] And / or,

[0063] The second protocol includes the UDP protocol;

[0064] And / or,

[0065] The upgrade system also includes: a status prompt module;

[0066] The status indication module is used to acquire and output the real-time status information of the device; wherein, the real-time status information includes at least one of the device idle status, device transmission status, and device completion status.

[0067] According to a fourth aspect of this disclosure, an upgrade system for firmware devices in an embedded system is provided. The upgrade system is applied to a device end, which is provided with a first protocol communication interface and a second protocol communication interface.

[0068] The upgrade system includes:

[0069] The instruction receiving module is used to receive upgrade instruction information sent by the server through the first protocol using the first protocol communication interface, and to receive target upgrade package information sent by the server through the second protocol using the second protocol communication interface.

[0070] Wherein, the first protocol is a protocol for transmitting complete data, and the second protocol is a protocol for transmitting data in real time;

[0071] The instruction storage module is used to sequentially store the target upgrade package information in the initial storage area;

[0072] The upgrade module is used to perform an upgrade operation based on the upgrade instruction information and the target upgrade package information in the initial storage area.

[0073] Optionally, the upgrade instruction information includes a start instruction, a data transmission instruction, and an upgrade completion instruction;

[0074] The target upgrade package information includes package sequence number information, data upgrade information, and verification information;

[0075] The initial storage area includes a fixed data storage module and a differential data storage module;

[0076] In response to the upgrade instruction information being the start instruction, the upgrade module is used to:

[0077] In response to the presence of a reset flag in the initial storage area, the initial storage area is cleared, the update package information is stored in the initial storage area, and a first status information is sent to the server, wherein the first status information is an idle status.

[0078] In response to the presence of a breakpoint flag in the initial storage area, the differential data storage module is cleared, and the second upgrade package differential information is stored in the differential data storage module. The first status information is then sent to the server.

[0079] In response to the absence of the reset flag information and the breakpoint flag information in the initial storage area, the differential data storage module is cleared, and the first upgrade package differential information is stored in the differential data storage module, and the first status information is sent to the server.

[0080] or,

[0081] In response to the upgrade instruction information being the data transmission instruction, the upgrade module is configured to:

[0082] The data upgrade information in the initial storage area is obtained sequentially according to the package sequence information;

[0083] The different data upgrade information is verified based on a preset verification method, and verification results are generated.

[0084] In response to the successful verification result, the current update progress information is determined based on the packet sequence number information, and the server sends second status information; the second status information is the device transmission status.

[0085] In response to the failure of the verification result, the packet sequence number information corresponding to the failure of the data upgrade information verification is obtained, and the breakpoint flag information, the corresponding packet sequence number information and the second status information are sent to the server.

[0086] or,

[0087] In response to the upgrade instruction information being the upgrade completion instruction, the upgrade module is configured to:

[0088] The target upgrade package information in the initial storage area is cleared, and a third status information is sent to the server; the third status information is the device completion status.

[0089] According to a fifth aspect of this disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and for running on the processor, wherein the processor executes the computer program to implement the firmware device upgrade method in an embedded system as described in the first or second aspect of this disclosure.

[0090] According to a sixth aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the firmware device upgrade method in an embedded system as described in the first or second aspect of this disclosure.

[0091] According to a seventh aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the firmware device upgrade method in an embedded system as described in the first or second aspect of this disclosure.

[0092] Based on common knowledge in the field, the above-mentioned preferred conditions can be combined arbitrarily to obtain various preferred embodiments of this disclosure.

[0093] The positive and progressive effects of this disclosure are as follows:

[0094] The firmware upgrade method for embedded systems provided in this disclosure adopts a hybrid communication protocol to balance data transmission efficiency and control command reliability, ensuring the stability of the upgrade process; it combines the hardware characteristics of the storage medium to dynamically allocate storage resources, improve storage utilization, adapt to different models of embedded devices to achieve high reliability upgrades with low hardware resource consumption, and is suitable for low-cost embedded devices.

[0095] Furthermore, incremental firmware updates are achieved by transmitting data showing the differences between the old and new versions, reducing network bandwidth usage and storage resource consumption. A dual verification mechanism at the transport and hardware layers is constructed to ensure firmware data integrity. The entire upgrade process is managed through a state machine, enabling traceability and recovery after interruption and preventing device failure. Attached Figure Description

[0096] Figure 1 This is a flowchart illustrating the firmware device upgrade method for an embedded system on a server side, as provided in Embodiment 1 of this disclosure.

[0097] Figure 2 This is a schematic diagram of the process for obtaining target upgrade package information provided in Embodiment 1 of this disclosure;

[0098] Figure 3 This is a flowchart illustrating the firmware device upgrade method for an embedded system applied on the device side, as provided in Embodiment 2 of this disclosure.

[0099] Figure 4 This is a schematic diagram of the firmware device upgrade system in an embedded system on the server side, as provided in Embodiment 3 of this disclosure.

[0100] Figure 5 This is a schematic diagram of the firmware upgrade system for an embedded system applied on the device side, as provided in Embodiment 4 of this disclosure;

[0101] Figure 6 This is a schematic diagram of the structure of the electronic device provided in Embodiment 5 of this disclosure. Detailed Implementation

[0102] The present disclosure is further illustrated below by way of embodiments, but the present disclosure is not limited to the scope of the embodiments described herein.

[0103] The prefixes such as "first" and "second" used in this disclosure are merely for distinguishing different descriptive objects and do not limit the position, order, priority, quantity, or content of the described objects. The use of ordinal numbers and other prefixes used to distinguish descriptive objects in this disclosure does not constitute a limitation on the described objects. The description of the described objects is given in the claims or the context of the embodiments, and should not be construed as an unnecessary limitation. Furthermore, in the description of this embodiment, unless otherwise stated, "multiple" means two or more.

[0104] Example 1

[0105] This embodiment provides a firmware device upgrade method in an embedded system. The upgrade method is applied to the server. The server communicates with the device using dual protocols. The device is equipped with a first protocol communication interface and a second protocol communication interface.

[0106] like Figure 1 As shown, the upgrade methods include:

[0107] S11: Generate control command information; wherein, the control command information includes upgrade command information and target upgrade package information;

[0108] S12: The upgrade instruction information is sent to the device through the first protocol and the first protocol communication interface, and the target upgrade package information is sent to the device through the second protocol and the second protocol communication interface, so that the device can perform the upgrade operation based on the upgrade instruction information and the target upgrade package;

[0109] The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

[0110] The firmware upgrade method for embedded systems provided in this disclosure employs a hybrid communication protocol to balance data transmission efficiency and control command reliability, ensuring the stability of the upgrade process; it adapts to different models of embedded devices to achieve high-reliability upgrades with low hardware resource consumption, making it suitable for low-cost embedded devices.

[0111] Among them, such as Figure 2 As shown, step S11 includes:

[0112] S21: Generate update package information and obtain the current update package information stored in the device;

[0113] S22: Compare the updated upgrade package information with the first upgrade package difference information of the current upgrade information, and use it as the target upgrade package information.

[0114] In one implementation, incremental data packets are generated based on a binary differential algorithm, and resource optimization is achieved through protocol coordination and dynamic storage management.

[0115] Alternatively, step S11 may also include:

[0116] Generate update and upgrade package information;

[0117] In response to obtaining the reset flag information from the device, the update package is used as the target update package information.

[0118] In response to obtaining the breakpoint flag information from the device, the second upgrade package difference information based on the breakpoint flag information and the update upgrade package information is used as the target upgrade package information.

[0119] In this embodiment, incremental firmware updates are achieved by transmitting data showing the differences between the old and new versions, reducing network bandwidth usage and storage resource consumption. A dual verification mechanism at the transport and hardware layers is constructed to ensure firmware data integrity. The entire upgrade process is managed through a state machine, enabling traceability and recovery after interruption and preventing device failure.

[0120] In one embodiment, the server includes an instruction generation module, a hybrid communication module, and an response processing module. The instruction generation module generates upgrade control instructions (start instruction 0x70, data transmission instruction 0x72, upgrade confirmation instruction 0x71), encapsulating firmware metadata (total number of data packets, global checksum). The hybrid communication module reliably transmits control instructions via TCP protocol to ensure accurate delivery and efficiently transmits incremental data blocks via UDP protocol to maximize transmission efficiency. The response processing module parses the response code (ack_code) returned by the device and dynamically triggers a data retransmission mechanism; for example, it determines the final data packets to be transmitted based on the returned response code.

[0121] In this embodiment, the first protocol includes the TCP protocol; the second protocol includes the UDP protocol.

[0122] The upgrade method in this embodiment also includes:

[0123] Acquire and output real-time status information of the device; wherein, the real-time status information includes at least one of the following: device idle status, device transmission status, and device completion status.

[0124] The firmware upgrade method for embedded systems provided in this disclosure employs a hybrid communication protocol to balance data transmission efficiency and control command reliability, ensuring the stability of the upgrade process. Furthermore, incremental firmware updates are achieved by transmitting data showing the differences between the old and new versions, reducing network bandwidth usage and storage resource consumption. A dual verification mechanism at the transport and hardware layers is constructed to ensure firmware data integrity, and the entire upgrade process is managed through a state machine, enabling traceability and recovery after interruption and preventing device failure. The actual update status is obtained through real-time status information, improving the user experience.

[0125] Example 2

[0126] like Figure 3 As shown, this embodiment provides a firmware device upgrade method in an embedded system. The upgrade method is applied to the device side, which is equipped with a first protocol communication interface and a second protocol communication interface.

[0127] Upgrade methods include:

[0128] S31: Receive upgrade instruction information sent by the server through the first protocol using the first protocol communication interface, and receive target upgrade package information sent by the server through the second protocol using the second protocol communication interface;

[0129] The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

[0130] S32: Store the target upgrade package information sequentially in the initial storage area;

[0131] S33: Based on the upgrade instruction information, perform the upgrade operation using the target upgrade package information in the initial storage area.

[0132] In this embodiment, the upgrade instruction information includes a start instruction, a data transmission instruction, and an upgrade completion instruction;

[0133] The startup command, data transmission command, and upgrade completion command correspond to startup command 0x70, data transmission command 0x72, and upgrade confirmation command 0x71 in Embodiment 1, respectively.

[0134] The target upgrade package information includes package sequence number, data upgrade information, and verification information;

[0135] The initial storage area includes a fixed data storage module and a differential data storage module;

[0136] The steps of responding to the upgrade instruction information as a start instruction and sequentially storing the target upgrade package information in the initial storage area include:

[0137] In response to the presence of a reset flag in the initial storage area, the initial storage area is cleared, and the update package information is stored in the initial storage area. The first status information is sent to the server, which indicates an idle state.

[0138] In response to the presence of breakpoint marker information in the initial storage area, the differential data storage module is cleared, and the differential information of the second upgrade package is stored in the differential data storage module. The first status information is then sent to the server.

[0139] In response to the absence of reset flag information and breakpoint flag information in the initial storage area, the differential data storage module is cleared, the differential information of the first upgrade package is stored in the differential data storage module, and the first status information is sent to the server.

[0140] or,

[0141] In response to the upgrade instruction information as a data transfer instruction, the steps for upgrading the device based on the target upgrade package information in the initial storage area include:

[0142] Retrieve data upgrade information from the initial storage area sequentially according to the package sequence number;

[0143] The system verifies different data upgrade information based on a preset verification method and generates verification results.

[0144] In response to a successful verification result, the current update progress information is determined based on the packet sequence number information, and the server sends a second status information; the second status information is the device transmission status.

[0145] In response to a failed verification result, obtain the sequence number of the packet that failed the corresponding data upgrade information verification, and send the breakpoint flag information, the corresponding packet sequence number information, and the second status information to the server.

[0146] or,

[0147] In response to the upgrade instruction message, an upgrade completion instruction is issued. The upgrade methods include:

[0148] Clear the target upgrade package information in the initial storage area and send the third status information to the server; the third status information is the device completion status.

[0149] In one implementation, during the startup phase (i.e., upon receiving the 0x70 command): After receiving the 0x70 command in the idle state (FW_STATE_IDLE), the device begins the upgrade; it parses the total number of packets in the command, initializes the current packet sequence number and CRC (Cyclic Redundancy Check) value; it performs a forced reset check, checking the forced reset flag in the OTA information area. If the flag is set: a full erase is performed, clearing all historical data; if the flag is not set: an attempt is made to resume from the last interruption point; it parses the update type flag (full update or incremental update) in the command. During a full update: the sectors storing OTA (Over-the-Air) information and the blocks storing firmware data in the external Flash are erased. The number of blocks to be erased is calculated based on the total size, and then these blocks are erased. During an incremental update: only the OTA information sector is erased, retaining the firmware data area; the state switches to FW_STATE_RECEIVING, and an acknowledgment (ACK) response (0x01) is sent.

[0150] During the data transmission phase (i.e., upon receiving the 0x72 command): In the receive state (FW_STATE_RECEIVING), the device receives the data packet containing the 0x72 command; parses the frame sequence number and data length, with the data portion starting from FW_DATA_OFFSET; calculates the precise write address using the frame sequence number: EXT_FLASH_FW_DATA_ADDR + (frame_id-1)*data_len, achieving optimal storage space allocation and supporting non-contiguous writes (i.e., partial updates); writes the data to the corresponding address in the external Flash; immediately reads back and verifies the data after writing to ensure correctness; simultaneously, updates the CRC checksum byte-by-byte using the CRC32 table; during incremental updates, incremental CRC calculations are performed only on the current data block; calculates the progress percentage based on the frame sequence number and the total number of packets, printing progress information every 10% completion; and sends an ACK response (0x01) containing the current frame sequence number, enabling the server to confirm the transmission status, detect packet loss, and support resuming interrupted transmissions.

[0151] During the final stage (i.e., upon receiving the 0x71 command): After receiving the 0x71 command, the device prepares to end the upgrade; it performs a forced reset and clears the forced reset flag in the OTA information area, resetting last_frame to 0; it clears the forced reset flag in the OTA information area and constructs an OTA information structure (containing a magic number (fixed identifier), update type (full or incremental), total number of data blocks, number of updated blocks, standard block size, complete firmware CRC checksum, and incremental data CRC checksum (only valid for incremental updates), where the CRC32 is inverted and stored); it writes this information to the OTA information area of ​​the external Flash; and waits for the Flash operation to complete (via SPI status polling). It reads back the OTA information and verifies it to ensure correct writing. During incremental updates, it verifies whether the incremental CRC matches the calculated value. It sends an end confirmation (ACK) response (0x01); and jumps to the Bootloader (JumpToBootloader) (a small bootloader that runs first upon device startup, whose core task is to find and start the main system) to apply the new firmware.

[0152] In this embodiment, the device hardware is an MCU (microcontroller) with a main frequency of ≥80MHz and RAM ≤10KB; the external Flash (SPI / NOR type, the most commonly used and classic chip for storing boot code and firmware, with a capacity of 1MB–16MB) software initializes the network interface for the LWIP protocol stack (lightweight IP protocol stack) and is equipped with a communication adapter module, a dynamic storage module, a verification module and a state machine module.

[0153] The communication adapter module is used to establish a dual-protocol communication interface to achieve separate transmission and reception of control commands and data blocks.

[0154] The dynamic storage module is used to dynamically calculate the number of erase blocks, and determines the erasure range as needed based on the total size of the incremental packet and the size of the Flash physical erase unit; it adapts to storage operations, performs erase and write operations, and is compatible with SPI / NOR Flash with capacities of 1MB–16MB.

[0155] The verification module is used for transport layer cyclic redundancy check (CRC32) to calculate data check values ​​in real time; hardware layer readback and comparison verification is performed, and Flash data is read back immediately after writing to ensure physical storage correctness.

[0156] The state machine module is used to define three states (IDLE, RECEIVING, COMPLETE); the interrupt recovery mechanism records the transmission progress through frame sequence numbers and supports resuming interrupted transmissions.

[0157] By overcoming the compatibility limitations of traditional solutions through a modular collaborative architecture, it supports cross-platform deployment (MCU / FPGA).

[0158] The following describes the implementation principle of the firmware upgrade method for the embedded system applied on the device side in this embodiment using specific implementation methods:

[0159] On the device side, it is necessary to perform communication interface initialization, dynamic storage allocation, dynamic erasure strategy, dual verification, state machine management implementation, as well as upgrade confirmation and restart.

[0160] In the communication interface initialization: initialize the LWIP protocol stack, set a static IP address, configure the subnet mask and default gateway; create UDP server listening ports and TCP server listening ports; set the receive timeout and buffer size; implement IP whitelist filtering and command frame header verification.

[0161] In the dynamic storage allocation implementation: the external Flash is divided into an OTA information area to store upgrade status, CRC, frame ID, and reset flag, and a firmware data area to store firmware data packets managed in blocks.

[0162] The dynamic erasure strategy specifically includes: parsing the total number of packets after receiving the 0x70 command; calculating the total size and multiplying the total number of packets by the packet size; calculating the number of blocks to be erased according to the formula: number of blocks = (total size + 65535) / 65536; erasing only the calculated number of blocks (e.g., 1.5MB firmware only requires 24 64KB blocks); and retaining unmodified blocks during incremental updates.

[0163] The dual verification execution logic includes transport layer verification and application layer verification:

[0164] The steps of transport layer verification include: immediately reading back the Flash content after data is written; comparing the original data with the written data byte by byte; triggering retransmission when a single verification fails (up to 3 times).

[0165] The application layer verification steps include: calculating the CRC32 value in real time during incremental updates (optimized by lookup table method); verifying the complete firmware CRC at the end of the upgrade (inverted storage); and secondary verification after OTA information is written (magic number 0xA8A8A8A8).

[0166] In addition, there are fault tolerance mechanisms in the verification process: such as triggering a forced reset after 3 consecutive verification failures; discarding abnormal packets when the frame ID is not continuous; and automatically sending a 0x6F error frame after a 5-second timeout.

[0167] In state machine management, there are three specific states: IDLE state, RECEIVING state, and COMPLETE state.

[0168] When in IDLE state: listen for command 0x70, suspend data acquisition and monitoring tasks (DtUpdateHandle / DtMonitorHandle), and check the force reset flag (force_reset).

[0169] When in RECEIVING state: process 0x72 data frames (frame ID verification / address calculation / data writing), update incremental CRC in real time (incremental_crc), and persistently save the current frame ID (last_frame).

[0170] When in COMPLETE state: process the 0x71 end command, save OTA information and perform final verification, and clear the forced reset flag (force_reset=0).

[0171] In addition, there is a forced reset process in the state machine. The trigger conditions are: 0x7F command or GPIO (programmable pin) long press for 3 seconds or continuous error. At this time, the OTA information area and state variables are cleared and the upgrade process starts from the beginning (frame_id=1).

[0172] The upgrade confirmation and restart process includes three states: process termination, safe restart, and resume interrupted download.

[0173] The process at the end of the process includes: constructing an OTA information structure (including magic number / firmware size / CRC, etc.), writing and then reading back to verify the integrity of the information, and sending a final confirmation response (ACK 0x01).

[0174] During the safe reboot process: all peripheral interfaces (SPI / UART, etc.) are shut down, and the Bootloader loads the new firmware after verifying the CRC.

[0175] In resuming interrupted transmissions: the last valid frame ID (last_frame) is persistently stored; if there is no reset flag after a restart, transmission continues from last_frame+1; and the incremental CRC is recalculated from the saved value.

[0176] The firmware upgrade method for embedded systems disclosed herein addresses the storage resource bottleneck of small embedded devices by employing an incremental update mechanism that transmits only binary difference data. A hybrid architecture combining UDP incremental data transmission and TCP command control achieves an optimal balance between speed and reliability. A local dynamic computing strategy eliminates cloud dependency, and a dynamic erase / write strategy based on Flash physical characteristics (block erase / page programming) eliminates the need for additional computing resources. A dual verification mechanism of physical readback and CRC32 provides end-to-end protection from transmission to storage. The main program directly manages the entire upgrade process, and a tri-state machine combined with persistent frame sequence number storage ensures accurate continuation after any interruption. The hardware abstraction layer design is compatible with STM32 / FPGA platforms and supports plug-and-play 1MB-16MB SPI NOR Flash. The core algorithm runs on an MCU (≥80MHz), with RAM (random access memory) usage ≤10KB, making it suitable for low-cost devices.

[0177] This approach effectively improves the overall performance of firmware upgrades, significantly enhances transmission efficiency, reduces data volume, optimizes storage space utilization, and improves system response speed. Resource consumption is kept at a low level, equipment operational stability meets industrial requirements, fault tolerance is substantially enhanced, and the security and success rate of the upgrade process remain at a high level. The overall performance improvement surpasses traditional solutions, providing a more reliable upgrade solution for industrial equipment.

[0178] Example 3

[0179] like Figure 4 As shown, this embodiment provides a firmware device upgrade system for an embedded system. The upgrade system is applied to the server. The server communicates with the device using dual protocols. The device is equipped with a first protocol communication interface and a second protocol communication interface.

[0180] The system upgrade includes:

[0181] The instruction generation module 101 is used to generate control instruction information; wherein, the control instruction information includes upgrade instruction information and target upgrade package information;

[0182] The instruction transmission module 102 is used to send upgrade instruction information to the device through a first protocol and a first protocol communication interface, and to send target upgrade package information to the device through a second protocol and a second protocol communication interface, so that the device can perform an upgrade operation based on the upgrade instruction information and the target upgrade package.

[0183] The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

[0184] In this embodiment, the instruction generation module 102 is also used for:

[0185] Generate update package information and obtain the current update package information stored on the device;

[0186] Compare the updated upgrade package information with the first upgrade package information in the current upgrade package information, and use the differences as the target upgrade package information;

[0187] or,

[0188] Generate update and upgrade package information;

[0189] In response to obtaining the reset flag information from the device, the update package is used as the target update package information.

[0190] In this embodiment, the instruction generation module 102 is further configured to respond to the acquisition of breakpoint flag information from the device, and to use the second upgrade package difference information based on the breakpoint flag information and the update upgrade package information as the target upgrade package information.

[0191] The first protocol includes the TCP protocol;

[0192] The second protocol includes the UDP protocol;

[0193] The upgraded system also includes: a status notification module 103;

[0194] The status indication module 103 is used to acquire and output real-time status information of the device; wherein, the real-time status information includes at least one of the device idle status, device transmission status and device completion status.

[0195] For the system embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs.

[0196] The firmware upgrade system for embedded systems provided in this disclosure employs a hybrid communication protocol to balance data transmission efficiency and control command reliability, ensuring the stability of the upgrade process. It also dynamically allocates storage resources based on the hardware characteristics of the storage medium, improving storage utilization and adapting to different models of embedded devices to achieve high-reliability upgrades with lower hardware resource consumption, making it suitable for low-cost embedded devices.

[0197] Furthermore, incremental firmware updates are achieved by transmitting data showing the differences between the old and new versions, reducing network bandwidth usage and storage resource consumption. A dual verification mechanism at the transport and hardware layers is constructed to ensure firmware data integrity. The entire upgrade process is managed through a state machine, enabling traceability and recovery after interruption and preventing device failure.

[0198] Example 4

[0199] like Figure 5 As shown, this embodiment provides an upgrade system for firmware devices in an embedded system. The upgrade system is applied to the device side, which is equipped with a first protocol communication interface and a second protocol communication interface.

[0200] The system upgrade includes:

[0201] The instruction receiving module 201 is used to receive upgrade instruction information sent by the server through the first protocol using the first protocol communication interface, and to receive target upgrade package information sent by the server through the second protocol using the second protocol communication interface.

[0202] The first protocol is used for transmitting complete data, and the second protocol is used for transmitting data in real time.

[0203] Instruction storage module 202 is used to sequentially store target upgrade package information in the initial storage area;

[0204] Upgrade module 203 is used to perform upgrade operations based on upgrade instruction information and target upgrade package information in the initial storage area.

[0205] The upgrade instruction information includes the start instruction, data transfer instruction, and upgrade completion instruction;

[0206] The target upgrade package information includes package sequence number, data upgrade information, and verification information;

[0207] The initial storage area includes a fixed data storage module and a differential data storage module;

[0208] In response to the upgrade command message, which is a start command, the upgrade module is used for:

[0209] In response to the presence of a reset flag in the initial storage area, the initial storage area is cleared, and the update package information is stored in the initial storage area. The first status information is sent to the server, which indicates an idle state.

[0210] In response to the presence of breakpoint marker information in the initial storage area, the differential data storage module is cleared, and the differential information of the second upgrade package is stored in the differential data storage module. The first status information is then sent to the server.

[0211] In response to the absence of reset flag information and breakpoint flag information in the initial storage area, the differential data storage module is cleared, the differential information of the first upgrade package is stored in the differential data storage module, and the first status information is sent to the server.

[0212] or,

[0213] In response to the upgrade instruction information being a data transmission instruction, the upgrade module is used for:

[0214] Retrieve data upgrade information from the initial storage area sequentially according to the package sequence number;

[0215] The system verifies different data upgrade information based on a preset verification method and generates verification results.

[0216] In response to a successful verification result, the current update progress information is determined based on the packet sequence number information, and the server sends a second status information; the second status information is the device transmission status.

[0217] In response to a failed verification result, obtain the sequence number of the packet that failed the corresponding data upgrade information verification, and send the breakpoint flag information, the corresponding packet sequence number information, and the second status information to the server.

[0218] or,

[0219] In response to the upgrade instruction message being an upgrade complete instruction, the upgrade module is used for:

[0220] Clear the target upgrade package information in the initial storage area and send the third status information to the server; the third status information is the device completion status.

[0221] For the system embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs.

[0222] The firmware upgrade system for embedded systems provided in this disclosure employs a hybrid communication protocol to balance data transmission efficiency and control command reliability, ensuring the stability of the upgrade process. It also dynamically allocates storage resources based on the hardware characteristics of the storage medium, improving storage utilization and adapting to different models of embedded devices to achieve high-reliability upgrades with lower hardware resource consumption, making it suitable for low-cost embedded devices.

[0223] Furthermore, incremental firmware updates are achieved by transmitting data showing the differences between the old and new versions, reducing network bandwidth usage and storage resource consumption. A dual verification mechanism at the transport and hardware layers is constructed to ensure firmware data integrity. The entire upgrade process is managed through a state machine, enabling traceability and recovery after interruption and preventing device failure.

[0224] Example 5

[0225] like Figure 6 As shown, Figure 6 This is a schematic diagram of the corresponding electronic device provided in Embodiment 3 of this disclosure. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the methods described in the above embodiments. Figure 6 The electronic device 30 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0226] like Figure 6 As shown, the electronic device 30 can be represented in the form of a general computing device, such as a server device. The components of the electronic device 30 may include, but are not limited to: at least one processor 31, at least one memory 32, and a bus 33 connecting different system components (including memory 32 and processor 31).

[0227] Bus 33 includes a data bus, an address bus, and a control bus.

[0228] The memory 32 may include volatile memory, such as random access memory (RAM) 321 and / or cache memory 322, and may further include read-only memory (ROM) 323.

[0229] The memory 32 may also include a program / utility 325 having a set (at least one) of program modules 324, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0230] The processor 31 executes various functional applications and data processing, such as the methods described in the above embodiments of this disclosure, by running computer programs stored in the memory 32.

[0231] Electronic device 30 can also communicate with one or more external devices 34 (e.g., keyboard, pointing device, etc.). This communication can be performed via input / output (I / O) interface 35. Furthermore, the model-generating device 30 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 36. Figure 6 As shown, network adapter 36 communicates with other modules of the model-generated device 30 via bus 33. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems.

[0232] It should be noted that although several units / modules or sub-units / modules of the electronic device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.

[0233] Example 6

[0234] This disclosure also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the firmware device upgrade method in the embedded system provided in any of the above embodiments.

[0235] The readable storage medium may be more specifically adopted, including but not limited to: portable disk, hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.

[0236] Example 7

[0237] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the firmware device upgrade method in the embedded system described in any of the above embodiments.

[0238] The program code for executing the computer program product of this disclosure can be written in any combination of one or more programming languages, and the program code can be executed entirely on a user device, partially on a user device, as a stand-alone software package, partially on a user device and partially on a remote device, or entirely on a remote device.

[0239] While specific embodiments of this disclosure have been described above, those skilled in the art should understand that these are merely illustrative examples, and the scope of protection of this disclosure is defined by the appended claims. Those skilled in the art can make various changes or modifications to these embodiments without departing from the principles and essence of this disclosure, but all such changes and modifications fall within the scope of protection of this disclosure.

Claims

1. A method for upgrading firmware devices in an embedded system, characterized in that, The upgrade method is applied to the server; the server communicates with the device using dual protocols, and the device is equipped with a first protocol communication interface and a second protocol communication interface; The upgrade method includes: Generate control command information; wherein, the control command information includes upgrade command information and target upgrade package information; The upgrade instruction information is sent to the device via the first protocol communication interface through the first protocol, and the target upgrade package information is sent to the device via the second protocol communication interface through the second protocol, so that the device performs the upgrade operation based on the upgrade instruction information and the target upgrade package; The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

2. The firmware upgrade method for an embedded system according to claim 1, characterized in that, The step of generating control command information includes: Generate update package information and obtain the current update package information stored in the device. The updated upgrade package information and the first upgrade package difference information of the current upgrade information are compared and used as the target upgrade package information; or, Generate update and upgrade package information; In response to obtaining the reset flag information from the device, the update package is used as the target update package information.

3. The firmware upgrade method for an embedded system according to claim 2, characterized in that, In response to obtaining the breakpoint flag information on the device side, the second upgrade package difference information based on the breakpoint flag information and the update upgrade package information is used as the target upgrade package information.

4. The method for upgrading firmware devices in an embedded system according to any one of claims 1-3, characterized in that, The first protocol includes the TCP protocol; And / or, The second protocol includes the UDP protocol; And / or, The upgrade method also includes: Acquire and output the real-time status information of the device; wherein the real-time status information includes at least one of the device idle status, device transmission status, and device completion status.

5. A method for upgrading firmware devices in an embedded system, characterized in that, The upgrade method is applied to the device side, which is equipped with a first protocol communication interface and a second protocol communication interface. The upgrade method includes: The system uses the first protocol communication interface to receive upgrade instruction information sent by the server through the first protocol, and uses the second protocol communication interface to receive target upgrade package information sent by the server through the second protocol. Wherein, the first protocol is a protocol for transmitting complete data, and the second protocol is a protocol for transmitting data in real time; The target upgrade package information is stored sequentially in the initial storage area; Based on the upgrade instruction information, the upgrade operation is performed using the target upgrade package information in the initial storage area.

6. The firmware upgrade method for an embedded system according to claim 5, characterized in that, The upgrade instruction information includes a start instruction, a data transmission instruction, and an upgrade completion instruction; The target upgrade package information includes package sequence number information, data upgrade information, and verification information; The initial storage area includes a fixed data storage module and a differential data storage module; In response to the upgrade instruction information being the startup instruction, the step of sequentially storing the target upgrade package information in the initial storage area includes: In response to the presence of a reset flag in the initial storage area, the initial storage area is cleared, and the update package information is stored in the initial storage area. A first status information is sent to the server, where the first status information is an idle status. In response to the presence of a breakpoint flag in the initial storage area, the differential data storage module is cleared, and the differential information of the second upgrade package is stored in the differential data storage module. The first status information is then sent to the server. In response to the absence of the reset flag information and the breakpoint flag information in the initial storage area, the differential data storage module is cleared, and the first upgrade package differential information is stored in the differential data storage module, and the first status information is sent to the server. or, In response to the upgrade instruction information being the data transmission instruction, the step of completing the upgrade of the device based on the target upgrade package information in the initial storage area includes: The data upgrade information in the initial storage area is obtained sequentially according to the package sequence information; The different data upgrade information is verified based on a preset verification method, and verification results are generated. In response to the successful verification result, the current update progress information is determined based on the packet sequence number information, and the server sends second status information; the second status information is the device transmission status. In response to the failure of the verification result, the packet sequence number information corresponding to the failure of the data upgrade information verification is obtained, and the breakpoint flag information, the corresponding packet sequence number information and the second status information are sent to the server. or, In response to the upgrade instruction information being the upgrade completion instruction, the upgrade method includes: The target upgrade package information in the initial storage area is cleared, and a third status information is sent to the server; the third status information is the device completion status.

7. A firmware upgrade system for an embedded system, characterized in that, The upgrade system is applied to the server; the server communicates with the device using dual protocols, and the device is equipped with a first protocol communication interface and a second protocol communication interface; The upgrade system includes: The instruction generation module is used to generate control instruction information; wherein, the control instruction information includes upgrade instruction information and target upgrade package information; The instruction transmission module is used to send the upgrade instruction information to the device via the first protocol communication interface through the first protocol, and to send the target upgrade package information to the device via the second protocol communication interface through the second protocol, so that the device can perform an upgrade operation based on the upgrade instruction information and the target upgrade package; The first protocol is for transmitting complete data, and the second protocol is for transmitting data in real time.

8. A firmware upgrade system for an embedded system, characterized in that, The upgrade system is applied to the device, which is equipped with a first protocol communication interface and a second protocol communication interface. The upgrade system includes: The instruction receiving module is used to receive upgrade instruction information sent by the server through the first protocol using the first protocol communication interface, and to receive target upgrade package information sent by the server through the second protocol using the second protocol communication interface. Wherein, the first protocol is a protocol for transmitting complete data, and the second protocol is a protocol for transmitting data in real time; The instruction storage module is used to sequentially store the target upgrade package information in the initial storage area; The upgrade module is used to perform an upgrade operation based on the upgrade instruction information and the target upgrade package information in the initial storage area.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and for running on the processor, characterized in that, When the processor executes the computer program, it implements the firmware device upgrade method in the embedded system according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the firmware device upgrade method in the embedded system as described in any one of claims 1 to 6.