Disclosure of Invention
The embodiment of the invention aims to provide a firmware upgrading method, a firmware upgrading device and a computer readable storage medium, which can improve the firmware upgrading efficiency.
To solve the foregoing technical problem, an embodiment of the present invention provides a firmware upgrading method, including:
when a firmware upgrading instruction sent by an upper computer is received, starting a circulating waiting program for controlling the reset of the watchdog program;
when a preset initialization program is operated, judging whether the watchdog program is reset or not;
if the watchdog program is not reset, executing a preset application program;
if the watchdog program is reset, judging whether a data packet sent by the upper computer is received within preset time; if not, executing a preset application program; and if so, utilizing the data packet to execute upgrading operation on the firmware.
Optionally, before the performing an upgrade operation on the firmware by using the data packet, the method further includes:
judging whether the device name carried in the data packet is matched with the device name recorded in the system, whether the firmware version number carried in the data packet is matched with the firmware version number recorded in a preset storage medium, and whether the size of the firmware carried in the data packet is smaller than or equal to the capacity of the storage medium;
if yes, executing the step of executing upgrading operation on the firmware by using the data packet;
if not, judging that the data packet is invalid data, and performing alarm prompt.
Optionally, before the executing the preset application program, the method further includes:
reading firmware information from a preset storage medium, and verifying the firmware information according to a set verification bit;
and executing a preset application program after the firmware information passes the verification.
Optionally, the method further comprises:
and when the firmware information is not verified, displaying prompt information of firmware information failure.
Optionally, when a firmware upgrade instruction sent by the upper computer is received, starting a loop waiting program for controlling reset of the watchdog program includes:
when instruction information sent by an upper computer is received, judging whether the instruction information is a firmware upgrading instruction or not;
if yes, a circular waiting program for controlling the reset of the watchdog program is started.
The embodiment of the invention also provides a firmware upgrading device, which comprises a starting unit, a first judging unit, an executing unit, a second judging unit and an upgrading unit;
the starting unit is used for starting a circulating waiting program for controlling the reset of the watchdog program when receiving a firmware upgrading instruction sent by the upper computer;
the first judging unit is used for judging whether the watchdog program is reset or not when a preset initialization program is operated;
the execution unit is used for executing a preset application program if the watchdog program is not reset;
the second judging unit is used for judging whether a data packet sent by the upper computer is received within a preset time or not if the watchdog program is reset; if not, triggering the execution unit to execute a preset application program; if yes, triggering the upgrading unit;
and the upgrading unit is used for executing upgrading operation on the firmware by using the data packet.
Optionally, the system further comprises a third judging unit and a prompting unit;
the third judging unit is configured to, before the upgrade operation is performed on the firmware by using the data packet, judge whether a device name carried in the data packet matches a device name recorded in a system, whether a firmware version number carried in the data packet matches a firmware version number recorded in a preset storage medium, and whether a size of the firmware carried in the data packet is smaller than or equal to a capacity of the storage medium; if yes, triggering the upgrading unit; if not, triggering the prompting unit;
and the prompting unit is used for judging the data packet as invalid data and carrying out alarm prompting.
Optionally, the system further comprises a verification unit;
the verification unit is used for reading firmware information from a preset storage medium and verifying the firmware information according to a set verification bit; and when the firmware information passes the verification, triggering the execution unit to execute a preset application program.
Optionally, the device further comprises a display unit;
and the display unit is used for displaying prompt information of firmware information failure when the firmware information is not verified.
Optionally, the starting unit is specifically configured to, when receiving instruction information sent by an upper computer, determine whether the instruction information is a firmware upgrade instruction; if yes, a circular waiting program for controlling the reset of the watchdog program is started.
An embodiment of the present invention further provides a firmware upgrading apparatus, including:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the firmware upgrade method as claimed in any one of the above.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the firmware upgrading method according to any one of the above are implemented.
According to the technical scheme, when a firmware upgrading instruction sent by an upper computer is received, a circulating waiting program for controlling the reset of the watchdog program is started; when a preset initialization program is operated, judging whether the watchdog program is reset or not; if the watchdog program is not reset, it indicates that the current initialization program is not operated to implement the firmware upgrade operation, and in order to ensure the normal operation of the system, a preset application program may be executed at this time. If the watchdog program is reset, it indicates that firmware upgrading operation needs to be executed, and at this time, it can be determined whether a data packet sent by the upper computer is received within a preset time. When the data packet sent by the upper computer is not received within the preset time, the reset of the watchdog program caused by the program runaway may occur, the firmware is not upgraded, and the preset application program can be executed at the moment in order to ensure the normal operation of the system. And when the data packet sent by the upper computer is received within the preset time, the data packet is utilized to carry out upgrading operation on the firmware. In the technical scheme, the firmware upgrading operation is triggered by adopting the independent watchdog program, so that the execution efficiency of firmware upgrading is effectively improved. And a cyclic waiting program is added in the system software program, so that the watchdog program is reset, and the development difficulty of the software program is greatly reduced.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Next, a firmware upgrading method provided by an embodiment of the present invention is described in detail. Fig. 1 is a flowchart of a firmware upgrading method according to an embodiment of the present invention, where the method includes:
s101: and when a firmware upgrading instruction sent by the upper computer is received, starting a circulating waiting program for controlling the reset of the watchdog program.
In the embodiment of the invention, the firmware is upgraded by a software deployment mode.
The watchdog program has a set timing time, and when the set timing time is reached and a response message sent by the system is not received, the watchdog program is triggered to reset.
In the embodiment of the invention, in order to reduce the difficulty of software deployment, a loop waiting program can be added in a system software program to reset a watchdog program.
When the system receives a firmware upgrading instruction sent by the upper computer, the loop waiting program can be started, the watchdog program starts timing at the moment, and when the timing time of the watchdog program is reached, the watchdog program can automatically reset.
The system receives the instruction information in various forms, and different types of instruction information are used for executing different operations. In the embodiment of the invention, the specific form of the firmware upgrading instruction can be preset, and when the system receives the instruction information sent by the upper computer, whether the instruction information is the firmware upgrading instruction can be judged; and when the instruction information is a firmware upgrading instruction, starting a loop waiting program for controlling the reset of the watchdog program.
S102: and when the preset initialization program is operated, judging whether the watchdog program is reset or not.
In the embodiment of the present invention, a program for running firmware may be used as an application program, and a preprocessing program for upgrading firmware may be used as an initialization program.
The watchdog program may trigger an initialization program upon reset, at which time the initialization program is run.
Considering that there are many factors that trigger the initialization program in practical applications, when the initialization program is executed, it may not be caused by the reset of the watchdog program. Therefore, when the preset initialization program is executed, it may be further determined whether the watchdog program is reset in order to determine whether the upgrade operation of the firmware needs to be performed.
When the watchdog program is not reset, it indicates that the current initialization program is operated and is not used for implementing the firmware upgrade operation, and in order to ensure the normal operation of the system, S103 may be executed at this time.
When the watchdog program is reset, it indicates that the firmware upgrade operation needs to be performed, and at this time, S104 may be performed.
S103: and executing the preset application program.
S104: and judging whether the data packet sent by the upper computer is received within the preset time.
The value of the preset time can be set according to the time spent by the upper computer for transmitting the data packet, and is not limited herein.
When the firmware upgrading operation needs to be executed, the upper computer issues a corresponding data packet to a system of the lower computer, wherein the data packet is the firmware to be updated.
When the system does not receive the data packet sent by the upper computer within the preset time, the reset of the watchdog program caused by the program runaway may occur, the firmware is not upgraded, and the preset application program can be executed at the moment in order to ensure the normal operation of the system. And when the data packet sent by the upper computer is received within the preset time, S105 is executed.
S105: and performing upgrading operation on the firmware by using the data packet.
The data packet contains the device name corresponding to the firmware. In a specific implementation, the firmware to be upgraded can be determined according to the device name contained in the data packet, so that the firmware information contained in the data packet replaces the original firmware information, and the upgrading operation of the corresponding firmware is completed.
According to the technical scheme, when a firmware upgrading instruction sent by an upper computer is received, a circulating waiting program for controlling the reset of the watchdog program is started; when a preset initialization program is operated, judging whether the watchdog program is reset or not; if the watchdog program is not reset, it indicates that the current initialization program is not operated to implement the firmware upgrade operation, and in order to ensure the normal operation of the system, a preset application program may be executed at this time. If the watchdog program is reset, it indicates that firmware upgrading operation needs to be executed, and at this time, it can be determined whether a data packet sent by the upper computer is received within a preset time. When the data packet sent by the upper computer is not received within the preset time, the reset of the watchdog program caused by the program runaway may occur, the firmware is not upgraded, and the preset application program can be executed at the moment in order to ensure the normal operation of the system. And when the data packet sent by the upper computer is received within the preset time, the data packet is utilized to carry out upgrading operation on the firmware. In the technical scheme, the firmware upgrading operation is triggered by adopting the independent watchdog program, so that the execution efficiency of firmware upgrading is effectively improved. And a cyclic waiting program is added in the system software program, so that the watchdog program is reset, and the development difficulty of the software program is greatly reduced.
In the embodiment of the present invention, the data packet includes information such as a firmware version number and a firmware size in addition to the device name.
In order to ensure smooth execution of firmware upgrade, validity of the data packet may be detected before the firmware is upgraded by the data packet.
Specifically, it may be determined whether the device name carried in the data packet matches the device name recorded in the system, whether the firmware version number carried in the data packet matches the firmware version number recorded in the preset storage medium, and whether the size of the firmware carried in the data packet is smaller than or equal to the capacity of the storage medium.
When the device name carried in the data packet matches with the device name recorded in the system, it indicates that the firmware to be upgraded matches with the device, and at this time, the upgrade operation of the firmware can be executed.
The firmware version number is generally recorded in a digital form, and the higher the value of the number is, the newer the firmware version is. Taking numbers as an example of firmware version numbers, when a firmware upgrade operation is executed, and the firmware version number carried in a data packet is greater than the firmware version number recorded in a preset storage medium, it indicates that the firmware version number carried in the data packet matches the firmware version number recorded in the preset storage medium, and then the upgrade operation of the firmware can be executed.
When the size of the firmware carried in the data packet is smaller than or equal to the capacity of the storage medium, the upgrading operation of the firmware can be realized.
Therefore, when the device name carried in the packet matches the device name recorded in the system, the firmware version number carried in the packet matches the firmware version number recorded in the preset storage medium, and the firmware size carried in the packet is smaller than or equal to the capacity of the storage medium, the step of performing the upgrade operation on the firmware using the packet is performed.
When the device name carried in the data packet is not matched with the device name recorded in the system, or the firmware version number carried in the data packet is not matched with the firmware version number recorded in the preset storage medium, or the size of the firmware carried in the data packet is larger than the capacity of the storage medium, the upgrading operation of the firmware cannot be realized, at this moment, the data packet can be judged to be invalid data, and an alarm prompt is carried out.
By detecting the validity of the data packet, smooth execution of firmware upgrading operation can be guaranteed by the maximum program. When the data packet fails to pass the validity detection, the user can conveniently find and solve the problem in time by carrying out the alarm prompt, and the influence of the wrong data packet on the upgrading of the system firmware is reduced.
When the firmware information has problems, errors can occur in system operation, and when the firmware information is serious, the system can be crashed. Therefore, before executing the preset application program, the firmware information can be read from the preset storage medium and verified according to the set verification bits; and executing the preset application program after the firmware information passes the verification.
In a specific implementation, a Cyclic Redundancy Check (CRC) mode may be used to Check the correctness of the firmware information.
It is assumed that the firmware information is 20-bit data information, the first 18 bits are set as valid data in the CRC check, and the last two bits are set as check bit data. After the firmware information is read from the preset storage medium, the verification data can be calculated according to the first 18 bits of valid data of the firmware information, and when the calculated verification data is consistent with the last two bits of data of the firmware information read from the storage medium, it indicates that the firmware information read from the storage medium is not modified, and at this time, the preset application program can be executed.
In the embodiment of the invention, when the firmware information is not verified, prompt information of firmware information failure can be displayed, so that a user can replace or modify the failed firmware information in time.
By checking the firmware information, the correctness of the firmware information can be effectively ensured, so that the application program is ensured to call the correct firmware information, and the stability and the safety of system operation are ensured.
Fig. 2 is a schematic structural diagram of a firmware upgrading apparatus according to an embodiment of the present invention, where the apparatus includes a starting unit 21, a first determining unit 22, an executing unit 23, a second determining unit 24, and an upgrading unit 25;
the starting unit 21 is used for starting a circulating waiting program for controlling the reset of the watchdog program when receiving a firmware upgrading instruction sent by an upper computer;
a first judging unit 22, configured to judge whether the watchdog program is reset when a preset initialization program is executed;
the execution unit 23 is configured to execute a preset application program if the watchdog program is not reset;
the second judging unit 24 is configured to judge whether a data packet sent by the upper computer is received within a preset time if the watchdog program is reset; if not, the execution unit 23 is triggered to execute the preset application program; if yes, the upgrading unit 25 is triggered;
and an upgrade unit 25 for performing an upgrade operation on the firmware using the data packet.
Optionally, the system further comprises a third judging unit and a prompting unit;
a third judging unit, configured to judge whether a device name carried in the data packet matches a device name recorded in the system, whether a firmware version number carried in the data packet matches a firmware version number recorded in a preset storage medium, and whether a size of firmware carried in the data packet is smaller than or equal to a capacity of the storage medium before performing an upgrade operation on the firmware using the data packet; if yes, triggering an upgrading unit; if not, triggering a prompt unit;
and the prompting unit is used for judging the data packet as invalid data and carrying out alarm prompting.
Optionally, the system further comprises a verification unit;
the verification unit is used for reading the firmware information from a preset storage medium and verifying the firmware information according to a set verification bit; and when the firmware information passes the verification, triggering the execution unit to execute the preset application program.
Optionally, the device further comprises a display unit;
and the display unit is used for displaying prompt information of firmware information failure when the firmware information is not verified.
Optionally, the starting unit is specifically configured to, when receiving instruction information sent by the upper computer, determine whether the instruction information is a firmware upgrade instruction; if yes, a circular waiting program for controlling the reset of the watchdog program is started.
The description of the features in the embodiment corresponding to fig. 2 may refer to the related description of the embodiment corresponding to fig. 1, and is not repeated here.
According to the technical scheme, when a firmware upgrading instruction sent by an upper computer is received, a circulating waiting program for controlling the reset of the watchdog program is started; when a preset initialization program is operated, judging whether the watchdog program is reset or not; if the watchdog program is not reset, it indicates that the current initialization program is not operated to implement the firmware upgrade operation, and in order to ensure the normal operation of the system, a preset application program may be executed at this time. If the watchdog program is reset, it indicates that firmware upgrading operation needs to be executed, and at this time, it can be determined whether a data packet sent by the upper computer is received within a preset time. When the data packet sent by the upper computer is not received within the preset time, the reset of the watchdog program caused by the program runaway may occur, the firmware is not upgraded, and the preset application program can be executed at the moment in order to ensure the normal operation of the system. And when the data packet sent by the upper computer is received within the preset time, the data packet is utilized to carry out upgrading operation on the firmware. In the technical scheme, the firmware upgrading operation is triggered by adopting the independent watchdog program, so that the execution efficiency of firmware upgrading is effectively improved. And a cyclic waiting program is added in the system software program, so that the watchdog program is reset, and the development difficulty of the software program is greatly reduced.
Fig. 3 is a schematic diagram of a hardware structure of a firmware upgrading apparatus 30 according to an embodiment of the present invention, including:
a memory 31 for storing a computer program;
a processor 32 for executing a computer program to implement the steps of any of the firmware upgrade methods described above.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when being executed by a processor, the computer program realizes the steps of any one of the firmware upgrading methods.
The above details describe a firmware upgrading method, apparatus, and computer-readable storage medium provided by the embodiments of the present invention. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.