A firmware upgrade method, device, and computer storage medium

By configuring the upgrade area and backup area in the embedded system, comparing the version information and storing the firmware overwrite to the backup area when inconsistent, the crash problem caused by power outage or abnormality during the firmware upgrade of the embedded system is solved, and the stable operation and maintenance cost of the system is reduced.

CN114020526BActive Publication Date: 2025-08-05SHENZHEN NEOWAY TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111231138.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2025-08-05
Estimated Expiration
2041-10-22

AI Technical Summary

Technical Problem

During the firmware upgrade process of embedded systems, sudden power outage or firmware abnormality causes the system to crash or crash, increasing maintenance costs.

Method used

Configure the upgrade area and the backup area in the embedded system. By comparing the version information of the firmware to be upgraded with the version information of the firmware in the backup area, if it is inconsistent, the firmware overwrite of the firmware to be upgraded is stored in the backup area, and the backup area firmware is called during the upgrade process to ensure the normal operation of the system.

Benefits of technology

In the event of power outage or firmware abnormality, ensure the normal operation of the embedded system, avoid crashes or system crashes, and reduce maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020526B_ABST
    Figure CN114020526B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses a firmware upgrade method, device, and computer storage medium. The method includes: obtaining a firmware upgrade file and storing the firmware upgrade file in an upgrade area; obtaining the first version information of the firmware to be upgraded; if the backup area is not empty, obtaining the second version information of the backup area firmware stored in the backup area; if the first version information is different from the second version information, overwriting and storing the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area; performing a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded. By implementing the embodiment of the present application, during the firmware upgrade process, when a sudden power failure or firmware abnormality occurs, the backup area firmware can be called to ensure the normal operation of the embedded system, provide recovery ability, and avoid the risk of the embedded system crashing or the system collapsing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technologies, and in particular, to a firmware upgrade method, apparatus, and computer storage medium. Background Art

[0002] An embedded system is a dedicated computer system that can operate independently with the cooperation of hardware and software. With the development of electronic technologies and computer software technologies, embedded systems have been widely used in many fields such as daily life, industrial control, and industrial production. Therefore, the maintenance and upgrade of embedded systems have become increasingly important. Among them, various system functions in the embedded system are controlled by embedded firmware, which includes a bootloader, a kernel file, and a file system, and is usually stored in a flash memory (Flash). By periodically upgrading the embedded firmware, the functions of the embedded system can be continuously improved.

[0003] During the process of embedded firmware upgrade, if there is a sudden power failure or firmware abnormality, it may cause the embedded system to freeze or the system to crash. To address these faults, it is necessary to return the product to the factory for repair, which increases the maintenance cost of the embedded system. Summary of the Invention

[0004] Embodiments of this application provide a firmware upgrade method and apparatus, which can provide the recovery ability during the firmware upgrade process.

[0005] In a first aspect, embodiments of this application provide a firmware upgrade method, which is applied to an embedded system. The embedded system is configured with firmware to be upgraded, and the embedded system includes a first storage space and a second storage space. The first storage space includes an upgrade area and a backup area. The method includes: obtaining a firmware upgrade file and storing the firmware upgrade file in the upgrade area; obtaining first version information of the firmware to be upgraded; if the backup area is not empty, obtaining second version information of the backup area firmware stored in the backup area; if the first version information is different from the second version information, storing the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area in a covering manner; and performing a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0006] In one implementation, the specific implementation of obtaining the firmware upgrade file may be as follows: The embedded system sends a download request to the server; receives the first segmented data sent by the server and the first check value of the first segmented data; wherein, the first segmented data is split from the firmware upgrade file; checks the first segmented data according to the first check value, and after determining that the check is successful, requests the second segmented data and the second check value of the second segmented data, and the second segmented data is also split from the firmware upgrade file.

[0007] In one implementation, the method may further include: after successfully receiving the data of the firmware upgrade file, receiving the overall check value of the firmware upgrade file; checking the firmware upgrade file according to the overall check value, and performing a successful check processing after the check is successful.

[0008] In one implementation, the method may further include: after the embedded system obtains the first version information of the firmware to be upgraded, if the backup area is empty, storing the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area.

[0009] In one implementation, when the embedded system meets the first preset condition, it detects whether the backup area is empty; if the backup area is not empty, it performs a storage operation on the second storage space, so as to store the firmware in the backup area in the second storage space and run the firmware in the backup area.

[0010] In one implementation, the embedded system meeting the first preset condition may include any one of the following: the power failure of the embedded system causes the upgrade of the firmware to be upgraded to fail; the abnormal firmware to be upgraded causes the upgrade of the firmware to be upgraded to fail.

[0011] In one implementation, before performing the storage operation on the second storage space, the method may further include: determining whether the second storage space is empty; if it is not empty, clearing the data in the second storage space, so as to perform the storage operation on the second storage space.

[0012] In a second aspect, an embodiment of the present application provides a firmware upgrade device, and the device includes a unit for executing the method in the first aspect above.

[0013] In a third aspect, an embodiment of the present application provides a smart device, and the smart device includes a memory and a processor, the memory is used for storing a computer program, and the processor is configured to run the computer program to execute the method in the first aspect above.

[0014] Fourthly, an embodiment of the present application discloses a computer storage medium storing a computer program, which, when run by a processor, implements the method of the first aspect above.

[0015] By implementing the embodiments of the present application, when the first version information corresponding to the firmware to be upgraded is different from the second version information corresponding to the firmware in the backup area, the firmware indicated by the first version information corresponding to the firmware to be upgraded can be overwritten and stored in the backup area. When there is a sudden power failure or firmware anomaly, the firmware in the backup area can be called to ensure the normal operation of the embedded system, providing recovery capabilities, avoiding the risk of the embedded system crashing or system breakdown, and being beneficial to reducing the maintenance cost of the embedded system. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] To more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required for the description of the embodiments will be briefly introduced below.

[0017] Figure 1 is a schematic structural diagram of an embedded system provided by an embodiment of the present application;

[0018] Figure 2 is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application;

[0019] Figure 3a is a schematic flowchart of another firmware upgrade method provided by an embodiment of the present application;

[0020] Figure 3b is a schematic flowchart of another firmware upgrade method provided by an embodiment of the present application;

[0021] Figure 4 is a schematic flowchart of the process of obtaining a firmware upgrade file in a firmware upgrade method provided by an embodiment of the present application;

[0022] Figure 5 is a schematic flowchart of yet another firmware upgrade method provided by an embodiment of the present application;

[0023] Figure 6 is a schematic structural diagram of a firmware upgrade device provided by an embodiment of the present application;

[0024] Figure 7 is a schematic structural diagram of a smart device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] To facilitate understanding of a firmware upgrade method disclosed in the embodiments of the present application, the embedded system provided by the embodiments of the present application will be introduced first.

[0026] Please refer to Figure 1 ,Figure 1 A schematic diagram of an embedded system structure provided by an embodiment of this application. The embedded system in the embodiment of this application may include a first storage space and a second storage space. Among them, the first storage space may include an upgrade area and a backup area.

[0027] In the embodiment of this application, the first storage space may be a flash memory (Flash) that will not lose data due to power failure and can quickly read data, such as NOR Flash and NAND Flash. Among them, the upgrade area may be used to store firmware upgrade files, and the backup area may be used to store the firmware to be upgraded for backup. The second storage space may be a random access memory (Random Access Memory, RAM) that is convenient for reading and writing, such as a dynamic random access memory (Dynamic Random Access Memory, DRAM) and a static random access memory (Static Random-Access Memory, SRAM).

[0028] It should be noted that the embedded system in the embodiment of this application may include, but is not limited to, smart phones, wearable devices, tablet computers, personal computers (Personal Computer, PC), intelligent transportation systems, smart home control systems, smart medical systems, intelligent vehicle systems, industrial automation management systems, and so on.

[0029] In the embodiment of this application, the embedded system may obtain a firmware upgrade file from a server and store the firmware upgrade file in the upgrade area, which may be preset in the first storage space; the embedded system may obtain the first version information of the firmware to be upgraded to determine the version number corresponding to the firmware to be upgraded; if the backup area is not empty, that is, it indicates that the backup area stores the backup area firmware, which may be preset in the first storage space, then obtain the second version information of the backup area firmware stored in the backup area to determine the version number corresponding to the backup area firmware; if the first version information is different from the second version information, that is, it indicates that the version number corresponding to the firmware to be upgraded is different from the version number corresponding to the backup area firmware, then overwrite and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area, so that the backup area firmware remains consistent with the firmware to be upgraded in version; perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0030] The firmware upgrade method, device, and computer storage medium provided by this application will be introduced in detail below with reference to the accompanying drawings.

[0031] Please refer to Figure 2 , Figure 2It is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application. The embedded system is configured with firmware to be upgraded, and the embedded system includes a first storage space and a second storage space. The first storage space includes an upgrade area and a backup area. As Figure 2 shown, the method may include but is not limited to the following steps:

[0032] Step S201: Obtain a firmware upgrade file and store the firmware upgrade file in the upgrade area.

[0033] Specifically, if the embedded system receives a firmware upgrade instruction, it can obtain the firmware upgrade file from the server and temporarily store the firmware upgrade file in the upgrade area of the first storage space.

[0034] Among them, the embedded system can actively trigger the firmware upgrade instruction or generate the firmware upgrade instruction automatically at regular intervals. In one implementation, after receiving the firmware upgrade instruction, the embedded system can establish a connection with the server based on the File Transfer Protocol (FTP). Optionally, the data transfer mode between the embedded system and the server can be an active mode or a passive mode, which is not limited in the embodiments of the present application. In one implementation, a certificate can be pre-imported into the server. After the server and the embedded system establish an FTP connection, if the embedded system passes the certificate verification, it can establish an encrypted FTP connection with the server. Using this method for data transfer is beneficial to improving data security and making the firmware upgrade more secure and reliable.

[0035] In one implementation, the embedded system can receive a configuration file sent by the server. The configuration file includes firmware name information, firmware version information, and firmware download address. The configuration file can be pre-set in the server, and the configuration file information can be remotely updated through the server, improving the flexibility of firmware upgrade. Optionally, the configuration file information can be updated manually or automatically at regular intervals. The embedded system can parse the configuration file to obtain the firmware name information, firmware version information, and firmware download address. The embedded system compares the firmware version information corresponding to the firmware name information obtained by parsing with the firmware version information corresponding to the firmware name information stored locally to determine the name of the firmware to be upgraded. According to the firmware download address corresponding to the name of the firmware to be upgraded, the embedded system can send a firmware upgrade file download request to the server.

[0036] In one implementation, the firmware upgrade file can be split into multiple segmented data. For each segmented data, a Cyclic Redundancy Check (CRC) value can be calculated separately. The server can send each segmented data and the CRC check value corresponding to each segmented data to the embedded system in sequence. The embedded system can perform a check based on the received first segmented data and the check value of the first segmented data. If the check is successful, it indicates that the first segmented data is not damaged. The embedded system can send a segmented data check success message to the server and request the second segmented data and the check value of the second segmented data. If the check fails, it indicates that the first segmented data is damaged. The embedded system can report a segmented data check failure message to the server and immediately terminate the download. Compared with the method of performing the check after downloading all the firmware upgrade file data, through this method, anomalies can be detected in a timely manner during the firmware upgrade file download process, and the download can be terminated, which is beneficial to reducing traffic consumption.

[0037] In one implementation, after the server successfully sends the firmware upgrade file data, it can calculate the check value of the overall firmware upgrade file using the Message-Digest Algorithm 5 (MD5) and send this check value to the embedded system. The embedded system can perform an overall check on the received firmware upgrade file data based on the received overall check value of the firmware upgrade file. If the check is successful, it indicates that the firmware upgrade file is not damaged. The embedded system can send a firmware upgrade file check success message to the server and can also send a firmware upgrade file download success message to the user. If the check fails, it indicates that the firmware upgrade file is damaged. The embedded system can report a firmware upgrade file check failure message to the server and can also send a firmware upgrade file download failure message to the user. Through this method, it is beneficial to improve the reliability of the firmware upgrade file download.

[0038] In an embodiment of the present application, after the embedded system obtains the firmware upgrade file, it can be stored in the upgrade area of the first storage space. This upgrade area can be pre-set in the first storage space to facilitate subsequent invocation of the firmware upgrade file to upgrade the firmware to be upgraded.

[0039] Step S202: Obtain the first version information of the firmware to be upgraded.

[0040] Specifically, before the embedded system invokes the firmware upgrade file to upgrade the firmware to be upgraded, it can obtain the first version information of the firmware to be upgraded and record this first version information.

[0041] In an embodiment of the present application, different versions of firmware correspond to different version numbers. By obtaining the first version information of the firmware to be upgraded, the version number corresponding to the firmware to be upgraded can be determined.

[0042] Step S203: If the backup area is not empty, obtain the second version information of the backup area firmware stored in the backup area.

[0043] Specifically, the embedded system can detect whether the backup area is empty. The backup area can be preset in the first storage space. If the backup area is not empty, the embedded system can obtain the second version information of the backup area firmware stored in the backup area and record the second version information.

[0044] In one implementation, the backup area can be one of multiple backup partitions preset in the first storage space, where one firmware name corresponds to one backup partition. If the backup area is one of the multiple backup partitions preset in the first storage space, the backup area is the backup partition corresponding to the firmware name of the firmware to be upgraded.

[0045] In one implementation, the embedded system can detect the backup area before upgrading the firmware to be upgraded, or can detect the backup area regularly. In one implementation, the instruction for the embedded system to detect the backup area can be triggered by the user, or can be generated automatically by the embedded system at a preset time interval. The embodiments of the present application do not limit this.

[0046] In one implementation, if the detection result of the backup area is not empty, it indicates that the backup area firmware of the firmware to be upgraded is stored in the backup area, and the second version information of the backup area firmware can be obtained to determine the version number of the backup area firmware.

[0047] Step S204: If the first version information is different from the second version information, overwrite and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area.

[0048] Specifically, the embedded system can compare the first version information corresponding to the firmware to be upgraded with the second version information corresponding to the firmware in the backup area. If the first version information corresponding to the firmware to be upgraded is the same as the second version information corresponding to the firmware in the backup area, it indicates that the version number corresponding to the firmware to be upgraded is the same as the version number corresponding to the firmware in the backup area of the firmware to be upgraded, and it means that the firmware in the backup area stored in the backup area is the current version of the firmware to be upgraded. Then, the backup area retains the storage of the firmware in the backup area corresponding to the second version information. If the first version information corresponding to the firmware to be upgraded is different from the second version information corresponding to the firmware in the backup area, it indicates that the version number corresponding to the firmware to be upgraded is different from the version number corresponding to the firmware in the backup area of the firmware to be upgraded, and it means that the firmware in the backup area stored in the backup area is not the current version of the firmware to be upgraded. Then, the firmware indicated by the first version information corresponding to the firmware to be upgraded is stored in the backup area by overwriting, that is, the firmware in the backup area corresponding to the second version information is deleted, and the firmware indicated by the first version information corresponding to the firmware to be upgraded is stored in the backup area. By this means, the firmware in the backup area can be kept consistent with the version of the firmware to be upgraded. When the upgrade of the firmware to be upgraded fails, the firmware in the backup area can be called in time to restore the normal operation of the embedded system.

[0049] Step S205: Perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0050] Specifically, after determining that the firmware in the backup area stored in the backup area has the same version number as the firmware to be upgraded, perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0051] In one implementation, before the embedded system performs a storage operation on the second storage space, it can also detect whether the second storage space is empty. If it is not empty, clear the data in the second storage space. By this means, it can be ensured that there is no interference from other data when the firmware upgrade file in the upgrade area is copied to the second storage space to upgrade the firmware to be upgraded, and the stability of the firmware upgrade is improved.

[0052] By implementing the embodiments of the present application, when the first version information corresponding to the firmware to be upgraded is different from the second version information corresponding to the firmware in the backup area, the firmware indicated by the first version information corresponding to the firmware to be upgraded is stored in the backup area by overwriting, and then the firmware upgrade file in the upgrade area is copied to the second storage space to upgrade the firmware to be upgraded. If a sudden power-off or firmware abnormality occurs during the upgrade process, the firmware in the backup area can be called to ensure the normal operation of the embedded system. By this means, the risk of the embedded system crashing or the system collapsing can be avoided.

[0053] Please refer to Figure 3a , Figure 3a which is a schematic flowchart of another firmware upgrade method provided by an embodiment of the present application. The embedded system is configured with a firmware to be upgraded, and the embedded system includes a first storage space and a second storage space. The first storage space includes an upgrade area and a backup area. Specifically, as Figure 3a shown, another firmware upgrade method of an embodiment of the present application may include but is not limited to the following steps:

[0054] S301: Obtain a firmware upgrade file and store the firmware upgrade file in the upgrade area.

[0055] S302: Obtain the first version information of the firmware to be upgraded.

[0056] In an embodiment of the present application, the execution processes of steps S301 and S302 can be respectively referred to the specific descriptions of steps S201 and S202 in Figure 2 and will not be elaborated here.

[0057] S303: Detect whether the backup area is empty.

[0058] Specifically, the purpose of the embedded system to detect whether the backup area is empty is to determine whether a backup operation needs to be performed. The backup area can be preset in the first storage space. If the backup area is empty, it means that a backup operation needs to be performed; if the backup area is not empty, the second version information of the backup area firmware stored in the backup area can be obtained. If the first version information of the firmware to be upgraded is different from the second version information of the backup area firmware, a backup operation also needs to be performed; if the first version information of the firmware to be upgraded is the same as the second version information of the backup area firmware, it means that a backup operation does not need to be performed.

[0059] S304: If the backup area is empty, store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area.

[0060] Specifically, if the backup area is empty, that is, it means that a backup operation needs to be performed. The embedded system can store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area. That is, the firmware indicated by the first version information corresponding to the firmware to be upgraded is determined as the backup area firmware. By this way, recovery ability can be provided for the firmware upgrade process.

[0061] S305: If the backup area is not empty, obtain the second version information of the backup area firmware stored in the backup area.

[0062] Specifically, if the backup area is not empty, the second version information of the backup area firmware stored in the backup area can be obtained and the second version information can be recorded. By obtaining the second version information of the backup area firmware stored in the backup area, the version number of the backup area firmware can be determined.

[0063] S306: If the first version information is different from the second version information, the firmware indicated by the first version information corresponding to the firmware to be upgraded is overwritten and stored in the backup area.

[0064] Specifically, the embedded system can compare the first version information corresponding to the firmware to be upgraded with the second version information corresponding to the backup area firmware. If the first version information is different from the second version information, it indicates that the version number corresponding to the firmware to be upgraded is different from the version number corresponding to the backup area firmware of the firmware to be upgraded, indicating that the backup area firmware stored in the backup area is not the current version of the firmware to be upgraded. Then, a backup operation needs to be performed. The embedded system can overwrite and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area, that is, delete the backup area firmware corresponding to the second version information and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area. If the first version information corresponding to the firmware to be upgraded is the same as the second version information corresponding to the backup area firmware, it indicates that the version number corresponding to the firmware to be upgraded is the same as the version number corresponding to the backup area firmware of the firmware to be upgraded, indicating that the backup area firmware stored in the backup area is the current version of the firmware to be upgraded. Then, no backup operation needs to be performed, and the backup area of the embedded system will retain the storage of the backup area firmware corresponding to the second version information. In this way, the backup area firmware can be kept consistent with the version of the firmware to be upgraded. When the upgrade of the firmware to be upgraded fails, the backup area firmware can be called in time to restore the normal operation of the embedded system.

[0065] S307: Determine whether the second storage space is empty.

[0066] In the embodiment of the present application, before the embedded system performs a storage operation on the second storage space, it can be determined whether the second storage space is empty. If the second storage space is empty, it indicates that there is no data stored in the second storage space. If the second storage space is not empty, it indicates that there are other data stored in the second storage space.

[0067] S308: If the second storage space is not empty, clear the data in the second storage space to facilitate performing a storage operation on the second storage space.

[0068] Specifically, before the embedded system performs a storage operation on the second storage space, if the second storage space is not empty, clear the data in the second storage space, that is, delete the data in the second storage space. In this way, interference from other data can be avoided when the embedded system performs a storage operation on the second storage space.

[0069] S309: If the second storage space is empty, perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0070] Specifically, if the second storage space is empty, it indicates that there is no stored data in the second storage space. The embedded system can perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, that is, copy the firmware upgrade file in the upgrade area to the second storage space for running, so as to upgrade the firmware to be upgraded.

[0071] It can be seen that by implementing Figure 3a the described firmware upgrade method, when the backup area is empty and the firmware in the backup area is inconsistent with the version of the firmware to be upgraded, a backup operation can be performed in a timely manner to ensure that the backup area stores the backup area firmware consistent with the version of the firmware to be upgraded, providing the recovery ability during the firmware upgrade process.

[0072] It should be noted that in the embodiments of the present application, during the firmware upgrade process, it can also be determined whether the embedded system meets the first preset condition. If the embedded system meets the first preset condition, then execute as Figure 3b shown in steps S310 - S311; if the embedded system does not meet the first preset condition, then the steps S310 - S311 as Figure 3b shown can be ignored.

[0073] Please refer to Figure 3b , Figure 3b which is a flowchart of another firmware upgrade method provided by the embodiments of the present application. The embedded system is configured with the firmware to be upgraded, and the embedded system includes a first storage space and a second storage space. The first storage space includes an upgrade area and a backup area. Specifically, as Figure 3b shown, another firmware upgrade method of the embodiments of the present application may include but is not limited to the following steps:

[0074] S310: When the embedded system meets the first preset condition, detect whether the backup area is empty.

[0075] Specifically, the embedded system meeting the first preset condition may indicate that the upgrade of the firmware to be upgraded by the embedded system fails. If the upgrade of the firmware to be upgraded by the embedded system fails, then detect whether the backup area is empty.

[0076] In one implementation, the embedded system satisfying the first preset condition may include any of the following: the power-off of the embedded system causes the failure of upgrading the firmware to be upgraded; or, the abnormality of the firmware to be upgraded causes the failure of upgrading the firmware to be upgraded. Whether the embedded system satisfies the first preset condition can be judged according to the update information of the embedded system, where the update information may be an indication information of power failure during the upgrade process of the embedded system, or an indication information of abnormal firmware upgrade.

[0077] In one implementation, if the embedded system suddenly loses power during the firmware upgrade process, it can generate the first indication information, and the first indication information can be used to indicate that the embedded system satisfies the first preset condition. According to the first indication information, the embedded system can perform an operation of detecting whether the backup area is empty.

[0078] In one implementation, after the embedded system is powered on and starts up, it can detect the firmware to be upgraded. The embedded system can determine whether it satisfies the first preset condition by detecting the identification bit of the firmware to be upgraded. If the status of the identification bit of the firmware to be upgraded is normal, it indicates that the firmware to be upgraded is normal, and the embedded system does not satisfy the first preset condition; if the status of the identification bit of the firmware to be upgraded is abnormal, it indicates that the firmware to be upgraded is abnormal, and then the second indication information can be generated, and the second indication information can be used to indicate that the embedded system satisfies the first preset condition. According to the second indication information, the embedded system can perform an operation of detecting whether the backup area is empty.

[0079] S311: If the backup area is not empty, then according to the firmware in the backup area, a storage operation is performed on the second storage space, so as to store the firmware in the backup area to the second storage space and run the firmware in the backup area.

[0080] In an embodiment of the present application, when the embedded system satisfies the first preset condition, if the backup area is not empty, it indicates that the backup area stores the backup firmware of the firmware to be upgraded, then the backup firmware can be called to perform a storage operation on the second storage space, so as to store the backup firmware to the second storage space and run the backup firmware.

[0081] By implementing the embodiments of the present application, it can be ensured that the backup area stores the backup firmware consistent with the version of the firmware to be upgraded. If sudden power-off or firmware abnormality occurs during the upgrade process, the backup firmware can be called to ensure the normal operation of the embedded system. In this way, the risk of the embedded system crashing or the system collapsing can be avoided.

[0082] Please refer to Figure 4 , Figure 4 which is a schematic flow diagram of obtaining a firmware upgrade file in a firmware upgrade method provided by an embodiment of the present application. As Figure 4As shown, the method may include but is not limited to the following steps:

[0083] S401: Send a download request to the server.

[0084] Specifically, if the embedded system receives a firmware upgrade instruction, it may send a firmware upgrade file download request to the server.

[0085] In one implementation, the embedded system can actively trigger the firmware upgrade instruction or generate the firmware upgrade instruction automatically at regular intervals. In one implementation, after receiving the firmware upgrade instruction, the embedded system can establish an FTP connection with the server based on the File Transfer Protocol. Optionally, the data transfer mode between the embedded system and the server can be the active mode or the passive mode, which is not limited in the embodiments of this application. In one implementation, a certificate can be pre-imported into the server. After the server and the embedded system establish an FTP connection, if the embedded system passes the certificate verification, it can establish an encrypted FTP connection with the server. Using this method for data transfer is beneficial to improving data security and making the firmware upgrade more secure and reliable.

[0086] In one implementation, the server can send a configuration file to the embedded system. The configuration file includes firmware name information, firmware version information, and firmware download address. The configuration file can be pre-set in the server, and the configuration file information can be remotely updated through the server, improving the flexibility of firmware upgrade. Optionally, the configuration file information can be updated manually or automatically by the server at regular intervals. The embedded system can parse the configuration file to obtain the firmware name information, firmware version information, and firmware download address. The embedded system compares the firmware version information corresponding to the firmware name information obtained by parsing with the firmware version information corresponding to the firmware name information stored locally to determine the name of the firmware to be upgraded. According to the firmware download address corresponding to the name of the firmware to be upgraded, the embedded system can send a firmware upgrade file download request to the server.

[0087] S402: Receive the first segmented data sent by the server and the check value of the first segmented data.

[0088] Specifically, the firmware upgrade file can be split into multiple segmented data, and the CRC check value can be calculated for each segmented data. The server can send each segmented data and the CRC check value corresponding to each segmented data to the embedded system in sequence, and the embedded system can receive the first segmented data sent by the server and the check value of the first segmented data.

[0089] S403: Detect whether the verification is successful.

[0090] Specifically, the embedded system can detect whether the verification is successful based on the received first segmented data and the verification value of the first segmented data. If the verification is successful, it indicates that the first segmented data is not damaged. The embedded system can send a message indicating successful verification of the segmented data to the server and request the second segmented data and the verification value of the second segmented data. If the verification fails, it indicates that the first segmented data is damaged. The embedded system can report a message indicating failed verification of the segmented data to the server and immediately end the download.

[0091] S404: Receive the second segmented data and the verification value of the second segmented data.

[0092] Specifically, after the verification of the first segmented data is successful, the embedded system can receive the second segmented data and the verification value of the second segmented data. If the verification of the second segmented data is successful, the embedded system can sequentially receive the next segmented data and the verification value of the next segmented data, and so on in a loop until all the data of the firmware upgrade file is successfully received.

[0093] S405: After successfully receiving the data of the firmware upgrade file, receive the overall verification value of the firmware upgrade file.

[0094] Specifically, after the server successfully sends the data of the firmware upgrade file, it can calculate the MD5 verification value of the overall firmware upgrade file and send this verification value to the embedded system. The embedded system can receive the overall verification value of the firmware upgrade file and perform an overall verification on the data of the firmware upgrade file based on this overall verification value of the firmware upgrade file.

[0095] S406: Detect whether the verification is successful.

[0096] Specifically, the embedded system can perform an overall verification on the received data of the firmware upgrade file based on the overall verification value of the firmware upgrade file received. If the verification is successful, it indicates that the firmware upgrade file is not damaged. The embedded system can store the obtained firmware upgrade file in the upgrade area of the first storage space for subsequent invocation of the firmware upgrade file to upgrade the firmware to be upgraded. If the verification fails, it indicates that the firmware upgrade file is damaged. The embedded system ends the process of obtaining the firmware upgrade file.

[0097] By implementing the embodiments of the present application, anomalies can be detected in a timely manner during the process of obtaining the firmware upgrade file, and the download can be immediately ended, which is beneficial to saving time costs and avoiding waste of unnecessary traffic.

[0098] Please refer to Figure 5 , Figure 5It is a schematic flowchart of another firmware upgrade method provided by an embodiment of the present application. The embedded system is configured with a firmware to be upgraded, and the embedded system includes a first storage space and a second storage space. The first storage space includes an upgrade area and a backup area. Specifically, as Figure 5 shown, the method may include but is not limited to the following steps:

[0099] S501: Determine whether the first preset condition is satisfied.

[0100] Specifically, the embedded system satisfying the first preset condition may include any one of the following: the power-off of the embedded system causes the upgrade of the firmware to be upgraded to fail; or, the firmware to be upgraded is abnormal, resulting in the failure of the upgrade of the firmware to be upgraded. Whether the embedded system satisfies the first preset condition can be determined according to the update information of the embedded system. Among them, the update information may be an indication information of power failure during the upgrade process of the embedded system, or an indication information of abnormal firmware upgrade.

[0101] In one implementation, if there is a power-off situation in the embedded system, the first indication information may be generated, and the first indication information may be used to indicate that the embedded system satisfies the first preset condition. In one implementation, after the embedded system is powered on and started, the firmware to be upgraded can be detected. The embedded system can determine whether the first preset condition is satisfied by detecting the identification bit of the firmware to be upgraded. If the status of the identification bit of the firmware to be upgraded is normal, it indicates that the firmware to be upgraded is normal, and the embedded system does not satisfy the first preset condition; if the status of the identification bit of the firmware to be upgraded is abnormal, it indicates that the firmware to be upgraded is abnormal, and the second indication information may be generated, and the second indication information may be used to indicate that the embedded system satisfies the first preset condition.

[0102] S502: Detect whether the backup area is empty.

[0103] Specifically, in the case where the embedded system does not satisfy the first preset condition, it can be detected whether the backup area is empty. The backup area may be preset in the first storage space. It should be noted that when the embedded system does not satisfy the first preset condition, the purpose of performing the operation of detecting whether the backup area is empty is to determine whether the backup operation needs to be performed

[0104] S503: Store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area.

[0105] Specifically, if the backup area is empty, it means that the backup operation needs to be performed. The embedded system can store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area. That is, the firmware indicated by the first version information corresponding to the firmware to be upgraded is determined as the firmware in the backup area.

[0106] S504: Obtain the second version information of the backup area firmware stored in the backup area.

[0107] Specifically, if the backup area is not empty, the second version information of the backup area firmware stored in the backup area can be obtained and the second version information can be recorded. By obtaining the second version information of the backup area firmware stored in the backup area, the version number of the backup area firmware can be determined.

[0108] S505: If the first version information is different from the second version information, overwrite and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area.

[0109] It should be noted that for the execution process of step S505, refer to Figure 2 the specific description of step S204 in

[0110] S506: Perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0111] It should be noted that for the execution process of step S506, refer to Figure 2 the specific description of step S205 in

[0112] S507: Detect whether the backup area is empty.

[0113] Specifically, under the condition that the embedded system meets the first preset condition, it can be detected whether the backup area is empty, and the backup area can be preset in the first storage space. It should be noted that when the embedded system meets the first preset condition, the purpose of performing the operation of detecting whether the backup area is empty is to determine whether there is a callable backup area firmware stored in the backup area.

[0114] S508: Perform a storage operation on the second storage space according to the backup area firmware, so as to store the backup area firmware in the second storage space and run the backup area firmware.

[0115] Specifically, if the backup area is not empty, that is, it indicates that there is a callable backup area firmware stored in the backup area, then a storage operation can be performed on the second storage space according to the backup area firmware, so as to store the backup area firmware in the second storage space and run the backup area firmware.

[0116] In one implementation, before the embedded system performs a storage operation on the second storage space, it can also detect whether the second storage space is empty. If it is not empty, the data in the second storage space is cleared. In this way, it can be ensured that there is no interference from other data when the backup area firmware is stored in the second storage space and the backup area firmware is run.

[0117] It should be noted that the purpose of starting the device after step S506 is to run the to-be-upgraded firmware that has completed the upgrade; the purpose of starting the device after step S508 is to run the backup area firmware to restore the normal operation of the embedded system.

[0118] By implementing the embodiments of the present application, when the embedded system does not meet the first preset condition, the to-be-upgraded firmware can be backed up in a timely manner, and when the embedded system meets the first preset condition, the backup area firmware can be called to ensure the normal operation of the embedded system. In this way, the risk of the embedded system crashing or the system collapsing can be avoided.

[0119] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a firmware upgrade device provided by the embodiments of the present application. Specifically, as Figure 6 shown, the firmware upgrade device 60 may include:

[0120] A receiving unit 601, configured to obtain a firmware upgrade file and store the firmware upgrade file in the upgrade area.

[0121] A processing unit 602, configured to obtain the first version information of the to-be-upgraded firmware; if the backup area is not empty, obtain the second version information of the backup area firmware stored in the backup area; if the first version information is different from the second version information, overwrite and store the firmware indicated by the first version information corresponding to the to-be-upgraded firmware in the backup area; perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the to-be-upgraded firmware.

[0122] In one implementation, the firmware upgrade device 60 may further include a sending unit 603, configured to send a download request to a server; the receiving unit 601 may further be configured to receive the first segmented data sent by the server and the first check value of the first segmented data; wherein, the first segmented data is split from the firmware upgrade file; the processing unit 602 may further be configured to check the first segmented data according to the first check value, and after determining that the check is successful, request the second segmented data and the second check value of the second segmented data, and the second segmented data is also split from the firmware upgrade file.

[0123] In one implementation, the receiving unit 601 may further be configured to receive the overall check value of the firmware upgrade file after successfully receiving the data of the firmware upgrade file; the processing unit 602 may further be configured to verify the firmware upgrade file according to the overall check value, and perform a successful verification process after the verification is successful.

[0124] In one implementation, the processing unit 602 may further be configured to, after obtaining the first version information of the firmware to be upgraded, store the firmware indicated by the first version information of the firmware to be upgraded in the backup area if the backup area is empty.

[0125] In one implementation, the processing unit 602 may further be configured to detect whether the backup area is empty when the firmware upgrade device 60 meets a first preset condition; if the backup area is not empty, perform a storage operation on the second storage space according to the firmware in the backup area, so as to store the firmware in the backup area in the second storage space and run the firmware in the backup area.

[0126] In one implementation, the firmware upgrade device 60 meeting the first preset condition may include any one of the following: the firmware upgrade of the firmware to be upgraded fails due to the power-off of the firmware upgrade device 60; the firmware upgrade of the firmware to be upgraded fails due to the abnormality of the firmware to be upgraded.

[0127] In one implementation, before performing the storage operation on the second storage space, the processing unit 602 may further be configured to determine whether the second storage space is empty; if not, clear the data in the second storage space, so as to perform the storage operation on the second storage space.

[0128] The embodiments of the present application and Figures 2 - 5 The method embodiments shown are based on the same concept and have the same technical effects. For the specific principle, please refer to Figures 2 - 5 the description of the embodiments shown, which will not be elaborated here.

[0129] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an intelligent device provided by an embodiment of the present application. Specifically, as Figure 7 shown, the intelligent device 70 may include a receiver 701, a transmitter 702, a memory 703, and a processor 704. The receiver 701, the transmitter 702, the memory 703, and the processor 704 are connected through one or more communication buses.

[0130] The receiver 701 may be configured to receive data. For example, the receiver 701 may be configured to receive a firmware upgrade file. The transmitter 702 may be configured to send data. For example, the transmitter 702 may be configured to send a download request.

[0131] The memory 703 may include a read-only memory and a random access memory, and provide instructions and data to the processor 704. A part of the memory 703 may also include a non-volatile random access memory. The memory 703 may also be divided into a first storage space and a second storage space. Among them, the first storage space may be a flash memory, such as NOR Flash or NAND Flash, and the second storage space may be a random access memory (RAM), such as a dynamic random access memory (DRAM) or a static random access memory (SRAM).

[0132] The processor 704 may be a central processing unit (CPU), and the processor 704 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor. Optionally, the processor 704 may also be any conventional processor, etc. Among them:

[0133] The memory 703 is used to store program instructions.

[0134] The processor 704 is used to call the program instructions stored in the memory 703 for:

[0135] Obtain a firmware upgrade file and store the firmware upgrade file in the upgrade area;

[0136] Obtain the first version information of the firmware to be upgraded;

[0137] If the backup area is not empty, obtain the second version information of the backup area firmware stored in the backup area;

[0138] If the first version information is different from the second version information, overwrite and store the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area;

[0139] Perform a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded.

[0140] In one implementation, the processor 704 can also be used to send a download request to the server; receive the first segmented data sent by the server and the first check value of the first segmented data; wherein, the first segmented data is split from the firmware upgrade file; verify the first segmented data according to the first check value, and after determining that the verification is successful, request the second segmented data and the second check value of the second segmented data, and the second segmented data is also split from the firmware upgrade file.

[0141] In one implementation, the processor 704 can also be used to receive the overall check value of the firmware upgrade file after successfully receiving the data of the firmware upgrade file; verify the firmware upgrade file according to the overall check value, and perform a successful verification process after the verification is successful.

[0142] In one implementation, the processor 704 can also be used to store the firmware indicated by the first version information of the firmware to be upgraded in the backup area after obtaining the first version information of the firmware to be upgraded, if the backup area is empty.

[0143] In one implementation, the processor 704 can also be used to detect whether the backup area is empty when the intelligent device 70 meets the first preset condition; if the backup area is not empty, perform a storage operation on the second storage space according to the firmware in the backup area, so as to store the firmware in the backup area in the second storage space and run the firmware in the backup area.

[0144] In one implementation, the intelligent device 70 meeting the first preset condition can include any one of the following: the upgrade of the firmware to be upgraded fails due to the power-off of the intelligent device 70; the upgrade of the firmware to be upgraded fails due to the abnormality of the firmware to be upgraded.

[0145] In one implementation, before performing the storage operation on the second storage space, the processor 704 can also be used to determine whether the second storage space is empty; if it is not empty, clear the data in the second storage space, so as to perform the storage operation on the second storage space.

[0146] It should be noted that Figure 7 For the content not mentioned in the corresponding embodiments and the specific implementation manners of each step, reference can be made to Figures 2 - 5 the embodiments shown and the foregoing content, which will not be elaborated here.

[0147] The embodiment of the present application also provides a computer-readable storage medium, and the computer storage medium stores a computer program, which when run by a processor, causes the processor to execute the steps performed in the method embodiment as Figures 2 - 5 shown.

[0148] The above disclosure only shows some embodiments of the present application. Of course, it cannot be used to limit the scope of rights of the present application. Those of ordinary skill in the art can understand all or part of the processes of implementing the above embodiments, and the equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.

Claims

1. A firmware upgrade method, characterized in that: The method is applied to an embedded system, wherein the embedded system is configured with firmware to be upgraded, and the embedded system includes a first storage space and a second storage space, wherein the first storage space includes an upgrade area and a backup area, and the method includes: Send a download request to the server; Receive first segmented data and a first check value of the first segmented data sent by the server; wherein the first segmented data is split from a firmware upgrade file; Verifying the first segmented data according to the first check value, and requesting the second segmented data and the second check value of the second segmented data after determining that the verification is successful, and repeating the process until the data of the firmware upgrade file is successfully received; wherein the second segmented data is also split from the firmware upgrade file; Storing the firmware upgrade file in the upgrade area; Obtaining first version information of the firmware to be upgraded; Determining whether the embedded system meets a first preset condition according to the update information of the embedded system; In the case that the embedded system does not meet the first preset condition, detecting whether the backup area is empty; wherein, when the embedded system does not meet the first preset condition, it indicates that the firmware to be upgraded in the embedded system is in a normal state; If the backup area is empty, storing the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area; If the backup area is not empty, obtaining the second version information of the backup area firmware stored in the backup area; If the first version information is different from the second version information, overwriting and storing the firmware indicated by the first version information corresponding to the firmware to be upgraded in the backup area; performing a storage operation on the second storage space according to the firmware upgrade file in the upgrade area, so as to copy the firmware upgrade file in the upgrade area to the second storage space to upgrade the firmware to be upgraded; In the case where the embedded system meets a first preset condition, detecting whether the backup area is empty; If the backup area is not empty, a storage operation is performed on the second storage space according to the backup area firmware, so as to store the backup area firmware in the second storage space and run the backup area firmware.

2. The method according to claim 1, characterized in that The method further comprises: After successfully receiving the data of the firmware upgrade file, receiving the overall checksum of the firmware upgrade file; The firmware upgrade file is verified according to the overall verification value, and verification success processing is performed after the verification is successful.

3. The method according to claim 1, characterized in that The embedded system satisfies the first preset condition including any one of the following: The embedded system is powered off, causing the firmware to be upgraded to fail to be upgraded; The firmware to be upgraded is abnormal, resulting in upgrade failure of the firmware to be upgraded.

4. The method according to any one of claims 1 to 3, characterized in that Before performing the storage operation on the second storage space, the method further includes: determining whether the second storage space is empty; If it is not empty, the data in the second storage space is cleared to facilitate the execution of the storage operation on the second storage space.

5. A firmware upgrade device, characterized in that: The apparatus comprises a unit for executing the method according to any one of claims 1 to 4.

6. A smart device, characterized in that: The method comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor is configured to run the computer program to execute the method according to any one of claims 1 to 4.

7. A computer storage medium, characterized in that The computer storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Firmware upgrade method device

    CN105653299A

  • A method and apparatus for firmware upgrade

    CN109189451A