Software upgrading method and device, computer equipment, storage medium and program product

By dividing dual (or multiple) partition upgrade areas in the MCU storage space, using these areas alternately for software upgrades, and storing the new version of the software in another unused area after the upgrade is completed, the problem of software damage caused by accidental power outage during the MCU software upgrade process is solved, and the software is safely upgraded and the system is stable.

CN120010888APending Publication Date: 2025-05-16镁佳(北京)科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510101243.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

During the MCU software upgrade process, the software is easily damaged due to unexpected power outages and other reasons, and cannot start normally.

Method used

Using a dual (or multiple) partition upgrade strategy, the storage space is divided into at least two upgrade areas, and these areas are used alternately for software upgrades. When the upgrade is complete, store the new version of the software in another unused area to ensure that it can still be started from a secure backup area in the event of an unexpected power outage.

Benefits of technology

It effectively avoids the problems of software corruption and inability to start normally, ensures that the MCU can start safely even if an unexpected power outage occurs during the upgrade process, and reduces the risk of data loss and damage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010888A_ABST
    Figure CN120010888A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software upgrading, and discloses a software upgrading method and device, computer equipment, a storage medium and a program product. The method comprises the steps that a storage space is divided, and at least two upgrading areas are determined; determining a first target upgrading area from the at least two upgrading areas; wherein the first target upgrading area is a current unused area; downloading the upgrading software to the target upgrading area, and determining whether the first running state of the upgrading software is a first preset state or not; if the first running state of the upgrading software is a first preset state, configuring the first target upgrading area as a second target upgrading area; wherein the second target upgrading area is an area for operating upgrading software; and operating the upgrading software in the second target upgrading area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software upgrading, and in particular to a software upgrading method, device, computer equipment, storage medium and program product. Background Art

[0002] With the widespread application of embedded systems, microcontroller units (MCUs), as their core components, undertake multiple functions such as data processing, control and communication. With the continuous advancement of technology and the growing demand, MCU software needs to be frequently updated to meet new functional requirements, fix known vulnerabilities or optimize performance.

[0003] At present, the MCU software upgrade method usually adopts the "in-place update" strategy, that is, directly overwriting the new version of the software in the original software storage area. This method is relatively simple to implement, but it exposes a series of problems in actual operation.

[0004] If an unexpected power outage occurs during the upgrade process (such as unstable power supply or user error), it may cause software damage and make the MCU unable to start normally. Summary of the invention

[0005] In view of this, the present invention provides a software upgrading method, apparatus, computer equipment, storage medium and program product.

[0006] In a first aspect, the present invention provides a software upgrade method, the method comprising: dividing a storage space to determine at least two upgrade areas; determining a first target upgrade area from the at least two upgrade areas; wherein the first target upgrade area is a currently unused area; downloading the upgrade software to the target upgrade area, and determining whether a first operating state of the upgrade software is a first preset state; if the first operating state of the upgrade software is the first preset state, configuring the first target upgrade area as a second target upgrade area; wherein the second target upgrade area is an area for running the upgrade software; and running the upgrade software in the second target upgrade area.

[0007] The software upgrade method provided in this embodiment effectively solves this problem by introducing a dual (or multiple) partition upgrade strategy. Specifically, the method divides the storage space, determines at least two upgrade areas (usually referred to as area A and area B), and alternately uses these two areas during the upgrade process. When the software needs to be upgraded, first determine the currently unused area as the first target upgrade area (for example, if the software currently running is in area A, area B is the first target upgrade area). Then, download the upgrade software to this target upgrade area and verify its integrity. Once the running state of the upgrade software in the first target upgrade area reaches the preset standard (i.e., the first preset state), the system configures this area as a new running area (i.e., the second target upgrade area) and runs the upgraded software therein. Even if an unexpected power outage occurs during the upgrade process, since the new software version has been completely stored in another unused area, the MCU can still start from this safe backup area, thereby avoiding the problem of software damage and failure to start normally.

[0008] In a possible implementation, determining a first target upgrade area from at least two upgrade areas includes: acquiring a flag bit of each upgrade area; and determining an upgrade area whose flag bit is a preset flag bit as the first target upgrade area.

[0009] In the software upgrade method provided in this embodiment, the flag bit is a clear indicator of the upgrade area status and can directly reflect the current usage of the upgrade area. By reading the flag bit, the system can quickly and accurately determine which upgrade area is idle or unused, and thus use it as the first target upgrade area.

[0010] In one possible implementation, determining whether the first operating state of the upgrade software is a first preset state includes: detecting whether the integrity information of the upgrade software is the preset integrity information; detecting whether the correctness information of the upgrade software is the preset correctness information; if the integrity information of the upgrade software is the preset integrity information, and the correctness information of the upgrade software is the preset correctness information, determining whether the first operating state of the upgrade software is the first preset state.

[0011] The software upgrade method provided in this embodiment can ensure that the upgraded software has not been tampered with or damaged during the transmission process by detecting the integrity information of the upgraded software. Integrity verification is the basis for ensuring the security of software upgrades. It ensures that the software version received by the user is complete and has not been maliciously modified. In addition, through the dual detection of integrity information and correctness information, potential problems can be discovered in time before the upgrade, thereby avoiding failures during the upgrade process. This helps to reduce equipment downtime, user complaints and maintenance costs caused by upgrade failures.

[0012] In one possible implementation, if the first operating state of the upgrade software is the first preset state, after configuring the first target upgrade area as the second target upgrade area, the method also includes: backing up the target data in the third target upgrade area to the first target upgrade area; wherein the third target upgrade area is a currently used area of ​​at least two upgrade areas; detecting whether the second operating state of the upgrade software is the second preset state; if the second operating state of the upgrade software is not the second preset state, converting the flag bit of the first target upgrade area into the initial flag bit, so that the third target upgrade area runs the old version of the software.

[0013] The software upgrade method provided in this embodiment backs up the target data in the currently used area (the third target upgrade area) to the unused upgrade area (the first target upgrade area) before the upgrade, which can ensure that even if an unexpected situation (such as power failure, software damage, etc.) occurs during the upgrade process, the system can be quickly restored through the backup data, thereby ensuring the security and integrity of the data. In addition, if the upgraded software (the second operating state) does not meet expectations (not the second preset state), the system can be rolled back to the old version of the software by converting the flag bit of the first target upgrade area into the initial flag bit, and the system state can be quickly restored using the backup data, reducing the risk of data loss and damage.

[0014] In one possible implementation, converting the flag bit of the first target upgrade area into an initial flag bit so that the third target upgrade area runs the old version of the software includes: loading the configuration of the first target upgrade area, converting the flag bit of the first target upgrade area into an initial flag bit, and converting the flag bit of the third target upgrade area into a flag bit for starting the software; reading the flag bit of the first target upgrade area and the flag bit of the third target upgrade area through a loader so that the third target upgrade area runs the old version of the software.

[0015] In the software upgrade method provided in this embodiment, if the upgraded software (located in the first target upgrade area) has compatibility problems or functional abnormalities, the system can quickly restore to the old version (located in the third target upgrade area) to ensure system stability and business continuity. In addition, by modifying the flag bit of the upgrade area, the system can accurately control which version of the software is loaded and run. This increases the controllability of the upgrade process, allowing system administrators to select the appropriate software version as needed.

[0016] In a possible implementation, the method further includes: detecting data loss and / or damage of the old version of the software, generating a detection result; and storing the detection result in a log.

[0017] The software upgrade method provided in this embodiment can detect data loss and / or damage of the old version of the software, so that the system can promptly discover data problems and take corresponding measures to repair or restore, thereby preventing data loss from causing serious impact on system stability and business continuity. In addition, the detection result log provides important clues for troubleshooting. When a problem occurs in the system, the technician can quickly locate the problem by analyzing the detection results in the log and take corresponding measures to repair it.

[0018] In a second aspect, the present invention provides a software upgrade device, which includes: a partitioning module, used to divide the storage space and determine at least two upgrade areas; a first determination module, used to determine a first target upgrade area from at least two upgrade areas; wherein the first target upgrade area is a currently unused area; a second determination module, used to download the upgrade software to the target upgrade area, and determine whether the first running state of the upgrade software is a first preset state; a configuration module, used to configure the first target upgrade area as a second target upgrade area if the first running state of the upgrade software is the first preset state; wherein the second target upgrade area is an area for running the upgrade software; and an operation module, used to run the upgrade software in the second target upgrade area.

[0019] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the software upgrade method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0020] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the software upgrade method of the first aspect or any corresponding embodiment thereof.

[0021] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the software upgrade method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 is a flowchart of a software upgrade method according to an embodiment of the present invention;

[0024] Figure 2 is a structural block diagram of a software upgrading device according to an embodiment of the present invention;

[0025] Figure 3 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0027] According to an embodiment of the present invention, a software upgrade method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0028] In this embodiment, a software upgrade method is provided, which can be used for computer equipment, such as computers, servers, etc. Figure 1 is a flowchart of a software upgrade method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0029] Step S101, divide the storage space to determine at least two upgrade areas.

[0030] The storage space may be a memory area on an MCU (microcontroller unit) or other embedded device for storing software and data. The upgrade area may be characterized as a specific area divided out of the storage space for storing different versions of software for software upgrade.

[0031] Specifically, in the storage space of the MCU, at least two independent upgrade areas are divided according to the requirements of software upgrade. These areas are used to store different versions of software so that version switching can be performed safely during the upgrade process.

[0032] As an example, the storage space is divided into two upgrade areas, area A and area B. Area A is used to store the currently running software version, and area B is used as a backup upgrade area.

[0033] As an example, more upgrade areas (such as A, B, C areas, etc.) are divided according to the storage space size of the MCU and the frequency of software upgrades, so as to perform multi-version management or a more flexible upgrade strategy when necessary.

[0034] In one possible implementation, the storage space of the MCU is divided into two independent partitions, called partition A and partition B. When the system is idle, the partition size is dynamically adjusted according to the needs of the current software to optimize the use of the storage space. In specific implementation, two independent partitions are first divided in the storage space of the MCU: partition A and partition B. These two partitions can be located anywhere in the storage space, but they are usually divided together continuously for the convenience of management. This can be achieved by writing specific software logic that can monitor the needs of the current software and adjust the size of the partition according to these needs. For example: when partition A needs to be expanded, some data in partition B may need to be migrated to other places to make more space for partition A. The system can monitor the needs of the current software in real time, including the running programs, the amount of data stored, and the future storage demand forecast. Based on these monitoring data, the system needs to make a decision to determine whether the partition size needs to be adjusted and how to adjust it.

[0035] As an example, assume that the MCU has 1MB of memory space, which is initially divided into 512KB partition A and 512KB partition B. Now there is a new software requirement that requires more memory space to store data. The system monitors that the memory space of partition A is about to be exhausted, while partition B has enough remaining space. The system decides to allocate some space from partition B for partition A to use. This may require migrating some data in partition B to other locations in the memory space (such as unused areas or external storage devices). The system performs an adjustment operation to increase the size of partition A to the required extent (for example, to 768KB) while reducing the size of partition B accordingly (for example, to 256KB). After the adjustment is completed, the system restores the previously backed up data and verifies the integrity and correctness of the data.

[0036] Step S102: determining a first target upgrade area from at least two upgrade areas; wherein the first target upgrade area is a currently unused area.

[0037] The first target upgrade area can be characterized as an area selected as currently unused and prepared for storing new upgrade software during the software upgrade process. Specifically, among the divided upgrade areas, a currently unused area is selected as the first target upgrade area for storing the software to be upgraded.

[0038] As an example, if the software is currently running in area A, area B is selected as the first target upgrade area.

[0039] As an example, among multiple upgrade areas, an unused area is selected as a first target upgrade area according to an upgrade policy or priority.

[0040] Step S103: download the upgrade software to the target upgrade area, and determine whether the first running state of the upgrade software is a first preset state.

[0041] The first preset state can be characterized as the expected state that the upgrade software should reach after downloading and preliminary verification, usually indicating that the software has been successfully downloaded and the preliminary test is normal. The software to be upgraded is downloaded to the first target upgrade area and preliminary verification or testing is performed to determine whether the status of the upgrade software meets expectations.

[0042] As an example, the upgrade software is downloaded to area B (the first target upgrade area) through a communication interface such as a serial port or a network, and a simple test program is run to verify the integrity of the software.

[0043] As an example, after the download is complete, a hash value of the downloaded software is calculated using a hash algorithm and compared with the expected hash value to verify the correctness of the software.

[0044] In one possible implementation, the basic startup test performed before switching to the first target upgrade area includes a startup integrity check, a basic function test, a key module self-check, resource usage, error handling and recovery, logging, startup time, and environmental self-check. Among them, the startup integrity check includes boot loading and startup code execution, and the basic function test includes hardware initialization and kernel startup. The key module self-check is to perform a self-check of key functional modules to ensure that these modules can at least start and run basic functions. Resource usage includes memory check and CPU load. Error handling and recovery include error handling mechanisms and exception handling. Logging is to record important events in the startup process for subsequent analysis. The startup time is to measure and record the startup time of the new software to ensure that it does not exceed the expected range. The environmental self-check is to check whether the new software is adapted to the current operating environment. The operating environment includes temperature and voltage.

[0045] Step S104: if the first running state of the upgrade software is the first preset state, the first target upgrade area is configured as the second target upgrade area; wherein the second target upgrade area is an area where the upgrade software runs.

[0046] The second target upgrade area can be characterized as an area configured to run the upgrade software after the upgrade software passes the preliminary verification, that is, the running area of ​​the new software version. Specifically, if the running state of the upgrade software in the first target upgrade area meets expectations (that is, the first preset state), the area is configured as a new running area (the second target upgrade area) to prepare to run the upgraded software.

[0047] As an example, the configuration information in the MCU is updated to mark area B (the first target upgrade area) as a new operating area (the second target upgrade area).

[0048] As an example, after a configuration update, some additional operations may need to be performed, such as resetting the MCU or switching to a new operating region.

[0049] Step S105: running the upgrade software in the second target upgrade area.

[0050] After the configuration is completed, the MCU starts running the upgraded software in the second target upgrade area.

[0051] To further illustrate the software upgrade process, if there is an MCU device, its storage space is divided into two upgrade areas, area A and area B. Area A is currently running the old version of the software. Now a software upgrade is required. The storage space is divided to determine the two upgrade areas, area A and area B. From area A and area B, area B is determined as the first target upgrade area (because area A is running the software). The new version of the upgrade software is downloaded to area B, and the integrity of the software is verified by a hash algorithm. After the verification is passed, the first operating state of the upgrade software is determined to be the first preset state. The configuration information in the MCU is updated, and area B is marked as the new operating area (the second target upgrade area). After the MCU is reset, the upgraded software is loaded and run from area B.

[0052] The software upgrade method provided in this embodiment effectively solves this problem by introducing a dual (or multiple) partition upgrade strategy. Specifically, the method divides the storage space, determines at least two upgrade areas (usually referred to as area A and area B), and alternately uses these two areas during the upgrade process. When the software needs to be upgraded, first determine the currently unused area as the first target upgrade area (for example, if the software currently running is in area A, area B is the first target upgrade area). Then, download the upgrade software to this target upgrade area and verify its integrity. Once the running state of the upgrade software in the first target upgrade area reaches the preset standard (i.e., the first preset state), the system configures this area as a new running area (i.e., the second target upgrade area) and runs the upgraded software therein. Even if an unexpected power outage occurs during the upgrade process, since the new software version has been completely stored in another unused area, the MCU can still start from this safe backup area, thereby avoiding the problem of software damage and failure to start normally.

[0053] In a possible implementation, the above step S102 includes:

[0054] Step a1, obtaining the flag bit of each upgrade area.

[0055] One or more binary bits used to represent a specific state or attribute. In the software upgrade scenario, the flag bit is usually used to indicate the state of the upgrade area, such as whether it is occupied, whether it contains a valid upgrade package, etc. Specifically, it can be achieved by accessing specific locations or registers in the storage area, which store flag bit information related to the upgrade area status.

[0056] As an example, directly accessing a specific address in a memory area and reading the flag value stored at that address may require knowledge of the layout of the memory area and the storage location of the flag.

[0057] As an example, the flag bit of the upgrade area is obtained by calling a specific function or API provided by the MCU. These functions or APIs may have encapsulated the logic of accessing the storage area and reading the flag bit.

[0058] Step a2: determine the upgrade area whose flag is a preset flag as the first target upgrade area.

[0059] When the flag bit of a certain upgrade area matches the preset flag bit, the area is determined as the first target upgrade area, that is, the area currently prepared to store the new upgrade package.

[0060] As an example, after reading the flags of each upgrade area, conditional statements (such as if statements) are used to compare these flags with preset flags one by one. When a match is found, the identifier or address of the upgrade area is recorded and determined as the first target upgrade area.

[0061] As an example, a loop structure is used to traverse the flags of all upgrade areas, and a comparison operation is performed in the loop body. When a match is found, the loop is exited and the currently traversed upgrade area is determined to be the first target upgrade area.

[0062] In specific implementation, the storage space of the MCU is divided into two upgrade areas: area A and area B. Each area has a flag bit to indicate whether the area is occupied (for example, 0 for unoccupied and 1 for occupied). Now a software upgrade is required, and it is hoped that an unoccupied upgrade area will be selected as the target area. Get the flag bits of area A and area B. Suppose that by accessing a specific address or calling an API, we get the flag bit of area A to be 0 and the flag bit of area B to be 1. The upgrade area whose flag bit is a preset flag bit (here is 0, indicating unoccupied) is determined as the first target upgrade area. Since the flag bit of area A is 0, which matches the preset flag bit, area A is determined as the first target upgrade area. Next, a new upgrade package can be downloaded to area A, and its flag bit can be updated to indicate that the area is occupied.

[0063] In the software upgrade method provided in this embodiment, the flag bit is a clear indicator of the upgrade area status and can directly reflect the current usage of the upgrade area. By reading the flag bit, the system can quickly and accurately determine which upgrade area is idle or unused, and thus use it as the first target upgrade area.

[0064] In a possible implementation, determining whether the first running state of the upgrade software is the first preset state in the above step S103 includes:

[0065] Step b1, detecting whether the integrity information of the upgraded software is the preset integrity information.

[0066] The preset integrity information can be characterized as the integrity information that the upgraded software is expected to have during the software upgrade process. Specifically, it is achieved by comparing the integrity information of the upgraded software with the preset integrity information.

[0067] As an example, a hash value of the upgrade software is calculated using a hash algorithm and compared with a preset hash value (ie, preset integrity information). If the two match, the integrity of the upgrade software is verified.

[0068] As an example, the digital signature technology is used to verify the signature of the upgrade software, and check whether the signature matches the preset digital signature (ie, the preset integrity information). If they match, the integrity of the upgrade software is verified.

[0069] Step b2, detecting whether the correctness information of the upgraded software is the preset correctness information.

[0070] The preset correctness information can be characterized as the correctness requirements or standards that the upgraded software is expected to meet during the software upgrade process. The correctness of the upgraded software is verified to ensure that it meets specific requirements or standards. This may include checking the software version, compatibility, configuration parameters, etc.

[0071] As an example, the metadata of the upgrade software (such as the Manifest file) is parsed, and it is checked whether the version information therein matches the preset version requirement (ie, the preset correctness information).

[0072] As an example, verify whether the configuration parameters of the upgrade software meet the hardware and software requirements of the target device (i.e., preset correctness information). This may involve checking the CPU type, memory size, operating system version, etc.

[0073] Step b3: if the integrity information of the upgrade software is the preset integrity information, and the correctness information of the upgrade software is the preset correctness information, determine whether the first running state of the upgrade software is the first preset state.

[0074] After the integrity and correctness of the upgrade software have been verified, this step involves determining whether the upgrade software is ready for further installation or operation. This can be achieved by checking the initial state of the software or performing some preliminary tests.

[0075] As an example, the initialization code of the upgrade software is executed, and it is checked whether any error occurs during the initialization process. If the initialization is successful and there is no error, the upgrade software is considered to be in the first preset state.

[0076] As an example, some basic test programs are run to verify whether the basic functions of the upgrade software are normal. If the test passes and no abnormality is detected, the upgrade software is considered to be in the first preset state.

[0077] In specific implementation, there is a new software upgrade package that needs to be installed on the MCU. During the upgrade process, the following steps are required to verify the integrity and correctness of the upgrade software and determine its running status: Calculate the hash value of the upgrade software and compare it with the preset hash value. If the two match, the integrity of the upgrade software is verified. Check the version information and configuration parameters of the upgrade software to ensure that they meet the hardware and software requirements of the MCU. If all checks pass, the correctness of the upgrade software is verified. Execute the initialization code of the upgrade software and run some basic test programs to verify its basic functions. If the initialization is successful and the test passes, the upgrade software is considered to be in the first preset state and is ready for further installation or operation.

[0078] The software upgrade method provided in this embodiment can ensure that the upgraded software has not been tampered with or damaged during the transmission process by detecting the integrity information of the upgraded software. Integrity verification is the basis for ensuring the security of software upgrades. It ensures that the software version received by the user is complete and has not been maliciously modified. In addition, through the dual detection of integrity information and correctness information, potential problems can be discovered in time before the upgrade, thereby avoiding failures during the upgrade process. This helps to reduce equipment downtime, user complaints and maintenance costs caused by upgrade failures.

[0079] In a possible implementation, the above step S104 includes:

[0080] Step c1: backing up target data in a third target upgrade area to the first target upgrade area; wherein the third target upgrade area is a currently used area among the at least two upgrade areas.

[0081] The third target upgrade area can represent the upgrade area of ​​the current version of the software currently being used or stored in the storage space of the MCU. The data in the currently used upgrade area (the third target upgrade area) is migrated to another upgrade area (the first target upgrade area). Specifically, the data of the current software version is retained during the upgrade process so that it can be restored when needed.

[0082] As an example, the software code and user data in the third target upgrade area are directly copied to the first target upgrade area. This may require accessing a specific address or register of the storage area and using an appropriate copy command or function.

[0083] As an example, using a specific backup and recovery tool or API to migrate data, these tools may have encapsulated the logic of accessing the storage area, copying the data, and updating the flag.

[0084] Step c2, detecting whether the second running state of the upgrade software is a second preset state.

[0085] After the upgrade software has been copied to the target area and attempted to run, this step involves verifying that the software is running as expected. This can include checking whether the software has started successfully, is running smoothly, and reports any errors.

[0086] As an example, run some basic test programs or scripts to verify that the basic functions of the upgraded software are normal. These tests may include checking the software's startup time, response time, memory usage, etc.

[0087] As an example, use the logging and analysis tool to monitor the running log of the upgrade software and check whether any abnormal or error messages are recorded.

[0088] Step c3: if the second running state of the upgrade software is not the second preset state, convert the flag bit of the first target upgrade area to the initial flag bit, so that the third target upgrade area runs the old version of the software.

[0089] If the running state of the upgraded software does not meet expectations (i.e., it is not the second preset state), this step involves resetting the flag bit of the first target upgrade area to the initial state to indicate that the area no longer contains a valid software copy. This is usually to allow the system to roll back to the old version of the software to avoid system downtime due to errors or instability in the new version.

[0090] In specific implementation, there are two upgrade areas in the storage space of the MCU: Area A (currently used area, i.e., the third target upgrade area) and Area B (backup area, i.e., the first target upgrade area). Now a software upgrade is required, and it is hoped that the new version of the software will be installed in Area B, while retaining the old version of the software in Area A as a backup. Copy the software code and user data in Area A to Area B. This can be achieved by directly accessing the storage area or using a backup and recovery tool. Try to start the new version of the software from Area B and run some basic test programs to verify its functionality. If the test passes and the software runs smoothly, the new version of the software is considered to be in the second preset state. If the new version of the software fails to run successfully (i.e., it is not the second preset state), the flag bit of Area B is reset to the initial flag bit value to indicate that the area no longer contains a valid copy of the software. The system can then fall back to the old version of the software in Area A to ensure the continuity and stability of the system.

[0091] Specifically, the above step c3 includes:

[0092] Step c31, loading the configuration of the first target upgrade area, converting the flag bit of the first target upgrade area into an initial flag bit, and converting the flag bit of the third target upgrade area into a flag bit for starting the software.

[0093] The loader can be a software tool or component that is responsible for reading flags or other configuration information in a storage area and deciding which upgrade area should be used to start the software based on this information. The loader usually runs when the system starts to ensure that the correct software version is loaded. First, the current configuration of the first target upgrade area is loaded (this may include reading its flag); second, based on the loaded configuration (or based on other logical decisions), the flag values ​​of the first target upgrade area and the third target upgrade area are changed. For the first target upgrade area, the flag is reset to the initial state, indicating that the area no longer contains a valid software copy or is no longer used for startup. For the third target upgrade area, the flag is set to a value indicating that the area contains a valid software copy and should be used for startup.

[0094] As an example, directly accessing a specific address or register in a memory area to read and update a flag bit may require the use of low-level hardware access commands or functions.

[0095] As an example, use a configuration management tool or API to read the configuration of the upgrade area and update the flag. These tools may have encapsulated the logic of accessing the storage area, reading the configuration, and updating the flag.

[0096] Step c32: read the flag bit of the first target upgrade area and the flag bit of the third target upgrade area through the loader, so that the third target upgrade area runs the old version software.

[0097] The loader reads the flags of the two upgrade areas and decides which area should be used to start the software based on the read values.

[0098] Specifically, since step c31 has set the flag bit of the third target upgrade area to the value for startup, the loader will select the third target upgrade area to run the software. It should be noted that although the step description mentions "so that the third target upgrade area runs the old version of the software", in fact, the loader selects the startup area based on the value of the flag bit, and does not directly involve the judgment of the software version. The selection of the software version has been indirectly completed by updating the flag bit in the previous step.

[0099] As an example, the loader runs when the system boots up and reads flags in the storage area to determine which upgrade area contains a valid copy of the software. It then loads and runs the software in that area.

[0100] The software upgrade method provided in this embodiment backs up the target data in the currently used area (the third target upgrade area) to the unused upgrade area (the first target upgrade area) before the upgrade, which can ensure that even if an unexpected situation (such as power failure, software damage, etc.) occurs during the upgrade process, the system can be quickly restored through the backup data, thereby ensuring the security and integrity of the data. In addition, if the upgraded software (the second operating state) does not meet expectations (not the second preset state), the system can be rolled back to the old version of the software by converting the flag bit of the first target upgrade area into the initial flag bit, and the system state can be quickly restored using the backup data, reducing the risk of data loss and damage.

[0101] In addition, if the upgraded software (located in the first target upgrade area) has compatibility issues or functional abnormalities, the system can quickly restore to the old version (located in the third target upgrade area) to ensure system stability and business continuity. Moreover, by modifying the flag bit of the upgrade area, the system can accurately control which version of the software is loaded and run. This increases the controllability of the upgrade process, allowing system administrators to select the appropriate software version as needed.

[0102] In a possible implementation, the method further includes:

[0103] Step d1, detecting data loss and / or damage of the old version software, and generating a detection result.

[0104] Perform an integrity check on the data of the old version of the software to determine whether there is any data loss or damage. Specifically, it may include checking the size of the data file, checksum (such as MD5, SHA-1, etc.) or other data integrity indicators to verify the integrity and correctness of the data. Based on the check results, a test result is generated, which indicates whether the data of the old version of the software is intact.

[0105] As an example, use a file verification tool to calculate the checksum of a data file of an old version of the software and compare it with the pre-stored checksum value. If the two do not match, it indicates that the data may be corrupted.

[0106] As an example, check to see if the data files for the old version of the software exist and are the expected size. If the files are missing or the size is different, data may have been lost.

[0107] As an example, for old version software data of database type, a database integrity check (such as a DBCC command) may be executed to verify the integrity and consistency of the data.

[0108] Step d2, storing the detection result in a log.

[0109] The test results generated in step d1 are recorded in a log file. Specifically, the test time, test object (i.e., data of the old version of the software), test results (whether the data is lost or damaged), and other relevant information (such as test tools, test personnel, etc.) are written into the log. By recording this information, the process and results of the data integrity check can be easily tracked and audited.

[0110] The software upgrade method provided in this embodiment can detect data loss and / or damage of the old version of the software, so that the system can promptly discover data problems and take corresponding measures to repair or restore, thereby preventing data loss from causing serious impact on system stability and business continuity. In addition, the detection result log provides important clues for troubleshooting. When a problem occurs in the system, the technician can quickly locate the problem by analyzing the detection results in the log and take corresponding measures to repair it.

[0111] In this embodiment, a software upgrade device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0112] This embodiment provides a software upgrade device, such as Figure 2 As shown, it includes: a partition module 201, used to divide the storage space and determine at least two upgrade areas; a first determination module 202, used to determine a first target upgrade area from at least two upgrade areas; wherein the first target upgrade area is a currently unused area; a second determination module 203, used to download the upgrade software to the target upgrade area, and determine whether the first running state of the upgrade software is a first preset state; a configuration module 204, used to configure the first target upgrade area as a second target upgrade area if the first running state of the upgrade software is the first preset state; wherein the second target upgrade area is an area for running the upgrade software; and an operation module 205, used to run the upgrade software in the second target upgrade area.

[0113] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0114] The software upgrade device in this embodiment is presented in the form of a functional unit, where the functional unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0115] The embodiment of the present invention also provides a computer device having the above Figure 2 The software upgrade device shown.

[0116] See also Figure 3 , Figure 3 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 3 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.

[0117] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0118] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0119] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0120] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0121] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0122] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0123] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0124] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A software upgrade method, characterized in that: The method comprises: Divide the storage space and identify at least two upgrade areas; Determine a first target upgrade area from the at least two upgrade areas; wherein the first target upgrade area is a currently unused area; Downloading the upgrade software to the target upgrade area, and determining whether the first running state of the upgrade software is a first preset state; If the first running state of the upgrade software is the first preset state, configuring the first target upgrade area as the second target upgrade area; wherein the second target upgrade area is the area where the upgrade software is running; The upgrade software is run in the second target upgrade area.

2. The software upgrade method according to claim 1, characterized in that: The determining a first target upgrade region from the at least two upgrade regions comprises: Get the flags of each upgrade area; The upgrade area whose flag bit is a preset flag bit is determined as the first target upgrade area.

3. The software upgrade method according to claim 1, characterized in that: The determining whether the first running state of the upgrading software is a first preset state includes: Detecting whether the integrity information of the upgraded software is preset integrity information; Detecting whether the correctness information of the upgraded software is the preset correctness information; If the integrity information of the upgrade software is the preset integrity information, and the correctness information of the upgrade software is the preset correctness information, it is determined whether the first running state of the upgrade software is the first preset state.

4. The software upgrade method according to claim 2, characterized in that: If the first running state of the upgrade software is the first preset state, after configuring the first target upgrade area as the second target upgrade area, the method further includes: Backing up target data in a third target upgrade area to the first target upgrade area; wherein the third target upgrade area is a currently used area in at least two upgrade areas; Detecting whether the second running state of the upgrade software is a second preset state; If the second running state of the upgrade software is not the second preset state, the flag bit of the first target upgrade area is converted into an initial flag bit, so that the third target upgrade area runs the old version of software.

5. The software upgrade method according to claim 4, characterized in that: Converting the flag bit of the first target upgrade area into an initial flag bit so that the third target upgrade area runs the old version software includes: Loading the configuration of the first target upgrade area, converting the flag bit of the first target upgrade area into an initial flag bit, and converting the flag bit of the third target upgrade area into a flag bit for starting software; The flag bit of the first target upgrade area and the flag bit of the third target upgrade area are read by the loader, so that the third target upgrade area runs the old version software.

6. The software upgrade method according to claim 5, characterized in that: The method further comprises: Detecting data loss and / or damage of the old version of the software and generating a detection result; The detection result is stored in a log.

7. A software upgrade device, characterized in that: The device comprises: A partitioning module, used to partition the storage space and determine at least two upgrade areas; A first determining module, configured to determine a first target upgrade area from the at least two upgrade areas; wherein the first target upgrade area is a currently unused area; A second determination module is used to download the upgrade software to the target upgrade area and determine whether the first running state of the upgrade software is a first preset state; a configuration module, configured to configure the first target upgrade area as a second target upgrade area if the first running state of the upgrade software is a first preset state; wherein the second target upgrade area is an area where the upgrade software is running; A running module is used to run the upgrade software in the second target upgrade area.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the software upgrade method according to any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the software upgrading method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the software upgrading method according to any one of claims 1 to 6.