CN117971272A - Program upgrading method and electronic equipment - Google Patents

Program upgrading method and electronic equipment Download PDF

Info

Publication number
CN117971272A
CN117971272A CN202410201678.XA CN202410201678A CN117971272A CN 117971272 A CN117971272 A CN 117971272A CN 202410201678 A CN202410201678 A CN 202410201678A CN 117971272 A CN117971272 A CN 117971272A
Authority
CN
China
Prior art keywords
upgrade
preset
data
area
array information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410201678.XA
Other languages
Chinese (zh)
Inventor
王丁
李世军
龙海洋
王昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
If New Energy Technology Jiangsu Co ltd
Original Assignee
If New Energy Technology Jiangsu Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by If New Energy Technology Jiangsu Co ltd filed Critical If New Energy Technology Jiangsu Co ltd
Priority to CN202410201678.XA priority Critical patent/CN117971272A/en
Publication of CN117971272A publication Critical patent/CN117971272A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a program upgrading method and electronic equipment, which relate to the technical field of embedded equipment software updating and are applied to the electronic equipment, wherein the electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; the method comprises the following steps: reading upgrading bit data of the upgrading bit zone, and determining array information according to the upgrading bit data; the upgrade flag bit data comprises identification information; determining whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed; if the array information is determined to be equal to the first preset identifier, jumping to the application program area for operation; if the array information is determined to be not equal to the first preset identifier, the upgrade package data is received according to the upgrade rule and written into the application program area for program upgrade. According to the technical scheme, the memory partition of the main control module is used as the memory space of the upgrade package data, so that the development cost of hardware and software is reduced.

Description

Program upgrading method and electronic equipment
Technical Field
The present invention relates to the field of embedded device software updating technologies, and in particular, to a program upgrading method and an electronic device.
Background
Power electronics are gradually perfected in their function during the continuous development, debugging and testing process. The developed vehicle-mounted reverse charging integrated machine has the advantage that a system stored when reaching the hand of a user is a version with more perfect functions after repeated testing by a manufacturer. In order to realize the long-period quality assurance and high-quality user experience required by the power electronic product, manufacturers need to keep the aging test for a long time after selling the product, and follow up user feedback to adjust the software strategy in time. Generally, the optimization at the software level includes optimization in terms of communication information, machine performance, usage logic, and the like. In addition, for some special use scene electronic equipment, for example, a vehicle-mounted reverse charging all-in-one machine has some special requirements on appearance flatness, so that a common burning debugging interface before leaving the factory of the machine needs to be matched with a burner or an emulator for use when the machine is used, and the interface is not opened to a user after the machine is sold. This requires the user to upgrade the system program via other communication interfaces.
Currently, in the prior art, a common program upgrading mode is to write a new program into a nonvolatile memory of a chip through an external programming device, and the mode generally needs to take out a control board of the device, update the program through a burner, or use the external memory as a backup space of an upgrade package; and in the use process, jumper wires and reserved burning ports are needed, so that the method is only suitable for debugging and use in development environments or factories, is not beneficial to upgrading equipment on the user side, meanwhile, the possibility of power failure exists in equipment upgrading, and once a chip is powered down, the loading of an upgrade package is stopped immediately, the upgrading cannot be completed, and the upgrading position and the upgrading completion degree cannot be accurately determined.
Disclosure of Invention
The invention provides a program upgrading method and electronic equipment, which reduce the development cost of hardware and software and improve the use experience of a user by taking a storage partition of a main control module as a storage space of upgrade package data.
According to one aspect of the invention, the invention provides a program upgrading method, which is applied to electronic equipment, wherein the electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; the method comprises the following steps:
Reading upgrading bit data of the upgrading bit zone, and determining array information according to the upgrading bit data; the upgrade flag bit data comprises identification information;
determining whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed;
if the array information is determined to be equal to the first preset identifier, jumping to the application program area for operation;
If the array information is determined to be not equal to the first preset identifier, the upgrade package data is received according to the upgrade rule and written into the application program area for program upgrade.
Optionally, if it is determined that the array information is not equal to the first preset identifier, receiving upgrade package data according to an upgrade rule, writing the upgrade package data into the application program area to perform program upgrade, including: if the array information is determined not to be equal to the first preset identifier, an upgrading request is sent; determining whether an upgrade instruction is received within a first preset time; if the upgrading instruction is received within the first preset time, determining whether the array information meets the first preset condition; if the array information is determined to meet the first preset condition, receiving upgrade package data according to an upgrade rule, and writing the upgrade package data into an application program area for program upgrade; if the array information is determined to not meet the first preset condition, transmitting the array information to the upper computer; the array information is used for indicating the upper computer to issue the upgrade package data from the continuous transmission address.
Optionally, if it is determined that the array information meets the first preset condition, receiving upgrade package data according to an upgrade rule, writing the upgrade package data into the application program area for program upgrade, including: if the array information is determined to meet the first preset condition, the upgrading zone bit data of the upgrading zone bit area are erased, and the updating identification information is a second preset identification; the second preset mark indicates that the array information meets a first preset condition; erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information into a third preset identification; the third preset identifier indicates that the backup data of the backup area is erased; copying application program data of the application program area, writing the application program data into the backup area, erasing upgrading flag bit data of the upgrading flag bit area, and updating the identification information into a fourth preset identification; the fourth preset identifier indicates that the application program data of the application program area is copied and written into the backup area; erasing application program data of the application program area, and erasing upgrading bit data of the upgrading bit area, wherein the upgrading identification information is a fifth preset identification; the fifth preset identifier indicates that the application data of the application area is erased.
Optionally, after updating the identification information to the fifth preset identification, the method further includes: informing the upper computer to group and issue the upgrade package data from the initial position of the upgrade package data; circularly receiving the upgrade package data, and sequentially writing the upgrade package data into the application program area according to the address grouping according to the upgrade rule; reading the upgrade flag bit data of the upgrade flag bit area every time a group of upgrade packet data is successfully written, and automatically increasing the upgrade flag bit data by a fixed value; after the complete receiving of the upgrade package data is determined, the upgrade flag bit data of the upgrade flag bit area is erased, the upgrade identification information is a sixth preset identification, and the upgrade package data is jumped to the application program area to operate; the sixth preset identifier indicates that the upgrade package data are completely received.
Optionally, if it is determined that the array information does not meet the first preset condition, sending the array information to the upper computer includes: if the array information is determined not to meet the first preset condition, determining whether the array information is a second preset mark or not; if the array information is determined to be the second preset identification, executing the step of erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information to be the third preset identification; if the array information is determined not to be the second preset identifier, determining whether the array information is the third preset identifier; if the array information is determined to be the third preset identification, returning the application program data of the copy application program area to be written into the backup area, and erasing the upgrade flag bit data of the upgrade flag bit area, wherein the update identification information is the fourth preset identification; if the array information is determined not to be the third preset mark, determining whether the array information is the fourth preset mark; if the array information is determined to be the fourth preset identification, returning to the step of executing the step of erasing the application program area to be the application program data, and erasing the upgrading bit data of the upgrading bit area, wherein the updating identification information is the fifth preset identification; and if the array information is determined not to be the fourth preset mark, transmitting the array information to the upper computer.
Optionally, the method further comprises: if it is determined that the upgrading instruction is not received within the first preset time, determining whether the array information meets a second preset condition; if the array information is determined to meet the second preset condition, erasing the application program data of the application program area, copying the backup data of the backup area to the application program area, and jumping to the application program area for operation; if the array information is determined not to meet the second preset condition, jumping to the application program area for operation.
Optionally, after notifying the upper computer to issue the upgrade package data from the initial position packet of the upgrade package data, the method further includes: determining whether the upgrade package data is successfully checked; if the verification of the upgrade package data is determined to fail, informing the upper computer to resend the upgrade package data; determining whether the retransmission times of the same upgrade package data are less than or equal to preset times; if the number of times of retransmitting the same upgrade package data is determined to be greater than the preset number of times, the main control module is restarted after power failure; if the number of times of retransmitting the same upgrade package data is less than or equal to the preset number of times, returning to execute the step of receiving the upgrade package data according to the upgrade rule and writing the upgrade package data into the application program area.
Optionally, after notifying the upper computer to issue the upgrade package data from the initial position packet of the upgrade package data, the method further includes: determining whether next group of upgrade package data is received within a second preset time; if the fact that the next group of upgrade package data is not received within the second preset time is determined, the main control module is powered down and restarted; if the next group of upgrade package data is received within the second preset time, the upgrade package data is continuously and circularly received.
Optionally, after updating the identification information to be the sixth preset identification and jumping to the application area for operation, the method further includes: the identification information is reset to a default value.
According to another aspect of the present invention, the present invention further provides a program upgrading apparatus, which is applied to an electronic device, and the electronic device includes a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; the device comprises:
the information determining module is used for reading the upgrading zone bit data of the upgrading zone bit area and determining array information according to the upgrading zone bit data; the upgrade flag bit data comprises identification information;
the information judging module is used for determining whether the array information is equal to a first preset mark; the first preset identifier indicates that program upgrading is not needed;
The program running module is used for jumping to the application program area for running if the array information is determined to be equal to the first preset identifier;
And the program upgrading module is used for receiving the upgrading packet data according to the upgrading rule and writing the upgrading packet data into the application program area to upgrade the program if the array information is determined to be unequal to the first preset identifier.
According to another aspect of the present invention, there is also provided an electronic apparatus including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the program upgrade method of any one of the embodiments of the present invention.
According to another aspect of the present invention, there is also provided a computer readable storage medium storing computer instructions for causing a processor to execute the program upgrading method according to any of the embodiments of the present invention.
The technical scheme of the invention is applied to electronic equipment, and the electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; determining array information according to the upgrade flag bit data by reading the upgrade flag bit data of the upgrade flag bit area; the upgrade flag bit data comprises identification information; determining whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed; if the array information is determined to be equal to the first preset identifier, jumping to the application program area for operation; if the array information is determined to be not equal to the first preset identifier, the upgrade package data is received according to the upgrade rule and written into the application program area for program upgrade. According to the method, firstly, the storage partition of the main control module is used as the storage space of the upgrade package data, the development cost of hardware and software is reduced, and further, the program upgrade process is accurately determined by determining the relation between the array information and the first preset mark, so that the upgrade safety is ensured, and the use experience of a user is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a program upgrade method provided in one embodiment of the present application;
FIG. 2 is a flow chart of a program upgrade method provided in one embodiment of the present application;
FIG. 3 is a flow chart of a program upgrade method provided in one embodiment of the present application;
FIG. 4 is a flow chart of a program upgrade method provided in one embodiment of the present application;
FIG. 5 is a schematic diagram of a program upgrade apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order that those skilled in the art will better understand the present invention, a more complete description of the same will be rendered by reference to the appended drawings, wherein it is to be understood that the illustrated embodiments are merely exemplary of some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Fig. 1 is a flowchart of a program upgrading method provided in an embodiment of the present application, where the embodiment is applicable to a version upgrading situation of an embedded application of an electronic device, and the method may be performed by a main control module of the electronic device, where the main control module may be implemented in a form of hardware and/or software, and in a specific embodiment, the main control module may be configured in the electronic device; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area, and also comprises a bootstrap program area, wherein the bootstrap program area is used for storing bootstrap program Bootloader which is software specially developed for updating the application program. As shown in fig. 1, the method of this embodiment specifically includes the following steps:
S101, reading upgrade flag bit data of an upgrade flag bit area, and determining array information according to the upgrade flag bit data.
The electronic device may be, for example, a lower computer, which may be in communication connection with an upper computer, for receiving and feeding back an instruction of the upper computer, where the upper computer is a computer or a single chip microcomputer that may directly send an operation instruction and upgrade package data. Preferably, the upper computer may be a smart phone of the user. The electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area. The electronic equipment further comprises a Bluetooth transmission chip and an auxiliary power supply, and the Bluetooth transmission chip is connected with the main control module through a bus so as to transmit data. The auxiliary power supply is connected with the main control module and the bluetooth transparent transmission chip respectively, the voltage that the auxiliary power supply provided for the main control module can be 5 volts for example, the voltage that the auxiliary power supply provided for the bluetooth transparent transmission chip can be 3 volts for example, and the embodiment is not limited to this. Because the power supplies of the Bluetooth transparent transmission chip and the main control chip are respectively and independently powered, the Bluetooth transparent transmission chip can maintain the communication connection with the upper computer without interruption when the main control module is powered down and restarted, thereby providing hardware support for the subsequent program upgrading process. The reset pin of the main control chip of the main control module is controlled by the other pin through the high and low level enabled by the software, and the Bluetooth transparent transmission chip power supply is independent of the main control chip power supply of the main control module.
The application program area is used for storing the current code of the program operation; the backup area is used for storing and backing up the current code of the program operation, so that the backup data stored in the backup area can be restored to the application program area when the version rollback is required, and the normal operation of the equipment is ensured; the upgrade zone bit area is used for storing data representing the upgrade stage of the program, and even when the main control module is powered down and restarted, the stored data of the upgrade zone bit area is not lost, and after the main control module is restarted, whether the equipment needs to be upgraded or the stage where the upgrade is located can be determined by reading the upgrade zone bit area. The upgrade flag bit data includes identification information for recording identification information characterizing a stage in which the upgrade process is located. The array information refers to a single-structure array arranged in a simple ordering structure.
Specifically, the main control module reads the upgrade flag bit data of the upgrade flag bit area, determines the identification information of the upgrade flag bit area according to the upgrade flag bit data, and stores the identification information of the upgrade flag bit area in the array, thereby determining the array information, namely the array information at least comprises the identification information of the upgrade flag bit area.
S102, determining whether the array information is equal to a first preset identifier.
The first preset identifier is preset identifier information and is used for indicating that the current program does not need to be updated.
Specifically, it is determined whether the array information is equal to the first preset identifier, if it is determined that the array information is equal to the preset first preset identifier, it is determined that program upgrading is not required currently, and S103 is executed. If it is determined that the array information is not equal to the preset first preset identifier, it is determined that the current program needs to be updated, and S104 is executed.
Illustratively, determining whether the first preset flag is 0xFFFF or 0x7777, and 0xFFFF or 0x7777 each indicate that the current program does not require an upgrade. If it is determined that the array information is equal to the preset first preset flag 0xFFFF or 0x7777, it is determined that the current program does not need to be updated currently, and S103 is executed. If it is determined that the array information is not equal to the preset first preset flag 0xFFFF or 0x7777, it is determined that the current program needs to be updated, and S104 is executed.
S103, jumping to an application program area for operation.
Specifically, if the array information is determined to be equal to the first preset identifier, it is determined that program upgrading is not needed to be performed on the current program at present, the current program is directly jumped to the application program area, and program codes stored in the application program area are operated.
S104, receiving upgrade package data according to upgrade rules, and writing the upgrade package data into an application program area to upgrade the program.
The upgrade rule is a preset rule for upgrading the program according to the upgrade package data. The upgrade package data refers to a new program file required for program upgrade, and is used for updating and upgrading the current program.
Specifically, if the array information is determined not to be equal to the first preset identifier, determining that program upgrading is currently required to be performed on the current program, receiving upgrade package data from an upper computer according to an upgrade rule, and writing the received upgrade package data into an application program area to realize upgrading of the current program.
Further, after the program upgrading is determined to be finished, initializing the program, determining whether the data identifier of the upgrading zone bit data of the upgrading zone bit is a first preset identifier, and if the data identifier of the upgrading zone bit data of the upgrading zone bit is determined to be the first preset identifier, guiding the program to start the application program; if the data identification of the upgrading zone bit data of the upgrading zone bit zone is not the first preset identification, the data of the data zone bit zone is erased, the data identification is updated to the first preset identification, and the program is guided to be started.
The technical scheme of the embodiment is applied to electronic equipment, and the electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; determining array information according to the upgrade flag bit data by reading the upgrade flag bit data of the upgrade flag bit area; the upgrade flag bit data comprises identification information; determining whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed; if the array information is determined to be equal to the first preset identifier, jumping to the application program area for operation; if the array information is determined to be not equal to the first preset identifier, the upgrade package data is received according to the upgrade rule and written into the application program area for program upgrade. On the basis of the embodiment, the method and the device reduce the development cost of hardware and software by taking the storage partition of the main control module as the storage space of the upgrade package data, and further accurately determine the program upgrade process by determining the relation between the array information and the first preset identifier, thereby ensuring upgrade safety and improving the use experience of users.
FIG. 2 is a flow chart of a program upgrade method provided in an embodiment of the present application, which is applicable to version upgrade of a program, and the method may be performed by a program upgrade apparatus, which may be implemented in hardware and/or software, and in a specific embodiment, the program upgrade apparatus may be configured in an electronic device, where the electronic device includes a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area. On the basis of the above embodiment, if it is determined that the array information is not equal to the first preset identifier, the upgrade package data is received according to the upgrade rule and written into the application program area for program upgrade, as shown in fig. 2, the method specifically includes the following steps:
s201, reading upgrade flag bit data of the upgrade flag bit area, and determining array information according to the upgrade flag bit data.
Wherein the upgrade flag bit data includes identification information.
Specifically, the main control module reads the upgrade flag bit data of the upgrade flag bit area, determines the identification information of the upgrade flag bit area according to the upgrade flag bit data, and stores the identification information of the upgrade flag bit area in the array, thereby determining the array information, namely the array information at least comprises the identification information of the upgrade flag bit area.
S202, determining whether the array information is equal to a first preset identifier.
The first preset identifier indicates that program upgrading is not needed.
Specifically, it is determined whether the array information is equal to the first preset identifier, if it is determined that the array information is not equal to the preset first preset identifier, it is determined that the current program needs to be updated, and S203 is executed. If it is determined that the array information is equal to the preset first preset identifier, it is determined that the current program does not need to be updated, and S210 is executed.
S203, sending an upgrade request.
The upgrade request is used for the electronic equipment to send request information to the upper computer to inform the upper computer that program upgrade is needed currently. The upper computer is a computer, a singlechip or intelligent electronic terminal equipment (such as a smart phone, a tablet personal computer and the like) which can directly send an operation instruction, and is in communication connection with the electronic equipment.
Specifically, if it is determined that the array information is not equal to the first preset identifier, the electronic device sends an upgrade request to the upper computer through the main control module to request the upper computer to allow program upgrade.
S204, determining whether an upgrade instruction is received within a first preset time.
The first preset time is a preset time for receiving the upgrade instruction, and may be, for example, 1 second, 3 seconds, 5 seconds, or the like, which is not limited in this embodiment. The upgrade instruction is used for the upper computer to inform the electronic equipment whether the program upgrade can be performed.
Specifically, determining whether the electronic device receives an upgrade instruction sent by the upper computer within a first preset time, and if it is determined that the electronic device receives the upgrade instruction sent by the upper computer within the first preset time, executing S205; if it is determined that the electronic device does not receive the upgrade instruction sent by the upper computer within the first preset time, S208 is executed.
S205, determining whether the array information meets a first preset condition.
The first preset condition is a preset condition for judging whether the array information meets the upgrading requirement or not.
Specifically, determining whether the array information meets a first preset condition, and if the array information meets the first preset condition, executing S206; if it is determined that the array information does not satisfy the first preset condition, S207 is performed.
S206, receiving the upgrade package data according to the upgrade rule, and writing the upgrade package data into the application program area to upgrade the program.
Specifically, if it is determined that the array information meets the first preset condition, upgrade package data is received according to an upgrade rule, and the collected upgrade package data is written into an application program area to upgrade a program.
S207, transmitting the array information to the upper computer.
The array information is used for indicating the upper computer to issue the upgrade package data from the continuous transmission address.
Specifically, if the array information is determined not to meet the first preset condition, the array information is sent to the upper computer, and the upper computer is informed to issue the upgrade package data from the continuous transmission address.
S208, determining whether the array information meets a second preset condition.
The second preset condition is a preset condition for determining the array information when the upgrade instruction is not received within the first preset time, for example, whether the array information is preset with an identification interval may be determined, which is not limited in this embodiment.
Specifically, if it is determined that the upgrade instruction is not received within the first preset time, determining whether the array information meets a second preset condition, and if it is determined that the array information meets the second preset condition, executing S209; if it is determined that the array information does not satisfy the second preset condition, S210 is performed.
S209, erasing the application program data of the application program area, and copying the backup data of the backup area to the application program area.
Specifically, if it is determined that the array information satisfies the second preset condition, the application data of the application area is erased, the backup data of the backup area is copied to the application area, and S210 is continuously executed.
S210, jumping to an application program area to run.
Specifically, if the array information is determined not to meet the second preset condition, directly jumping to the application program area for operation.
According to the technical scheme of the embodiment, the upgrading zone bit data of the upgrading zone bit area are read, and the array information is determined according to the upgrading zone bit data; determining whether the array information is equal to a first preset identifier; if the array information is determined to be not equal to a preset first preset mark, determining that the current program needs to be subjected to program upgrading, and executing the upgrading request; determining whether an upgrade instruction is received within a first preset time; if the electronic equipment is determined to receive the upgrade instruction sent by the upper computer within the first preset time, executing the determination of whether the array information meets the first preset condition; if the array information is determined to meet the first preset condition, receiving upgrade package data according to an upgrade rule, and writing the upgrade package data into an application program area for program upgrade; if the array information is determined to not meet the first preset condition, transmitting the array information to the upper computer; if the electronic equipment is determined not to receive the upgrade instruction sent by the upper computer within the first preset time, determining whether the array information meets a second preset condition; if the array information is determined to meet the second preset condition, erasing the application program data of the application program area, copying the backup data of the backup area to the application program area, and jumping to the application program area for operation; if the array information is determined to not meet the second preset condition, jumping to the application program area for operation; if the array information is determined to be equal to the preset first preset identifier, determining that program upgrading of the current program is not needed currently, and jumping to an application program area for operation. On the basis of the embodiment, firstly, whether the array information is equal to the first preset identifier is determined, and then whether the array information meets the first preset condition and the second preset condition is determined, so that different upgrading steps are executed according to different conditions, the program upgrading process is accurately determined, upgrading safety is guaranteed, and the use experience of a user is improved.
FIG. 3 is a flowchart of a program upgrade method provided in an embodiment of the present application, where the embodiment is applicable to a version upgrade of a program, and the method may be performed by a program upgrade apparatus, where the program upgrade apparatus may be implemented in hardware and/or software, and in a specific embodiment, the program upgrade apparatus may be configured in an electronic device, where the electronic device includes a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area. On the basis of the above embodiment, further description will be made on determining whether the array information satisfies the first preset condition, as shown in fig. 3, the method specifically includes the following steps:
s301, reading upgrade flag bit data of an upgrade flag bit area, and determining array information according to the upgrade flag bit data.
Wherein the upgrade flag bit data includes identification information.
Specifically, the main control module reads the upgrade flag bit data of the upgrade flag bit area, determines the identification information of the upgrade flag bit area according to the upgrade flag bit data, and stores the identification information of the upgrade flag bit area in the array, thereby determining the array information, namely the array information at least comprises the identification information of the upgrade flag bit area.
S302, determining whether the array information is equal to a first preset identifier.
The first preset identifier indicates that program upgrading is not needed.
Specifically, it is determined whether the array information is equal to the first preset identifier, if it is determined that the array information is not equal to the preset first preset identifier, it is determined that the current program needs to be updated, and S303 is executed. If it is determined that the array information is equal to the preset first preset identifier, it is determined that the current program does not need to be updated, and S316 is executed.
S303, sending an upgrade request.
The upgrade request is used for the electronic equipment to send request information to the upper computer to inform the upper computer that program upgrade is needed currently. The upper computer is a computer or a single chip microcomputer which can directly send operation instructions and is generally used for controlling electronic equipment.
Specifically, if it is determined that the array information is not equal to the first preset identifier, the electronic device sends an upgrade request to the upper computer through the main control module to request the upper computer to allow program upgrade.
S304, determining whether an upgrade instruction is received within a first preset time.
The first preset time is a preset time for receiving the upgrade instruction, and may be, for example, 1 second, 3 seconds, 5 seconds, or the like, which is not limited in this embodiment. The upgrade instruction is used for the upper computer to inform the electronic equipment whether the program upgrade can be performed.
Specifically, determining whether the electronic device receives an upgrade instruction sent by the upper computer within a first preset time, and if it is determined that the electronic device receives the upgrade instruction sent by the upper computer within the first preset time, executing S305; if it is determined that the electronic device does not receive the upgrade instruction sent by the upper computer within the first preset time, S314 is executed.
S305, determining whether the array information is equal to a preset identification threshold value.
The first preset condition is a preset condition for judging whether the array information meets the upgrading requirement or not. The preset identification threshold is a preset identification threshold used for determining whether the array information meets a first preset condition, for example, may be 0x2000.
Specifically, determining whether the array information meets a first preset condition, that is, determining whether the array information is equal to a preset identification threshold, if the array information is determined to be equal to the preset identification threshold, determining that the array information meets the first preset condition, and executing S306; if it is determined that the array information is not equal to the preset identification threshold, it is determined that the array information does not satisfy the first preset condition, and S310 is executed.
S306, erasing upgrading bit data of the upgrading bit zone, and updating the identification information into a second preset identification.
And if the array information is determined to meet the first preset condition, the upgrading zone bit data of the upgrading zone bit area are erased, and the identification information is updated to be a second preset identification.
Specifically, the second preset identifier may be, for example, 0x3000, which indicates that the electronic device has erased the upgrade flag data. Therefore, when the electronic device is restarted due to upgrade errors in the link due to various reasons, the boot program reads the second preset identifier when reading the upgrade flag bit data, which indicates that the electronic device has erased the upgrade flag bit data, so that the electronic device needs to perform program upgrade, that is, the requirement that the determined number of sets of information in step S302 is not equal to the preset first preset identifier is met, and the current program needs to be subjected to program upgrade is determined.
S307, the backup data of the backup area is erased, the upgrading zone bit data of the upgrading zone bit area is erased, and the updating identification information is a third preset identification.
After the upgrading zone bit data of the upgrading zone bit area are erased, updating the identification information to be a second preset identification, further erasing the backup data of the backup area, then erasing the upgrading zone bit data of the upgrading zone bit area, and updating the identification information to be a third preset identification.
Specifically, the third preset identifier may be, for example, 0x4000, which indicates that the backup data of the backup area is erased. Therefore, when the electronic device is restarted due to upgrade errors in the link due to various reasons, the bootstrap program reads the third preset identifier when reading the upgrade flag bit data, which indicates that the backup data of the backup area of the electronic device is erased, and also indicates that the electronic device needs to perform program upgrade at this time, that is, the requirement that the determined number of sets of information in step S302 is not equal to the preset first preset identifier is met, and it is determined that the current program needs to be subjected to program upgrade.
And S308, copying application program data of the application program area, writing the application program data into the backup area, erasing upgrading bit data of the upgrading bit area, and updating the identification information into a fourth preset identification.
And after the backup data of the backup area is erased, the upgrading zone bit data of the upgrading zone bit area is erased, the updating identification information is a third preset identification, the application program data of the copying application program area is written into the backup area, the upgrading zone bit data of the upgrading zone bit area is erased, and the identification information is updated to a fourth preset identification.
Specifically, the fourth preset flag may be, for example, 0x5000, which indicates that the application data of the application area has been copied and written to the backup area. Therefore, when the electronic device is restarted due to upgrade errors in the link due to various reasons, the bootstrap program reads the fourth preset identifier when reading the upgrade flag bit data, which indicates that the application program data of the application program area of the electronic device is copied to the backup area, which also indicates that the electronic device needs to perform program upgrade at this time, that is, the requirement that the determined number of sets of information in step S302 is not equal to the preset first preset identifier is met, and it is determined that the current program needs to be subjected to program upgrade.
S309, erasing application program data of the application program area, and erasing upgrading bit data of the upgrading bit area, wherein the upgrading identification information is a fifth preset identification.
And writing the application program data of the copied application program area into the backup area, erasing the upgrading bit data of the upgrading bit area, erasing the application program data of the application program area after the updating identification information is a fourth preset identification, and erasing the upgrading bit data of the upgrading bit area again, wherein the updating identification information is a fifth preset identification. The vacated application program area is ready to receive the upgrade package data transmitted by the upper computer.
Specifically, the fifth preset identifier may be, for example, 0x6000, which indicates that the application data of the application area is erased. Therefore, when the electronic device is restarted due to upgrade errors in the link due to various reasons, the bootstrap program reads the fifth preset identifier when reading the upgrade flag bit data, which indicates that the application program data of the application program area of the electronic device is erased, and also indicates that the electronic device needs to perform program upgrade at this time, that is, the requirement that the determined number of sets of information in step S302 is not equal to the preset first preset identifier is met, and it is determined that the current program needs to be subjected to program upgrade.
S310, determining whether the array information is a second preset identifier.
The second preset identifier may be, for example, 0x3000, which indicates that the upgrade flag bit data has been erased.
Specifically, if it is determined that the array information does not meet the first preset condition, determining whether the array information is a second preset identifier, if it is determined that the array information is the second preset identifier, returning to S307, erasing the backup data of the backup area, erasing the upgrade flag bit data of the upgrade flag bit area, and updating the identifier information to be a third preset identifier. If it is determined that the array information is not the second preset identifier, S311 is continued to be executed.
S311, determining whether the array information is a third preset identification.
The third preset identifier may be, for example, 0x4000, which indicates that the backup data of the backup area is erased.
Specifically, if it is determined that the array information is not the second preset identifier, determining whether the array information is the third preset identifier, if it is determined that the array information is the third preset identifier, returning to S308, copying the application data of the application area to write into the backup area, erasing the upgrade flag bit data of the upgrade flag bit area, and updating the identifier information to be the fourth preset identifier. If it is determined that the array information is not the third preset identification, S312 is continued to be executed.
S312, determining whether the array information is a fourth preset identification.
The fourth preset identifier may be, for example, 0x5000, which indicates that the application data of the application area has been copied and written into the backup area.
Specifically, if it is determined that the array information is not the third preset identifier, determining whether the array information is the fourth preset identifier, if it is determined that the array information is the fourth preset identifier, returning to execute S309, erasing the application program area to be the application program data, erasing the upgrade flag bit data of the upgrade flag bit area, and updating the identifier information to be the fifth preset identifier. If it is determined that the array information is not the fourth preset identification, execution continues to S313.
S313, transmitting the array information to the upper computer.
Specifically, if it is determined that the array information is not the fourth preset identifier, the array information is sent to the upper computer. The array information is used for indicating the upper computer to issue the upgrade package data from the continuous transmission address. This step will be further described in the following examples.
S314, determining whether the array information meets a second preset condition.
The second preset condition is a preset condition for determining the array information when the upgrade instruction is not received within the first preset time, for example, whether the array information is preset with an identification interval may be determined, which is not limited in this embodiment.
Specifically, when it is determined that the upgrade instruction is not received within the first preset time, that is, the electronic device cannot communicate with the upper computer at this time so as to continue program upgrade. To ensure that normal use of the electronic device is not compromised, version rollback is required for the electronic device that failed to upgrade to restore to the pre-upgrade application version. Accordingly, it may be determined whether the array information satisfies a second preset condition, wherein the second preset condition may be determining whether the array information is a fourth preset identification or a fifth preset identification; the fourth preset identifier is preset identifier information, for example, may be 0x5000, which indicates that the application data of the application area has been copied and written into the backup area; the fifth preset identifier is preset identifier information, for example, may be 0x6000, which indicates that the application data of the application area is erased. If it is determined that the array information is the fourth preset identifier or the fifth preset identifier, it indicates that the application program in the application program area has been erased or partially erased in the previous upgrading process, and the backup area has stored backup data, so as to meet the requirement of rollback of the software version, thereby determining that the array information meets the second preset condition, and continuing to execute S315. If it is determined that the array information is not the fourth preset identifier or the fifth preset identifier, it indicates that the application program in the application program area is still complete in the previous upgrading process, and the application program may be directly run, thereby determining that the array information does not meet the second preset condition, and continuing to execute S316.
S315, erasing the application program data of the application program area, and copying the backup data of the backup area to the application program area.
Specifically, if it is determined that the array information meets the second preset condition, the application data of the application area is erased, the backup data of the backup area is copied to the application area, the rollback of the software version is completed, and S316 is continuously executed.
S316, jumping to the application program area for operation.
Specifically, if the array information is determined not to meet the second preset condition, jumping to the application program area for operation.
According to the technical scheme of the embodiment, the upgrading zone bit data of the upgrading zone bit area are read, and the array information is determined according to the upgrading zone bit data; determining whether the array information is equal to a first preset identifier; if the array information is determined to be not equal to a preset first preset mark, determining that the current program needs to be subjected to program upgrading, and executing the upgrading request; determining whether an upgrade instruction is received within a first preset time; if the electronic equipment is determined to receive the upgrade instruction sent by the upper computer within the first preset time, determining whether the array information is equal to a preset identification threshold value; if the array information is determined to be equal to the preset identification threshold value, determining that the array information meets a first preset condition, erasing upgrading zone bit data of an upgrading zone bit zone, and updating the identification information to be a second preset identification; erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information into a third preset identification; copying application program data of the application program area, writing the application program data into the backup area, erasing upgrading flag bit data of the upgrading flag bit area, and updating the identification information into a fourth preset identification; erasing application program data of the application program area, and erasing upgrading bit data of the upgrading bit area, wherein the upgrading identification information is a fifth preset identification; if the array information is determined to be not equal to the preset identification threshold value, determining that the array information does not meet the first preset condition, determining whether the array information is a second preset identification, if the array information is determined to be the second preset identification, returning back to execute the step of erasing the backup data of the backup area, erasing the upgrading zone bit data of the upgrading zone bit area, and updating the identification information to be a third preset identification step; if the array information is determined not to be the second preset identifier, determining whether the array information is the third preset identifier; if the array information is determined to be the third preset identification, returning the application program data of the copy application program area to be written into the backup area, and erasing the upgrade flag bit data of the upgrade flag bit area, wherein the update identification information is the fourth preset identification; if the array information is determined not to be the third preset mark, determining whether the array information is the fourth preset mark; if the array information is determined to be the fourth preset identification, returning to the step of executing the step of erasing the application program area to be the application program data, and erasing the upgrading bit data of the upgrading bit area, wherein the updating identification information is the fifth preset identification; if the array information is determined not to be the fourth preset mark, transmitting the array information to the upper computer; if the electronic equipment is determined not to receive the upgrade instruction sent by the upper computer within the first preset time, determining whether the array information meets a second preset condition; if the array information is determined to meet the second preset condition, the application program data of the application program area are erased, and the backup data of the backup area are copied to the application program area; if the array information is determined to not meet the second preset condition, jumping to the application program area for operation; if the array information is determined to be equal to a preset first preset identifier, determining that program upgrading of the current program is not needed currently, and executing jump to an application program area for operation. On the basis of the embodiment, the identification of the array information is determined and the identification of the array information is continuously updated according to the upgrading rule, so that the program upgrading position and the upgrading path can be accurately positioned through the identification, the program upgrading process is accurately determined, the software version of the electronic equipment can be rolled back after the upgrading fails, the upgrading safety is ensured, the normal operation of the electronic equipment is recovered, and the use experience of a user is improved.
FIG. 4 is a flowchart of a program upgrade method provided in an embodiment of the present application, where the embodiment is applicable to a version upgrade of a program, and the method may be performed by a program upgrade apparatus, where the program upgrade apparatus may be implemented in hardware and/or software, and in a specific embodiment, the program upgrade apparatus may be configured in an electronic device, where the electronic device includes a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area. On the basis of the above embodiment, for further description after updating the identification information to the fifth preset identification, as shown in fig. 4, the method specifically includes the following steps:
S401, notifying an upper computer to send the upgrade package data from the initial position group of the upgrade package data.
The initial position is the position where the initial address storing the upgrade package data is located.
Specifically, after the application area data is erased and the update identification information is the fifth preset identification, the electronic device may begin to receive the upgrade package data to perform OTA upgrade, so that the electronic device notifies the upper computer to issue the upgrade package data from the initial position packet of the upgrade package data.
When the upper computer transmits the upgrade package data, a sub-package transmission mode is adopted, each sub-package is 132 bytes, the first three bytes are the data package attribute, the serial number and the serial number inverse code, the middle 128 bytes are the upgrade data, and the last byte is the check code.
S402, the serial port receives upgrade package data.
After the electronic equipment receives the data packetizing, every two bytes are processed into 16-bit data, each flash address can be written into 16-bit data, and eight addresses are used as a group to be written into the flash.
S403, determining whether the upgrade package data is successfully checked.
Specifically, by determining whether the upgrade package data is abnormal, if it is determined that the upgrade package data is abnormal, S404 is performed; if it is determined that the upgrade package data is not abnormal, S407 is performed.
S404, notifying the upper computer to resend the upgrade data packet.
S405, determining whether the retransmission times of the same upgrade package data are less than or equal to the preset times.
The number of retransmissions refers to the number of repeated transmissions of the same upgrade packet data, and the preset number of transmissions of the upgrade packet data may be, for example, 2 or 3, which is not limited in this embodiment.
Specifically, it is determined whether the number of retransmissions of the same upgrade package data is less than or equal to a preset number of times, and if it is determined that the number of retransmissions of the same upgrade package data is greater than the preset number of times, S406 is performed. If it is determined that the number of retransmissions of the same upgrade package data is less than or equal to the preset number of retransmissions, the step of receiving the upgrade package data according to the upgrade rule and writing the upgrade package data into the application area is performed in return, and specifically, the step S402 is performed in return.
S406, the main control module is powered down and restarted.
Specifically, if it is determined that the number of times of retransmission of the same upgrade package data is greater than the preset number of times, the chip pin of the main control module is placed at a low level, so that the main control module is powered down and restarted, and returns to the step of reading the upgrade flag bit data of the upgrade flag bit area, and determining the array information according to the upgrade flag bit data.
For example, the preset number of times is determined to be 3, and if the lower computer fails to receive a certain group of upgrade package data, the lower computer will notify the upper computer to resend the group of upgrade package data. If the verification fails for three times continuously, the reset pin of the main control chip is actively set to be at a high level, the reset output pin is at a low level, the main control module is restarted after power failure, and the main control module enters a guide mode again to carry out upgrading.
S407, notifying the upper computer to send the next group of upgrade package data.
Specifically, if it is determined that the upgrade package data is not abnormal, the upper computer is notified to send the next group of upgrade package data.
Illustratively, if it is determined that there is no abnormality in the upgrade package data, the upgrade package data is written to the application area in a group of 64 addresses (128 bytes). Further, the method comprises the steps of,
S408, determining whether the next group of upgrade package data is received within a second preset time.
The second preset time is a preset time interval for receiving the upgrade packet data, for example, may be 3 seconds, 5 seconds, or the like, which is not limited in this embodiment. The initial position is calculated specifically by dividing 128 bytes into a small group and 1024 bytes into a large group by fixing the size of the upgrade data packet used each time. For example: 128 bytes are the minimum erasing unit of the memory of the chip used currently, 128 bytes are taken as a group of transmission data, 8 groups of transmission data, namely 1024 bytes, are transmitted, and the lower computer automatically increases 8 the data of the upgrading zone bit area of the upgrading process and writes the data. When unexpected power failure occurs in the process of receiving the upgrade package data, after the lower computer is restarted, the data is sent to the upper computer, and the lower computer starts to continuously transmit the upgrade package data from the address +1.
Specifically, after informing the upper computer to issue the upgrade package data from the initial position group of the upgrade package data, determining whether the next group of upgrade package data is received within a second preset time; if it is determined that the next group of upgrade package data is not received within the second preset time, returning to execute S406, and controlling the main control module to perform power-down restarting; if it is determined that the next group of upgrade package data is received within the second preset time, S409 is performed.
For example, the second preset time is determined to be 5 seconds, the lower computer is notified to transmit the next set of upgrade package data every time the lower computer receives the set of upgrade package data, if a new set of upgrade package data is not received within 5 seconds, the reset pin of the main control chip is set to be at a high level, the reset output pin is at a low level, the main control chip is restarted after power is lost, and the main control chip enters the boot mode again to perform upgrade.
S409, circularly receiving the upgrade package data.
Specifically, if it is determined that the next group of upgrade package data is received within the second preset time, the upgrade package data is continuously and circularly received, and the upgrade package data is sequentially written into the application program area according to the address packet.
S410, reading the upgrade flag bit data of the upgrade flag bit area every time a group of upgrade packet data is successfully written, and automatically increasing the upgrade flag bit data by a fixed value.
The fixed value is a self-increment value of the preset upgrade flag bit data, which is not limited in this embodiment.
Specifically, the upgrade package data are sequentially written into the application program area according to the address group, and each time a group of upgrade package data are successfully written, the upgrade flag bit data of the upgrade flag bit area are read, and the upgrade flag bit data are automatically increased by a fixed value.
Illustratively, every 1024 bytes are written, the upgrade flag bit data of the upgrade flag bit area is read, after the upgrade flag bit data is self-increased by a fixed value of 8, the upgrade flag bit data of the upgrade flag bit area is erased, and the upgrade flag bit data value after the self-increased fixed value is written. Therefore, even if the electronic equipment has abnormal conditions (such as abnormal power failure and the like) in the process of receiving the upgrade package data, the upgrade flag bit data is read and sent to the upper computer only after the electronic equipment is controlled to restart, the upper computer can know which data package is transmitted in the previous upgrade package transmission process according to the received upgrade flag bit data, and the upper computer starts to continuously transmit the upgrade package from the address +1. Therefore, the upgrade mode enables the electronic equipment to continuously transmit the upgrade package after power failure and restarting, and does not need to receive the complete upgrade package again, so that the upgrade package transmission process is quickened, the upgrade time is saved, and the use experience of a user is improved.
S411, receiving the end frame data packet.
The end frame data packet is sent by the upper computer to inform the electronic equipment that all the upgrade packet data sending is completed.
And S412, after the fact that the whole data of the upgrade package is received is determined, the upgrade flag bit data of the upgrade flag bit area is erased, and the upgrade identification information is a sixth preset identification.
The sixth preset flag may be, for example, 0x7000, which indicates that the upgrade package data is determined to be completely received.
Specifically, after the upgrade package data are all received, the upgrade flag bit data of the upgrade flag bit area are erased, the upgrade identification information is a sixth preset identification, and the operation steps are carried out by continuing to jump to the application program area.
In a specific embodiment, optionally, after updating the identification information to the sixth preset identification and jumping to the application area for running, the method further includes: the identification information is reset to a default value.
Specifically, after the update identification information is the sixth preset identification and jumps to the application area for operation, the identification information 0x7000 is reset to the default value 0xFFFF.
The method has the advantages that after the lower computer is restarted rapidly, the lower computer enters the guide program, when the fact that the data of the on-line upgrading zone bit region indicate that the program needs to be upgraded is detected, the corresponding upgrading flow, the program rollback flow or the upgrading packet continuous transmission flow are entered according to the difference of the data of the zone bit region, and the upgrading efficiency of program upgrading and the use experience sense of a user are improved.
According to the technical scheme, after the update identification information is the fifth preset identification, the upper computer is informed to send the upgrade package data from the initial position group of the upgrade package data; the serial port receives upgrade package data; determining whether the upgrade package data is successfully checked; if the data of the upgrade package is abnormal, informing the upper computer to resend the upgrade data package; determining whether the retransmission times of the same upgrade package data are less than or equal to preset times; if the number of times of retransmitting the same upgrade package data is determined to be greater than the preset number of times, the main control module is restarted after power failure; if the number of times of retransmitting the same upgrade package data is less than or equal to the preset number of times, returning to execute the step of receiving the upgrade package data according to the upgrade rule and writing the upgrade package data into the application program area, and specifically returning to execute the serial port to receive the upgrade package data; if the upgrade package data is determined to be abnormal, informing the upper computer to inform the upper computer to send next group of upgrade package data; determining whether next group of upgrade package data is received within a second preset time; if the fact that the next group of upgrade package data is not received within the second preset time is determined, returning to the execution main control module to perform power-down restarting; if the next group of upgrade package data is received within the second preset time, circularly receiving the upgrade package data; reading the upgrade flag bit data of the upgrade flag bit area every time a group of upgrade packet data is successfully written, and automatically increasing the upgrade flag bit data by a fixed value; sending an ending instruction to a lower computer; after the update package data are completely received, the update flag bit data of the update flag bit area are erased, the update identification information is a sixth preset identification, and the operation steps are carried out by continuing to jump to the application program area. On the basis of the embodiment, after the update identification information is the fifth preset identification, the update package data is received and checked, the update package data is divided into a plurality of groups of data packages to be received, the sending times and the receiving time intervals of each group of data packages are determined, all the update package data are accurately received, the update flag bit data of the update flag bit area are erased, the new identification information is the sixth preset identification, the update package data continue to jump to the application program area to operate, the accuracy and the high efficiency of receiving the update package data are improved, and the safe operation of a lower computer and the safe use condition of a user are ensured.
FIG. 5 is a schematic structural diagram of a program upgrading apparatus according to an embodiment of the present application, which is applied to an electronic device, and the electronic device includes a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; the device comprises: an information determination module 501, an information determination module 502, a program execution module 503, and a program upgrade module 504. Wherein,
The information determining module 501 is configured to read upgrade flag bit data of the upgrade flag bit area, and determine array information according to the upgrade flag bit data; wherein the upgrade flag bit data includes identification information.
The information judging module 502 is configured to determine whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed.
And the program running module 503 is configured to jump to the application area for running if it is determined that the array information is equal to the first preset identifier.
And the program upgrading module 504 is configured to receive the upgrade package data according to the upgrade rule and write the upgrade package data into the application program area for program upgrading if it is determined that the array information is not equal to the first preset identifier.
Optionally, the program upgrade module 504 is specifically configured to: if it is determined that the array information is not equal to the first preset identifier, receiving upgrade package data according to an upgrade rule, writing the upgrade package data into an application program area, and performing program upgrade, including: if the array information is determined not to be equal to the first preset identifier, an upgrading request is sent; determining whether an upgrade instruction is received within a first preset time; if the upgrading instruction is received within the first preset time, determining whether the array information meets the first preset condition; if the array information is determined to meet the first preset condition, receiving upgrade package data according to an upgrade rule, and writing the upgrade package data into an application program area for program upgrade; if the array information is determined to not meet the first preset condition, transmitting the array information to the upper computer; the array information is used for indicating the upper computer to issue the upgrade package data from the continuous transmission address.
Optionally, if it is determined that the array information meets the first preset condition, the program upgrade module 504 is specifically configured to: receiving upgrade package data according to upgrade rules and writing the upgrade package data into an application program area for program upgrade, wherein the method comprises the following steps: if the array information is determined to meet the first preset condition, the upgrading zone bit data of the upgrading zone bit area are erased, and the updating identification information is a second preset identification; the second preset mark indicates that the array information meets a first preset condition; erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information into a third preset identification; the third preset identifier indicates that the backup data of the backup area is erased; copying application program data of the application program area, writing the application program data into the backup area, erasing upgrading flag bit data of the upgrading flag bit area, and updating the identification information into a fourth preset identification; the fourth preset identifier indicates that the application program data of the application program area is copied and written into the backup area; erasing application program data of the application program area, and erasing upgrading bit data of the upgrading bit area, wherein the upgrading identification information is a fifth preset identification; the fifth preset identifier indicates that the application data of the application area is erased.
Optionally, the apparatus comprises: the data receiving module is used for notifying the upper computer to group and issue the upgrade package data from the initial position of the upgrade package data after the update identification information is a fifth preset identification; circularly receiving the upgrade package data, and sequentially writing the upgrade package data into the application program area according to the address grouping according to the upgrade rule; reading the upgrade flag bit data of the upgrade flag bit area every time a group of upgrade packet data is successfully written, and automatically increasing the upgrade flag bit data by a fixed value; after the complete receiving of the upgrade package data is determined, the upgrade flag bit data of the upgrade flag bit area is erased, the upgrade identification information is a sixth preset identification, and the upgrade package data is jumped to the application program area to operate; the sixth preset identifier indicates that the upgrade package data are completely received.
Optionally, if it is determined that the array information does not meet the first preset condition, the array information is sent to the upper computer, and the program upgrading module 504 is specifically configured to: if the array information is determined not to meet the first preset condition, determining whether the array information is a second preset mark or not; if the array information is determined to be the second preset identification, executing the step of erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information to be the third preset identification; if the array information is determined not to be the second preset identifier, determining whether the array information is the third preset identifier; if the array information is determined to be the third preset identification, returning the application program data of the copy application program area to be written into the backup area, and erasing the upgrade flag bit data of the upgrade flag bit area, wherein the update identification information is the fourth preset identification; if the array information is determined not to be the third preset mark, determining whether the array information is the fourth preset mark; if the array information is determined to be the fourth preset identification, returning to the step of executing the step of erasing the application program area to be the application program data, and erasing the upgrading bit data of the upgrading bit area, wherein the updating identification information is the fifth preset identification; and if the array information is determined not to be the fourth preset mark, transmitting the array information to the upper computer.
Optionally, the program upgrade module 504 is further configured to: if it is determined that the upgrading instruction is not received within the first preset time, determining whether the array information meets a second preset condition; if the array information is determined to meet the second preset condition, erasing the application program data of the application program area, copying the backup data of the backup area to the application program area, and jumping to the application program area for operation; if the array information is determined not to meet the second preset condition, jumping to the application program area for operation.
Optionally, the apparatus further comprises: and (5) restarting the module after power failure. The method is particularly used for: after informing an upper computer to group and issue the upgrade package data from the initial position of the upgrade package data, determining whether the upgrade package data is successfully checked; if the verification of the upgrade package data is determined to fail, informing the upper computer to resend the upgrade package data; determining whether the retransmission times of the same upgrade package data are less than or equal to preset times; if the number of times of retransmitting the same upgrade package data is determined to be greater than the preset number of times, the main control module is restarted after power failure; if the number of times of retransmitting the same upgrade package data is less than or equal to the preset number of times, returning to execute the step of receiving the upgrade package data according to the upgrade rule and writing the upgrade package data into the application program area.
Optionally, the apparatus further comprises: and a data receiving module. The method is particularly used for: after informing the upper computer to group and issue the upgrade package data from the initial position of the upgrade package data, determining whether the next group of upgrade package data is received in a second preset time; if the fact that the next group of upgrade package data is not received within the second preset time is determined, the main control module is powered down and restarted; if the next group of upgrade package data is received within the second preset time, the upgrade package data is continuously and circularly received.
Optionally, the apparatus further comprises: and a reset module. The method is particularly used for: and after the updated identification information is the sixth preset identification and the application program area is jumped to run, resetting the identification information to a default value.
The program upgrading device provided by the embodiment can execute the program upgrading method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 6 is a schematic diagram of an electronic device provided in one embodiment of the application, the electronic device being intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a Memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a random access Memory (also referred to as "random access Memory", random Access Memory, RAM) 13, etc., in which the Memory stores a computer program executable by the at least one processor, and the processor 11 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks. The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, such as a program upgrade method.
In some embodiments, the program upgrade method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When a computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the program upgrade method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the program upgrade method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above can be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. The program upgrading method is characterized by being applied to electronic equipment, wherein the electronic equipment comprises a main control module; the storage partition of the main control module comprises an upgrade zone bit area, a backup area and an application program area; the method comprises the following steps:
reading the upgrade flag bit data of the upgrade flag bit area, and determining array information according to the upgrade flag bit data; wherein, the upgrade flag bit data comprises identification information;
determining whether the array information is equal to a first preset identifier; the first preset identifier indicates that program upgrading is not needed;
If the array information is determined to be equal to the first preset identifier, jumping to the application program area for operation;
And if the array information is determined not to be equal to the first preset identifier, receiving upgrade package data according to an upgrade rule, and writing the upgrade package data into the application program area to upgrade the program.
2. The program upgrading method according to claim 1, wherein if it is determined that the array information is not equal to the first preset identifier, receiving upgrade package data according to an upgrade rule, writing the upgrade package data into the application program area for program upgrading, and comprising:
if the array information is determined to be not equal to the first preset identifier, an upgrading request is sent;
Determining whether an upgrade instruction is received within a first preset time;
if the upgrading instruction is received within the first preset time, determining whether the array information meets a first preset condition;
if the array information is determined to meet the first preset condition, receiving the upgrade package data according to an upgrade rule, and writing the upgrade package data into the application program area for program upgrade;
If the array information is determined not to meet the first preset condition, sending the array information to an upper computer; the array information is used for indicating the upper computer to issue the upgrade package data from the continuous transmission address.
3. The program upgrade method according to claim 2, wherein if it is determined that the array information satisfies the first preset condition, the program upgrade is performed by receiving the upgrade package data according to an upgrade rule and writing the upgrade package data into the application program area, including:
If the array information is determined to meet the first preset condition, the upgrading zone bit data of the upgrading zone bit area are erased, and the identification information is updated to be a second preset identification; the second preset identifier indicates that the array information meets the first preset condition;
erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information into a third preset identification; wherein, the third preset mark indicates that the backup data of the backup area is erased;
Copying application program data of the application program area, writing the application program data into the backup area, erasing upgrading flag bit data of the upgrading flag bit area, and updating the identification information into a fourth preset identification; wherein, the fourth preset identifier indicates that the application program data of the application program area is copied and written into the backup area;
erasing application program data of the application program area, erasing upgrading bit data of the upgrading bit area, and updating the identification information into a fifth preset identification; wherein the fifth preset identifier indicates that the application data of the application area is erased.
4. The program upgrade method according to claim 3, further comprising, after said updating the identification information to a fifth preset identification:
notifying the upper computer to group and issue the upgrade package data from the initial position of the upgrade package data;
Circularly receiving the upgrade package data, and sequentially writing the upgrade package data into the application program area according to the upgrade rule and the address grouping;
Reading the upgrade flag bit data of the upgrade flag bit area and automatically increasing the upgrade flag bit data by a fixed value every time a group of upgrade packet data is successfully written;
After the upgrade package data are all received, the upgrade flag bit data of the upgrade flag bit area are erased, the identification information is updated to be a sixth preset identification, and the upgrade package data are jumped to the application program area to operate; wherein, the sixth preset identifier indicates that the upgrade package data is completely received.
5. The method of claim 4, wherein if the determining that the array information does not meet the first preset condition, sending the array information to an upper computer includes:
if the array information is determined not to meet the first preset condition, determining whether the array information is the second preset mark or not;
If the array information is determined to be the second preset identification, executing the step of erasing the backup data of the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information to be a third preset identification;
if the array information is determined not to be the second preset identifier, determining whether the array information is the third preset identifier;
if the array information is determined to be the third preset identification, returning to the step of executing the copying of the application program data of the application program area to write the application program data into the backup area, erasing the upgrading bit data of the upgrading bit area, and updating the identification information to be a fourth preset identification;
if the array information is determined not to be the third preset identifier, determining whether the array information is the fourth preset identifier;
if the array information is determined to be the fourth preset identification, returning to the step of executing the step of erasing the application program area to be the application program data and erasing the upgrading zone bit data of the upgrading zone bit area, and updating the identification information to be a fifth preset identification;
And if the array information is determined not to be the fourth preset identifier, transmitting the array information to an upper computer.
6. The program upgrade method according to claim 2, further comprising:
if it is determined that the upgrading instruction is not received within the first preset time, determining whether the array information meets a second preset condition;
If the array information is determined to meet the second preset condition, erasing the application program data of the application program area, copying the backup data of the backup area to the application program area, and jumping to the application program area for operation;
And if the array information is determined not to meet the second preset condition, jumping to the application program area for operation.
7. The program upgrade method according to claim 4, further comprising, after notifying the host computer to issue the upgrade package data from an initial location packet of the upgrade package data:
determining whether the upgrade package data is successfully checked;
If the upgrade package data verification fails, notifying the upper computer to resend the upgrade package data;
determining whether the same retransmission times of the upgrade package data are less than or equal to preset times;
if the same retransmission times of the upgrade package data are determined to be greater than the preset times, the main control module is powered down and restarted;
and if the same retransmission times of the upgrade package data are less than or equal to the preset times, returning to execute the step of receiving the upgrade package data according to the upgrade rule and writing the upgrade package data into the application program area.
8. The program upgrade method according to claim 4, further comprising, after notifying the host computer to issue the upgrade package data from an initial location packet of the upgrade package data:
determining whether the next group of upgrade package data is received within a second preset time;
if the fact that the next group of upgrade package data is not received within the second preset time is determined, the main control module is powered down and restarted;
and if the next group of upgrade package data is received within the second preset time, continuing to circularly receive the upgrade package data.
9. The program upgrade method according to claim 4, wherein after the updating the identification information is a sixth preset identification and jumping to the application program area for operation, further comprising:
And resetting the identification information to a default value.
10. An electronic device, the electronic device comprising:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein,
The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the program upgrade method of any one of claims 1-9.
CN202410201678.XA 2024-02-23 2024-02-23 Program upgrading method and electronic equipment Pending CN117971272A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410201678.XA CN117971272A (en) 2024-02-23 2024-02-23 Program upgrading method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410201678.XA CN117971272A (en) 2024-02-23 2024-02-23 Program upgrading method and electronic equipment

Publications (1)

Publication Number Publication Date
CN117971272A true CN117971272A (en) 2024-05-03

Family

ID=90852995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410201678.XA Pending CN117971272A (en) 2024-02-23 2024-02-23 Program upgrading method and electronic equipment

Country Status (1)

Country Link
CN (1) CN117971272A (en)

Similar Documents

Publication Publication Date Title
EP2375323A1 (en) Firmware image update and management
CN111813428A (en) Method and device for upgrading terminal firmware, electronic equipment and storage medium
CN114003538B (en) Identification method of intelligent network card and intelligent network card
CN102945173A (en) User program on-line upgrading system and method
CN113064748B (en) Process succession method, device, electronic equipment and storage medium
CN114281394A (en) Method, system, equipment and medium for fast on-line upgrading program
CN112015447B (en) System updating method and device of electronic equipment, electronic equipment and storage medium
CN108874422B (en) Software online upgrading method for refrigerator electric control board, refrigerator electric control board and refrigerator
CN107894900B (en) MCU upgrading method and system
EP2750030A1 (en) Method, apparatus and processor for reading BIOS
CN117971272A (en) Program upgrading method and electronic equipment
CN111610995B (en) Device firmware upgrading method and device, electronic device and storage medium
US11586504B2 (en) Electronic apparatus and boot method thereof
CN115033261A (en) Program updating method, device, equipment and storage medium
CN114995854A (en) Application program online upgrading method and device, terminal and operation machine
CN116802635A (en) BIOS update for electronic device
CN115794179A (en) Program upgrading method and device, electronic equipment and storage medium
CN111723038B (en) Signal compensation method and device, electronic equipment and storage medium
CN116775152A (en) Chip starting method and chip
CN111666094B (en) Real-time firmware upgrading system and method
CN117931254A (en) Firmware upgrading method and device, electronic equipment and storage medium
CN107341065B (en) Method and device for outputting debugging information
CN116185457A (en) Data updating method, integrated circuit chip, electronic device, and storage medium
CN117539523A (en) Firmware upgrading method, device, controller, system and storage medium
CN115421761A (en) Method, device, system, equipment and medium for upgrading micro-control unit application program

Legal Events

Date Code Title Description
PB01 Publication