Firmware upgrading method and device, electronic equipment and computer readable storage medium

By segmenting the firmware upgrade files and broadcasting multiple rounds, the problems of success rate and low efficiency of a large number of equipment firmware upgrades are solved, and efficient firmware upgrades are achieved in a low-cost communication environment.

CN120104159APending Publication Date: 2025-06-06SUZHOU HEGUANG TONGYAO INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, when a large number of devices are upgraded firmware, the upgrade success rate and efficiency are low, especially in low-cost communication solutions that are susceptible to external interference.

Method used

By obtaining and parsing the firmware upgrade file, obtaining verification information, dividing it into multiple parts to generate multiple upgrade file packages, and broadcasting the verification information and upgrade file packages to all slave devices until all devices complete the firmware upgrade.

Benefits of technology

In the presence of communication interference, multiple rounds of broadcast ensure that all slave devices complete firmware upgrades, improving the upgrade success rate and efficiency without human intervention and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104159A_ABST
    Figure CN120104159A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a firmware upgrading method and device, electronic equipment and a computer readable storage medium, and relates to the field of firmware upgrading. The main device obtains and analyzes the firmware upgrading file to obtain verification information; segmenting the firmware upgrading file into a plurality of parts, and respectively generating a plurality of upgrading file packages; a round of broadcasting is carried out, and the verification information and all the upgrading file packages are broadcast and issued to all the slave devices in sequence; and judging whether the slave equipment does not finish firmware upgrading or not, and if so, carrying out the next round of broadcasting until all the slave equipment finish firmware upgrading. Therefore, in a scene of performing firmware upgrading on a large number of devices, all slave devices can be ensured to complete firmware upgrading through a multi-round broadcast mode even if communication interference exists, and the whole upgrading process does not need manual intervention and maintenance, so that the upgrading efficiency is improved while the upgrading success rate is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of firmware upgrade, and in particular to a firmware upgrade method, device, electronic device and computer-readable storage medium. Background Art

[0002] With the rapid development of distributed photovoltaic power stations, the use of photovoltaic module intelligent shutdown devices, photovoltaic module intelligent optimizers and other devices in power stations is becoming more and more widespread. Usually, each or two photovoltaic panels are equipped with one of the above devices, resulting in thousands of devices in a power station. How to efficiently upgrade and maintain these devices is undoubtedly a huge challenge.

[0003] In actual applications, photovoltaic power stations often use low-cost communication solutions such as power line carrier communication based on cost and construction considerations. This type of communication method is easily affected by external interference, which affects the communication quality, resulting in low upgrade success rate and efficiency when upgrading the firmware of a large number of devices. Summary of the invention

[0004] In view of this, an object of the present invention is to provide a firmware upgrade method, device, electronic device and computer-readable storage medium to solve the problems of low upgrade success rate and upgrade efficiency when performing firmware upgrades on a large number of devices in the prior art.

[0005] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0006] In a first aspect, the present invention provides a firmware upgrade method, which is applied to a master device, wherein the master device is communicatively connected with a plurality of slave devices; the method comprises:

[0007] Obtain and parse the firmware upgrade file to obtain verification information;

[0008] Dividing the firmware upgrade file into multiple parts, and generating multiple upgrade file packages respectively;

[0009] Perform a round of broadcasting to broadcast the verification information and each upgrade file package to all slave devices in turn;

[0010] Determine whether there are slave devices that have not completed the firmware upgrade. If so, perform the next round of broadcasting until all slave devices have completed the firmware upgrade.

[0011] In an optional implementation manner, broadcasting the verification information and each of the upgrade file packages to all slave devices in sequence includes:

[0012] Generate broadcast messages corresponding to the verification information and broadcast messages corresponding to each of the upgrade file packages in sequence, and send the generated broadcast messages to all slave devices.

[0013] In an optional implementation manner, the broadcast message further includes at least one of heartbeat information and data acquisition information; the data acquisition information is used to indicate the operation data of the acquisition target slave device.

[0014] In an optional implementation manner, the determining whether there is any slave device that has not completed the firmware upgrade includes:

[0015] Obtaining the current firmware version number of each of the slave devices according to the data acquisition response message returned by each of the slave devices; the data acquisition response message carries the current firmware version number of the slave device;

[0016] If the current firmware version number of the slave device is different from the firmware version number corresponding to the firmware upgrade file, it is determined that the firmware upgrade of the slave device has not been completed.

[0017] In an optional implementation manner, dividing the firmware upgrade file into multiple parts and generating multiple upgrade file packages respectively includes:

[0018] The firmware upgrade file is divided into multiple upgrade file packages according to a fixed byte length.

[0019] In a second aspect, the present invention provides a firmware upgrade method, which is applied to a slave device, wherein the slave device is communicatively connected to a master device; the method comprises:

[0020] Receiving the verification information and each upgrade file package sequentially issued by the master device in the current round of broadcasting, and writing each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device by segmenting the acquired firmware upgrade file;

[0021] After receiving the last upgrade file package sent by the master device in the current round of broadcasting, judging whether the complete firmware upgrade file is received according to the verification information;

[0022] If the complete firmware upgrade file is received, the upgrade process is triggered; if the complete firmware upgrade file is not received, wait to receive the upgrade file package sent by the master device in the next round of broadcasting until the complete firmware upgrade file is received.

[0023] In an optional implementation manner, writing each of the upgrade file packages into a predetermined storage location includes:

[0024] Determine the offset position of each upgrade file package in the firmware upgrade file according to the frame sequence number of the message in which each upgrade file package is located;

[0025] Each of the upgrade file packages is written into a corresponding address in the predetermined storage location according to the offset position.

[0026] In an optional implementation, the verification information includes a verification code and a firmware version number, and the method further includes:

[0027] After receiving the verification code and the firmware version number, setting the system upgrade state to a receiving state or a non-receiving state according to the firmware version number; the receiving state indicates that an upgrade is required, and the non-receiving state indicates that an upgrade is not required;

[0028] Determine whether to perform an erasing operation on the predetermined storage location according to the firmware version number and the verification code.

[0029] In an optional implementation manner, writing each of the upgrade file packages into a predetermined storage location includes:

[0030] When the system upgrade state is the receiving state, each upgrade file package is written into a predetermined storage location.

[0031] In an optional implementation manner, after receiving the verification information and each upgrade file package sequentially sent by the master device in the current round of broadcasting, the method further includes:

[0032] When the system upgrade state is the non-receiving state, each received upgrade file package is discarded.

[0033] In an optional implementation manner, setting the system upgrade state to a receiving state or a non-receiving state according to the firmware version number includes:

[0034] If the firmware version number is consistent with the current firmware version number of the slave device, the system upgrade state is set to a non-receiving state; if the firmware version number is inconsistent with the current firmware version number of the slave device, the system upgrade state is set to a receiving state.

[0035] In an optional implementation manner, determining whether to perform an erase operation on the predetermined storage location according to the firmware version number and the verification code includes:

[0036] If the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is inconsistent with the verification code sent by the master device in the previous round of broadcasting, then the currently received verification code is saved, and an erasing operation is performed on the predetermined storage location;

[0037] If the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is consistent with the verification code sent by the master device in the previous round of broadcasting, the erasing operation is not performed on the predetermined storage location.

[0038] In an optional embodiment, the method further comprises:

[0039] After each time the upgrade file package is written, the written upgrade file package is read out from the predetermined storage location;

[0040] If the read upgrade file package is inconsistent with the original upgrade file package, the minimum erasure area where the written upgrade file package is located is erased.

[0041] In a third aspect, the present invention provides a firmware upgrade device, which is applied to a master device, wherein the master device is communicatively connected with a plurality of slave devices; the device comprises:

[0042] A parsing module is used to obtain and parse the firmware upgrade file to obtain verification information;

[0043] A segmentation module, used to segment the firmware upgrade file into multiple parts, respectively generating multiple upgrade file packages;

[0044] The sending module is used to perform a round of broadcasting, broadcasting the verification information and each upgrade file package to all slave devices in turn; judging whether there is a slave device that has not completed the firmware upgrade, and if so, performing the next round of broadcasting until all slave devices have completed the firmware upgrade.

[0045] In a fourth aspect, the present invention provides a firmware upgrade device, which is applied to a slave device, wherein the slave device is communicatively connected to a master device; the device comprises:

[0046] A receiving module, used to receive the verification information and each upgrade file package sent in sequence by the master device in the current round of broadcasting, and write each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device after segmenting the acquired firmware upgrade file;

[0047] A judgment module, configured to judge whether a complete firmware upgrade file is received according to the verification information after receiving the last upgrade file package sent by the master device in the current round of broadcasting;

[0048] The upgrade module is used to trigger the upgrade process if the complete firmware upgrade file is received; if the complete firmware upgrade file is not received, wait to receive the upgrade file package sent by the master device in the next round of broadcasting until the complete firmware upgrade file is received.

[0049] In a fifth aspect, the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of a firmware upgrade method as described in any one of the aforementioned embodiments.

[0050] In a sixth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the firmware upgrade method as described in any one of the aforementioned embodiments are implemented.

[0051] The firmware upgrade method, device, electronic device and computer-readable storage medium provided by the embodiments of the present invention are as follows: the master device obtains and parses the firmware upgrade file to obtain verification information; divides the firmware upgrade file into multiple parts, and generates multiple upgrade file packages respectively; performs a round of broadcasting, and broadcasts the verification information and each upgrade file package to all slave devices in turn; determines whether there are slave devices that have not completed the firmware upgrade, and if so, performs the next round of broadcasting until all slave devices have completed the firmware upgrade. In this way, in the scenario of firmware upgrades for a large number of slave devices, even if there is communication interference, multiple rounds of broadcasting can be used to ensure that all slave devices complete the firmware upgrade, and the entire upgrade process does not require human intervention and maintenance, which improves the upgrade success rate while also improving the upgrade efficiency.

[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0054] Figure 1 A schematic diagram of an application scenario applicable to an embodiment of the present invention is shown;

[0055] Figure 2 A schematic diagram of a process flow of a firmware upgrade method applied to a master device provided by an embodiment of the present invention is shown;

[0056] Figure 3 A schematic diagram of a flow chart of a firmware upgrade method applied to a slave device provided by an embodiment of the present invention is shown;

[0057] Figure 4A functional module diagram of a firmware upgrade device applied to a main device provided by an embodiment of the present invention is shown;

[0058] Figure 5 A functional module diagram of a firmware upgrade device applied to a slave device provided by an embodiment of the present invention is shown;

[0059] Figure 6 A block diagram of an electronic device provided by an embodiment of the present invention is shown.

[0060] Icon: 100 - cloud platform; 200 - master device; 300 - slave device; 110 - memory; 120 - processor; 130 - communication module; 610 - parsing module; 620 - segmentation module; 630 - sending module; 710 - receiving module; 720 - judgment module; 730 - upgrade module. DETAILED DESCRIPTION

[0061] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0062] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.

[0063] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0064] Please refer to Figure 1 , is a schematic diagram of an application scenario applicable to an embodiment of the present invention. Figure 1As shown, the cloud platform 100 is connected to multiple master devices 200, and each master device 200 is connected to multiple slave devices 300. The master device 200 may be a data concentrator, and the slave device 300 may be a photovoltaic device such as a photovoltaic module intelligent switch, a photovoltaic module intelligent optimizer, etc.

[0065] In actual applications, based on cost, construction and other considerations, photovoltaic power stations often use low-cost communication solutions such as power line carrier communication. This type of communication method is easily affected by external interference, which affects the communication quality. When upgrading the firmware of a large number of slave devices 300, there are problems with low upgrade success rate and upgrade efficiency.

[0066] Based on this, an embodiment of the present invention provides a firmware upgrade method, device, electronic device and computer-readable storage medium, which divides the firmware upgrade file and adopts multiple rounds of broadcasting to ensure that all slave devices 300 complete the firmware upgrade. The entire upgrade process does not require human intervention and maintenance, which improves the upgrade success rate while also improving the upgrade efficiency.

[0067] Please refer to Figure 2 , is a flowchart of a firmware upgrade method for a master device 200 provided in an embodiment of the present invention. It should be noted that the firmware upgrade method of the present invention is not based on Figure 2 It should be understood that in other embodiments, the order of some steps in the firmware upgrade method of the present invention can be interchanged according to actual needs, or some steps can be omitted or deleted. Figure 2 The specific process shown is described in detail.

[0068] Step S201, obtain and parse the firmware upgrade file to obtain verification information.

[0069] In this embodiment, a firmware upgrade instruction can be initiated through the cloud platform 100. After receiving the firmware upgrade instruction sent by the cloud platform 100, the main device 200 obtains the firmware upgrade file from the cloud platform 100. The main device 200 parses the firmware upgrade file to obtain verification information such as a verification code and a firmware version number.

[0070] Step S202, dividing the firmware upgrade file into multiple parts, and generating multiple upgrade file packages respectively.

[0071] In this embodiment, the main device 200 divides the acquired firmware upgrade file into multiple upgrade file packages, which can effectively reduce the amount of data transmitted in a single time, reduce the transmission error rate caused by the large amount of data, and thus reduce the impact of external interference on the firmware upgrade.

[0072] Step S203: perform a round of broadcasting to broadcast the verification information and each upgrade file package to all slave devices in turn.

[0073] In this embodiment, after the master device 200 obtains the verification information and multiple upgrade file packages corresponding to the firmware upgrade file, the verification information and each upgrade file package are broadcasted in a certain order to all slave devices 300. By sending data to multiple slave devices 300 at the same time by broadcasting, compared with upgrading each device one by one, the total time required for upgrading can be effectively reduced and the upgrade efficiency can be improved.

[0074] Step S204, determining whether there is a slave device that has not completed the firmware upgrade, if so, performing the next round of broadcasting until all slave devices have completed the firmware upgrade.

[0075] In this embodiment, after each round of broadcasting, the master device 200 will determine whether there are slave devices 300 that have not completed the firmware upgrade. If yes, the next round of broadcasting is performed to ensure that all devices can receive the complete firmware upgrade file and finally complete the firmware upgrade. This mechanism of broadcasting multiple rounds until all slave devices 300 complete the firmware upgrade ensures that all slave devices 300 can complete the firmware upgrade even in the case of severe communication interference, thereby improving the upgrade success rate.

[0076] It can be seen that in the firmware upgrade method provided by the embodiment of the present invention, the master device obtains and parses the firmware upgrade file to obtain verification information; divides the firmware upgrade file into multiple parts, and generates multiple upgrade file packages respectively; performs a round of broadcasting, and broadcasts the verification information and each upgrade file package to all slave devices in turn; determines whether there are slave devices that have not completed the firmware upgrade, and if so, performs the next round of broadcasting until all slave devices have completed the firmware upgrade. In this way, in the scenario of firmware upgrades for a large number of slave devices, even if there is communication interference, multiple rounds of broadcasting can be used to ensure that all slave devices complete the firmware upgrade, and the entire upgrade process does not require human intervention and maintenance, which improves the upgrade success rate while also improving the upgrade efficiency.

[0077] In one implementation, the above step S202 may specifically include: dividing the firmware upgrade file into multiple upgrade file packages according to a fixed byte length.

[0078] In this embodiment, the main device 200 can divide the firmware upgrade file into m upgrade file packages according to the size of the firmware upgrade file and a fixed byte length, wherein the length of the mth upgrade file package is determined according to the remaining size of the firmware upgrade file.

[0079] In this embodiment, the fixed byte length may be a byte length agreed upon in advance by the master device 200 and the slave device 300, such as 1MB. The fixed byte length may also be set by the master device 200 according to the actual size of the firmware upgrade file. For example, when the firmware upgrade file is relatively large, the firmware upgrade file may be divided according to a byte length of 2MB or 4MB; in this case, when the master device 200 broadcasts the verification information, it is also necessary to send the re-determined byte length to each slave device 300, so that the slave device 300 can determine the storage address of the upgrade file package after receiving the divided upgrade file package later.

[0080] In one embodiment, the master device 200 may send the verification information and each upgrade file package in the form of a broadcast message. Specifically, in the above step S203, the verification information and each upgrade file package are broadcasted and sent to all slave devices 300 in sequence, which may include: sequentially generating a broadcast message corresponding to the verification information and a broadcast message corresponding to each upgrade file package, and sending the generated broadcast message to all slave devices 300.

[0081] For example, the master device 200 divides the firmware upgrade file into m upgrade file packages, generates the 0th frame broadcast message (frame number is 0) based on the verification information, and generates the 1st to mth frames broadcast messages (frame numbers are 1 to m) based on the m upgrade file packages. The master device 200 first sends the 0th frame broadcast message to all slave devices 300, and then sends the 1st to mth frames broadcast messages to all slave devices 300 in sequence.

[0082] During the normal operation of the master device 200, on the one hand, it is necessary to periodically broadcast heartbeat messages to ensure that all slave devices 300 operate normally; on the other hand, it will also periodically send data acquisition messages to read the operating data of each slave device 300. In the prior art, firmware upgrade messages, heartbeat messages, and data acquisition messages are sent separately. For example, if you want the slave device 300 to perform firmware upgrade and data acquisition at the same time, you need to send firmware upgrade messages and data acquisition messages separately. When the firmware of the slave device 300 is upgraded, the normal operation of the slave device 300 will be affected to a certain extent. In order not to affect the normal operation of the slave device during the firmware upgrade process and to improve the communication efficiency at the same time, the embodiment of the present invention integrates the data acquisition message, the heartbeat message, and the firmware upgrade message into a broadcast message and sends it to the slave device 300, so that the slave device 300 can perform multiple actions such as firmware upgrade and data acquisition after receiving the broadcast message.

[0083] That is to say, the broadcast message generated by the master device 200 may also include at least one of heartbeat information and data collection information; the data collection information is used to indicate the operation data of the target slave device to be collected.

[0084] Specifically, a broadcast message template can be set in advance in the master device 200, and the file data related to the firmware upgrade (such as verification information and the upgrade file package obtained by segmentation), heartbeat information, and data acquisition information can be filled in the template. In this way, during the firmware upgrade process, all slave devices 300 can normally receive the heartbeat message to maintain normal operation, and can also receive the file data of the firmware upgrade; and the target slave device that matches the data acquisition information can also send a data acquisition response message to the master device 200, so the master device 200 can still normally collect the operating data of all slave devices 300.

[0085] It can be seen that the embodiment of the present invention integrates the data acquisition message, heartbeat message and firmware upgrade message into one broadcast message, which not only ensures the normal operation of the slave device 300, but also does not affect the firmware upgrade process, and the firmware upgrade process can continue. In an environment with relatively large interference such as a photovoltaic power station, the number of messages is reduced, the number of communication channels occupied is saved, and the upgrade success rate is improved. In the prior art, since the three messages are sent separately, for example, if you want the slave device 300 to perform firmware upgrades and data acquisition at the same time, you need to send two messages; however, the embodiment of the present invention can be integrated into one message and sent to the slave device 300. After receiving the message, the slave device 300 can perform the two actions of firmware upgrade and data acquisition.

[0086] Since all slave devices 300 can normally receive data acquisition information and return corresponding data acquisition response messages to the master device 200 during the firmware upgrade process, the current firmware version number of the slave device 300 can be added to the data acquisition response message returned by the slave device 300, so that the master device 200 can continuously refresh and collect the firmware version numbers of all slave devices 300 during the normal data acquisition process, and then determine whether all slave devices 300 have completed the firmware upgrade. Based on this, the above step S204 determines whether there are slave devices 300 that have not completed the firmware upgrade, which may specifically include: obtaining the current firmware version number of each slave device according to the data acquisition response message returned by each slave device; the data acquisition response message carries the current firmware version number of the slave device; if the current firmware version number of the slave device is different from the firmware version number corresponding to the firmware upgrade file, it is determined that the slave device has not completed the firmware upgrade.

[0087] For example, a firmware version number field is added to the data acquisition response message from the slave device 300 to the master device 200, and the master device 200 can continuously refresh and collect the firmware version numbers of all slave devices 300 during the normal data acquisition process. During the refresh and collection process, if the firmware version number of at least one slave device 300 is different from the firmware version number corresponding to the firmware upgrade file, it indicates that there are still slave devices 300 whose firmware version numbers are old versions and the firmware upgrade has not been completed. At this time, the master device 200 will repeat the firmware upgrade process until the firmware version numbers of all slave devices 300 have become the latest versions, and the master device 200 ends the firmware upgrade process.

[0088] In actual applications, the master device 200 can also count the upgrade success rate according to the judgment result of whether each slave device 300 has completed the firmware upgrade to determine the upgrade progress. In addition, the master device 200 can also report the upgrade success rate to the cloud platform 100 according to the set period; after all slave devices 300 have completed the firmware upgrade, the master device 200 can also actively report the upgrade completion information to the cloud platform 100. In this way, the manual intervention time can be effectively reduced and the maintenance cost can be saved.

[0089] Please refer to Figure 3 , is a flowchart of a firmware upgrade method for a slave device 300 provided in an embodiment of the present invention. It should be noted that the firmware upgrade method of the present invention is not based on Figure 3 It should be understood that in other embodiments, the order of some steps in the firmware upgrade method of the present invention can be interchanged according to actual needs, or some steps can be omitted or deleted. Figure 3 The specific process shown is described in detail.

[0090] Step S301, receiving the verification information and each upgrade file package sequentially sent by the master device in the current round of broadcasting, and writing each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device by segmenting the acquired firmware upgrade file.

[0091] In this embodiment, the master device 200 can obtain the firmware upgrade file from the cloud platform 100, and parse the firmware upgrade file to obtain verification information such as the verification code and the firmware version number; the firmware upgrade file is divided into multiple upgrade file packages according to a fixed byte length. In each round of broadcasting, the master device 200 will broadcast the verification information and each upgrade file package to all slave devices 300 in turn, and the slave device 300 will write the received upgrade file package into a predetermined storage location.

[0092] The predetermined storage location may be a portion of the storage area divided in the flash memory of the slave device 300 for storing a new firmware upgrade file so as to perform a firmware upgrade on the slave device 300 .

[0093] Step S302: after receiving the last upgrade file package sent by the master device in the current round of broadcasting, it is determined whether a complete firmware upgrade file is received according to the verification information.

[0094] For example, the master device 200 divides the firmware upgrade file into m upgrade file packages. In the current round of broadcasting, the master device 200 will broadcast the verification information and the m upgrade file packages to all slave devices 300 in turn. After the slave device 300 receives the mth upgrade file package and writes it into the predetermined storage location, the file data stored in the entire predetermined storage location is verified. When the calculated verification code is consistent with the verification code in the verification information received by the slave device 300, it is determined that the slave device 300 has received the complete firmware upgrade file; when the calculated verification code is inconsistent with the verification code in the verification information received by the slave device 300, it is determined that the slave device 300 has not received the complete firmware upgrade file and packet loss has occurred.

[0095] Step S303, if a complete firmware upgrade file is received, the upgrade process is triggered; if a complete firmware upgrade file is not received, wait for the upgrade file package sent by the master device in the next round of broadcasting until a complete firmware upgrade file is received.

[0096] In this embodiment, when the slave device 300 determines that a complete firmware upgrade file has been received, the upgrade process is triggered to complete the firmware upgrade; when the slave device 300 determines that a complete firmware upgrade file has not been received, it is necessary to wait for the upgrade file package sent by the master device 200 in the next round of broadcasting to supplement the lost upgrade file package.

[0097] It can be seen that through multiple rounds of broadcasts from the master device, the slave device can continuously supplement the lost upgrade file packages, so that each slave device can gradually accumulate and splice the firmware upgrade file in the case of packet loss, ensuring that all slave devices can eventually receive the complete firmware upgrade file. In scenarios with relatively low communication quality, multiple rounds of broadcasts can also ensure that all slave devices can be successfully upgraded, improving the upgrade success rate.

[0098] In one embodiment, writing each upgrade file package to a predetermined storage location in step S301 may specifically include: determining the offset position of each upgrade file package in the firmware upgrade file according to the frame sequence number of the message containing each upgrade file package; and writing each upgrade file package to a corresponding address in the predetermined storage location according to the offset position.

[0099] In this embodiment, the master device 200 sends the verification information and each upgrade file package in the form of a broadcast message, wherein the broadcast message corresponding to the verification information is the 0th frame broadcast message, and the frame number is 0; the broadcast message corresponding to each upgrade file package is the 1st to mth frame broadcast message, and the frame numbers are 1 to m. Therefore, when the slave device 300 receives the 1st to mth frame broadcast message, it can determine the offset position of the upgrade file package in the firmware upgrade file according to the frame number of the message, and then write each upgrade file package into the corresponding address in the predetermined storage location according to the offset position.

[0100] For example, the slave device 300 can divide the storage location into multiple storage blocks according to the byte length agreed in advance with the master device 200 or the byte length actually set by the master device 200, and write the upgrade file package in the broadcast message with a frame number of 1 into the first storage block, and write the upgrade file package in the broadcast message with a frame number of 2 into the second storage block, and so on, so as to write each upgrade file package into the corresponding storage block in the order of the frame number.

[0101] In actual applications, data writing errors may occur due to external interference, voltage anomalies, etc. Based on this, the embodiment of the present invention adopts a mechanism of reading back after writing data, that is, after each upgrade file package is written, the written upgrade file package is read from a predetermined storage location; if the read upgrade file package is inconsistent with the original upgrade file package, the minimum erasable area where the written upgrade file package is located is erased.

[0102] In this embodiment, the minimum erase area can be a sector or a storage block. After writing the data, the slave device 300 reads back and compares it with the original upgrade file package. If an inconsistency is found, the sector or storage block where the upgrade file package is located is erased. In this way, the abnormal situation of data writing errors can be effectively handled. The erased area can continue to be written after receiving the upgrade file package issued in the next round of broadcasting by the master device 200, thereby supplementing the erased data.

[0103] In one embodiment, the 0th frame broadcast message sent by the master device 200 includes verification information, and the verification information includes a verification code and a firmware version number. After receiving the verification code and the firmware version number, the slave device 300 sets the system upgrade state to a receiving state or a non-receiving state according to the firmware version number; the receiving state indicates that an upgrade is required, and the non-receiving state indicates that an upgrade is not required; and whether to perform an erase operation on the predetermined storage location is determined according to the firmware version number and the verification code.

[0104] In this embodiment, after receiving the 0th frame broadcast message from device 300, the firmware version number and the check code carried in the 0th frame broadcast message will be judged, and the firmware version number carried in the 0th frame broadcast message will be compared with the current firmware version number of the slave device 300. It can be determined whether the slave device 300 needs a firmware upgrade. If a firmware upgrade is required, the system upgrade status of the slave device 300 is set to a receiving status; if a firmware upgrade is not required, the system upgrade status of the slave device 300 is set to a non-receiving status.

[0105] According to the characteristics of the flash memory, data must be erased before being written, and when writing to the flash memory, the data bit can only be changed from 1 to 0, not vice versa. Therefore, the slave device 300 needs to determine whether the first round of broadcasting of the master device 200 has just started, that is, whether the new firmware upgrade file is recognized for the first time, based on the firmware version number and the check code, and then determine whether it is necessary to perform an erase operation on the predetermined storage location.

[0106] In one embodiment, the above-mentioned setting of the system upgrade status to a receiving status or a non-receiving status according to the firmware version number may specifically include: if the firmware version number is consistent with the current firmware version number of the slave device, setting the system upgrade status to a non-receiving status; if the firmware version number is inconsistent with the current firmware version number of the slave device, setting the system upgrade status to a receiving status.

[0107] In this embodiment, the slave device 300 compares the received firmware version number with the current firmware version number of the slave device 300. If they are consistent, it indicates that the slave device 300 has been upgraded to the latest version and does not need to be upgraded further, and the system upgrade status is set to the non-receiving status; if they are inconsistent, it indicates that there is a new version of the firmware upgrade file, and the system upgrade status is set to the receiving status.

[0108] In one implementation, writing each upgrade file package into a predetermined storage location in the above step S301 may specifically include: when the system upgrade state is a receiving state, writing each upgrade file package into the predetermined storage location.

[0109] That is to say, after receiving the 1st to mth frame broadcast message, the slave device 300 will determine whether the system upgrade status is the receiving status. If it is the receiving status, it will determine the offset position of the upgrade file package in the firmware upgrade file based on the frame number of the message where the upgrade file package is located; and write the upgrade file package to the corresponding address in the predetermined storage location based on the offset position.

[0110] In addition, since when the system upgrade status is the non-receiving status, it indicates that the slave device 300 does not need firmware upgrade, the slave device 300 discards each received upgrade file package when the system upgrade status is the non-receiving status.

[0111] In one embodiment, the above steps determine whether to perform an erase operation on the predetermined storage location based on the firmware version number and the verification code, and specifically may include: if the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is inconsistent with the verification code sent by the master device in the previous round of broadcasting, then save the currently received verification code and perform an erase operation on the predetermined storage location; if the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is consistent with the verification code sent by the master device in the previous round of broadcasting, then do not perform an erase operation on the predetermined storage location.

[0112] That is to say, when the received firmware version number is inconsistent with the current firmware version number of the slave device 300, the slave device 300 will determine whether the received verification code is consistent with the verification code sent by the master device 200 in the previous round of broadcasting. If they are inconsistent, it means that the first round of broadcasting of the master device 200 has just started, and the slave device 300 has recognized the new firmware upgrade file for the first time. It is necessary to save the received verification code and perform an erase operation on the predetermined storage location. If they are consistent, it means that the slave device 300 has received the same file before, and the erase operation is not performed on the predetermined storage location, so that the lost file data can be supplemented based on the data stored in the predetermined storage location in the future.

[0113] It can be seen that in the embodiment of the present invention, when the slave device first recognizes a new firmware upgrade file, an erase operation will be performed; in the subsequent upgrade file package reception process, it is only necessary to calculate the offset position of the upgrade file package according to the frame sequence number and write it to the corresponding position in the predetermined storage position. Even if some upgrade file packages are lost in the middle, the corresponding position can still be written after the file data is received in the next round to supplement the file data lost in the previous round. For the file data that was not lost in the previous round, the slave device will also perform a write operation after receiving it in the next round, but according to the characteristics of the flash memory, the file data is still the original data and will not affect the firmware upgrade.

[0114] In order to execute the corresponding steps in the above embodiment and various possible methods, an implementation method of a firmware upgrade apparatus applied to the master device 200 and the slave device 300 is respectively given below.

[0115] Please refer to Figure 4 , a functional module diagram of a firmware upgrade device applied to a main device 200 according to an embodiment of the present invention is provided. It should be noted that the basic principle and technical effects of the firmware upgrade device provided in this embodiment are the same as those of the above embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment. The firmware upgrade device includes: a parsing module 610, a segmentation module 620 and a sending module 630.

[0116] The parsing module 610 is used to obtain and parse the firmware upgrade file to obtain verification information.

[0117] It can be understood that the parsing module 610 can execute the above step S201.

[0118] The segmentation module 620 is used to segment the firmware upgrade file into multiple parts and generate multiple upgrade file packages respectively.

[0119] It can be understood that the segmentation module 620 can execute the above step S202.

[0120] The sending module 630 is used to perform a round of broadcasting, broadcasting the verification information and each upgrade file package to all slave devices 300 in turn; judging whether there is any slave device 300 that has not completed the firmware upgrade, if so, performing the next round of broadcasting until all slave devices 300 have completed the firmware upgrade.

[0121] It can be understood that the sending module 630 can execute the above step S203.

[0122] Optionally, the sending module 630 is specifically configured to sequentially generate broadcast messages corresponding to the verification information and broadcast messages corresponding to each upgrade file package, and send the generated broadcast messages to all slave devices 300 .

[0123] Optionally, the broadcast message also includes at least one of heartbeat information and data collection information; the data collection information is used to indicate the collection of operating data of the target slave device.

[0124] Optionally, the above-mentioned sending module 630 is also specifically used to obtain the current firmware version number of each slave device 300 based on the data acquisition response message returned by each slave device 300; the data acquisition response message carries the current firmware version number of the slave device 300; if the current firmware version number of the slave device 300 is different from the firmware version number corresponding to the firmware upgrade file, it is determined that the slave device 300 has not completed the firmware upgrade.

[0125] Optionally, the segmentation module 620 is specifically configured to segment the firmware upgrade file into multiple upgrade file packages according to a fixed byte length.

[0126] Please refer to Figure 5 , a functional module diagram of a firmware upgrade device applied to a slave device 300 is provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the firmware upgrade device provided in this embodiment are the same as those in the above embodiment. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above embodiment. The firmware upgrade device includes: a receiving module 710, a judging module 720 and an upgrading module 730.

[0127] The receiving module 710 is used to receive the verification information and each upgrade file package sequentially sent by the master device 200 in the current round of broadcasting, and write each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device 200 by segmenting the acquired firmware upgrade file.

[0128] It can be understood that the receiving module 710 can execute the above step S301.

[0129] The judgment module 720 is used to judge whether a complete firmware upgrade file is received according to the verification information after receiving the last upgrade file package sent by the master device 200 in the current round of broadcasting.

[0130] It can be understood that the determination module 720 can execute the above step S302.

[0131] The upgrade module 730 is used to trigger the upgrade process if a complete firmware upgrade file is received; if a complete firmware upgrade file is not received, wait to receive the upgrade file package sent by the main device 200 in the next round of broadcasting until a complete firmware upgrade file is received.

[0132] It can be understood that the upgrade module 730 can execute the above step S303.

[0133] Optionally, the receiving module 710 is specifically used to determine the offset position of each upgrade file package in the firmware upgrade file according to the frame sequence number of the message containing each upgrade file package; and write each upgrade file package to a corresponding address in a predetermined storage location according to the offset position.

[0134] Optionally, the verification information includes a verification code and a firmware version number. The firmware upgrade device may further include a processing module, which is used to set the system upgrade status to a receiving status or a non-receiving status according to the firmware version number after receiving the verification code and the firmware version number; the receiving status indicates that an upgrade is required, and the non-receiving status indicates that an upgrade is not required; determine whether to perform an erase operation on the predetermined storage location based on the firmware version number and the verification code.

[0135] Optionally, the receiving module 710 is specifically configured to write each upgrade file package into a predetermined storage location when the system upgrade state is a receiving state.

[0136] Optionally, the receiving module 710 is further configured to discard each received upgrade file package after receiving the verification information and each upgrade file package sequentially sent by the master device 200 in the current round of broadcasting, if the system upgrade state is a non-receiving state.

[0137] Optionally, the processing module is specifically used to set the system upgrade status to a non-receiving status if the firmware version number is consistent with the current firmware version number of the slave device 300; if the firmware version number is inconsistent with the current firmware version number of the slave device 300, set the system upgrade status to a receiving status.

[0138] Optionally, the processing module is also specifically used to save the currently received verification code and perform an erase operation on the predetermined storage location if the firmware version number is inconsistent with the current firmware version number of the slave device 300, and the verification code is inconsistent with the verification code sent by the master device 200 in the previous round of broadcasting; if the firmware version number is inconsistent with the current firmware version number of the slave device 300, and the verification code is consistent with the verification code sent by the master device 200 in the previous round of broadcasting, then no erase operation is performed on the predetermined storage location.

[0139] Optionally, the firmware upgrade device may also include an erasing module, which is used to read the written upgrade file package from a predetermined storage location after each upgrade file package is written; if the read upgrade file package is inconsistent with the original upgrade file package, the minimum erasing area where the written upgrade file package is located is erased.

[0140] Please refer to Figure 6 , is a block diagram of an electronic device that can implement the above-mentioned master device 200 and slave device 300 provided by an embodiment of the present invention. The electronic device includes a memory 110, a processor 120 and a communication module 130. The memory 110, the processor 120 and the communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0141] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.

[0142] The processor 120 is used to read / write data or programs stored in the memory 110 and execute corresponding functions. For example, when the computer program stored in the memory 110 is executed by the processor 120, the firmware upgrade method disclosed in the above embodiments can be implemented.

[0143] The communication module 130 is used to establish a communication connection between the electronic device and other devices through a network, and to send and receive data through the network.

[0144] It should be understood that Figure 6 The structure shown is only a schematic diagram of the structure of the electronic device. The electronic device may also include Figure 6 More or fewer components as shown, or with Figure 6 Different configurations are shown. Figure 6 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0145] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by the processor 120, the firmware upgrade method disclosed in the above embodiments is implemented.

[0146] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0147] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0148] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory 110 (ROM, Read-Only Memory), random access memory 110 (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

[0149] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A firmware upgrade method, characterized in that: Applied to a master device, the master device is communicatively connected with a plurality of slave devices; the method comprises: Obtain and parse the firmware upgrade file to obtain verification information; Dividing the firmware upgrade file into multiple parts, and generating multiple upgrade file packages respectively; Perform a round of broadcasting to broadcast the verification information and each upgrade file package to all slave devices in turn; Determine whether there are slave devices that have not completed the firmware upgrade. If so, perform the next round of broadcasting until all slave devices have completed the firmware upgrade.

2. The firmware upgrade method according to claim 1, characterized in that: The step of broadcasting the verification information and each of the upgrade file packages to all slave devices in sequence includes: Generate broadcast messages corresponding to the verification information and broadcast messages corresponding to each of the upgrade file packages in sequence, and send the generated broadcast messages to all slave devices.

3. The firmware upgrade method according to claim 2, characterized in that: The broadcast message also includes at least one of heartbeat information and data collection information; the data collection information is used to indicate the collection of operating data of the target slave device.

4. The firmware upgrade method according to claim 1, characterized in that: The determining whether there is any slave device that has not completed the firmware upgrade includes: Obtaining the current firmware version number of each of the slave devices according to the data acquisition response message returned by each of the slave devices; the data acquisition response message carries the current firmware version number of the slave device; If the current firmware version number of the slave device is different from the firmware version number corresponding to the firmware upgrade file, it is determined that the firmware upgrade of the slave device has not been completed.

5. The firmware upgrade method according to any one of claims 1 to 4, characterized in that: The step of dividing the firmware upgrade file into multiple parts and generating multiple upgrade file packages respectively includes: The firmware upgrade file is divided into multiple upgrade file packages according to a fixed byte length.

6. A firmware upgrade method, characterized in that: Applied to a slave device, the slave device is communicatively connected with a master device; the method comprises: Receiving the verification information and each upgrade file package sequentially issued by the master device in the current round of broadcasting, and writing each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device by segmenting the acquired firmware upgrade file; After receiving the last upgrade file package sent by the master device in the current round of broadcasting, judging whether the complete firmware upgrade file is received according to the verification information; If the complete firmware upgrade file is received, the upgrade process is triggered; if the complete firmware upgrade file is not received, wait to receive the upgrade file package sent by the master device in the next round of broadcasting until the complete firmware upgrade file is received.

7. The firmware upgrade method according to claim 6, characterized in that: Writing each of the upgrade file packages into a predetermined storage location includes: Determine the offset position of each upgrade file package in the firmware upgrade file according to the frame sequence number of the message in which each upgrade file package is located; Each of the upgrade file packages is written into a corresponding address in the predetermined storage location according to the offset position.

8. The firmware upgrade method according to claim 6, characterized in that: The verification information includes a verification code and a firmware version number, and the method further includes: After receiving the verification code and the firmware version number, setting the system upgrade state to a receiving state or a non-receiving state according to the firmware version number; the receiving state indicates that an upgrade is required, and the non-receiving state indicates that an upgrade is not required; Determine whether to perform an erasing operation on the predetermined storage location according to the firmware version number and the verification code.

9. The firmware upgrade method according to claim 8, characterized in that: Writing each of the upgrade file packages into a predetermined storage location includes: When the system upgrade state is the receiving state, each upgrade file package is written into a predetermined storage location.

10. The firmware upgrade method according to claim 8, characterized in that: After receiving the verification information and each upgrade file package sequentially sent by the master device in the current round of broadcasting, the method further includes: When the system upgrade state is the non-receiving state, each received upgrade file package is discarded.

11. The firmware upgrade method according to claim 8, characterized in that: The step of setting the system upgrade state to a receiving state or a non-receiving state according to the firmware version number includes: If the firmware version number is consistent with the current firmware version number of the slave device, the system upgrade state is set to a non-receiving state; if the firmware version number is inconsistent with the current firmware version number of the slave device, the system upgrade state is set to a receiving state.

12. The firmware upgrade method according to claim 8, characterized in that: The determining whether to perform an erasure operation on the predetermined storage location according to the firmware version number and the verification code includes: If the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is inconsistent with the verification code sent by the master device in the previous round of broadcasting, then the currently received verification code is saved, and an erasing operation is performed on the predetermined storage location; If the firmware version number is inconsistent with the current firmware version number of the slave device, and the verification code is consistent with the verification code sent by the master device in the previous round of broadcasting, the erasing operation is not performed on the predetermined storage location.

13. The firmware upgrade method according to claim 6, characterized in that: The method further comprises: After each time the upgrade file package is written, the written upgrade file package is read out from the predetermined storage location; If the read upgrade file package is inconsistent with the original upgrade file package, the minimum erasure area where the written upgrade file package is located is erased.

14. A firmware upgrade device, characterized in that: Applied to a master device, the master device is communicatively connected with a plurality of slave devices; the device comprises: A parsing module is used to obtain and parse the firmware upgrade file to obtain verification information; A segmentation module, used to segment the firmware upgrade file into multiple parts, respectively generating multiple upgrade file packages; The sending module is used to perform a round of broadcasting, broadcasting the verification information and each upgrade file package to all slave devices in turn; judging whether there is a slave device that has not completed the firmware upgrade, and if so, performing the next round of broadcasting until all slave devices have completed the firmware upgrade.

15. A firmware upgrade device, characterized in that: Applied to a slave device, the slave device is communicatively connected with a master device; the device comprises: A receiving module, used to receive the verification information and each upgrade file package sent in sequence by the master device in the current round of broadcasting, and write each upgrade file package into a predetermined storage location; each upgrade file package is obtained by the master device after segmenting the acquired firmware upgrade file; A judgment module, configured to judge whether a complete firmware upgrade file is received according to the verification information after receiving the last upgrade file package sent by the master device in the current round of broadcasting; The upgrade module is used to trigger the upgrade process if the complete firmware upgrade file is received; if the complete firmware upgrade file is not received, wait to receive the upgrade file package sent by the master device in the next round of broadcasting until the complete firmware upgrade file is received.

16. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the firmware upgrade method according to any one of claims 1 to 13.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the firmware upgrade method according to any one of claims 1 to 13 are implemented.

Citation Information

Patent Citations

  • Method based on controller area network (CAN) bus and used for conducting batch upgrading for device firmware

    CN102546784A

  • Firmware upgrading method and device, computer equipment and storage medium

    CN111949293A

  • Firmware upgrading method based on narrowband Internet of Things, terminal equipment and computer readable storage medium

    CN112306514A

  • Firmware upgrading method for slave node equipment of master-slave system and storage medium

    CN117675572A

  • Method and system for synchronously updating programs of energy storage power supply multistage network environment equipment

    CN117873536A