Firmware upgrade method, device, equipment and computer readable storage medium
By receiving and storing the sub-data packets sent by the server in the communication module of the IoT terminal, until the reception is completed and written to the processor, the problem of too long firmware upgrade time is solved and a faster firmware upgrade process is achieved.
Patent Information
- Application Number
- CN202011422981.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-08
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-12-08
AI Technical Summary
In the existing technology, the firmware upgrade of IoT terminals takes too long, mainly because the server needs to wait for the terminal to confirm receipt of each packet of data before issuing the next packet, resulting in the entire upgrade process taking a long time.
By obtaining the sub-data packets issued by the server in the communication module of the IoT terminal, if the preset conditions are met (such as the amount of received data reaching the threshold or the duration reaching the preset duration), the communication module is controlled to stop sending sub-data packets. The received sub-data packets are stored in the storage unit until all sub-data packets are received and then written into the program area of the processor.
It reduces the firmware upgrade time, increases the firmware upgrade speed, reduces the data processing pressure on the processor, and avoids delays caused by the traditional one-send-one communication method.
Smart Images

Figure CN112416408B
Abstract
Description
Technical Field
[0001] The present disclosure relates to embedded device technology, and more particularly to a firmware upgrade method, apparatus, device, and computer-readable storage medium. Background Art
[0002] With the development of Internet of Things technology, many electronic devices are connected to the Internet. For example, many instruments can also join the network, so as to realize automatic data collection.
[0003] Among them, many IoT terminals connected to the IoT use firmware upgrades to update their functions. Generally, a complete firmware upgrade package is sent to the IoT terminal through a server, and the IoT terminal stores the received firmware upgrade package and writes it to the processor.
[0004] With the rapid development of IoT terminals, the functions of IoT terminals have increased, and the amount of code has also increased. During the firmware upgrade process, after the server sends a packet of data, it needs to wait for the IoT terminal to confirm that it has been received successfully before sending the next packet of data, which greatly prolongs the firmware upgrade time. Summary of the invention
[0005] The present disclosure provides a firmware upgrade method, device, equipment and computer-readable storage medium to solve the problem of long firmware upgrade time in the prior art.
[0006] A first aspect of the present disclosure is to provide a firmware upgrade method, which is applied to a processor in an Internet of Things terminal, wherein the Internet of Things terminal includes the processor, a communication module, and a storage unit, and the method includes:
[0007] Repeat the following steps until it is determined that the communication module has received all the sub-data packets sent by the server: in the process of obtaining the sub-data packets from the communication module, if it is determined that the preset conditions are met, control the communication module to stop sending the sub-data packets, wherein the sub-data packets are continuously sent by the server to the communication module, and the sub-data packets are obtained by splitting the firmware upgrade package; store the received sub-data packets in the storage unit;
[0008] Each sub-data packet stored in the storage unit is written into the program area of the processor.
[0009] Another aspect of the present disclosure is to provide a firmware upgrade device, which is applied to a processor in an Internet of Things terminal, wherein the Internet of Things terminal includes the processor, a communication module, and a storage unit, and the device includes:
[0010] The control unit is used to repeatedly perform the following steps until it is determined that the communication module has completed receiving the sub-data packets sent by the server: in the process of obtaining the sub-data packets from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-data packets, wherein the sub-data packets are continuously sent by the server to the communication module, and the sub-data packets are obtained by splitting the firmware upgrade package; the received sub-data packets are stored in the storage unit;
[0011] The writing unit is used to write each sub-data packet stored in the storage unit into the program area of the processor.
[0012] Another aspect of the present disclosure is to provide a firmware upgrade device, comprising:
[0013] Memory;
[0014] Processor; and
[0015] Computer programs;
[0016] Wherein, the computer program is stored in the memory and is configured to be executed by the processor to implement the firmware upgrade method as described in the first aspect above.
[0017] Yet another aspect of the present disclosure is to provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the firmware upgrade method as described in the first aspect above.
[0018] The technical effects of the firmware upgrade method, device, equipment and computer-readable storage medium provided by the present disclosure are:
[0019] The firmware upgrade method, device, equipment and computer-readable storage medium provided by the embodiments of the present disclosure are applied to the processor in the Internet of Things terminal, and the Internet of Things terminal includes a processor, a communication module and a storage unit. The scheme includes: repeatedly executing the following steps until it is determined that the communication module has received the sub-data packet sent by the server: in the process of obtaining the sub-data packet from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-data packet, wherein the sub-data packet is continuously sent by the server to the communication module, and the sub-data packet is obtained by splitting the firmware upgrade package; the received sub-data packet is stored in the storage unit; each sub-data packet stored in the storage unit is written into the program area of the processor. In the firmware upgrade method, device, equipment and computer-readable storage medium provided by the embodiments of the present disclosure, the communication module can be controlled to stop sending the sub-data packet to the processor under certain circumstances, even if the communication module continues to receive the sub-data packet sent by the server, the processor can process the data normally, thereby reducing the firmware upgrade time and improving the firmware upgrade speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of a firmware upgrade process is shown as an exemplary embodiment;
[0021] Figure 2A This is a schematic diagram of the structure of an Internet of Things terminal shown as an exemplary embodiment of the present application;
[0022] Figure 2B This is a schematic diagram of the structure of an Internet of Things terminal shown in another exemplary embodiment of the present application;
[0023] Figure 3 This is a flowchart of a firmware upgrade method shown in an exemplary embodiment of the present application;
[0024] Figure 4 This is a schematic diagram of a data transmission process according to an exemplary embodiment of the present application;
[0025] Figure 5 This is a flowchart of a firmware upgrade method shown in another exemplary embodiment of the present application;
[0026] Figure 6 A flowchart of a sub-data packet processing process shown in an exemplary embodiment of the present application;
[0027] Figure 7 This is a structural diagram of a firmware upgrade device shown in an exemplary embodiment of the present application;
[0028] Figure 8 This is a structural diagram of a firmware upgrade device shown in another exemplary embodiment of the present application;
[0029] Fig. 9 This is a structural diagram of a firmware upgrade device shown as an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0030] There are currently a large number of IoT terminal devices that can upload data through the Internet, eliminating the need for manual data collection. For example, gas meters, water meters, and electricity meters can all be connected to the Internet to automatically report data.
[0031] As the functions of IoT terminals increase, the firmware of IoT terminals needs to be upgraded. Generally, data needs to be sent to them multiple times during the firmware upgrade process to complete the upgrade.
[0032] Figure 1 The figure is a schematic diagram of a firmware upgrade process according to an exemplary embodiment.
[0033] like Figure 1As shown, the IoT terminal 11 can be connected to the server 12 through the network. When an upgrade is required, the server 12 can send upgrade data in batches to the IoT terminal 11. For example, after the server 12 sends data packet 1, it waits to receive a response instruction from the IoT terminal 11. After receiving the response instruction 1, the server 12 sends data packet 2 to the IoT terminal 11.
[0034] This approach will result in a longer upgrade time for the IoT terminal 11 .
[0035] In the solution provided by the present application, the IoT terminal continuously receives data sent by the server through the communication module, and the communication module sends the received data to the processor of the IoT terminal so that the processor processes the data. When the preset conditions are met, the communication module is controlled to stop sending data to the processor, and after the processor stores the received data in the storage unit, the communication module is controlled to continue sending the received data to the processor. Therefore, the solution provided by the present application does not require a one-to-one communication method, thereby increasing the speed of firmware upgrades, and is provided with a mechanism for controlling the communication module to stop sending data to the processor, which can reduce the data processing pressure of the processor.
[0036] Figure 2A This is a schematic diagram of the structure of an Internet of Things terminal shown as an exemplary embodiment of the present application; Figure 2B This is a schematic diagram of the structure of an Internet of Things terminal shown in another exemplary embodiment of the present application.
[0037] like Figure 2A As shown, the IoT terminal may include a processor 21, a communication module 22 and a storage unit 23. The processor 21 has computing capabilities to execute the method provided in the present application.
[0038] Specifically, the communication module 22 is used to communicate with the outside world. For example, the IoT terminal interacts with the server through the communication module 22 .
[0039] Furthermore, the storage unit 23 is used to store data, for example, data collected by the IoT terminal, and data sent by the server.
[0040] like Figure 2B As shown, the processor 21 may also include multiple sub-chips, for example, two sub-chips, one being a main processor 211 and the other being a communication processor 212, so that the method provided in the present application is executed by multiple sub-chips, thereby reducing the data processing pressure of a single chip.
[0041] Figure 3 The flowchart of a firmware upgrade method is shown as an exemplary embodiment of the present application.
[0042] The firmware upgrade method provided in the present application can be applied to the Internet of Things terminal as shown in FIG. 2 , and can be specifically executed by a processor in the Internet of Things terminal.
[0043] like Figure 3 As shown, the firmware upgrade method provided by this application includes:
[0044] Step 301, in the process of obtaining sub-data packets from the communication module, if it is determined that the processor meets the preset conditions, the communication module is controlled to stop sending sub-data packets. The sub-data packets are continuously sent by the server to the communication module, and the sub-data packets are obtained by splitting the firmware upgrade package.
[0045] When the function of the IoT terminal needs to be updated, the firmware upgrade package used for the upgrade can be stored in the server, and the server can send the firmware upgrade package to the IoT terminal. For example, R&D personnel can upload the prepared firmware upgrade package to the server, and after reaching the predetermined time, the server sends the firmware upgrade package to the IoT terminal.
[0046] Specifically, the communication module of the IoT terminal may receive the firmware upgrade package sent by the server, and then the communication module may send the received data to the processor, which may process the received data.
[0047] Furthermore, the server splits the firmware upgrade package into multiple sub-data packages and continuously sends these sub-data packages. After receiving the sub-data packages, the communication module can send them to the processor, so that the processor processes the data.
[0048] In the method provided in the present application, the IoT terminal continuously receives the firmware upgrade package, thereby reducing the firmware upgrade time.
[0049] Figure 4 This is a schematic diagram of a data transmission process according to an exemplary embodiment of the present application.
[0050] like Figure 4 As shown, the communication module 22 of the IoT terminal receives the sub-data packet sent by the server 41. After receiving the sub-data packet, the communication module 22 sends it to the processor 21.
[0051] In actual application, when the processor obtains a sub-packet from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-packet. For example, when the number of bytes of the sub-packet that the processor has received reaches a threshold, a message to stop sending data can be sent to the communication module, thereby controlling the communication module to no longer send sub-packets to the processor. Since the amount of data that the processor can process is limited, the above threshold can be set to the upper limit of the amount of data that the processor can process. For another example, when the duration that the processor has not received a sub-packet reaches a preset duration, a message to stop sending data can also be sent to the communication module, thereby controlling the communication module to no longer send sub-packets to the processor.
[0052] In the method provided in the present application, a mechanism is provided for the communication module to stop sending sub-data packets to the processor, so that the Internet of Things terminal can continue to receive data sent by the server without causing the problem that the processor cannot process the received data.
[0053] Please continue to refer to Figure 4 In an optional implementation, a time for the IoT terminal to report data can be set, and when the time is reached, the IoT terminal establishes a communication connection with the server. The IoT terminal reports data to the server based on the communication connection. If the firmware of the IoT terminal needs to be upgraded, the server can send an instruction including a sub-data packet to the IoT terminal after processing the data.
[0054] Step 302: Store the received sub-data packet into a storage unit.
[0055] After the processor controls the communication module to stop sending the sub-data packet, the processor stores the sub-data packet obtained from the communication module into the storage unit, thereby releasing the processing resources.
[0056] Specifically, after step 302, step 301 is continued to be executed, that is, sub-data packets are continued to be obtained from the communication module, and the sub-data packets are stored in the storage unit based on steps 301 and 302 until the communication module completes receiving the sub-data packets sent by the server.
[0057] Furthermore, the total length of the received sub-packets can be obtained to determine whether the sub-packets sent by the server have been received. For example, the total length of the firmware upgrade package can be recorded in the first sub-packet sent by the server. The IoT terminal can determine whether the sub-packets sent by the server have been received based on this information.
[0058] Step 303, writing each sub-data packet stored in the storage unit into the program area of the processor.
[0059] In actual application, after the communication module receives the sub-data packets sent by the server and the processor writes the sub-data packets sent by the communication module into the storage unit, each sub-data packet stored in the storage unit can be written into the program area.
[0060] Among them, a program area is set in the processor for storing execution code. When the processor runs the code therein, it can realize certain functions, such as collecting data, uploading data, etc. The processor writes each sub-data packet stored in the storage unit into the program area of the processor, which can realize the update of the code, thereby updating the function of the Internet of Things terminal.
[0061] Specifically, the processor may erase the code in its internal program area, and then write the code in the storage unit into the program area, thereby replacing the code in the program area.
[0062] The method provided in this embodiment is used for performing firmware upgrade. The method is executed by a device equipped with the method provided in this embodiment. The device is usually implemented in hardware and / or software.
[0063] The firmware upgrade method provided in the embodiment of the present application is applied to the processor in the Internet of Things terminal, and the Internet of Things terminal includes a processor, a communication module and a storage unit. The method includes: repeatedly executing the following steps until it is determined that the communication module has received the sub-data packet sent by the server: in the process of obtaining the sub-data packet from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-data packet, wherein the sub-data packet is continuously sent by the server to the communication module, and the sub-data packet is obtained by splitting the firmware upgrade package; the received sub-data packet is stored in the storage unit; each sub-data packet stored in the storage unit is written into the program area of the processor. In the method provided in the embodiment of the present application, the communication module can be controlled to stop sending sub-data packets to the processor under certain circumstances. Even if the communication module continues to receive the sub-data packets sent by the server, the processor can process the data normally, thereby reducing the firmware upgrade time and improving the firmware upgrade speed.
[0064] Figure 5 The flowchart of a firmware upgrade method is shown as another exemplary embodiment of the present application.
[0065] like Figure 5 As shown, the firmware upgrade method provided by this application includes:
[0066] Step 501, in the process of obtaining sub-data packets from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending sub-data packets, wherein the sub-data packets are continuously sent by the server to the communication module, and the sub-data packets are obtained by splitting the firmware upgrade package.
[0067] When the function of the IoT terminal needs to be updated, the firmware upgrade package used for the upgrade can be stored in the server, and the server can send the firmware upgrade package to the IoT terminal. For example, R&D personnel can upload the prepared firmware upgrade package to the server.
[0068] Specifically, the server may split the firmware upgrade package into multiple sub-packets, and continuously send the sub-packets to the IoT terminal when it is necessary to control the IoT terminal to upgrade. For example, after reaching a predetermined time, the server may continuously send the sub-packets to the IoT terminal in sequence.
[0069] Furthermore, the sub-data packet may include a data packet of the information frame type, and may also include a data packet of the data frame type. The data packet of the information frame type includes some information of the firmware upgrade package, such as the firmware version number, total length, first check code, and total number of frames. The data packet of the data frame type may include relevant information of the frame data, such as the frame number, firmware data length, offset address, and second check code, and the data packet of the data frame type may also include specific upgrade data.
[0070] In actual application, the communication module of the IoT terminal receives the sub-data packet sent by the server, and then the communication module sends the received sub-data packet to the processor, which processes the received sub-data packet.
[0071] In one implementation, if the structure of the IoT terminal is as follows Figure 2A As shown, this step can be executed by the processor.
[0072] In another implementation, if the structure of the IoT terminal is as follows Figure 2B As shown, this step can be performed by the communication processor.
[0073] For example, you can set the flow control function in the communication module. When the preset conditions are met, such as Figure 2A The processor in Figure 2B The communication processor in the communication module can control the communication module to start the flow control function, thereby controlling the communication module to stop sending sub-data packets.
[0074] In the method provided in the present application, the IoT terminal continuously receives the firmware upgrade package, thereby reducing the firmware upgrade time.
[0075] In actual application, when the processor obtains the sub-data packet from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-data packet.
[0076] The preset condition may include that the number of bytes of the received sub-data packets reaches a threshold value. Since the amount of data that the processor can process is limited, the above threshold value may be set to an upper limit of the amount of data that the processor can process. When the processor receives a sub-data packet with a number of sub-bytes reaching the threshold value, the communication module is controlled to stop sending data to the processor, so that the processor can process the received data, and after the processing is completed, the communication module is controlled to send sub-data packets to the processor.
[0077] Specifically, the preset conditions may also include that the time duration for which a sub-packet has not been received reaches a preset time duration. When the communication module has not sent data to the processor for a long time, it can be considered that the server side no longer sends sub-packets. In this case, there are no more sub-packets to be transmitted. Therefore, the communication module can be controlled to stop sending data to the processor.
[0078] Step 502: parse the received sub-data packet to verify the received sub-data packet.
[0079] Furthermore, the processor may parse the received sub-data packet to verify whether the data in the data packet is complete. If the verification is successful, step 503 may be executed to store the received sub-data packet in the storage unit.
[0080] Figure 6 The flowchart of the sub-data packet processing process is shown as an exemplary embodiment of the present application.
[0081] like Figure 6 As shown, in the method provided by the present application, after the processor receives the sub-data packet sent by the communication module, step 601 can be executed.
[0082] Step 601: Perform different processing on the received sub-data packet according to whether there is a data packet currently cached.
[0083] If the structure of the IoT terminal is Figure 2A As shown, a location for caching data packets may be provided in the processor, and the received sub-data packets may be processed according to whether a data packet for upgrading firmware is cached in the processor.
[0084] If the structure of the IoT terminal is Figure 2B As shown, the communication processor may be provided with a location for caching data packets, and the received sub-data packets may be processed according to whether the communication processor has cached data packets for upgrading firmware. If there are data packets currently cached, step 602 is executed.
[0085] In one implementation, if the structure of the IoT terminal is as follows Figure 2A As shown, step 602 may be executed when a data packet for upgrading the firmware is cached in the processor.
[0086] In another implementation, if the structure of the IoT terminal is as follows Figure 2B As shown, when a data packet for upgrading the firmware is cached in the communication processor, the communication processor executes step 602 .
[0087] Step 602: Combine the currently received sub-data packet with the buffered data packet to obtain a combined data packet.
[0088] The currently received sub-data packet may be spliced after the buffered data packet to obtain a combined data packet.
[0089] Specifically, after obtaining the combined data packet, the length of the combined data packet may be obtained, specifically, the byte length information included in the combined data packet may be obtained, and different processing may be performed according to the length information.
[0090] Step 603: If the length of the combined data packet meets the parsing length, the combined data packet is parsed.
[0091] Step 604: If the length of the combined data packet does not conform to the parsed length, the combined data packet is cached.
[0092] If the structure of the IoT terminal is Figure 2A As shown, the processor can execute steps 603 and 604; if the structure of the IoT terminal is as follows Figure 2B As shown, steps 603 and 604 may be executed by the communication processor.
[0093] Furthermore, if the data length in the combined data packet meets the parsing length, that is, the data in the combined data packet can be parsed, the combined data packet is parsed.
[0094] In actual application, if the length of the combined data packet does not meet the parsing length, that is, the data in the combined data packet is insufficient to be parsed, the combined data packet can be cached and wait for receiving the sub-data packets again for joint parsing and processing.
[0095] If no data packet is currently buffered, the sub-data packet is processed differently according to whether the currently received sub-data packet includes a frame header.
[0096] If the frame header is included, different processing is performed based on the length of the sub-data. Specifically, step 605 or 606 can be performed. If the frame header is not included, step 607 is performed.
[0097] Step 605: If the sub-data packet includes a frame header and the length of the sub-data packet meets the parsing length, the currently received sub-data packet is parsed.
[0098] Step 606: If the sub-data packet includes a frame header and the length of the sub-data packet does not conform to the parsed length, the received sub-data packet is cached.
[0099] If the structure of the IoT terminal is Figure 2A As shown, the processor can execute steps 605 and 606; if the structure of the IoT terminal is as follows Figure 2B As shown, steps 605 and 606 may be executed by the communication processor.
[0100] If the sub-data packet includes a frame header, it can be considered that the sub-data packet includes the beginning part of a complete data frame.
[0101] If the length of the sub-data packet meets the parsing length, that is, the sub-data packet includes both the starting part and a sufficient amount of data for parsing, the sub-data packet can be parsed.
[0102] If the length of the sub-packet does not meet the parsing length, that is, the sub-packet includes the starting part but does not have enough data for parsing, the sub-packet can be cached and merged after receiving a new sub-packet.
[0103] Step 607: If the sub-data packet does not include a frame header, a parsing failure message is sent to the server via the communication module.
[0104] If the structure of the IoT terminal is Figure 2A As shown, this step can be performed by the processor; if the structure of the IoT terminal is as follows Figure 2B As shown, this step can be performed by the communication processor.
[0105] Among them, if the received sub-packet does not include a frame header, it means that the sub-packet does not include the starting part of the complete data packet, and there is no cached data packet at this time, so the current sub-packet cannot be spliced after other data packets, resulting in the current received sub-packet having no frame header, and it cannot be parsed and processed. At this time, a parsing failure message can be sent to the server through the communication module.
[0106] Specifically, the parsing failure message may include identification information of the sub-data packet, such as a frame number.
[0107] Furthermore, the above process of parsing the sub-data packets or the combined data packets specifically includes:
[0108] A cyclic redundancy check is used to determine whether the data packet is complete.
[0109] In actual application, a check code may be included in the frame header of the data packet. During parsing, the data in the data packet is calculated to obtain another check code. The check code included in the frame header can be compared with the calculated other check code. If the comparison is successful, the check is considered to have passed.
[0110] Step 503: Store the received sub-data packet into a storage unit.
[0111] If the structure of the IoT terminal is Figure 2A As shown, the processor can execute steps 503-507; if the structure of the IoT terminal is as follows Figure 2B As shown, steps 503-507 may be executed by the communication processor.
[0112] If the sub-data packet is successfully verified, step 503 may be executed.
[0113] In addition, if the sub-data packet is successfully verified, step 504 may be executed. The execution sequence of step 503 and step 504 is not limited.
[0114] Step 504, determine whether the frame number of the sub-data packet is continuous with the frame number included in the processed sub-data packet; if the frame numbers are not continuous, determine that the frame number is missing.
[0115] The sub-data packets split by the server may have frame numbers, and the frame numbers of the sub-data packets should be continuous, for example, the frame numbers may be 1, 2, 3, 4, 5, and so on.
[0116] If the sub-packet currently being processed includes a frame number, it can be determined whether it is continuous with the frame number in the sub-packet previously processed. If not, the missing frame number of the interruption can be determined. For example, if the frame number in the sub-packet currently being processed is 10 and the frame number included in the sub-packet previously processed is 8, it can be determined that the missing frame number is 9.
[0117] After step 503, step 501 may be continued until it is determined that the communication module has received all the sub-data packets sent by the server.
[0118] Step 505: Send a data sending request including the missing frame number to the server through the communication module.
[0119] After the above cycle is completed, if the missing frame number is determined, a data sending request is sent to the server through the communication module. The data sending request includes the missing frame number.
[0120] Specifically, if there is a missing frame number, it means that there is a missing sub-data packet. Therefore, a data sending request can be sent to the server based on the missing frame number, so that the server sends the missing sub-data packet.
[0121] Step 506: Receive the missing data packet sent by the server through the communication module, and parse and process the missing data packet.
[0122] Furthermore, after sending a data sending request to the server, the server can send missing data packets corresponding to the missing frame numbers to the IoT terminal based on the request, and the communication module in the IoT terminal can receive these missing data packets. The communication module then sends the received data packets to the processor, so that the processor can receive these missing data packets and parse them. The specific parsing method is similar to the above solution.
[0123] Step 507: verify the firmware upgrade package according to the parsed sub-data package.
[0124] After the sub-data package is stored in the storage unit, the firmware upgrade package can be verified according to the parsed sub-data package.
[0125] The sub-data packet sent by the server may include an information frame data packet, which may include information of the entire firmware upgrade package, such as data length and a check code. The firmware upgrade package composed of each sub-data packet may be checked based on this information. If the check passes, step 508 is executed. If the check fails, a message indicating that the upgrade has failed is fed back to the server through the communication module.
[0126] Step 508: After reaching a preset time, erase the code in the program area.
[0127] If the structure of the IoT terminal is Figure 2A As shown, the processor can execute steps 508 and 509; if the structure of the IoT terminal is as follows Figure 2B As shown, steps 508 and 509 may be executed by the main processor.
[0128] Among them, the firmware upgrade time can be set. For example, the IoT terminal can be set to upgrade in the early morning, and the IoT device can automatically erase the code in the internal program area at the early morning.
[0129] Specifically, after reaching a preset time, the boot area program can be run to verify the firmware upgrade package composed of sub-data packages in the storage unit, and if the verification passes, the code in the program area is erased.
[0130] Step 509, writing the stored sub-data package into the program area.
[0131] After erasing is complete, the sub-data package stored in the storage unit is written into the program area, thereby completing the firmware upgrade process.
[0132] Figure 7 This is a structural diagram of a firmware upgrade device shown in an exemplary embodiment of the present application.
[0133] like Figure 7 As shown, the firmware upgrade device provided in this embodiment is applied to a processor in an Internet of Things terminal, and the Internet of Things terminal includes the processor, a communication module and a storage unit, and the device includes:
[0134] The control unit 71 is used to repeatedly perform the following steps until it is determined that the communication module has completed receiving the sub-data packet sent by the server: in the process of obtaining the sub-data packet from the communication module, if it is determined that the preset condition is met, the communication module is controlled to stop sending the sub-data packet, wherein the sub-data packet is continuously sent to the communication module by the server, and the sub-data packet is obtained by splitting the firmware upgrade package; the received sub-data packet is stored in the storage unit;
[0135] The writing unit 72 is used to write each sub-data packet stored in the storage unit into the program area of the processor.
[0136] The firmware upgrade device provided in this embodiment is applied to the processor in the Internet of Things terminal, and the Internet of Things terminal includes a processor, a communication module and a storage unit. The device includes: a control unit, which is used to repeatedly perform the following steps until it is determined that the communication module has received the sub-data packet sent by the server: in the process of obtaining the sub-data packet from the communication module, if it is determined that the preset conditions are met, the communication module is controlled to stop sending the sub-data packet, wherein the sub-data packet is continuously sent by the server to the communication module, and the sub-data packet is obtained by splitting the firmware upgrade package; the received sub-data packet is stored in the storage unit; a writing unit is used to write each sub-data packet stored in the storage unit into the program area of the processor. In the device provided in the embodiment of the present application, the communication module can be controlled to stop sending sub-data packets to the processor under certain circumstances. Even if the communication module continues to receive sub-data packets sent by the server, the processor can process data normally, thereby reducing the firmware upgrade time and improving the firmware upgrade speed.
[0137] The specific principles and implementation methods of the firmware upgrade device provided in this embodiment are similar to Figure 3 The embodiments shown are similar and will not be described again here.
[0138] Figure 8 This is a structural diagram of a firmware upgrade device shown in another exemplary embodiment of the present application.
[0139] like Figure 8 As shown, based on the above embodiment, the firmware upgrade device provided in this embodiment, in an optional implementation manner, the device further includes a parsing unit 73, which is used for: before the control unit 71 stores the received sub-data packet in the storage unit:
[0140] The received sub-data packet is parsed to verify the received sub-data packet.
[0141] In an optional implementation manner, the parsing unit 73 is specifically configured to:
[0142] The received sub-data packet is processed differently according to whether there is a data packet cached.
[0143] In an optional implementation, the parsing unit 73 includes a first parsing module 731, which is used to:
[0144] If there is a data packet in the cache, combining the sub-data packet currently received with the cached data packet to obtain a combined data packet;
[0145] If the length of the combined data packet meets the parsing length, the combined data packet is parsed;
[0146] If the length of the combined data packet does not conform to the parsed length, the combined data packet is cached.
[0147] In an optional implementation, the parsing unit 73 includes a second parsing module 732, which is used to:
[0148] If the data packet is not buffered, the sub-data packet is processed differently according to whether the sub-data packet currently received includes a frame header.
[0149] In an optional implementation, the second parsing module 732 is specifically configured to:
[0150] If the sub-data packet includes a frame header and the length of the sub-data packet meets the parsing length, the sub-data packet currently received is parsed.
[0151] In an optional implementation, the second parsing module 732 is specifically configured to:
[0152] If the sub-data packet includes a frame header and the length of the sub-data packet does not conform to the parsed length, the received sub-data packet is cached.
[0153] In an optional implementation, the second parsing module 732 is specifically configured to:
[0154] If the sub-data packet does not include a frame header, a parsing failure message is sent to the server via the communication module.
[0155] In an optional implementation, the parsing unit 73 is specifically configured to:
[0156] Whether the data packet is complete data is determined by a cyclic redundancy check.
[0157] In an optional implementation, the device further includes a judgment unit 74, configured to:
[0158] Determining whether the frame number of the sub-data packet is continuous with the frame number included in the processed sub-data packet;
[0159] If the frame numbers are not consecutive, it is determined that the frame numbers are missing.
[0160] In an optional implementation, the device further includes a downloading unit 75, configured to:
[0161] Sending a data sending request including the missing frame number to the server through the communication module;
[0162] The missing data packets sent by the server are received through the communication module, and the missing data packets are parsed and processed.
[0163] In an optional implementation, the device further includes a verification unit 76, configured to, after receiving the sub-data packet sent by the server:
[0164] Verifying the firmware upgrade package according to the parsed sub-data package;
[0165] After the verification is passed, the writing unit 72 executes the step of writing each sub-data packet stored in the storage unit into the program area of the processor.
[0166] In an optional implementation, the writing unit 72 includes:
[0167] An erasing module 721, configured to erase the code in the program area after a preset time is reached;
[0168] The writing module 722 is used to write the stored sub-data package into the program area.
[0169] Optionally, the writing unit 72 further includes a verification module 723, which is used for, before the erasing module 721 erases the code of the program area:
[0170] The boot area program is run to verify the stored firmware upgrade package composed of sub-data packages. If the verification passes, the erasing module 721 executes the step of erasing the code of the program area.
[0171] Optionally, the sub-data packet includes an information frame type and a data frame type.
[0172] Optionally, the preset condition includes any one of the following:
[0173] The number of bytes of the received sub-data packet reaches a threshold, and the duration for which the sub-data packet is not received reaches a preset duration.
[0174] The specific principles and implementation methods of the firmware upgrade device provided in this embodiment are similar to Figure 5 The embodiments shown are similar and will not be described again here.
[0175] Fig. 9 This is a structural diagram of a firmware upgrade device shown as an exemplary embodiment of the present application.
[0176] like Fig. 9 As shown, the firmware upgrade device provided in this embodiment includes:
[0177] Memory 91;
[0178] Processor 92; and
[0179] Computer programs;
[0180] The computer program is stored in the memory 91 and is configured to be executed by the processor 92 to implement any of the firmware upgrade methods described above.
[0181] This embodiment also provides a computer-readable storage medium having a computer program stored thereon.
[0182] The computer program is executed by a processor to implement any of the firmware upgrade methods described above.
[0183] This embodiment further provides a computer program, including program code. When a computer runs the computer program, the program code executes any one of the firmware upgrade methods described above.
[0184] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0185] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A firmware upgrade method, characterized in that: The method is applied to a processor in an IoT terminal, wherein the IoT terminal includes the processor, a communication module and a storage unit, and the method includes: Repeat the following steps until it is determined that the communication module has completed receiving the sub-data packet sent by the server: in the process of the processor obtaining the sub-data packet from the communication module, if it is determined that the preset condition is met, control the communication module to stop sending the sub-data packet to the processor, wherein the sub-data packet is continuously sent by the server to the communication module, and the sub-data packet is obtained by splitting the firmware upgrade package; parse the received sub-data packet to verify the received sub-data packet; if the verification passes, store the received sub-data packet in the storage unit; the preset condition includes any one of the number of bytes of the received sub-data packet reaching a threshold and the duration of not receiving the sub-data packet reaching a preset duration; Writing each sub-data packet stored in the storage unit into the program area of the processor; The parsing process of the received sub-data packet to verify the received sub-data packet includes: Processing the received sub-data packet differently according to whether there is a data packet cached in the processor; If there is a data packet in the cache, combining the sub-data packet currently received with the cached data packet to obtain a combined data packet; If the length of the combined data packet meets the parsing length, the combined data packet is parsed; If the length of the combined data packet does not conform to the parsed length, caching the combined data packet; If the data packet is not cached, the sub-data packet is processed differently according to whether the sub-data packet currently received includes a frame header; If the sub-data packet includes a frame header and the length of the sub-data packet meets the parsing length, parsing the sub-data packet currently received; If the sub-data packet includes a frame header and the length of the sub-data packet does not conform to the parsed length, buffering the received sub-data packet; If the sub-data packet does not include a frame header, a parsing failure message is sent to the server via the communication module.
2. The method according to claim 1, characterized in that: Parsing of sub-packets or combined packets includes: Whether the sub-data packet or the combined data packet is complete data is determined by a cyclic redundancy check.
3. The method according to claim 1, characterized in that Also includes: Determining whether the frame number of the sub-data packet is continuous with the frame number included in the processed sub-data packet; If the frame numbers are not consecutive, it is determined that the frame numbers are missing.
4. The method according to claim 3, characterized in that After receiving the sub-data packet sent by the server, the method further includes: Sending a data sending request including the missing frame number to the server through the communication module; The missing data packets sent by the server are received through the communication module, and the missing data packets are parsed and processed.
5. The method according to claim 1, characterized in that After receiving the sub-data packet sent by the server, the method further includes: Verifying the firmware upgrade package according to the parsed sub-data package; After the verification is passed, the step of writing each sub-data packet stored in the storage unit into the program area of the processor is executed.
6. The method according to claim 1, characterized in that The step of writing each sub-data packet stored in the storage unit into the program area of the processor includes: After reaching a preset time, erasing the code in the program area; The stored sub-data packet is written into the program area.
7. The method according to claim 6, characterized in that Before erasing the code of the program area, the method includes: The boot area program is run to verify the stored firmware upgrade package composed of sub-data packages, and if the verification passes, the step of erasing the code in the program area is executed.
8. The method according to claim 1, characterized in that The sub-data packet includes an information frame type and a data frame type.
9. A firmware upgrade device, characterized in that: The device is applied to a processor in an IoT terminal, wherein the IoT terminal includes the processor, a communication module and a storage unit, and the device includes: A control unit, configured to repeatedly perform the following steps until it is determined that the communication module has completed receiving the sub-data packet sent by the server: in the process of the processor obtaining the sub-data packet from the communication module, if it is determined that the preset condition is met, the communication module is controlled to stop sending the sub-data packet to the processor, wherein the sub-data packet is continuously sent by the server to the communication module, and the sub-data packet is obtained by splitting the firmware upgrade package; the received sub-data packet is parsed to verify the received sub-data packet; if the verification is passed, the received sub-data packet is stored in the storage unit; the preset condition includes any one of the number of bytes of the received sub-data packet reaching a threshold value and the duration of not receiving the sub-data packet reaching a preset duration; A writing unit, used for writing each sub-data packet stored in the storage unit into the program area of the processor; A parsing unit, configured to perform different processing on the received sub-data packet according to whether there is a data packet cached; The parsing unit includes a first parsing module and a second parsing module. The first parsing module is configured to combine the currently received sub-packet with the cached data packet to obtain a combined data packet if a data packet is cached; parse the combined data packet if the length of the combined data packet meets the parsing length; and cache the combined data packet if the length of the combined data packet does not meet the parsing length; The second parsing module is configured to perform different processing on the sub-data packet according to whether the sub-data packet currently received includes a frame header if the data packet is not cached; The second parsing module is specifically used to parse the sub-packet currently received if the sub-packet includes a frame header and the length of the sub-packet meets the parsing length; cache the received sub-packet if the sub-packet includes a frame header and the length of the sub-packet does not meet the parsing length; and send a parsing failure message to the server through the communication module if the sub-packet does not include a frame header.
10. A firmware upgrade device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: A computer program is stored thereon, The computer program is executed by a processor to implement the method according to any one of claims 1 to 8.
