Firmware upgrade method and storage medium
By broadcasting the start and end frames through the master device, the firmware data is sent after the slave device is ready. This solves the low efficiency problem of the serial method, realizes the parallel upgrade of multiple devices, and improves the upgrade efficiency and system reliability.
Patent Information
- Application Number
- CN202510912077.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-03
AI Technical Summary
In the serial mode, the master device can only upgrade the firmware of one slave device at a time, which is inefficient.
The master device broadcasts a start frame containing the first verification information. The target slave device enters the firmware upgrade state after parsing and uses the first flag and end frame to ensure that the firmware data is sent after preparation. The target slave device receives and erases the data frame until the software version numbers of all devices are consistent with the firmware data.
It enables simultaneous upgrades of multiple slave devices, improves firmware upgrade efficiency, reduces network load and labor costs, enhances system reliability, and avoids the spread of single-point failures.
Smart Images

Figure CN120498999B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of firmware upgrade, and in particular to a firmware upgrade method and storage medium. Background Art
[0002] The RS485 bus system has been widely used in medium- and long-distance communications within industrial automation due to its simple hardware design, flexible control, and low cost. In typical project deployments, RS485-based communication systems employ a master-slave architecture, where a master device connects to multiple slave devices. Each slave device has a unique communication address, and data exchange between the master and slave devices is achieved through addressing. To optimize device performance and enhance functionality, slave device firmware upgrades are required.
[0003] In related technologies, firmware upgrades for slave devices are typically performed serially. Specifically, a master device sends firmware data to each slave device individually based on a manually configured communication address. This means the master device upgrades the firmware for only one slave device at a time. Once the upgrade is complete for one slave device, the master device then upgrades the firmware for the next slave device.
[0004] However, in the serial mode, the master device can only upgrade the firmware of one slave device at a time, which is inefficient. Summary of the Invention
[0005] The present application provides a firmware upgrade method and storage medium to solve the problem of low efficiency in serial mode where a master device can only upgrade the firmware of one slave device at a time, thereby achieving the purpose of improving the efficiency of firmware upgrade.
[0006] In a first aspect, the present application provides a firmware upgrade method, which is applied to a master device in a master-slave communication system, the master-slave communication system including a master device and multiple slave devices, including:
[0007] The master device broadcasts a start frame including first verification information, where the first verification information is used to indicate device information of a target slave device, where the target slave device is a slave device whose firmware is to be upgraded.
[0008] The master device starts a timer each time it receives a first flag, and broadcasts firmware data when the first timer duration is longer than a first period and the next first flag is not received. The first flag is used to indicate that the target slave device is entering a firmware upgrade state. The first flag is sent according to the first period when the target slave device parses the first verification information and enters the firmware upgrade state according to the first verification information.
[0009] The master device broadcasts a send end frame to enable the target slave device to perform a firmware upgrade based on the firmware data. The send end frame is used to indicate that the firmware data has been sent.
[0010] In one possible design, the firmware data is broadcasted, including:
[0011] The master device divides the firmware data into N data frames, where N is a positive integer;
[0012] The master device broadcasts the nth data frame, where n is a positive integer less than or equal to N;
[0013] The master device starts a timer each time it receives a second flag, and if the second timer duration is longer than the second period and the next second flag is not received, it broadcasts and sends the (n+1)th data frame until N data frames are sent. The second flag is used to indicate that the target slave device is in the process of erasing firmware data.
[0014] The second flag is sent according to the second cycle during the process of erasing the firmware data in the nth data frame into the memory when the target slave device correctly parses the nth data frame.
[0015] In one possible design, the method further includes:
[0016] After the master device determines that the firmware upgrade of the target slave device is complete, it polls the software version number of the target slave device;
[0017] When there are non-upgraded slave devices whose software version numbers are inconsistent with the software version numbers in the firmware data among the target slave devices, the firmware upgrade method is repeatedly executed for the non-upgraded slave devices until the software version numbers of all the target slave devices are consistent with the software version numbers in the firmware data.
[0018] In one possible design, the first verification information is an MD5 value obtained by combining the model, hardware version number, software version number and production date of the target slave device.
[0019] In one possible design, the start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform a firmware upgrade if it is determined that the firmware data is correct.
[0020] In a second aspect, the present application provides a firmware upgrade method, which is applied to a slave device in a master-slave communication system, the master-slave communication system including a master device and multiple slave devices, the method comprising:
[0021] The plurality of slave devices receive and parse a start frame broadcasted by the master device, the start frame including first verification information, the first verification information being used to indicate device information of a target slave device, the target slave device being a slave device whose firmware is to be upgraded;
[0022] After parsing the first verification information, the target slave device enters a firmware upgrade state according to the first verification information, and sends a first flag to the master device according to a first period during the process of entering the firmware upgrade state, wherein the first flag is used to indicate that the target slave device is entering the firmware upgrade state;
[0023] The target slave device receives firmware data broadcasted by the master device; wherein the firmware data is broadcasted by the master device when the master device starts timing each time it receives a first flag and when the first timing duration is greater than the first period and the next first flag is not received;
[0024] The target slave device receives the end frame broadcast by the master device, which is used to indicate that the firmware data has been sent.
[0025] The target slave device performs firmware upgrade based on the firmware data.
[0026] In a possible design, receiving firmware data sent by the master device includes:
[0027] The target slave device receives and parses the nth data frame broadcasted by the master device. The nth data frame is one of the N data frames obtained by the master device by segmenting the firmware data. N is a positive integer greater than or equal to 1.
[0028] When the target slave device correctly parses the nth data frame, it erases the firmware data in the nth data frame into the memory, and sends a second flag to the master device according to the second cycle during the erasing process, the second flag being used to indicate that the target slave device is in the process of erasing the firmware data;
[0029] The target slave device receives the n+1th data frame broadcasted by the master device until N data frames are received; wherein, the n+1th data frame is broadcasted by the master device when it starts timing each time it receives a second flag and has not received the next second flag when the second timing time is longer than the second period.
[0030] In one possible design, the method further includes:
[0031] When there is an unupgraded slave device among the target slave devices whose software version number is inconsistent with the software version number in the firmware data, the unupgraded slave device repeatedly executes the firmware upgrade method until the software version numbers of all target slave devices are consistent with the software version numbers in the firmware data.
[0032] In one possible design, entering a firmware upgrade state according to the first verification information includes:
[0033] The target slave device calculates third verification information according to the device information of the target slave device;
[0034] When the third verification information is consistent with the first verification information, the target slave device enters a firmware upgrade state.
[0035] In one possible design, the first verification information is an MD5 value obtained by combining the model, hardware version number, software version number and production date of the target slave device.
[0036] In one possible design, the start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform a firmware upgrade if it is determined that the firmware data is correct.
[0037] In the firmware upgrade method provided in the first aspect or the second aspect, a master device broadcasts a start frame to notify a target slave device that a firmware upgrade is about to be performed. The slave device determines whether a firmware upgrade is required and prepares for the firmware upgrade based on the start frame. After parsing the first verification information in the start frame, the target slave device enters a firmware upgrade state based on the first verification information and sends a first flag to the master device according to a first period during the firmware upgrade process. The master device determines whether the target slave device can start the firmware upgrade based on the first flag, ensuring that the target slave device is ready when the firmware data is subsequently transmitted, thereby ensuring smooth firmware data transmission. The master device starts a timer each time it receives a first flag. If the first timer duration exceeds the first period and the next first flag is not received, the master device broadcasts the firmware data. This allows the master device to broadcast the firmware data only after ensuring that the target slave device has entered the firmware upgrade state, thereby improving the success rate of the transmission and helping to improve the success rate of the firmware upgrade. The master device only needs to send the firmware data once through broadcasting, and each target slave device can receive the firmware data simultaneously, thereby helping to improve the efficiency of the firmware upgrade. The master device broadcasts a send completion frame, ensuring that the target slave devices can upgrade based on the complete firmware data, thereby improving the success rate of the firmware upgrade. The target slave devices then upgrade based on the firmware data. This allows the master device to send firmware data only once, allowing the target slave devices to upgrade in parallel based on the firmware data, eliminating the need for each device to wait for the upgrade. This decouples the total upgrade time from the number of devices, improving the efficiency of the firmware upgrade.
[0038] In addition, during the firmware upgrade process, there is no need to manually set up and verify the communication address and firmware data, which can realize automatic firmware upgrade, avoid errors, simplify the firmware upgrade process, and abnormal devices can exit the upgrade state by themselves, thereby improving the success rate of firmware upgrade.
[0039] Furthermore, when a target slave device has an abnormality, the abnormal device can be automatically isolated to avoid the problem of single point failure spreading in the serial upgrade method, without affecting other normally upgraded target slave devices, thereby enhancing the reliability of the master-slave communication system.
[0040] This method is particularly suitable for the operation and maintenance scenarios of large-scale equipment groups in industrial sites, and can significantly reduce network load and labor costs during the upgrade process.
[0041] In a third aspect, the present application provides a firmware upgrade device, comprising: a module for executing the method in any possible design in the above-mentioned first aspect.
[0042] In a fourth aspect, the present application provides a firmware upgrade device, comprising: a module for executing the method in any possible design in the above-mentioned second aspect.
[0043] In a fifth aspect, the present application provides an electronic device comprising a memory and a first processor, wherein the memory stores a computer executable program or instructions, and when the processor executes the computer executable program or instructions, it implements a firmware upgrade method as described in any possible design from the first aspect to the second aspect and from the first aspect to the second aspect.
[0044] In a sixth aspect, the present application provides an electronic device comprising a second processor, which, when executing a computer executable program or instruction in a memory, implements a firmware upgrade method as in any possible design from the first aspect to the second aspect and from the first aspect to the second aspect.
[0045] In the seventh aspect, the present application provides a computer-readable storage medium, on which a computer-executable program or instruction is stored. When the computer-executable program or instruction is executed by a processor, a firmware upgrade method as in any possible design from the first aspect to the second aspect and from the first aspect to the second aspect is implemented.
[0046] In an eighth aspect, the present application provides a computer program product, comprising: execution instructions, the execution instructions being stored in a readable storage medium, at least one processor of an electronic device being able to read the execution instructions from the readable storage medium, and at least one processor executing the execution instructions so that the electronic device implements a firmware upgrade method as in any possible design from the first aspect to the second aspect and from the first aspect to the second aspect.
[0047] The above description is only an overview of the technical solutions of the embodiments of the present application. In order to more clearly understand the technical means of the embodiments of the present application, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of the structure of a master-slave communication system provided in one embodiment of the present application.
[0049] Figure 2 An interactive diagram of a firmware upgrade method provided in one embodiment of the present application.
[0050] Figure 3 An interactive diagram of a method for broadcasting firmware data provided by one embodiment of the present application.
[0051] Figure 4 An interactive diagram of a firmware upgrade method provided in one embodiment of the present application.
[0052] Figure 5 A flowchart of a method for entering a firmware upgrade state provided in one embodiment of the present application.
[0053] Figure 6 A flowchart of a method for performing firmware upgrade provided in one embodiment of the present application.
[0054] Figure 7 A schematic diagram of the structure of a firmware upgrade device provided in one embodiment of the present application.
[0055] Figure 8 A schematic diagram of the structure of a firmware upgrade device provided in one embodiment of the present application.
[0056] Figure 9 A schematic structural diagram of an electronic device provided in one embodiment of the present application.
[0057] Figure 10 A schematic structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0058] In this application, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can mean: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a alone, b alone, or c alone can mean: a alone, b alone, c alone, a and b combined, a and c combined, b and c combined, or a, b, and c combined, where a, b, and c can be single or plural. In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance.
[0059] The directions or positional relationships indicated by terms such as "center", "longitudinal", "lateral", "up", "down", "left", "right", "front", and "back" are based on the directions or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present application and simplifying the description. They do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction. Therefore, they should not be understood as limiting the present application.
[0060] The terms "connected" and "connect" should be interpreted broadly. For example, "connected" or "connected" in a circuit structure can refer not only to a physical connection, but also to an electrical connection or a signal connection. For example, it can be a direct connection, i.e., a physical connection, or an indirect connection through at least one intermediate component, as long as the circuit is interconnected. It can also refer to internal connectivity between two components. Signal connection can refer not only to signal connection through circuits but also to signal connection through media, such as radio waves. Those skilled in the art will understand the specific meanings of the above terms in this application on a case-by-case basis.
[0061] Illustratively, the present application provides a firmware upgrade method, a master-slave communication system, and a storage medium. By setting a busy flag, the master device sends firmware data to the slave devices to be upgraded based on broadcasting. Without manually setting the communication address, each slave device to be upgraded can accurately receive the firmware data, and can also perform firmware upgrades at the same time, thereby improving the efficiency of the firmware upgrade.
[0062] The firmware upgrade method provided in this application is applied to a master-slave communication system, which includes a master device and multiple slave devices. The firmware upgrade method is performed by the master device and the slave devices, or by a firmware upgrade device in the master device and a firmware upgrade device in the slave devices. The firmware upgrade device can be implemented through a combination of software and / or hardware.
[0063] See also Figure 1 , Figure 1 This is a schematic diagram of the structure of a master-slave communication system provided in one embodiment of the present application. Figure 1 As shown, the master-slave communication system of the present application may include: a master device 11 and multiple slave devices 12.
[0064] in, Figure 1 The example in which the number of slave devices 12 is 3 is used for illustration. The present application does not limit the number of slave devices 12 .
[0065] The master device 11 may be a digital display meter or an electric energy meter, and the slave device 12 may also be a digital display meter or an electric energy meter.
[0066] In the master-slave communication system, the slave device 12 can also serve as the master device, and this application does not impose any restrictions on this.
[0067] The master device 11 is communicatively connected to a plurality of slave devices 12 .
[0068] Among them, multiple slave devices 12 can also be connected to each other for communication. Figure 1 Not shown in the figure.
[0069] For example, the master device 11 and the slave devices 12 may be directly or indirectly connected via a wired or wireless communication method. The slave devices 12 may be directly or indirectly connected to each other via a wired or wireless communication method.
[0070] Wired communication methods include coaxial cables, optical fibers, and digital subscriber lines (DSL), while wireless communication methods include Bluetooth, infrared, Wi-Fi, and microwaves.
[0071] In some specific examples, the master device 11 and the multiple slave devices 12 can communicate with each other via a ModBus communication protocol based on an RS485 bus.
[0072] In some specific examples, RJ45 (registered jack 45) interfaces are provided on the master device 11 and the multiple slave devices 12. The master device 11 and the multiple slave devices 12 can communicate with each other through the RJ45 interfaces according to the RS-485 protocol.
[0073] Below, the following embodiments of the present application will be based on Figure 1 As an example, the master-slave communication system with the structure shown in the figure is combined with Figures 2 to 6 , the firmware upgrade method provided by this application is elaborated in detail.
[0074] See also Figure 2 , Figure 2 This is an interactive diagram of a firmware upgrade method provided in one embodiment of the present application. Figure 2 As shown, the method includes:
[0075] S101: The master device broadcasts a start frame.
[0076] Correspondingly, multiple slave devices receive and parse the start frame broadcasted by the master device.
[0077] The start frame includes first verification information, and the first verification information is used to indicate device information of a target slave device, where the target slave device is a slave device whose firmware is to be upgraded.
[0078] When the target slave device needs to perform a firmware upgrade, the master device broadcasts a start frame, thereby notifying the target slave device through the start frame to prepare for the firmware upgrade.
[0079] Considering that the slave device needs to determine whether a firmware upgrade is required, the master device may add first verification information to the start frame, so that the slave device can know whether a firmware upgrade is required based on the first verification information.
[0080] Specifically, the master device can generate first verification information based on the device information of the target slave device, and send the first verification information to the slave device through a start frame. After receiving the start frame, the slave device can determine whether a firmware upgrade is required based on the first verification information and the device information stored in itself.
[0081] For example, the master device may determine the software version number of the target slave device as the first verification information. After receiving the start frame, the slave device may determine whether a firmware upgrade is required based on the software version number of the target slave device and its own stored software version number.
[0082] After receiving the start frame, multiple slave devices verify the start frame based on the check bit in the start frame. After the verification is successful, the start frame is parsed.
[0083] When the verification fails, the slave device does not need to respond to ensure that the channel is not occupied.
[0084] Based on this, the master device notifies the target slave device of the upcoming firmware upgrade by broadcasting a start frame. The slave device determines whether the firmware upgrade is required and prepares for the firmware upgrade based on the start frame.
[0085] S102: After parsing the first verification information, the target slave device enters a firmware upgrade state according to the first verification information, and sends a first flag to the master device according to a first period during the process of entering the firmware upgrade state.
[0086] Correspondingly, the master device receives the first flag sent by the target slave device.
[0087] For each slave device, after parsing the first verification information, the slave device may determine whether a firmware upgrade is required based on the device information indicated in the first verification information and the device information stored in the slave device.
[0088] If the device information indicated in the first verification information is consistent with the device information stored in the slave device, the slave device determines that a firmware upgrade is required and enters a firmware upgrade state; if not, the slave device determines that a firmware upgrade is not required.
[0089] For example, if the master device determines the software version number of the target slave device as the first verification information, then for each slave device, after the slave device obtains the first verification information, it can read the software version number stored in itself, and compare its own software version number with the software version number in the received first verification information. If its own software version number is consistent with the first verification information, then the slave device is the target slave device and needs to perform a firmware upgrade; if its own software version number is inconsistent with the first verification information, then the slave device does not need to perform a firmware upgrade.
[0090] For example, a master-slave communication system includes four slave devices, namely slave A, slave B, slave C, and slave D. The software version numbers of the four slave devices are shown in Table 1 below:
[0091] Table 1
[0092]
[0093] If the software version number of the target slave device in the first verification information is 2025.01.125, it means that the slave device with the software version number 2025.01.125 needs to be upgraded, while the slave devices with software version numbers other than 2025.01.125 do not need to be upgraded. Based on Table 1, slave devices A and C are determined to need to be upgraded, and the target slave devices include slave devices A and C.
[0094] Based on this, after parsing the first verification information, the target slave device determines to enter the firmware upgrade state according to the first verification information. The target slave device can perform operations such as status check, data backup, power check, connection status check, and storage medium preparation to enter the firmware upgrade state.
[0095] During the process of entering the firmware upgrade state, the target slave device transmits a first flag to the master device according to a first cycle. After broadcasting the start frame, the master device can immediately begin monitoring the channel. Upon receiving the first flag from the target slave device, the master device can determine that the target slave device has determined that a firmware upgrade is required and is preparing for it. After entering the firmware upgrade state, the target slave device stops transmitting the first flag. When the master device no longer receives the first flag, it can confirm that the target slave device has entered the firmware upgrade state and can begin the firmware upgrade.
[0096] The first flag is used to indicate that the target slave device is entering a firmware upgrade state.
[0097] The first mark may be, for example, a numeric mark, an alphabetic mark, or a symbol mark, and the first mark may be represented by the American Standard Code for Information Interchange (ASCII).
[0098] In some examples, the target slave device can use the carrier sense multiple access / collision detection (CSMA / CD) protocol with collision detection to send the first flag. Before sending the first flag, the target slave device will check whether the channel is idle. If the channel is idle, the target slave device will send the first flag. While sending the first flag, the target slave device will continue to monitor the network. If a conflict is detected in the network, the target slave device will immediately stop sending the first flag and retry after a random delay. The target slave device repeats the above steps until the first flag is successfully sent or the upper limit of the retry number is reached.
[0099] In addition, after parsing the first verification information, the slave device that does not need to perform firmware upgrade among the multiple slave devices determines that the firmware upgrade is not needed based on the first verification information, and thus does not need to perform any operation.
[0100] Based on this, the target slave device enters the firmware upgrade state, and the master device determines whether the target slave device can start the firmware upgrade according to the first flag, ensuring that the target slave device is ready when the firmware data is subsequently transmitted, thereby ensuring smooth transmission of the firmware data.
[0101] S103: The master device starts timing each time it receives a first flag, and broadcasts and sends firmware data when the first timing duration is greater than the first period and the next first flag is not received.
[0102] Correspondingly, the target slave device receives the firmware data broadcasted by the master device.
[0103] When the master device receives the first first flag, it can be known that the target slave device is entering the firmware upgrade state. The master device starts a timer every time it receives a first flag to obtain the first timing duration. If the next first flag is not received when the first timing duration is greater than the first cycle, that is, the target slave device does not send the first flag for a duration greater than the first cycle, that is, the target slave device stops sending the first flag, indicating that the target slave device has entered the firmware upgrade state, then the master device can broadcast and send the firmware data.
[0104] Therefore, the master device can broadcast and send firmware data only when it is ensured that the target slave device has entered the firmware upgrade state through the first flag, which can improve the success rate of the transmission and thus help improve the success rate of the firmware upgrade.
[0105] When the target slave device enters the firmware upgrade state, it receives the firmware data broadcast by the master device. The master device only needs to send the firmware data once in the form of broadcast, and each target slave device can receive the firmware data at the same time, which helps to improve the efficiency of the firmware upgrade.
[0106] S104: The master device broadcasts a sending end frame.
[0107] Correspondingly, the target slave device receives the end frame broadcast by the master device.
[0108] The end frame is used to indicate that the firmware data has been sent.
[0109] After the master device sends all the firmware data to the target slave device, the master device can send an end frame to inform the target slave device that the firmware data has been sent. Therefore, when the target slave device receives the end frame, it knows that all the firmware data has been received, ensuring that the firmware upgrade can be performed based on the complete firmware data, thereby improving the success rate of the firmware upgrade.
[0110] S105: The target slave device performs a firmware upgrade according to the firmware data.
[0111] The target slave device restarts and is upgraded according to the firmware data, thereby completing the firmware upgrade.
[0112] Based on this, all target slave devices can upgrade their firmware in parallel at the same time without having to wait in sequence, which improves the efficiency of firmware upgrade.
[0113] In an embodiment of the present application, a master device broadcasts a start frame to notify a target slave device that a firmware upgrade is imminent. The slave device then determines whether a firmware upgrade is required and prepares for the upgrade based on the start frame. After parsing the first verification information in the start frame, the target slave device enters a firmware upgrade state based on the first verification information and, while in the firmware upgrade state, sends a first flag to the master device based on a first period. The master device determines whether the target slave device can begin the firmware upgrade based on the first flag, ensuring that the target slave device is ready when the firmware data is subsequently transmitted, thereby ensuring smooth firmware data transmission. The master device starts a timer each time it receives a first flag. If the first timer duration exceeds the first period and the next first flag is not received, the master device broadcasts the firmware data. This ensures that the master device only broadcasts the firmware data after ensuring that the target slave device has entered the firmware upgrade state, thereby improving the success rate of the firmware upgrade. The master device only broadcasts the firmware data once, allowing each target slave device to receive the firmware data simultaneously, thereby improving the efficiency of the firmware upgrade. The master device broadcasts an end frame to ensure that the target slave device can perform the firmware upgrade based on the complete firmware data, thereby improving the success rate of the firmware upgrade. The target slave devices perform firmware upgrades based on the firmware data. This allows the master device to send firmware data only once, allowing the target slave devices to upgrade in parallel based on the firmware data, eliminating the need for each device to wait for the upgrade. This decouples the total upgrade time from the number of devices, improving the efficiency of firmware upgrades.
[0114] In addition, during the firmware upgrade process, there is no need to manually set up and verify the communication address and firmware data, which can realize automatic firmware upgrade, avoid errors, simplify the firmware upgrade process, and abnormal devices can exit the upgrade state by themselves, thereby improving the success rate of firmware upgrade.
[0115] Furthermore, when a target slave device has an abnormality, the abnormal device can be automatically isolated to avoid the problem of single point failure spreading in the serial upgrade method, without affecting other normally upgraded target slave devices, thereby enhancing the reliability of the master-slave communication system.
[0116] This method is particularly suitable for the operation and maintenance scenarios of large-scale equipment groups in industrial sites, and can significantly reduce network load and labor costs during the upgrade process.
[0117] Based on the above exemplary description, the master device can be configured as follows: Figure 3 The firmware data is broadcasted in the manner shown.
[0118] See also Figure 3 , Figure 3 This is an interactive diagram of a method for broadcasting firmware data provided by an embodiment of the present application. Figure 3 As shown, the method includes:
[0119] S201: The master device divides the firmware data into N data frames.
[0120] Wherein, N is a positive integer.
[0121] Generally speaking, the amount of firmware data is large. Before broadcast transmission, it needs to be divided into multiple data frames so that it can be broadcast to the target slave device in sequence.
[0122] S202: The master device broadcasts and sends the nth data frame.
[0123] Correspondingly, the target slave device receives the nth data frame broadcasted by the master device.
[0124] Wherein, n is a positive integer less than or equal to N.
[0125] S203 : When the target slave device correctly parses the nth data frame, it writes the firmware data in the nth data frame to the memory, and sends a second flag to the master device according to the second cycle during the writing process.
[0126] Correspondingly, the master device receives the second flag.
[0127] The second flag is used to indicate that the target slave device is performing firmware data erasing.
[0128] After receiving the nth data frame from the target device, the target device verifies the nth data frame based on the check bit in the nth data frame. After the verification is successful, the target device parses the nth data frame.
[0129] When the verification fails, the target slave device does not need to respond to ensure that the channel is not occupied.
[0130] The target slave device, after correctly parsing and obtaining the firmware data from the nth data frame, erases and writes the firmware data in the nth data frame to the memory.
[0131] During the erase / write process, the target slave device sends a second flag to the master device according to the second cycle. After broadcasting the nth data frame, the master device can immediately start monitoring the channel. After receiving the second flag sent by the target slave device, the master device can know that the target slave device is already erasing the firmware data corresponding to the nth data frame. After the erase / write process is complete, the target slave device stops sending the second flag. When the master device no longer receives the second flag, it can confirm that the target slave device has completed the erase / write process and can start sending the n+1th data frame.
[0132] The first flag and the second flag, and the way in which the target slave device sends the second flag are similar to the way in which the first flag is sent. Please refer to the description in S102 and will not be repeated here.
[0133] The first flag and the second flag may be the same, and the master device may identify the first flag and the second flag according to the stage of the firmware upgrade. Of course, the first flag and the second flag may also be different, and this application does not limit this.
[0134] Based on this, the target slave device erases and writes the firmware data corresponding to the nth data frame, and the master device determines whether the erasure of the target slave device is completed according to the second flag, ensuring that when the n+1th data frame is subsequently transmitted, the target slave device has completed the erasure of the nth data frame, avoiding conflicts and ensuring smooth transmission of firmware data.
[0135] S204: The master device starts timing each time it receives a second flag, and broadcasts and sends the (n+1)th data frame if it has not received the next second flag when the second timing duration is greater than the second period, until all N data frames are sent.
[0136] Correspondingly, the target slave device receives the (n+1)th data frame broadcasted by the master device.
[0137] When the master device receives the first second flag, it will know that the target slave device is being erased. The master device starts a timer every time it receives a second flag to obtain the second timing duration. If the next second flag is not received when the second timing duration is greater than the second cycle, that is, the target slave device has not sent the second flag for a duration greater than the second cycle, that is, the target slave device stops sending the second flag, indicating that the target slave device has been erased and written, then the master device can broadcast and send the n+1th data frame.
[0138] Therefore, the master device can broadcast the (n+1)th data frame only when it is ensured that the target slave device has completed erasing the (n)th data frame through the second flag, thereby helping to improve the success rate of the firmware upgrade.
[0139] Based on the above exemplary description, after completing one firmware upgrade, the firmware upgrade method further includes the following S106 and S107.
[0140] See also Figure 4 , Figure 4 This is an interactive diagram of a firmware upgrade method provided in one embodiment of the present application. Figure 4 As shown, the method further includes:
[0141] S106 : After determining that the firmware upgrade of the target slave device is complete, the master device polls the software version number of the target slave device.
[0142] The master device can determine that the firmware upgrade of the target slave device is complete in a variety of ways.
[0143] As a feasible implementation method, the target slave device can send a third flag to the master device according to the third cycle during the firmware upgrade based on the firmware data. The master device starts a timing each time it receives a third flag, and determines that the firmware upgrade of the target slave device is completed when the third timing time is longer than the third cycle and the next third flag is not received.
[0144] As another feasible implementation, when the target slave device completes the firmware upgrade according to the firmware data, the master device determines that the firmware upgrade of the target slave device is completed upon receiving a polling instruction from an operator.
[0145] As another feasible implementation, the master device may wait for a preset time period after sending the firmware data, and determine that the firmware upgrade of the target slave device is completed after the preset time period.
[0146] Therefore, after determining that the firmware upgrade of the target slave device is completed, the master device polls the software version number in each target slave device to determine whether the firmware upgrade of the target slave device is completed.
[0147] S107: The master device determines whether there is a non-upgraded slave device among the target slave devices whose software version number is inconsistent with the software version number in the firmware data.
[0148] If there is an unupgraded slave device among the target slave devices whose software version number is inconsistent with the software version number in the firmware data, continue to execute S101 until the software version numbers of all target slave devices are consistent with the software version numbers in the firmware data; otherwise, end the firmware upgrade.
[0149] An unupgraded slave device means that the firmware has not been upgraded to the version indicated by the firmware data. Therefore, the software version number stored in the unupgraded slave device is inconsistent with the software version number in the firmware data. The master device can thus determine whether the target slave device has completed the firmware upgrade. If the firmware upgrade is not completed, the master device repeats the firmware upgrade method again to ensure that all slave devices that need to be upgraded have completed the firmware upgrade, avoiding omissions and improving the success rate of the firmware upgrade.
[0150] Based on the above exemplary description, the target slave device can be configured as follows: Figure 5 Enter the firmware upgrade state in the manner shown.
[0151] See also Figure 5 , Figure 5 This is a flowchart of a method for entering a firmware upgrade state provided in one embodiment of the present application. Figure 5 As shown, the method includes:
[0152] S301: The target slave device calculates third verification information according to the device information of the target slave device.
[0153] The target slave device can read the device information of the target slave device stored in the memory, and calculate the third verification information based on the device information of the target slave device using the same algorithm as that used by the master device to obtain the first verification information.
[0154] For example, if the master device determines the MD5 value corresponding to the software version number of the target slave device as the first verification information, the target slave device may determine the MD5 value corresponding to the software version number stored in itself as the third verification information.
[0155] The MD5 value is calculated using the message-digest algorithm 5 (MD5). MD5 is fast to calculate and easy to process and transmit, which helps improve the efficiency of firmware upgrades.
[0156] Based on this, the target slave device may match the third verification information with the first verification information to determine that it enters the waiting-for-upgrade state.
[0157] S302: When the third verification information is consistent with the first verification information, the target slave device enters a firmware upgrade state.
[0158] If the third verification information is consistent with the first verification information, the target slave device can determine that a firmware upgrade is required, and the target slave device can perform status check, data backup, power check, connection status check, storage medium preparation and other operations to enter the firmware upgrade state.
[0159] Based on this, the target slave device can enter the firmware upgrade state only when it is ensured that an upgrade is required by comparing the third verification information with the first verification information, thereby improving the accuracy of the firmware upgrade.
[0160] Based on the above exemplary description, the first verification information is an MD5 value obtained by combining the model, hardware version number, software version number and production date of the target slave device.
[0161] Based on this, the target slave device can determine the MD5 value obtained by combining the target slave device model, hardware version number, software version number, and production date stored in the target slave device as the third verification information, and compare the third verification information with the first verification information to determine whether to enter the firmware upgrade state.
[0162] By calculating the MD5 value based on various device information for verification, the accuracy of verification can be improved, thereby ensuring that the slave devices that need to upgrade the firmware enter the firmware upgrade state, and the slave devices that do not need to upgrade the firmware do not need to perform any operation, thereby improving the efficiency of the firmware upgrade.
[0163] Based on the above exemplary description, the start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data. The target slave device can be based on the following Figure 6 Upgrade the firmware in the manner shown.
[0164] See also Figure 6 , Figure 6 This is a flowchart of a method for performing firmware upgrades provided in one embodiment of the present application. Figure 6 As shown, the method further includes:
[0165] S401 : After receiving the end frame, the target slave device determines whether the firmware data is correct according to the second verification information and the firmware data.
[0166] If it is determined that the firmware data is correct, the target slave device executes S402 ; if it is determined that the firmware data is incorrect, the target slave device executes S403 .
[0167] Determining that the firmware data is correct means that the firmware data is complete and correct. Determining that the firmware data is incorrect means that the firmware data is wrong or missing.
[0168] The target slave device calculates the fourth verification information based on the received firmware data using the same algorithm as the master device used to obtain the second verification information. If the received firmware data is complete and correct, the calculated fourth verification information should be consistent with the second verification information. The target slave device can then determine that the firmware data is correct if the fourth verification information is consistent with the second verification information. Otherwise, the firmware data is determined to be incorrect.
[0169] In some examples, the master device can calculate the MD5 value corresponding to the firmware data based on the firmware data and send it to the target slave device through the start frame. Therefore, after the target slave device obtains all the firmware data, it calculates a new MD5 value and compares the two MD5 values. If they are consistent, the firmware upgrade is performed.
[0170] In addition, the master device may also send the second verification information in the end frame.
[0171] S402: Restart and perform firmware upgrade.
[0172] The target slave device restarts and performs firmware upgrade after ensuring that the firmware data is correct, thereby avoiding errors during the upgrade process and improving the success rate of the firmware upgrade.
[0173] S403: Exit the firmware upgrade state.
[0174] If it is determined that the firmware data is incorrect, the target slave device exits the firmware upgrade state to avoid occupation.
[0175] The following describes the domain name, number of bytes, and data content of a start frame, in conjunction with Table 2:
[0176] Table 2
[0177]
[0178] In Table 2, the address represents the address of the master device sending the start frame. 00H can be used to represent a broadcast transmission. 32+2*K represents the data length of the start frame. The firmware name and size can be expressed in ASCII.
[0179] Combined with Table 3, the domain name, number of bytes and data content of a data frame are introduced. Taking the first data frame as an example, as shown in Table 3:
[0180] Table 3
[0181]
[0182] Among them, the packet number 0001H represents the first data frame, and P represents the data length of the data frame.
[0183] Combined with Table 4, the domain name, number of bytes and data content of an end frame are introduced. As shown in Table 4:
[0184] Table 4
[0185]
[0186] Where Q represents the data length of the end frame. The end data 00H indicates that this frame is the end frame.
[0187] In Table 2, Table 3, and Table 4 above, the check bits may be obtained using a 16-bit cyclic redundancy check (CRC) algorithm.
[0188] Exemplarily, the present application also provides a firmware upgrade device.
[0189] Figure 7 A schematic diagram of the structure of a firmware upgrade device provided in one embodiment of the present application.
[0190] like Figure 7 As shown, the firmware upgrade device 100 can exist independently or be integrated into other devices, and can communicate with the slave devices mentioned above to implement the operations corresponding to the master device in any of the above method embodiments.
[0191] The firmware upgrade apparatus 100 may include a transceiver unit 101 and a processing unit 102. The transceiver unit 101 may also be referred to as a communication interface or communication unit. The processing unit 102 may read instructions and / or data from the storage unit to enable the firmware upgrade apparatus 100 to implement the aforementioned method embodiments. The transceiver unit 101 may implement the corresponding communication functions, and the processing unit 102 may be used to process data.
[0192] Optionally, the firmware upgrading apparatus 100 may further include a storage unit, which may be used to store instructions and / or data.
[0193] The firmware upgrade device 100 can be used to perform the actions performed by the master device in the aforementioned method embodiments. The firmware upgrade device 100 can be a master device or a component that can be configured on a master device. The transceiver unit 101 is used to perform the reception-related operations of the master device in the aforementioned method embodiments, and the processing unit 102 is used to perform data processing.
[0194] Optionally, the transceiver unit 101 may include a sending unit and a receiving unit. The sending unit is configured to perform the sending operation in the aforementioned method embodiment. The receiving unit is configured to perform the receiving operation in the aforementioned method embodiment.
[0195] It should be noted that the firmware upgrade device 100 may include a sending unit but not a receiving unit. Alternatively, the firmware upgrade device 100 may include a receiving unit but not a sending unit. The specific implementation depends on whether the above solution executed by the firmware upgrade device 100 includes both sending and receiving actions.
[0196] As an example, the firmware upgrade device 100 is used to execute the above Figures 2 to 6 Actions performed by the master device in the illustrated embodiment.
[0197] The firmware upgrade device 100 may include a transceiver unit 101 and a processing unit 102 .
[0198] The transceiver unit 101 is configured to broadcast a start frame, the start frame including first verification information, the first verification information being used to indicate device information of a target slave device, the target slave device being a slave device whose firmware is to be upgraded;
[0199] The processing unit 102 is configured to start a timing each time a first flag is received. The transceiver unit 101 is configured to broadcast the firmware data if the first timing duration is greater than a first period and no next first flag is received. The first flag is configured to indicate that the target slave device is entering a firmware upgrade state. The first flag is sent according to the first period when the target slave device enters the firmware upgrade state according to the first verification information after parsing the first verification information.
[0200] The transceiver unit 101 is configured to broadcast a sending end frame so that the target slave device can perform a firmware upgrade according to the firmware data. The ending frame is used to indicate that the sending of the firmware data is completed.
[0201] It should be understood that the execution of the above corresponding processes by each unit has been described in detail in the above method embodiment, and for the sake of brevity, it will not be repeated here.
[0202] In some examples, the processing unit 102 is specifically configured to divide the firmware data into N data frames, where N is a positive integer;
[0203] The transceiver unit 101 is specifically configured to broadcast and send the nth data frame, where n is a positive integer less than or equal to N;
[0204] The processing unit 102 is specifically configured to start timing each time a second flag is received. The transceiver unit 101 is specifically configured to, if the second timing duration is greater than the second period and the next second flag has not been received, broadcast and send the (n+1)th data frame until N data frames are sent. The second flag is used to indicate that the target slave device is performing firmware data erasure.
[0205] The second flag is sent according to the second cycle during the process of erasing the firmware data in the nth data frame into the memory when the target slave device correctly parses the nth data frame.
[0206] In some examples, the transceiver unit 101 is also used to poll the software version number in the target slave device after determining that the firmware upgrade of the target slave device is completed; when there is a non-upgraded slave device in the target slave device whose software version number is inconsistent with the software version number in the firmware data, the firmware upgrade method is repeatedly executed for the non-upgraded slave device until the software version numbers of all the target slave devices are consistent with the software version numbers in the firmware data.
[0207] In some examples, the first verification information is an MD5 value obtained by combining the model, hardware version number, software version number, and production date of the target slave device.
[0208] In some examples, the start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform a firmware upgrade if it is determined that the firmware data is correct.
[0209] Exemplarily, the present application also provides a firmware upgrade device.
[0210] Figure 8 A schematic diagram of the structure of a firmware upgrade device provided in one embodiment of the present application.
[0211] like Figure 8 As shown, the firmware upgrade device 200 can exist independently or be integrated into other devices, and can communicate with the master device mentioned above to implement the operations corresponding to the slave device in any of the above method embodiments.
[0212] Firmware upgrade device 200 may include a transceiver unit 201 and a processing unit 202. Transceiver unit 201 may also be referred to as a communication interface or communication unit. Processing unit 202 may read instructions and / or data from a storage unit to enable firmware upgrade device 200 to implement the aforementioned method embodiments. Transceiver unit 201 may implement the corresponding communication functions, and processing unit 202 may be used to process data.
[0213] Optionally, the firmware upgrading apparatus 200 may further include a storage unit, which may be used to store instructions and / or data.
[0214] The firmware upgrade device 200 can be used to perform the actions performed by the slave device in the above method embodiments. The firmware upgrade device 200 can be a slave device or a component that can be configured on a slave device. The transceiver unit 201 is used to perform the reception-related operations of the slave device in the above method embodiments, and the processing unit 202 is used to perform data processing.
[0215] Optionally, the transceiver unit 201 may include a sending unit and a receiving unit. The sending unit is configured to perform the sending operation in the aforementioned method embodiment. The receiving unit is configured to perform the receiving operation in the aforementioned method embodiment.
[0216] It should be noted that the firmware upgrade device 200 may include a sending unit but not a receiving unit. Alternatively, the firmware upgrade device 200 may include a receiving unit but not a sending unit. The specific implementation depends on whether the above solution executed by the firmware upgrade device 200 includes both sending and receiving actions.
[0217] As an example, the firmware upgrade device 200 is used to execute the above Figures 2 to 6 Actions performed by the slave device in the illustrated embodiment.
[0218] The firmware upgrade device 200 may include a transceiver unit 201 and a processing unit 202 .
[0219] The transceiver unit 201 is configured to receive and parse a start frame broadcasted by the master device, the start frame including first verification information, the first verification information being used to indicate device information of a target slave device, the target slave device being a slave device whose firmware is to be upgraded;
[0220] The processing unit 202 is configured to, after parsing the first verification information, enter a firmware upgrade state according to the first verification information, and send a first flag to the master device according to a first period during the process of entering the firmware upgrade state, the first flag being used to indicate that the target slave device is entering the firmware upgrade state;
[0221] The transceiver unit 201 is configured to receive firmware data broadcasted by the master device; wherein the firmware data is broadcasted by the master device when it starts timing each time it receives a first flag and when the first timing duration is greater than a first period and the next first flag is not received;
[0222] The transceiver unit 201 is configured to receive an end frame broadcast by the master device, where the end frame indicates that the firmware data has been sent.
[0223] The processing unit 202 is configured to perform firmware upgrade according to the firmware data.
[0224] In some examples, the transceiver unit 201 is specifically configured to receive and parse an nth data frame broadcasted by the master device, where the nth data frame is one of N data frames obtained by the master device segmenting the firmware data, where N is a positive integer greater than or equal to 1.
[0225] The processing unit 202 is specifically configured to erase and write the firmware data in the nth data frame to the memory when the nth data frame is correctly parsed. The transceiver unit 201 is specifically configured to send a second flag to the master device according to the second cycle during the erasing process, where the second flag is used to indicate that the target slave device is in the process of erasing the firmware data.
[0226] The transceiver unit 201 is specifically used to receive the n+1th data frame broadcast by the master device until N data frames are received; wherein, the n+1th data frame is broadcast by the master device when it starts timing each time it receives a second flag, and when the second timing time is longer than the second period and the next second flag is not received.
[0227] In some examples, when there are non-upgraded slave devices in the target slave devices whose software version numbers are inconsistent with the software version numbers in the firmware data, the transceiver unit 201 and the processing unit 202 repeatedly execute the firmware upgrade method until the software version numbers of all target slave devices are consistent with the software version numbers in the firmware data.
[0228] In some examples, the processing unit 202 is specifically configured to calculate third verification information based on the device information of the target slave device;
[0229] The processing unit 202 is specifically configured to enter a firmware upgrade state when the third verification information is consistent with the first verification information.
[0230] In some examples, the first verification information is an MD5 value obtained by combining the model, hardware version number, software version number, and production date of the target slave device.
[0231] In some examples, the start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform a firmware upgrade if it is determined that the firmware data is correct.
[0232] Figure 9 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. Figure 9 As shown, the electronic device may include: a first processor 301 and a memory 302, wherein the memory 302 stores a computer program, and when the first processor 301 executes the computer program, the firmware upgrade method in the above method embodiment is implemented.
[0233] The electronic device can be used to execute the various steps and / or processes corresponding to the corresponding electronic devices in the above method embodiments.
[0234] Figure 10 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. Figure 10 As shown, the electronic device may include: a second processor 401, and when the second processor 401 executes the computer executable program or instructions in the memory, the firmware upgrade method in the above method embodiment is implemented.
[0235] The electronic device can be used to execute the various steps and / or processes corresponding to the corresponding electronic devices in the above method embodiments.
[0236] The electronic device of the present application can be used to implement the technical solutions of the above method embodiments, and its implementation principles and technical effects are similar. The operations implemented by each module can be further referred to the relevant description of the method embodiments, and will not be repeated here. The modules here can also be replaced by components or circuits.
[0237] Exemplarily, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the firmware upgrade method in the above method embodiment can be implemented.
[0238] Illustratively, the present application further provides a program product, the program product including execution instructions stored in a computer-readable storage medium. At least one processor of an electronic device can read the execution instructions from the computer-readable storage medium, and at least one processor executes the execution instructions so that the electronic device implements the firmware upgrade method in the above method embodiment.
[0239] Exemplarily, the present application also provides a chip, which is connected to a memory, or a memory is integrated on the chip. When the software program stored in the memory is executed, the firmware upgrade method in the above method embodiment is implemented.
[0240] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0241] Those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments, combinations of features from different embodiments are intended to be within the scope of this application and to form different embodiments. For example, in the claims, any one of the claimed embodiments may be used in any combination.
[0242] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A firmware upgrade method, characterized in that: A method for a master device in a master-slave communication system comprising a master device and multiple slave devices includes: The master device broadcasts a start frame, the start frame including first verification information, the first verification information being used to indicate device information of a target slave device, the target slave device being a slave device whose firmware is to be upgraded; The master device starts timing each time it receives a first flag, and broadcasts firmware data when the first timing duration is longer than a first period and the next first flag is not received, wherein the first flag is used to indicate that the target slave device is entering a firmware upgrade state; wherein the first flag is sent according to the first period by the target slave device during the process of entering the firmware upgrade state according to the first verification information after parsing the first verification information; The master device broadcasts a sending end frame, so that the target slave device performs a firmware upgrade according to the firmware data, and the end frame is used to indicate that the firmware data has been sent; The broadcasting of firmware data includes: The master device divides the firmware data into N data frames, where N is a positive integer; The master device broadcasts and sends the nth data frame, where n is a positive integer less than or equal to N; The master device starts timing each time it receives a second flag, and when the second timing duration is greater than the second period and the next second flag is not received, broadcasts and sends the (n+1)th data frame until the N data frames are sent, wherein the second flag is used to indicate that the target slave device is performing firmware data erasing; The second flag is sent according to the second cycle during the process of erasing the firmware data in the nth data frame into the memory when the target slave device correctly parses the nth data frame.
2. The method according to claim 1, characterized in that The method further comprises: After determining that the firmware upgrade of the target slave device is complete, the master device polls the software version number in the target slave device; When there is a non-upgraded slave device among the target slave devices whose software version number is inconsistent with the software version number in the firmware data, the firmware upgrade method is repeatedly executed for the non-upgraded slave device until the software version numbers of all target slave devices are consistent with the software version numbers in the firmware data.
3. The method according to claim 1 or 2, characterized in that The first verification information is an MD5 value obtained by combining the model, hardware version number, software version number and production date of the target slave device.
4. The method according to claim 1 or 2, characterized in that The start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform firmware upgrade if it is determined that the firmware data is correct.
5. A firmware upgrade method, characterized in that: A slave device applied to a master-slave communication system, wherein the master-slave communication system includes a master device and multiple slave devices, and the method includes: The multiple slave devices receive and parse the start frame broadcast by the master device, the start frame including first verification information, the first verification information being used to indicate device information of a target slave device, the target slave device being a slave device whose firmware is to be upgraded; After parsing the first verification information, the target slave device enters a firmware upgrade state according to the first verification information, and sends a first flag to the master device according to a first period during the process of entering the firmware upgrade state, wherein the first flag is used to indicate that the target slave device is entering the firmware upgrade state; The target slave device receives the firmware data broadcasted by the master device; wherein the firmware data is broadcasted by the master device when the master device starts timing each time it receives a first flag, and when the first timing duration is greater than a first period and the next first flag is not received; The target slave device receives the end frame broadcasted by the master device, where the end frame is used to indicate that the firmware data has been sent; The target slave device performs firmware upgrade according to the firmware data; The receiving of the firmware data sent by the master device includes: The target slave device receives and parses the nth data frame broadcasted by the master device, where the nth data frame is one of N data frames obtained by the master device dividing the firmware data, where N is a positive integer greater than or equal to 1; When the target slave device correctly parses the nth data frame, the target slave device erases the firmware data in the nth data frame to the memory, and sends a second flag to the master device according to a second cycle during the erasing process, wherein the second flag is used to indicate that the target slave device is in the process of erasing the firmware data; The target slave device receives the n+1th data frame broadcast by the master device until the N data frames are received; wherein, the n+1th data frame is broadcast by the master device when it starts timing each time it receives a second flag, and when the second timing time is longer than the second period and the next second flag is still not received.
6. The method according to claim 5, characterized in that The method further comprises: When there is an unupgraded slave device among the target slave devices whose software version number is inconsistent with the software version number in the firmware data, the unupgraded slave device repeatedly executes the firmware upgrade method until the software version numbers of all target slave devices are consistent with the software version numbers in the firmware data.
7. The method according to claim 5, characterized in that The step of entering the firmware upgrade state according to the first verification information includes: The target slave device calculates third verification information according to the device information of the target slave device; The target slave device enters a firmware upgrade state when the third verification information is consistent with the first verification information.
8. The method according to any one of claims 5 to 7, characterized in that The first verification information is an MD5 value obtained by combining the model, hardware version number, software version number and production date of the target slave device.
9. The method according to any one of claims 5 to 7, characterized in that The start frame also includes second verification information, which is an MD5 value obtained based on the firmware data. The second verification information is used to verify the firmware data so that the target slave device can determine whether the firmware data is correct based on the second verification information and the firmware data after receiving the end frame, and restart and perform firmware upgrade if it is determined that the firmware data is correct.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer-executable program or instruction, and the computer-executable program or instruction is configured to execute the method according to any one of claims 1 to 4, or 5 to 9.