Software upgrading method and device, electronic equipment and storage medium
By comparing and identifying the feature information of updated files in the embedded BMS system, the problems of program file damage and equipment error upgrade during the software upgrade process are solved, and the stability and reliability of software upgrades are achieved, ensuring timely after the upgrade. Roll back to the original program.
Patent Information
- Application Number
- CN202310826913.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-06
- Publication Date
- 2025-01-07
AI Technical Summary
When upgrading software programs of embedded BMS systems, it is easy to cause program files to be destroyed or the equipment to be upgraded to other equipment by mistake, resulting in operation failure or failure, and the existing technology lacks effective solutions.
By obtaining the file to be updated and storing it in the first area of external memory, performing feature information comparison processing, adding the identifier and verifying it and backing up the original program. The update program clears the identifier when it runs normally, otherwise it will be rolled back to the backup file to ensure the upgrade operation stability.
Effectively prevent upgrade exceptions caused by hardware mismatch, back up the original program in advance, ensure that it can be rolled back to the original program in abnormal situations, and ensure the stability and reliability of software upgrades.
Smart Images

Figure CN119271230A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of embedded software technology, and in particular to a software upgrading method, device, electronic device and storage medium. Background Art
[0002] The software of an embedded BMS system can usually be upgraded through a communication interface. A BMS system may contain multiple different types of devices (master control, slave control, etc.), or multiple similar devices with different software programs.
[0003] However, when upgrading the software programs of the equipment of the BMS system, the program files may be damaged or the equipment may mistakenly upgrade the programs of other equipment, which may eventually lead to inoperability or even failure. The prior art lacks corresponding solutions. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a software upgrade method, device, electronic device and storage medium, which can roll back to the old program after the program upgrade is completed and fails to run, thereby improving the stability of the upgrade operation.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a software upgrade method, comprising the following steps:
[0007] Acquire a file to be updated, and store the file to be updated in a first area of an external memory, wherein the file to be updated includes feature information;
[0008] Performing comparison processing on the characteristic information, and when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated;
[0009] Based on the first identifier, verify the file to be updated, and after the verification is passed, back up the backup file corresponding to the original program to the second area of the external memory;
[0010] The original program is updated based on the file to be updated to obtain an updated program, and the first identifier carried by the updated program is updated to a second identifier;
[0011] If the update program can run normally, the second identifier is cleared; if the update program cannot run normally, the update program is rolled back based on the second identifier and the backup file.
[0012] In a possible implementation, before obtaining the file to be updated, the method further includes:
[0013] A target device program is set, wherein the target device program includes a boot program and an application program, the application program corresponds to an application partition, the boot program is used to write the file to be updated into the application partition and guide the application program in the application partition to execute, the application program is used to download the file to be updated, and the application partition is used to run the application program in the application partition.
[0014] In a possible implementation manner, obtaining the file to be updated and storing the file to be updated in the first area of the external memory includes:
[0015] In response to an update request for the original program, establishing a connection with the file to be updated through a communication interface;
[0016] The file to be updated is downloaded to the first area through the application.
[0017] In a possible implementation, the application partition stores device information, and the comparing process on the characteristic information and, when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated includes:
[0018] The characteristic information is compared with the device information by the application program, and when the characteristic information matches the device information, the first identifier is written in a preset position of the electrically erasable programmable read-only memory, wherein the characteristic information or the device information includes at least one of the following information:
[0019] PCBA model, hardware version, software version.
[0020] In a possible implementation, the verifying the file to be updated based on the first identifier, and backing up the backup file corresponding to the original program to the second area of the external memory after the verification passes, includes:
[0021] When the boot program detects the first identifier, verifying the verification code of the file to be updated;
[0022] When the verification is passed, the original program in the application partition is backed up to the second area of the external memory.
[0023] In a possible implementation, the updating of the original program based on the file to be updated to obtain an updated program, and updating the first identifier carried by the updated program to a second identifier, includes:
[0024] Writing the file to be updated into the application partition and updating the original program through the boot program;
[0025] After the update is completed, the first identifier set at a preset position of the electrically erasable programmable read-only memory is updated to the second identifier, and the update program is guided to restart.
[0026] In a possible implementation manner, if the update program cannot run normally, rolling back the update program based on the second identifier and the backup file includes:
[0027] If the boot program detects the second identifier after the update program is restarted, writing the backup file into the application partition;
[0028] The backup file is executed and the second identifier is cleared when the backup file runs normally, wherein the second identifier is stored in a electrically erasable programmable read-only memory.
[0029] In a second aspect, an embodiment of the present application further provides a software upgrade device, the device comprising:
[0030] An acquisition module, used for acquiring a file to be updated, and storing the file to be updated in a first area of an external memory, wherein the file to be updated includes characteristic information;
[0031] A comparison module, used for performing comparison processing on the characteristic information, and when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated;
[0032] A verification module, configured to verify the file to be updated based on the first identifier, and back up the backup file corresponding to the original program to the second area of the external memory after the verification is passed;
[0033] An updating module, configured to update the original program based on the file to be updated, obtain an updated program, and update the first identifier carried by the updated program to a second identifier;
[0034] The rollback module is used to clear the second identifier if the update program can run normally; if the update program cannot run normally, roll back the update program based on the second identifier and the backup file.
[0035] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to execute the software upgrade method described in any one of the first aspects.
[0036] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the software upgrade method described in any one of the first aspects is executed.
[0037] The embodiments of the present application have the following beneficial effects:
[0038] By downloading the file to be updated to the first area of the external memory and solidifying the device information at a fixed position, the device information can be checked after the device completes downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. During the update, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, the original program can be rolled back. After the update, the software is determined to be running normally through the identification, and the rollback is performed in time in case of an anomaly to ensure the stability of the upgrade operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 is a flowchart of steps S101-S105 provided in an embodiment of the present application;
[0041] Figure 2 It is a flowchart of steps S1011-S1012 provided in an embodiment of the present application;
[0042] Figure 3 It is a flowchart of steps S1031-S1032 provided in an embodiment of the present application;
[0043] Figure 4 It is a flowchart of steps S1041-S1042 provided in an embodiment of the present application;
[0044] Figure 5 It is a flowchart of steps S1051-S1052 provided in an embodiment of the present application;
[0045] Figure 6 It is a structural diagram of a software upgrade device provided in an embodiment of the present application;
[0046] Figure 7 It is a schematic diagram of the composition structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0047] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0048] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0049] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0050] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0051] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0053] See also Figure 1 , Figure 1is a flowchart of steps S101-S105 of the software upgrade method provided in the embodiment of the present application, which will be combined with Figure 1 Steps S101-S105 are shown for explanation.
[0054] Step S101, obtaining a file to be updated, and storing the file to be updated in a first area of an external memory, wherein the file to be updated includes feature information;
[0055] Step S102, performing a comparison process on the characteristic information, and when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated;
[0056] Step S103, verifying the file to be updated based on the first identifier, and backing up the backup file corresponding to the original program to the second area of the external memory after the verification passes;
[0057] Step S104, updating the original program based on the file to be updated to obtain an updated program, and updating the first identifier carried by the updated program to a second identifier;
[0058] Step S105: if the update program can run normally, clear the second identifier; if the update program cannot run normally, roll back the update program based on the second identifier and the backup file.
[0059] The above-mentioned software upgrade method downloads the file to be updated to the first area of the external memory and solidifies the device information at a fixed position. In this way, the device can check the device information after the device completes downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. During the update, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, it can be rolled back to the original program. After the update, the software is determined to be running normally through the identification, and it is rolled back in time when an anomaly occurs, thereby ensuring the stability of the upgrade operation.
[0060] The above exemplary steps of the embodiments of the present application are described below respectively.
[0061] In step S101, a file to be updated is obtained and stored in a first area of an external memory, wherein the file to be updated includes feature information.
[0062] In some embodiments, before obtaining the file to be updated, the method further includes:
[0063] A target device program is set, wherein the target device program includes a boot program and an application program, the application program corresponds to an application partition, the boot program is used to write the file to be updated into the application partition and guide the application program in the application partition to execute, the application program is used to download the file to be updated, and the application partition is used to run the application program in the application partition.
[0064] The device program of the BMS system in this upgrade solution is divided into two parts, namely (boot) boot program and (APP) application program. The APP application program corresponds to an application partition, wherein the boot boot program is fixed and the APP application program can be upgraded online.
[0065] The Boot program function includes 1 "Write the program file to be updated (stored in the external FLASH area 1) to the program area of the chip" and 2 "Boot the APP application to execute". The APP application function includes 1 "BMS application" and 2 "Download the update program file (stored in the external FLASH area 1)", which is the file to be updated.
[0066] In some embodiments, see Figure 2 , Figure 2 is a flowchart of steps S1011-S1012 provided in an embodiment of the present application, Figure 1 The illustrated step S101 can be implemented through steps S1011 - S1012 , which will be described in conjunction with each step.
[0067] In step S1011, in response to an update request for the original program, a connection is established with the file to be updated via a communication interface.
[0068] In step S1012, the file to be updated is downloaded to the first area through the application.
[0069] Here, when the program needs to be updated, the PC establishes a connection with the APP application through a communication port such as RS485 and then downloads the APP program file to the external FLASH area 1 of the device.
[0070] In step S102, the characteristic information is compared and processed, and when the characteristic information meets a preset update condition, a first identifier is added to the file to be updated.
[0071] In some embodiments, the application partition stores device information, and the comparing process of the characteristic information and adding a first identifier to the file to be updated when the characteristic information meets a preset update condition includes:
[0072] The characteristic information is compared with the device information by the application program, and when the characteristic information matches the device information, the first identifier is written in a preset position of the electrically erasable programmable read-only memory, wherein the characteristic information or the device information includes at least one of the following information:
[0073] PCBA model, hardware version, software version.
[0074] Here, the application partition reserves the device information area for storing device information, including PCBA model, hardware version, software version, etc. The CRC32 value of the file is stored at the end of the program partition. Compilation will automatically link the device information and CRC information to generate the program file.
[0075] After the file to be updated is downloaded, the APP application checks the device information of the downloaded program file, compares the PCBA model, whether the hardware version matches, and whether the software version is higher. If all conditions are met, it is considered that the program file matches the current device, writes the "to be upgraded" flag to the specified location of the EEPROM, and resets the software to enter the boot program.
[0076] In step S103, based on the first identifier, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory.
[0077] In some embodiments, see Figure 3 , Figure 3 is a flowchart of steps S1031-S1032 provided in an embodiment of the present application, Figure 1 The illustrated step S103 can be implemented through steps S1031 - S1032 , which will be described in conjunction with each step.
[0078] In step S1031, when the boot program detects the first identifier, the verification code of the file to be updated is verified.
[0079] In step S1032, when the verification is passed, the original program in the application partition is backed up to the second area of the external memory.
[0080] Here, the Boot program detects the "to be upgraded" flag and checks whether the program file CRC is consistent. If it is consistent, it is considered that the program file is not damaged, and then the original APP program area is backed up to the external FLASH area 2.
[0081] In step S104, the original program is updated based on the file to be updated to obtain an updated program, and the first identifier carried by the updated program is updated to a second identifier.
[0082] In some embodiments, see Figure 4 , Figure 4 is a flowchart of steps S1041-S1042 provided in an embodiment of the present application, Figure 1 The illustrated step S104 can be implemented through steps S1041 - S1042 , which will be described in conjunction with each step.
[0083] In step S1041, the file to be updated is written into the application partition through the boot program and the original program is updated.
[0084] In step S1042, after the update is completed, the first identifier set at the preset position of the electrically erasable programmable read-only memory is updated to the second identifier, and the update program is guided to restart.
[0085] Here, after confirming that the backup is successful, update the files in the external FLASH program area 1 to the program area. After completion, update the logo to "upgrade confirmation" and then boot the new APP program to start.
[0086] In step S105, if the update program can run normally, the second identifier is cleared; if the update program cannot run normally, the update program is rolled back based on the second identifier and the backup file.
[0087] In some embodiments, see Figure 5 , Figure 5 It is a flow chart of steps S1051-S1052 provided in an embodiment of the present application. If the update program cannot run normally, the update program can be rolled back based on the second identifier and the backup file. This can be achieved through steps S1051-S1052, which will be explained in combination with each step.
[0088] In step S1051, if the boot program detects the second identifier after the update program is restarted, the backup file is written into the application partition;
[0089] In step S1052, the backup file is executed and when the backup file runs normally, the second identifier is cleared, wherein the second identifier is stored in a electrically erasable programmable read-only memory.
[0090] Here, the new APP program runs normally and interacts with the PC, and then the "upgrade confirmation" flag of the EEPROM is cleared. If the new APP program fails to run normally or fails to interact with the PC after running normally, the device will be restarted and enter the boot program. The boot program will check the "upgrade confirmation" flag and consider the program upgrade failed. The previously backed-up file in FLASH program area 2 will be written to the program area. After completion, the original APP program will be booted and executed. The original APP program runs normally and interacts with the PC, and then the "upgrade confirmation" flag will be cleared.
[0091] In summary, the embodiments of the present application have the following beneficial effects:
[0092] By downloading the file to be updated to the first area of the external memory and solidifying the device information at a fixed position, the device information can be checked after the device completes downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. During the update, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, the original program can be rolled back. After the update, the software is determined to be running normally through the identification, and the rollback is performed in time in case of an anomaly to ensure the stability of the upgrade operation.
[0093] Based on the same inventive concept, the embodiment of the present application also provides a software upgrade device corresponding to the software upgrade method in the first embodiment. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned software upgrade method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0094] like Figure 6 As shown, Figure 6 6 is a schematic diagram of the structure of a software upgrade device 600 provided in an embodiment of the present application. The software upgrade device 600 includes:
[0095] The acquisition module 601 is used to acquire a file to be updated and store the file to be updated in a first area of an external memory, wherein the file to be updated includes feature information;
[0096] A comparison module 602 is used to compare the characteristic information and add a first identifier to the file to be updated when the characteristic information meets a preset update condition;
[0097] A verification module 603, configured to verify the file to be updated based on the first identifier, and back up the backup file corresponding to the original program to the second area of the external memory after the verification is passed;
[0098] An updating module 604 is used to update the original program based on the file to be updated to obtain an updated program, and update the first identifier carried by the updated program to a second identifier;
[0099] The rollback module 605 is configured to clear the second identifier if the update program can run normally; and roll back the update program based on the second identifier and the backup file if the update program cannot run normally.
[0100] Those skilled in the art should understand that Figure 6 The implementation functions of each unit in the software upgrading device 600 shown can be understood by referring to the relevant description of the aforementioned software upgrading method. Figure 6 The functions of each unit in the software upgrading device 600 shown can be implemented by a program running on a processor, or can be implemented by a specific logic circuit.
[0101] In a possible implementation manner, before the acquisition module 601 acquires the file to be updated, the method further includes:
[0102] A target device program is set, wherein the target device program includes a boot program and an application program, the application program corresponds to an application partition, the boot program is used to write the file to be updated into the application partition and guide the application program in the application partition to execute, the application program is used to download the file to be updated, and the application partition is used to run the application program in the application partition.
[0103] In a possible implementation, the module acquisition module 601 acquires the file to be updated and stores the file to be updated in the first area of the external memory, including:
[0104] In response to an update request for the original program, establishing a connection with the file to be updated through a communication interface;
[0105] The file to be updated is downloaded to the first area through the application.
[0106] In a possible implementation, the application partition stores device information, and the comparison module 602 performs comparison processing on the feature information, and when the feature information meets a preset update condition, adds a first identifier to the file to be updated, including:
[0107] The characteristic information is compared with the device information by the application program, and when the characteristic information matches the device information, the first identifier is written in a preset position of the electrically erasable programmable read-only memory, wherein the characteristic information or the device information includes at least one of the following information:
[0108] PCBA model, hardware version, software version.
[0109] In a possible implementation, the verification module 603 verifies the file to be updated based on the first identifier, and backs up the backup file corresponding to the original program to the second area of the external memory after the verification is passed, including:
[0110] When the boot program detects the first identifier, verifying the verification code of the file to be updated;
[0111] When the verification is passed, the original program in the application partition is backed up to the second area of the external memory.
[0112] In a possible implementation, the updating module 604 updates the original program based on the file to be updated to obtain an updated program, and updates the first identifier carried by the updated program to a second identifier, including:
[0113] Writing the file to be updated into the application partition and updating the original program through the boot program;
[0114] After the update is completed, the first identifier set at a preset position of the electrically erasable programmable read-only memory is updated to the second identifier, and the update program is guided to restart.
[0115] In a possible implementation manner, if the update program cannot run normally, the rollback module 605 rolls back the update program based on the second identifier and the backup file, including:
[0116] If the boot program detects the second identifier after the update program is restarted, writing the backup file into the application partition;
[0117] The backup file is executed and the second identifier is cleared when the backup file runs normally, wherein the second identifier is stored in a electrically erasable programmable read-only memory.
[0118] The above-mentioned software upgrade device downloads the file to be updated to the first area of the external memory and solidifies the device information at a fixed position. In this way, the device can check the device information after the device completes downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. During the update, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, it can be rolled back to the original program. After the update, the software is determined to be running normally through the identification, and it is rolled back in time when an anomaly occurs, thereby ensuring the stability of the upgrade operation.
[0119] like Figure 7 As shown, Figure 7 The present invention provides a schematic diagram of the structure of an electronic device 700, wherein the electronic device 700 includes:
[0120] A processor 701, a storage medium 702 and a bus 703, wherein the storage medium 702 stores machine-readable instructions executable by the processor 701. When the electronic device 700 is running, the processor 701 communicates with the storage medium 702 via the bus 703, and the processor 701 executes the machine-readable instructions to perform the steps of the software upgrade method described in the embodiment of the present application.
[0121] In actual application, the components in the electronic device 700 are coupled together via the bus 703. It is understood that the bus 703 is used to realize the connection and communication between these components. In addition to the data bus, the bus 703 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus 703.
[0122] The above-mentioned electronic device downloads the file to be updated to the first area of the external memory and solidifies the device information at a fixed position. In this way, the device can check the device information after downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. When updating, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, it can be rolled back to the original program. After the update, the software is determined to be running normally through the identification, and it is rolled back in time when an anomaly occurs, ensuring the stability of the upgrade operation.
[0123] The embodiment of the present application further provides a computer-readable storage medium, which stores executable instructions. When the executable instructions are executed by at least one processor 701, the software upgrade method described in the embodiment of the present application is implemented.
[0124] In some embodiments, the storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface storage, an optical disk, or a compact disc read-only memory (CD ROM); it can also be various devices including one or any combination of the above memories.
[0125] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0126] As an example, executable instructions may, but do not necessarily, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (for example, files storing one or more modules, subroutines, or code portions).
[0127] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0128] The above-mentioned computer-readable storage medium downloads the file to be updated to the first area of the external memory and solidifies the device information at a fixed position. In this way, the device can check the device information after the device completes downloading the file to be updated to prevent upgrade anomalies caused by hardware mismatch. During the update, the file to be updated is verified, and after the verification is passed, the backup file corresponding to the original program is backed up to the second area of the external memory. In this way, the backup is performed in advance during the upgrade process, and when an anomaly occurs, it can be rolled back to the original program. After the update, the software is determined to be running normally through the identification, and it is rolled back in time when an anomaly occurs, ensuring the stability of the upgrade operation.
[0129] In the several embodiments provided in the present application, it should be understood that the disclosed methods and electronic devices can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0130] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0132] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a platform server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0133] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A software upgrade method, characterized in that: The following steps are involved: Acquire a file to be updated, and store the file to be updated in a first area of an external memory, wherein the file to be updated includes feature information; Performing comparison processing on the characteristic information, and when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated; Based on the first identifier, verify the file to be updated, and after the verification is passed, back up the backup file corresponding to the original program to the second area of the external memory; The original program is updated based on the file to be updated to obtain an updated program, and the first identifier carried by the updated program is updated to a second identifier; If the update program can run normally, the second identifier is cleared; if the update program cannot run normally, the update program is rolled back based on the second identifier and the backup file.
2. The method according to claim 1, characterized in that Before obtaining the file to be updated, the method further includes: A target device program is set, wherein the target device program includes a boot program and an application program, the application program corresponds to an application partition, the boot program is used to write the file to be updated into the application partition and guide the application program in the application partition to execute, the application program is used to download the file to be updated, and the application partition is used to run the application program in the application partition.
3. The method according to claim 2, characterized in that The step of obtaining the file to be updated and storing the file to be updated in the first area of the external memory includes: In response to an update request for the original program, establishing a connection with the file to be updated through a communication interface; The file to be updated is downloaded to the first area through the application.
4. The method according to claim 2, characterized in that: The application partition stores device information, and the feature information is compared and processed, and when the feature information meets a preset update condition, a first identifier is added to the file to be updated, including: The characteristic information is compared with the device information by the application program, and when the characteristic information matches the device information, the first identifier is written in a preset position of the electrically erasable programmable read-only memory, wherein the characteristic information or the device information includes at least one of the following information: PCBA model, hardware version, software version.
5. The method according to claim 2, characterized in that: The verifying the file to be updated based on the first identifier, and backing up the backup file corresponding to the original program to the second area of the external memory after the verification is passed, includes: When the boot program detects the first identifier, verifying the verification code of the file to be updated; When the verification is passed, the original program in the application partition is backed up to the second area of the external memory.
6. The method according to claim 2, characterized in that The updating of the original program based on the file to be updated to obtain an updated program, and updating the first identifier carried by the updated program to a second identifier, includes: Writing the file to be updated into the application partition and updating the original program through the boot program; After the update is completed, the first identifier set at a preset position of the electrically erasable programmable read-only memory is updated to the second identifier, and the update program is guided to restart.
7. The method according to claim 2, characterized in that If the update program cannot run normally, rolling back the update program based on the second identifier and the backup file includes: If the boot program detects the second identifier after the update program is restarted, writing the backup file into the application partition; The backup file is executed and the second identifier is cleared when the backup file runs normally, wherein the second identifier is stored in a electrically erasable programmable read-only memory.
8. A software upgrade device, characterized in that: The device comprises: An acquisition module, used for acquiring a file to be updated, and storing the file to be updated in a first area of an external memory, wherein the file to be updated includes characteristic information; A comparison module, used for performing comparison processing on the characteristic information, and when the characteristic information meets a preset update condition, adding a first identifier to the file to be updated; A verification module, configured to verify the file to be updated based on the first identifier, and back up the backup file corresponding to the original program to the second area of the external memory after the verification is passed; An updating module, configured to update the original program based on the file to be updated, obtain an updated program, and update the first identifier carried by the updated program to a second identifier; The rollback module is used to clear the second identifier if the update program can run normally; if the update program cannot run normally, roll back the update program based on the second identifier and the backup file.
9. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the software upgrade method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the software upgrading method according to any one of claims 1 to 7 is executed.