Embedded device upgrade and rollback method and system

By dividing specific storage areas and modules in embedded devices and using BOOT programs for upgrade file checksum backup, the problem of insufficient convenience and security in the upgrade and retrieval process of embedded devices is solved, and the stable upgrade and retrieval operation of the device is achieved.

CN119759404APending Publication Date: 2025-04-04FUJIAN NEBULA ELECTRONICS CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411702432.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Existing embedded devices lack convenience and security during the upgrade and retrieval process, which can easily lead to the equipment becoming bricked and the user data being lost.

Method used

By dividing the MCU storage area of ​​the embedded device into a BOOT area, an application area, a firmware storage area, an application backup area and an upgrade parameter storage area, and setting the factory firmware storage area in the external FLASH, the BOOT program performs legality and integrity verification of the upgrade file, backup the application and perform upgrade operations. The trigger signal of hardware IO is used to perform a back operation, and the number of system resets is recorded and the back is automatically performed.

Benefits of technology

It realizes the convenience and security of upgrade and retrieval of embedded equipment, avoids equipment bricking and user data loss, and improves the stability of operation and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759404A_ABST
    Figure CN119759404A_ABST
Patent Text Reader

Abstract

The present invention provides an embedded device upgrade rollback method and system in the field of embedded device upgrade management technology, the method comprising: step S1, dividing the storage area of ​​MCU into BOOT area, application area, firmware storage area, application backup area, upgrade parameter storage area, and setting the factory firmware storage area in the external FLASH; step S2, the BOOT program stores the upgrade file in the firmware storage area after performing a legality check on the upgrade file, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade file; step S3, the BOOT program reads the upgrade file based on the upgrade parameter and performs an integrity check, then backs up the application stored in the application area to the application backup area, and performs the upgrade based on the upgrade file; step S4, based on the trigger signal of hardware IO, reads the backed-up application from the application backup area to perform a rollback operation, or reads the stored factory firmware from the factory firmware storage area to perform rollback. The advantages of the present invention are: greatly improving the convenience and security of embedded device upgrade rollback.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of embedded device upgrade management, and in particular to an embedded device upgrade rollback method and system. Background Art

[0002] Upgrade rollback and hardware anti-bricking of embedded devices play a key role in the life cycle management of devices. Upgrade rollback is the process of downgrading the software version of an embedded device from the current version to the previous version. This is usually performed when there are problems with the new version of the software or it is incompatible with the existing hardware. If it is not performed correctly, it may cause the embedded device to not work properly (the device becomes bricked). Hardware anti-bricking is a technology that prevents embedded devices from becoming bricked (unable to start or run normally, usually caused by firmware or hardware problems) during upgrades, rollbacks, or other operations. It usually involves creating and restoring backups on embedded devices and using special recovery modes to fix possible problems.

[0003] Traditionally, after an embedded device is upgraded, if there is software compatibility or bug, the host computer needs to intervene to roll back the file. If the device becomes bricked during the upgrade, it needs to be returned to the factory for repair, which is very inconvenient and brings a lot of trouble to the operation and maintenance of the embedded device. User data may also be lost.

[0004] Therefore, how to provide an embedded device upgrade and rollback method and system to improve the convenience and security of embedded device upgrade and rollback has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a method and system for upgrading and rolling back an embedded device, so as to improve the convenience and security of upgrading and rolling back an embedded device.

[0006] In a first aspect, the present invention provides a method for upgrading and rolling back an embedded device, comprising the following steps:

[0007] Step S1, dividing the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area, a firmware storage area, an application backup area, and an upgrade parameter storage area, and setting a factory firmware storage area for storing the factory firmware in an external FLASH;

[0008] Step S2, after the BOOT program verifies the legitimacy of the upgrade file obtained by the embedded device, the upgrade file is stored in the firmware storage area, and the upgrade parameters of the upgrade parameter storage area are set based on the upgrade file;

[0009] Step S3, the BOOT program reads the upgrade file from the firmware storage area based on the upgrade parameters, performs integrity check on the upgrade file, backs up the application stored in the application area to the application backup area, and performs the upgrade operation based on the read upgrade file;

[0010] Step S4: Based on the trigger signal of the hardware IO, the backed-up application is read from the application backup area to perform a rollback operation, or the factory firmware stored in the factory firmware storage area is read to perform a rollback operation;

[0011] Step S5: The BOOT program records the number of system resets, and automatically performs a rollback operation based on the number of system resets.

[0012] Furthermore, in step S1, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform a rollback operation, and automatically start when the embedded device is powered on;

[0013] The application area is used to install applications and store user data during the operation of applications;

[0014] The firmware storage area is used to store upgrade files;

[0015] The application backup area is used to back up applications in the application area;

[0016] The upgrade parameter storage area is used to store upgrade parameters and adopts an EEPROM chip.

[0017] Furthermore, the step S2 is specifically as follows: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to verify the legitimacy of the upgrade file, and then stores the upgrade file after the legitimacy verification in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag, and storage address in the firmware storage area carried by the upgrade file.

[0018] Furthermore, the step S3 is specifically as follows:

[0019] The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

[0020] Furthermore, the step S4 is specifically as follows:

[0021] The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation.

[0022] The step S5 is specifically as follows:

[0023] The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold;

[0024] The BOOT program records the number of system resets in real time through a watchdog counter. If no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; if the number of system resets is greater than a preset number threshold within the first time threshold, a rollback operation is automatically performed to clear the number of system resets.

[0025] In a second aspect, the present invention provides an embedded device upgrade and rollback system, comprising the following modules:

[0026] The storage area division module is used to divide the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area, a firmware storage area, an application backup area and an upgrade parameter storage area, and set a factory firmware storage area in the external FLASH for storing the factory firmware;

[0027] An upgrade file storage module, used for storing the upgrade file obtained by the embedded device in the firmware storage area after the BOOT program verifies the legitimacy of the upgrade file, and setting the upgrade parameters of the upgrade parameter storage area based on the upgrade file;

[0028] An upgrade operation module, used for the BOOT program to read the upgrade file from the firmware storage area based on the upgrade parameters, perform integrity check on the upgrade file, back up the application stored in the application area to the application backup area, and perform the upgrade operation based on the read upgrade file;

[0029] A rollback operation module, configured to read the backed-up application from the application backup area to perform a rollback operation, or read the stored factory firmware from the factory firmware storage area to perform a rollback operation based on a trigger signal of the hardware IO;

[0030] The system reset monitoring module is used for the BOOT program to record the number of system resets and automatically perform a rollback operation based on the number of system resets.

[0031] Furthermore, in the storage area partitioning module, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform the rollback operation, and automatically start when the embedded device is powered on;

[0032] The application area is used to install applications and store user data during the operation of applications;

[0033] The firmware storage area is used to store upgrade files;

[0034] The application backup area is used to back up applications in the application area;

[0035] The upgrade parameter storage area is used to store upgrade parameters and adopts an EEPROM chip.

[0036] Furthermore, the upgrade file storage module is specifically used for: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to perform a legitimacy check on the upgrade file, and then stores the upgrade file after the legitimacy check in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag, and storage address in the firmware storage area carried by the upgrade file.

[0037] Furthermore, the upgrade operation module is specifically used for:

[0038] The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

[0039] Furthermore, the rollback operation module is specifically used for:

[0040] The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation.

[0041] The system reset monitoring module is specifically used for:

[0042] The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold;

[0043] The BOOT program records the number of system resets in real time through a watchdog counter. If no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; if the number of system resets is greater than a preset number threshold within the first time threshold, a rollback operation is automatically performed to clear the number of system resets.

[0044] The advantages of the present invention are:

[0045] 1. By dividing the storage area of ​​the MCU of the embedded device into the BOOT area, application area, firmware storage area, application backup area and upgrade parameter storage area for running the BOOT program, the factory firmware storage area for storing the factory firmware is set in the external FLASH; the BOOT program verifies the legitimacy of the upgrade file obtained by the embedded device and stores it in the firmware storage area, sets the upgrade parameters of the upgrade parameter storage area based on the upgrade file, reads the upgrade file from the firmware storage area based on the upgrade parameters, and backs up the application stored in the application area to the application backup area after performing integrity verification on the upgrade file, and performs the upgrade operation based on the read upgrade file; based on the trigger signal of the hardware IO, the BOOT program reads the backed up application from the application backup area to perform the rollback operation, or reads the backed up application from the factory firmware storage area The factory firmware stored in the storage area is read to perform a rollback operation, and the number of system resets is recorded, and the rollback operation is automatically performed based on the number of system resets; that is, the application is backed up by setting the application backup area, and the factory firmware storage area is set to store the factory firmware. When an exception occurs during the upgrade operation based on the upgrade file, the rollback operation can be performed based on the application backed up in the application backup area, or based on the factory firmware stored in the factory firmware storage area. If the embedded device becomes bricked, the factory firmware can be read from the factory firmware storage area based on the trigger signal of the hardware IO to perform a rollback operation. There is no need for the intervention of the host computer or return to the factory for repair as traditionally done. The backup of the application in the application backup area avoids the loss of user data as much as possible, which ultimately greatly improves the convenience and security of the embedded device upgrade rollback.

[0046] 2. The watchdog counter records the number of system resets in real time, and automatically performs rollback operations based on the number of system resets, which greatly ensures the stability of embedded device operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0048] Figure 1 The present invention is a flowchart of an embedded device upgrade and rollback method.

[0049] Figure 2 It is a structural schematic diagram of an embedded device upgrade and rollback system of the present invention. DETAILED DESCRIPTION

[0050] The technical solution in the embodiments of the present application has the following overall idea: backing up applications by setting an application backup area, and storing factory firmware by setting a factory firmware storage area. When an exception occurs when performing an upgrade operation based on an upgrade file, a rollback operation can be performed based on the application backed up in the application backup area, or based on the factory firmware stored in the factory firmware storage area. If the embedded device becomes bricked, the factory firmware can also be read from the factory firmware storage area based on the trigger signal of the hardware IO to perform a rollback operation. There is no need for the intervention of the host computer or return to the factory for repair as traditionally done. In addition, backing up the application in the application backup area avoids user data loss as much as possible, so as to improve the convenience and security of upgrading and rolling back the embedded device.

[0051] Please refer to Figure 1 to Figure 2 As shown, a preferred embodiment of an embedded device upgrade and rollback method of the present invention includes the following steps:

[0052] Step S1, dividing the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area (APP area), a firmware storage area, an application backup area, and an upgrade parameter storage area, and setting a factory firmware storage area for storing the factory firmware in the external FLASH; in specific implementation, the storage space of the firmware storage area can be subdivided; during the upgrade process of the embedded device, no information of the factory firmware storage area is displayed. In the case of a brick after the upgrade, after the embedded device is powered on, a specific action is triggered by using external hardware IO to read the factory firmware from the factory firmware storage area to perform a rollback operation;

[0053] Step S2, after the BOOT program verifies the legitimacy of the upgrade file obtained by the embedded device, the upgrade file is stored in the firmware storage area, and the upgrade parameters of the upgrade parameter storage area are set based on the upgrade file;

[0054] The upgrade file at least carries a file header, an upgrade source file, an upgrade flag, a rollback flag, a storage address, a signature, and a hash value;

[0055] Step S3, the BOOT program reads the upgrade file from the firmware storage area based on the upgrade parameters, performs integrity check on the upgrade file, backs up the application stored in the application area to the application backup area, and performs the upgrade operation based on the read upgrade file; during the upgrade process, the upgrade progress is updated in real time to the upgrade parameter storage area;

[0056] Step S4: Based on the trigger signal of the hardware IO, the backed-up application is read from the application backup area to perform a rollback operation, or the factory firmware stored in the factory firmware storage area is read from the factory firmware storage area to perform a rollback operation; during the rollback process, the rollback flag in the upgrade parameter storage area is updated;

[0057] Step S5: The BOOT program records the number of system resets, and automatically performs a rollback operation based on the number of system resets.

[0058] In step S1, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform rollback operations, and automatically start when the embedded device is powered on;

[0059] The application area is used to install applications and store user data during the operation of applications;

[0060] The firmware storage area is used to store upgrade files;

[0061] The application backup area is used to back up applications in the application area;

[0062] The upgrade parameter storage area is used to store upgrade parameters, and adopts an EEPROM chip, so that data will not be lost even if the power is off.

[0063] The specific steps of step S2 are as follows: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to verify the legitimacy of the upgrade file, and then stores the upgrade file after the legitimacy verification in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag and storage address in the firmware storage area carried by the upgrade file.

[0064] The step S3 is specifically as follows:

[0065] The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

[0066] The step S4 is specifically as follows:

[0067] The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation.

[0068] For example, if the trigger duration is between 5-20 seconds, the backed-up application is preferentially read from the application backup area to perform a rollback operation; if the trigger duration is longer than 20 seconds, the stored factory firmware is read from the factory firmware storage area to perform a rollback operation.

[0069] The step S5 is specifically as follows:

[0070] The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold;

[0071] The BOOT program records the number of system resets in real time through a watchdog counter, that is, the count is increased by 1 for each reset. If no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; if the number of system resets is greater than the preset number threshold within the first time threshold, the rollback operation is automatically executed to clear the number of system resets.

[0072] A preferred embodiment of an embedded device upgrade and rollback system of the present invention includes the following modules:

[0073] The storage area division module is used to divide the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area (APP area), a firmware storage area, an application backup area, and an upgrade parameter storage area, and set a factory firmware storage area for storing the factory firmware in the external FLASH; in specific implementation, the storage space of the firmware storage area can be subdivided; during the upgrade process of the embedded device, no information of the factory firmware storage area is displayed. In the case of a brick after the upgrade, after the embedded device is powered on, a specific action is triggered by using external hardware IO to read the factory firmware from the factory firmware storage area to perform a rollback operation;

[0074] An upgrade file storage module, used for storing the upgrade file obtained by the embedded device in the firmware storage area after the BOOT program verifies the legitimacy of the upgrade file, and setting the upgrade parameters of the upgrade parameter storage area based on the upgrade file;

[0075] The upgrade file at least carries a file header, an upgrade source file, an upgrade flag, a rollback flag, a storage address, a signature, and a hash value;

[0076] An upgrade operation module, used for the BOOT program to read the upgrade file from the firmware storage area based on the upgrade parameters, back up the application stored in the application area to the application backup area after performing integrity check on the upgrade file, and perform the upgrade operation based on the read upgrade file; during the upgrade process, the upgrade progress is updated in real time to the upgrade parameter storage area;

[0077] A rollback operation module, configured to read the backed-up application from the application backup area to perform a rollback operation, or read the stored factory firmware from the factory firmware storage area to perform a rollback operation based on a trigger signal of the hardware IO; and update the rollback flag in the upgrade parameter storage area during the rollback process;

[0078] The system reset monitoring module is used for the BOOT program to record the number of system resets and automatically perform a rollback operation based on the number of system resets.

[0079] In the storage area partitioning module, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform rollback operations, and automatically start when the embedded device is powered on;

[0080] The application area is used to install applications and store user data during the operation of applications;

[0081] The firmware storage area is used to store upgrade files;

[0082] The application backup area is used to back up applications in the application area;

[0083] The upgrade parameter storage area is used to store upgrade parameters, and adopts an EEPROM chip, so that data will not be lost even if the power is off.

[0084] The upgrade file storage module is specifically used for: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to verify the legitimacy of the upgrade file, and then stores the upgrade file after the legitimacy verification in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag and storage address in the firmware storage area carried by the upgrade file.

[0085] The upgrade operation module is specifically used for:

[0086] The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

[0087] The rollback operation module is specifically used for:

[0088] The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation.

[0089] For example, if the trigger duration is between 5-20 seconds, the backed-up application is preferentially read from the application backup area to perform a rollback operation; if the trigger duration is longer than 20 seconds, the stored factory firmware is read from the factory firmware storage area to perform a rollback operation.

[0090] The system reset monitoring module is specifically used for:

[0091] The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold;

[0092] The BOOT program records the number of system resets in real time through a watchdog counter, that is, the count is increased by 1 for each reset. If no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; if the number of system resets is greater than the preset number threshold within the first time threshold, the rollback operation is automatically executed to clear the number of system resets.

[0093] In summary, the advantages of the present invention are:

[0094] 1. By dividing the storage area of ​​the MCU of the embedded device into the BOOT area, application area, firmware storage area, application backup area and upgrade parameter storage area for running the BOOT program, the factory firmware storage area for storing the factory firmware is set in the external FLASH; the BOOT program verifies the legitimacy of the upgrade file obtained by the embedded device and stores it in the firmware storage area, sets the upgrade parameters of the upgrade parameter storage area based on the upgrade file, reads the upgrade file from the firmware storage area based on the upgrade parameters, and backs up the application stored in the application area to the application backup area after performing integrity verification on the upgrade file, and performs the upgrade operation based on the read upgrade file; based on the trigger signal of the hardware IO, the BOOT program reads the backed up application from the application backup area to perform the rollback operation, or reads the backed up application from the factory firmware storage area The factory firmware stored in the storage area is read to perform a rollback operation, and the number of system resets is recorded, and the rollback operation is automatically performed based on the number of system resets; that is, the application is backed up by setting the application backup area, and the factory firmware storage area is set to store the factory firmware. When an exception occurs during the upgrade operation based on the upgrade file, the rollback operation can be performed based on the application backed up in the application backup area, or based on the factory firmware stored in the factory firmware storage area. If the embedded device becomes bricked, the factory firmware can be read from the factory firmware storage area based on the trigger signal of the hardware IO to perform a rollback operation. There is no need for the intervention of the host computer or return to the factory for repair as traditionally done. The backup of the application in the application backup area avoids the loss of user data as much as possible, which ultimately greatly improves the convenience and security of the embedded device upgrade rollback.

[0095] 2. The watchdog counter records the number of system resets in real time, and automatically performs rollback operations based on the number of system resets, which greatly ensures the stability of embedded device operation.

[0096] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A method for upgrading and rolling back an embedded device, characterized in that: The steps include: Step S1, dividing the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area, a firmware storage area, an application backup area, and an upgrade parameter storage area, and setting a factory firmware storage area for storing the factory firmware in an external FLASH; Step S2, after the BOOT program verifies the legitimacy of the upgrade file obtained by the embedded device, the upgrade file is stored in the firmware storage area, and the upgrade parameters of the upgrade parameter storage area are set based on the upgrade file; Step S3, the BOOT program reads the upgrade file from the firmware storage area based on the upgrade parameters, performs integrity check on the upgrade file, backs up the application stored in the application area to the application backup area, and performs the upgrade operation based on the read upgrade file; Step S4: Based on the trigger signal of the hardware IO, the backed-up application is read from the application backup area to perform a rollback operation, or the factory firmware stored in the factory firmware storage area is read to perform a rollback operation; Step S5: The BOOT program records the number of system resets, and automatically performs a rollback operation based on the number of system resets.

2. The method for upgrading and rolling back an embedded device as claimed in claim 1, characterized in that: In step S1, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform rollback operations, and automatically start when the embedded device is powered on; The application area is used to install applications and store user data during the operation of applications; The firmware storage area is used to store upgrade files; The application backup area is used to back up applications in the application area; The upgrade parameter storage area is used to store upgrade parameters and adopts an EEPROM chip.

3. The method for upgrading and rolling back an embedded device as claimed in claim 1, characterized in that: The specific steps of step S2 are as follows: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to verify the legitimacy of the upgrade file, and then stores the upgrade file after the legitimacy verification in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag and storage address in the firmware storage area carried by the upgrade file.

4. The method for upgrading and rolling back an embedded device as claimed in claim 1, characterized in that: The step S3 is specifically as follows: The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

5. The method for upgrading and rolling back an embedded device as claimed in claim 1, characterized in that: The step S4 is specifically as follows: The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. The step S5 is specifically as follows: The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold; The BOOT program records the number of system resets in real time through a watchdog counter, and if no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; If within the first time threshold, the number of system resets is greater than a preset number threshold, a rollback operation is automatically performed to clear the number of system resets.

6. An embedded device upgrade and rollback system, characterized by: Includes the following modules: The storage area division module is used to divide the storage area of ​​the MCU of the embedded device into a BOOT area for running the BOOT program, an application area, a firmware storage area, an application backup area and an upgrade parameter storage area, and set a factory firmware storage area in the external FLASH for storing the factory firmware; An upgrade file storage module, used for storing the upgrade file obtained by the embedded device in the firmware storage area after the BOOT program verifies the legitimacy of the upgrade file, and setting the upgrade parameters of the upgrade parameter storage area based on the upgrade file; An upgrade operation module, used for the BOOT program to read the upgrade file from the firmware storage area based on the upgrade parameters, perform integrity check on the upgrade file, back up the application stored in the application area to the application backup area, and perform the upgrade operation based on the read upgrade file; A rollback operation module, configured to read the backed-up application from the application backup area to perform a rollback operation, or read the stored factory firmware from the factory firmware storage area to perform a rollback operation based on a trigger signal of the hardware IO; The system reset monitoring module is used for the BOOT program to record the number of system resets and automatically perform a rollback operation based on the number of system resets.

7. The embedded device upgrade and rollback system according to claim 6, characterized in that: In the storage area partitioning module, the BOOT program is used to verify the legitimacy and integrity of the upgrade file, back up the upgrade file, perform rollback operations, and automatically start when the embedded device is powered on; The application area is used to install applications and store user data during the operation of applications; The firmware storage area is used to store upgrade files; The application backup area is used to back up applications in the application area; The upgrade parameter storage area is used to store upgrade parameters and adopts an EEPROM chip.

8. The embedded device upgrade and rollback system according to claim 6, characterized in that: The upgrade file storage module is specifically used for: the BOOT program verifies the signature carried by the upgrade file obtained by the embedded device to verify the legitimacy of the upgrade file, and then stores the upgrade file after the legitimacy verification in the firmware storage area, and sets the upgrade parameters of the upgrade parameter storage area based on the upgrade flag, rollback flag and storage address in the firmware storage area carried by the upgrade file.

9. The embedded device upgrade and rollback system according to claim 6, characterized in that: The upgrade operation module is specifically used for: The BOOT program reads the upgrade parameters in the upgrade parameter storage area, determines whether the upgrade flag in the upgrade parameters is set, and if not, starts the application in the application area normally; if so, reads the upgrade file from the firmware storage area based on the storage address in the upgrade parameters, performs integrity check on the upgrade file based on the hash value carried by the upgrade file, backs up the application stored in the application area to the application backup area, records the backup operation, then erases the application area, and then performs the upgrade operation based on the read upgrade file.

10. The embedded device upgrade and rollback system according to claim 6, characterized in that: The rollback operation module is specifically used for: The embedded device obtains a trigger signal input by the hardware IO, and determines whether the trigger duration of the trigger signal falls within a preset first duration interval or a second duration interval. If it falls within the first duration interval, the backed-up application is preferentially read from the application backup area to perform a rollback operation. If there is no backed-up application in the application backup area, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. If it falls within the second duration interval, the factory firmware stored in the factory firmware storage area is read to perform a rollback operation. The system reset monitoring module is specifically used for: The BOOT program sets a first time threshold and a second time threshold, wherein the first time threshold is greater than the second time threshold; The BOOT program records the number of system resets in real time through a watchdog counter, and if no system reset operation is sent within the second time threshold, the number of system resets is reduced by 1; If within the first time threshold, the number of system resets is greater than a preset number threshold, a rollback operation is automatically performed to clear the number of system resets.

Citation Information

Cited By

  • Firmware upgrading system and method supporting real-time state monitoring and resisting power failure

    CN120848928A