CN111083001A - Firmware abnormity detection method and device - Google Patents

Firmware abnormity detection method and device Download PDF

Info

Publication number
CN111083001A
CN111083001A CN201811216428.4A CN201811216428A CN111083001A CN 111083001 A CN111083001 A CN 111083001A CN 201811216428 A CN201811216428 A CN 201811216428A CN 111083001 A CN111083001 A CN 111083001A
Authority
CN
China
Prior art keywords
address
target firmware
local server
electronic equipment
firmware
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.)
Granted
Application number
CN201811216428.4A
Other languages
Chinese (zh)
Other versions
CN111083001B (en
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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201811216428.4A priority Critical patent/CN111083001B/en
Publication of CN111083001A publication Critical patent/CN111083001A/en
Application granted granted Critical
Publication of CN111083001B publication Critical patent/CN111083001B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0817Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking functioning
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • H04L41/082Configuration setting characterised by the conditions triggering a change of settings the condition being updates or upgrades of network functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0866Checking the configuration
    • H04L41/0869Validating the configuration within one network element
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • H04L43/103Active monitoring, e.g. heartbeat, ping or trace-route with adaptive polling, i.e. dynamically adapting the polling rate
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a firmware abnormity detection method and a firmware abnormity detection device, wherein the method comprises the following steps: detecting whether a check file of the target firmware is stored in the electronic equipment, wherein the check file is a file which is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment; if not, determining that the target firmware is abnormal. According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.

Description

Firmware abnormity detection method and device
Technical Field
The present application relates to the field of device detection technologies, and in particular, to a firmware anomaly detection method and apparatus.
Background
The Network Video Recorder (NVR) can be connected to the network camera through a network, and is configured to receive video data transmitted by the network camera and store and manage the received video data, so that a distributed architecture for the network camera is implemented, and convenience is provided for storage, management and the like of the video data.
The firmware in the NVR can be considered as a "driver" of the NVR device, and is used for implementing the function of the NVR, so that the normal firmware can support the NVR to operate normally. Generally, firmware is solidified in a storage medium such as Flash memory (Flash memory) by a manufacturer. Based on the importance of the firmware in the NVR, in order to achieve the purposes of perfecting the function of the NVR, enhancing the stability of the NVR, repairing the bug of the NVR and the like, the firmware in the NVR can be upgraded irregularly, so that the function of the NVR is more perfect, the operation is more stable, the operation is safer and the like. The upgrade of the firmware is completed in the operating system of the NVR.
However, during the firmware upgrade process, the firmware upgrade may fail due to power failure, misoperation, and the like, thereby causing the firmware to be damaged. After the firmware is damaged, the user cannot find the damaged firmware in time, so that the operation of the NVR is affected, and the video data in the NVR is lost.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for detecting a firmware exception, so as to solve the problem of detecting a firmware exception. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a firmware exception detection method, where the method includes:
detecting whether a check file of a target firmware is stored in electronic equipment, wherein the check file is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment;
and if not, determining that the target firmware is abnormal.
Optionally, the detecting whether a verification file of the target firmware is stored in the electronic device includes:
detecting whether a verification file of a target firmware is stored in the electronic equipment or not in an initialization stage of starting the electronic equipment;
the method further comprises the following steps:
if a check file of the target firmware is stored in the electronic equipment, reading a check value in the check file in the initialization stage;
and when the read check value is a preset abnormal check value, determining that the target firmware is abnormal.
Optionally, the method further comprises:
when the read check value is not the abnormal check value, adding a preset value to the read check value to obtain a new check value, and writing the new check value into the check file as an updated check value of the check file; starting an operating system of the electronic equipment, and judging whether the operating system is started successfully;
if so, writing a default check value into the check file as an updated check value of the check file;
if not, restarting the initialization stage, and returning to the step of reading the check value in the check file in the initialization stage.
Optionally, the electronic device is in the same network as the local server, and the method further includes:
after determining that the target firmware is abnormal, sending a detection request message to the local server, wherein the detection request message carries identification information of the target firmware, so that the local server acquires the target firmware according to the identification information;
and acquiring the target firmware from the local server and installing the target firmware.
Optionally, the sending the probe request packet to the local server includes:
under the condition that the electronic equipment sends a detection request message to the local server, determining a time point of sending the detection request message last time as a first time point;
sending the detection request message to the local server at a second time point which is separated from the first time point by a first preset time length;
and sending the detection request message to the local server at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
Optionally, the method further comprises:
and when the target firmware is successfully installed, acquiring the identification information of the target firmware and storing the identification information.
Optionally, the obtaining the target firmware from the local server and installing the target firmware includes:
receiving a detection response message sent by the local server, wherein the detection response message carries: a server IP address, a device IP address, and a port number of the local server;
establishing connection with the local server by using the server IP address and the equipment IP address;
and downloading the target firmware from the local server through the port of the port number.
Optionally, the probe response message further carries an MAC address;
after the step of receiving the probe response packet sent by the local server, before the step of establishing a connection with the local server by using the server IP address and the device IP address, the method further includes:
acquiring the MAC address carried by the detection response message;
judging whether the obtained MAC address is matched with the MAC address of the electronic equipment or not;
and if so, executing the step of establishing connection with the local server by utilizing the server IP address and the equipment IP address.
Optionally, before the step of downloading the target firmware from the local server through the port of the port number, the method further includes:
and sending an Address Resolution Protocol (ARP) message to the local server, wherein the ARP message comprises the equipment IP address and the MAC address of the electronic equipment, so that the local server updates a stored ARP table entry according to the equipment IP address and the MAC address, and the ARP table entry records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment.
Optionally, the electronic device obtains the device IP address according to the following method:
the electronic equipment takes an IP address configured when the target firmware is installed as the equipment IP address;
the electronic equipment stores the equipment IP address locally;
the electronic device locally obtains the device IP address after determining that the target firmware is abnormal.
In a second aspect, an embodiment of the present application provides a firmware anomaly detection apparatus, including:
the device comprises a first detection module, a second detection module and a control module, wherein the first detection module is used for detecting whether a check file of target firmware is stored in electronic equipment or not, the check file is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment, and the check file is used for indicating that the target firmware is successfully installed in the electronic equipment;
and the first determining module is used for determining that the target firmware is abnormal when the detection result of the first detecting module is negative.
Optionally, the first detection module is specifically configured to:
detecting whether a verification file of a target firmware is stored in the electronic equipment or not in an initialization stage of starting the electronic equipment;
the device further comprises:
the reading module is used for reading the check value in the check file in the initialization stage when the detection result of the first detection module is yes;
and the second determining module is used for determining that the target firmware is abnormal when the read check value is a preset abnormal check value.
Optionally, the apparatus further comprises:
the second detection module is used for adding a preset value to the read check value to obtain a new check value when the read check value is not the abnormal check value, and writing the new check value into the check file to be used as an updated check value of the check file; starting an operating system of the electronic equipment, and detecting whether the operating system is started successfully;
the writing module is used for writing a default check value into the check file as an updated check value of the check file when the detection result of the second detection module is yes;
and the updating module is used for restarting the initialization stage and triggering the reading module to execute the initialization stage and read the check value in the check file when the detection result of the second detection module is negative.
Optionally, the electronic device is in the same network as the local server, and the apparatus further includes:
a first sending module, configured to send a probe request packet to the local server after determining that the target firmware is abnormal, where the probe request packet carries identification information of the target firmware, so that the local server obtains the target firmware according to the identification information;
and the first acquisition module is used for acquiring the target firmware from the local server and installing the target firmware.
Optionally, the sending module is specifically configured to:
under the condition that the electronic equipment sends a detection request message to the local server, determining a time point of sending the detection request message last time as a first time point;
sending the detection request message to the local server at a second time point which is separated from the first time point by a first preset time length;
and sending the detection request message to the local server at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
Optionally, the apparatus further comprises:
and the second acquisition module is used for acquiring the identification information of the target firmware and storing the identification information after the target firmware is successfully installed.
Optionally, the first obtaining module is specifically configured to:
receiving a detection response message sent by the local server, wherein the detection response message carries: a server IP address, a device IP address, and a port number of the local server;
establishing connection with the local server by using the server IP address and the equipment IP address;
and downloading the target firmware from the local server through the port of the port number.
Optionally, the probe response message further carries an MAC address; the device further comprises:
a third obtaining module, configured to obtain an MAC address carried in the probe response packet;
the judging module is used for judging whether the obtained MAC address is matched with the MAC address of the electronic equipment or not; if yes, triggering the first acquisition module to execute the connection with the local server by utilizing the server IP address and the equipment IP address.
Optionally, the apparatus further comprises:
and the second sending module is used for sending an ARP message to the local server, wherein the ARP message comprises the equipment IP address and the MAC address of the electronic equipment, so that the local server updates a stored ARP table entry according to the equipment IP address and the MAC address, and the ARP table entry records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment.
Optionally, the electronic device obtains the device IP address according to the following method:
the electronic equipment takes an IP address configured when the target firmware is installed as the equipment IP address;
the electronic equipment stores the equipment IP address locally;
the electronic device locally obtains the device IP address after determining that the target firmware is abnormal.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any one of the steps of the firmware abnormity detection method when executing the program stored in the memory.
In a fourth aspect, an embodiment of the present application provides a machine-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method implements any of the firmware anomaly detection method steps described above.
In the technical scheme provided by the embodiment of the application, whether a check file of the target firmware is stored in the electronic equipment is detected, wherein the check file is generated after the target firmware is successfully installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment; if not, determining that the target firmware is abnormal. According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a firmware exception detection method according to an embodiment of the present application;
FIG. 2 is another flowchart of a firmware exception detection method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of a firmware exception recovery method according to an embodiment of the present disclosure;
fig. 4 is a signaling diagram of a firmware exception recovery method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a firmware anomaly detection 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
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In order to solve the problem of detecting a firmware exception, an embodiment of the present application provides a firmware exception detection method and apparatus, where the firmware exception detection method includes:
detecting whether a check file of the target firmware is stored in the electronic equipment, wherein the check file is generated after the target firmware is successfully installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment;
if not, determining that the target firmware is abnormal.
In the technical scheme provided by the embodiment of the application, whether a check file of the target firmware is stored in the electronic equipment is detected, wherein the check file is generated after the target firmware is successfully installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment; if not, determining that the target firmware is abnormal. According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.
First, a firmware anomaly detection method provided in an embodiment of the present application is described below. The firmware anomaly detection method provided in the embodiment of the present application may be applied to an electronic device installed with firmware, and may also be applied to other devices except the electronic device installed with firmware, which is not limited herein. The following description will be given taking an example in which the firmware abnormality detection method is applied to an electronic apparatus in which firmware is installed. The electronic device may be a device in which firmware is installed, for example, a Network Video Recorder (NVR) device or the like.
The electronic equipment detects the firmware through the firmware abnormity detection method provided by the embodiment of the application, and can occur in different scenes. For example, the electronic device may be restarted after the firmware is installed, and the electronic device may perform firmware exception detection during the restart. For another example, the electronic device may perform firmware exception detection during each boot process. The scenarios for the firmware anomaly detection performed by the electronic device are not limited to the above two scenarios, and may also be performed in other scenarios, which are not limited herein.
Fig. 1 is a flowchart of a firmware exception detection method according to an embodiment of the present application, which includes the following steps.
S101, whether the electronic equipment stores the verification file of the target firmware or not is detected, and if not, the step S102 is executed.
The firmware anomaly detection method provided by the embodiment of the application can be directed to the firmware installed in the electronic equipment, and therefore, the target firmware can be any one or more pieces of firmware installed in the electronic equipment.
The verification file is a file generated after the target firmware is installed in the electronic device and stored in the electronic device, for example, the verification file is verify.
In one implementation, after the target firmware is installed in the electronic device, that is, after the target firmware is written into a storage medium such as a flash memory, the electronic device may create a verification file of the target firmware, that is, generate the verification file, and write the verification file into the storage medium stored in the target firmware. For example, the target firmware is written into the flash memory after the target firmware is installed, and the verification file of the target firmware is also written into the flash memory for storage. After the verification file is written into the storage medium, the successful installation of the target firmware in the electronic equipment can be indicated.
The check file is written to the storage medium only after the target firmware is installed. The abnormal conditions of power failure, misoperation and the like of the electronic equipment in the installation process of the target firmware can cause the installation failure of the target firmware, and at the moment, the verification file cannot be written into the storage medium. Therefore, it can be considered that the verification file can be used to indicate that the target firmware is successfully installed in the electronic device, that is, when the verification file of the target firmware is stored in the electronic device, the target firmware is successfully installed. In addition, when the verification file of the target firmware is stored in the electronic device, it can also indicate that the current target firmware is normal in the electronic device.
S102, determining that the target firmware is abnormal.
If it is determined that the verification file of the target firmware is not stored in the electronic device, such a result may be caused by the following two cases.
In the first case, the target firmware is not installed completely, so that the verification file of the target firmware is not written in the storage medium of the electronic device, resulting in that the verification file cannot be detected in the electronic device.
In the second case, the storage medium storing the verification file is worn out, so that the contents stored in the storage medium cannot be read. This situation may result in the verification file not being detectable in the electronic device.
The check file may not be detected in the electronic device under the above two conditions, and other conditions may also be included, which are not limited herein.
In any case, when it is determined that the verification file of the target firmware is not stored in the electronic device, it may be determined that the target firmware is abnormal.
In one embodiment, after determining that the target firmware is abnormal, prompting the user of the target firmware abnormality can be performed, so that the user can perform recovery processing on the abnormal target firmware in time. When prompting the abnormality of the target firmware, the electronic equipment can also display the abnormality information. The abnormal information may include at least one of a model of the target firmware, an identification code, a model of the electronic device, and the like. The displayed abnormal information can help a user to master the information aiming at the abnormal target firmware as soon as possible and timely recover the abnormal target firmware.
In one embodiment, the step of detecting whether the verification file of the target firmware is stored in the electronic device (S101) may include the following steps.
In an initialization stage of starting the electronic equipment, whether a verification file of target firmware is stored in the electronic equipment is detected.
The electronic device booting stage may include an initialization stage and an operating system booting stage. After the electronic device receives the start instruction, the electronic device enters an initialization stage, which may be completed by BootLoader and other boot programs in the electronic device. After the electronic device completes the initialization phase, the electronic device may enter an operating system boot phase.
In one implementation of the initialization phase, the boot program initializes hardware in the electronic device and establishes a memory space map, thereby bringing the software and hardware environment of the system to an appropriate state.
In one embodiment, in an initialization phase when the electronic device is started, if it is detected that a check file of the target firmware is stored in the electronic device, in the initialization phase, a check value in the check file may be read.
The verification value is stored in the verification file, the verification value can be changed, and different verification values can indicate whether the target firmware is successfully installed. When the target firmware is installed and the verification file of the target firmware is written in the storage medium, the verification value in the verification file is a default verification value, and the default verification value can be considered as an initial value of the verification value in the verification file. Therefore, when the check value in the check file is the default check value, it can be determined that the target firmware is successfully installed. The default check value may be set by a user, for example, the default check value may be 0.
In addition, the check value may indicate the number of consecutive starts of the initialization stage during the start-up process of the electronic device. Specifically, in a process of starting the electronic device once, each time an initialization stage is started, the electronic device may read a check value in the check file in each initialization stage process, add a preset value to the read check value to obtain a new check value, and write the new check value into the check file as an updated check value of the check file. The preset value may be set by a user, for example, the preset value is 1, so that each time the initialization stage is started, the check value is increased by 1.
Based on the above characteristics of the check value, the read check value can be used to indicate the number of times of continuous startup of the initialization stage in each initialization stage of the electronic device.
After reading the check value in the check file, the electronic device may determine that the target firmware is abnormal when the read check value is a preset abnormal check value.
The abnormal check value may be set by a user. When the read check value is an abnormal check value, the number of times of continuous start of the current initialization stage can be determined. Based on this, the exception check value may represent the number of times the initialization phase is allowed to be started continuously during one start-up of the electronic device. Therefore, in the process of one startup of the electronic equipment, when the number of times of continuous startup in the initialization stage reaches the abnormal check value, the target firmware can be considered to be abnormal.
For example, the default verification value is 0, the preset value is 1, and the exception verification value is 3, which indicates that the initialization stage is allowed to be continuously started 3 times in one startup process of the electronic device, and when the initialization stage is started for the third time, the target firmware may be considered to be abnormal. Therefore, after the initialization phase is completed, when the read check value is 3, which indicates that the current initialization phase has been started 3 times continuously, it can be determined that the target firmware is abnormal.
In one embodiment, the abnormal check value may indicate the number of times that the initialization phase is allowed to be continuously started in one starting process of the electronic device, and when the read check value is not the abnormal check value, it may be determined that the read check value is smaller than the abnormal check value.
The read check value is in the initialization phase. After the initialization phase is completed, the electronic device may enter an operating system boot phase, i.e., boot the operating system of the electronic device. The electronic device may determine whether the operating system is successfully started, and in one implementation, the electronic device may be preset with a watchdog, where the watchdog presets a time threshold, and the time threshold is a threshold for starting time of the operating system. After the initialization stage is completed, the electronic equipment starts an operating system, and if the operating system is started successfully, the electronic equipment enters the operating system; if the electronic device does not enter the operating system within the time period of the time threshold set by the watchdog, it may be considered that the operating system fails to start.
For example, if the time threshold preset by the watchdog in the electronic device is 1 minute, the electronic device starts the operating system after the initialization stage, and if the duration of the start of the operating system reaches 1 minute, the electronic device does not enter the operating system, it may be determined that the start of the operating system fails.
If the operating system is successfully started, the electronic equipment can enter normal operation. The electronic device may also write the default verification value into the verification file and use the default verification value as an updated verification value of the verification file. For example, a default verification value is set to be 0, when it is detected that the operating system is successfully started, and the current verification value in the verification file is 2, the electronic device writes the default verification value 0 into the verification file, and uses the default verification value 0 as the verification value after the verification file is updated.
And if the operation system is judged to be failed to start, restarting the initialization stage. In the initialization stage, the check value in the check file is read, and the read check value is added with a preset value to obtain a new check value. And writing the new check value into the check file as the updated check value of the check file. At this time, the check value stored in the check file is the new check value. The preset numerical value can be set by self-definition.
For example, the preset value is 1, if the read check value is 1, the obtained new check value is 2, and then the new check value 2 is written into the check file as the updated check value of the check file. In this way, the next time the check value is read from the check file, the read check value is 2.
After the updating of the check value in the check file is completed, the step of reading the check value in the check file in the initialization stage is returned to be executed until the starting frequency of the initialization stage reaches the abnormal check value, so that the target firmware can be determined to be abnormal, or before the starting frequency of the initialization stage reaches the abnormal check value, the operating system of the electronic equipment is successfully started, and the electronic equipment enters normal operation.
According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.
An embodiment of the present application provides a firmware anomaly detection method, as shown in fig. 2, which includes the following steps.
S201, in the initialization stage of starting the electronic device, detecting whether the electronic device stores the verification file of the target firmware, if not, executing step S202, and if so, executing step S203.
The electronic device is an NVR device, and a default verification value is preset to be 0.
After the target firmware in the NVR device is upgraded, that is, after the target firmware is installed, the NVR device creates a verification file of the target firmware as verify. Bin is created at this time with a check value of 0.
And in the initialization stage of starting the BootLoader, detecting whether a flash memory in the NVR equipment stores verify.
S202, determining that the target firmware is abnormal.
Bin may be determined to be abnormal if it is detected that no verify is stored on the flash memory of the NVR device.
S203, in the initialization stage, the check value in the check file is read.
If it is detected that the flash memory of the NVR device stores verify.bin, the NVR device may acquire verify.bin from the flash memory and read a check value from verify.bin in the process of performing the initialization stage by the BootLoader.
S204, when the read check value is a preset abnormal check value, determining that the target firmware is abnormal.
Wherein the preset abnormal check value is 3. If the check value read from the verify. bin by the NVR device is 3, it indicates that the number of times of starting the initialization phase by the BootLoader is 3, and at this time, it may be determined that the target firmware is abnormal.
S205, when the read check value is not the abnormal check value, adding a preset value to the read check value to obtain a new check value, and writing the new check value into the check file as an updated check value of the check file; and starting the operating system of the electronic equipment and judging whether the operating system is started successfully. If yes, step S206 is performed, and if no, step S207 is performed.
Wherein, the preset value is set to be 1. When the electronic device does not enter the operating system within the time length of the time threshold preset by the watchdog, namely after the operation system is judged to be failed to start, the NVR device restarts the initialization stage, namely restarts the BootLoader for initialization. In the process of initializing the BootLoader, reading a check value in a verify file verify.bin, adding 1 to the read check value to obtain a new check value, and writing the new check value into the verify.bin as an updated check value of the verify.bin.
If the check value read by the NVR device from verify is not 3, it may be determined that the read check value is less than 3, that is, the read check value may be any one of 0, 1, and 2.
When the check value read from the verify.bin by the NVR device is 0, which indicates that the current BootLoader has not started the initialization stage, at this time, 1 is added to the read check value to obtain a new check value of 1, and the new check value 1 is written into the verify.bin as the updated check value of the verify.bin.
When the check value read from the verify.bin by the NVR device is 1, which indicates that the number of times of starting the initialization phase of the current BootLoader is 1, at this time, 1 is added to the read check value to obtain a new check value of 2, and the new check value 2 is written into the verify.bin to be used as the updated check value of the verify.bin.
When the check value read from the verify.bin by the NVR device is 2, which indicates that the number of times of starting the initialization phase of the current BootLoader is 1, at this time, 1 is added to the read check value to obtain a new check value of 3, and the new check value of 3 is written into the verify.bin to be used as the updated check value of the verify.bin.
After the update of the check value is completed and the BootLoader starting initialization stage is completed, the NVR device continues to load the kernel, starts the operating system, and judges whether the operating system is started successfully.
And S206, writing the default check value into the check file as the updated check value of the check file.
And when the operating system is successfully started, writing a default check value 0 into the check file as the updated check value of the check file.
S207, restart the initialization phase, and return to step S203.
And restarting the initialization stage of the electronic device, namely restarting the BootLoader for initialization, and returning to execute the step S203, namely reading the check value in the check file in the initialization stage.
After determining that the target firmware is abnormal, the target firmware in which the abnormality occurs may be recovered. In one embodiment, the electronic device and the local server are in the same network, the electronic device and the local server may be in communication connection, and the same network may be a local area network. In one implementation, a local server and a plurality of electronic devices are included in the same local area network, and each electronic device is in communication connection with the local server.
The firmware exception recovery method provided by the embodiment of the application is applied to electronic equipment and can comprise the following steps.
S301, after determining that the target firmware is abnormal, sending a detection request message to a local server.
Wherein, the detection request message carries the identification information of the target firmware. The identification information is information for representing the firmware, that is, the identification information and the firmware have a one-to-one correspondence relationship. The identification information may include at least one of identification code, model number, version number, and the like. For example, the identification code of the target firmware is 1000, and the model of the target firmware is PBAM00, then the firmware can be determined to be the target firmware by the identification code 1000 and the model PBAM 00.
In an embodiment of the electronic device obtaining the identification information, when the target firmware is installed in the electronic device successfully, the electronic device may obtain the identification information of the target firmware and store the identification information.
In one implementation of storing the identification information, a storage medium or a storage area in the storage medium is provided in the electronic device for storing the identification information. The electronic device may acquire the identification information of the firmware and store the acquired identification information in the storage medium or the storage area whenever the firmware is successfully installed in the electronic device, and may directly acquire the identification information of the firmware from the storage medium or the storage area when the identification information of the firmware needs to be acquired. Therefore, the centralized storage of the identification information can be realized, and convenience is provided for storing the identification information and acquiring the identification information.
The method for sending the probe request message to the local server by the electronic device may be a multicast or broadcast method. Taking multicast as an example, after confirming that the target firmware is abnormal, the electronic device may perform initialization setting on the local network card device, and then may set a Media Access Control (MAC) address enabling reception, so as to facilitate subsequent interaction in a multicast manner.
At this time, the detection request message may also carry information indicating an interaction mode, where the information is used to indicate an interaction mode currently used by the electronic device, that is, to indicate that the electronic device may receive a data packet of the interaction mode. After the local server acquires the information representing the interactive mode, the data packet of the interactive mode can be sent in the subsequent interactive process with the electronic equipment.
For example, the probe request message sent by the electronic device to the server carries information indicating that the electronic device employs multicast, which indicates that the electronic device informs the local server that the local server can receive the multicast data packet. After receiving the probe request message sent by the electronic device, the local server can know that the electronic device can receive the multicast data packet, so that the multicast data packet can be sent to the electronic device in the subsequent interaction process with the electronic device.
The electronic equipment sends the detection request message to the local server, and the detection request message has the function of detecting whether the local server is started or not. If the local server is not started, the electronic equipment cannot receive the feedback of the local server; if the local server is started, the electronic device may receive feedback from the local server, and the electronic device may report information related to the firmware in which the abnormality occurs to the local server.
In order to increase the probability that the local server can receive the probe request message, the electronic device may send the probe request message to the local server multiple times. In order to reduce the number of probe request messages in the network within the same period of time, and thus reduce the transmission pressure of the network, in one embodiment, the step of sending the probe request message to the local server (S301) may include the following steps.
And under the condition that the electronic equipment sends the detection request message to the local server, determining the time point of sending the detection request message last time as a first time point.
Wherein, the last detection request message is the latest detection request message sent at the current time point. For example, the current time point is 12 points, and before the current time point, the electronic device sends the probe request packet to the local server for 3 times, where the times are: point 11, 30 minutes and point 11, 50 minutes, the time closest to the current time point is the probe request message sent by point 11, 50 minutes, and point 11, 50 minutes is the time point of the previous probe request message.
And sending a detection request message to the local server once at a second time point which is separated from the first time point by a first preset time length.
And sending the detection request message to the local server once again at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
The first preset time length and the second preset time length can be set by self-definition. The second preset duration is longer than the first preset duration, and the longer the number of the detection request messages sent to the local server by the electronic equipment is, the longer the time interval between the adjacent detection request messages sent later is.
In one implementation manner, in order to avoid a long interval between two adjacent detection request messages, a maximum duration threshold may be set for the first preset duration and the second preset duration, that is, the value ranges of the first preset duration and the second preset duration are not greater than the maximum duration threshold. And when the first preset time length and the second preset time length both reach the maximum time length threshold value, the time interval for subsequently sending the detection request message is the time length of the maximum time length threshold value.
For example, the time interval between the first sending of the probe request message to the local server and the second sending of the probe request message is 1 second or 2 seconds, the time interval between the second sending of the probe request message and the third sending of the probe request message is 2 seconds or 3 seconds, the time interval between the third sending of the probe request message and the fourth sending of the probe request message is 3 seconds or 4 seconds, and so on. The maximum time threshold is 10 seconds, that is, when the second preset time reaches 10 seconds, the time interval for subsequently sending the detection request message is 10 seconds.
For the local server, when a detection request message sent by the electronic device is received, the identification information of the target firmware carried in the detection request message can be obtained, and the local server obtains the target firmware according to the obtained identification information.
For an implementation manner of the local server, after receiving the probe request message and obtaining the identification information carried in the probe request message, the local server may detect whether the target firmware represented by the identification information is locally stored. If the target firmware is stored locally, the local server may directly obtain the target firmware from the local.
If not stored locally, the local server may request from the remote server. The local server is in communication connection with the remote server, and the remote server stores firmware.
In one implementation, the local server may send a firmware request message containing the identification information to the remote server. After receiving the firmware request message, the remote server may parse the firmware request message and obtain the identification information from the firmware request message. The remote server may acquire the target firmware indicated by the identification information according to the acquired identification information, and transmit the acquired target firmware to the local server. After the local server receives the target firmware sent by the remote server, the target firmware can be stored locally.
Through the embodiment, the local server provides available firmware for the electronic equipment, so that a user does not need to manually search the firmware, and the convenience of searching and downloading the firmware is improved.
S302, acquiring the target firmware from the local server and installing the target firmware.
After the electronic device successfully installs the target firmware, it can be considered that the recovery of the target firmware in which the exception occurs is completed.
In one embodiment, the electronic device may receive a probe response message sent by a local server.
The probe response message may be considered as a response message for the probe request message. The method for sending the detection response message by the local server is consistent with the method for sending the detection request message by the electronic equipment, namely when the electronic equipment sends the detection request message in a multicast mode, the local server also sends the detection response message in the multicast mode; when the electronic equipment sends the detection request message in a broadcasting mode, the local server also sends the detection response message in the broadcasting mode.
The probe response message may carry: the server IP address, device IP address, and port number of the local server. The device IP address is an IP address distributed by the local server for the electronic device. The port number is used for the local server to provide the download service to the electronic device.
In an embodiment of the electronic device obtaining the device IP address, when the electronic device installs the target firmware, the electronic device configures the IP address, and the electronic device may store the configured IP address locally as the device IP address. If the device IP address is corresponding to the target firmware, the electronic device stores the device IP address locally and the corresponding relationship between the device IP address and the target firmware is correspondingly stored.
For example, the electronic device locally stores a device IP address 1, a device IP address 2, and a device IP address 3, where the device IP address 1 corresponds to the firmware 1, the device IP address 2 corresponds to the firmware 2, and the device IP address 3 corresponds to the firmware 3. That is, device IP address 1 is an IP address configured by the electronic device when firmware 1 is installed, device IP address 2 is an IP address configured by the electronic device when firmware 2 is installed, and device IP address 3 is an IP address configured by the electronic device when firmware 3 is installed.
For the electronic device, after determining that the target firmware is abnormal, the device IP address may be obtained locally, specifically, the device IP address corresponding to the target firmware is determined according to the correspondence between the device IP address stored locally in the electronic device and the target firmware, and the device IP address is obtained.
After the electronic device obtains the device IP address, the electronic device sends the device IP address to the local server in a manner that the detection request message carries the device IP address, that is, the detection request message carries the device IP address.
The local server stores a pool of IP addresses that includes a plurality of available IP addresses. When the local server receives the detection request message, the local server can acquire the device IP address from the detection request message, match the device IP address with the IP address included in the IP address pool, and determine that the device IP address is available if the IP address in the IP address pool is matched with the device IP address and the matched IP address is not used.
After determining that the device IP address carried in the probe request message is available, the local server may carry the device IP address in the probe response message, indicating that the device IP address is available, and the electronic device may establish a connection with the local server by configuring the device IP address.
In another case, if the local server does not match the device IP address in the IP address pool, or the device IP address is used, it may be determined that the device IP address carried in the probe request message is unavailable. The local server may retrieve the available IP address from the pool of IP addresses and determine the IP address as the device IP address assigned to the electronic device. And carrying the re-determined equipment IP address in the detection response message sent by the local server, so that the electronic equipment establishes connection with the local server by configuring the equipment IP address.
After receiving the probe response message sent by the local server, the electronic device may establish a connection with the local server using the server IP address and the device IP address. In one implementation, after acquiring the device IP address from the probe response packet, the electronic device sets its own IP address as the device IP address. The electronic device connects to the local server of the server IP address using the device IP address, such that a communication connection based on the device IP address and the server IP address is established.
In one embodiment, after the electronic device establishes a connection with the local server, the electronic device may send an ACK (Acknowledgement character) request message to the local server, where the ACK request message is used to indicate that the electronic device has set a network environment and is ready to wait for transmission of the target firmware. After receiving the ACK request message, the local server may send an ACK response message to the electronic device, where the ACK response message is used to indicate that the local server has set a network environment and is ready to wait for transmission of the target firmware. The ACK response message may not carry any information.
After the electronic device establishes a connection with the local server, the electronic device may download the target firmware from the local server through the port of the assigned port number. In one implementation, after acquiring the port number from the probe response packet, the electronic device sets its port as the port of the port number, so that the electronic device can download the target firmware from the local server through the port of the port number. It can be considered that the local server functions as an FTP server, and the electronic device downloads the target firmware from the local server based on the FTP protocol.
Illustratively, the server IP address carried in the probe response message sent by the local server and received by the electronic device is 118.186.0.252, the device IP address is 118.186.0.112, and the port number is 21. The electronic device sets its own IP address to 118.186.0.112 and its own port to port number 21. The electronic device with IP address 118.186.0.112 establishes a connection with the local server with IP address 118.186.0.252 and, after establishing the connection, downloads the target firmware from the local server through the port with port number 21.
In yet another embodiment, the step of the electronic device obtaining the target firmware from the local server may include the following steps.
The electronic device may establish a communication connection in a unicast manner with the local server, and after the electronic device establishes the communication connection with the local server, the local server transmits the target firmware to the electronic device in a unicast manner.
In another embodiment, the step of the electronic device obtaining the target firmware from the local server may include the steps of: the electronic equipment sends a target firmware request to the local server, and the local server sends the target firmware to the local server after receiving the target firmware request.
In one embodiment, when there are a plurality of electronic devices connected to the local server and the local server needs to provide a download service for the plurality of electronic devices, the local server may assign a port number to each of the electronic devices, and the port numbers assigned to the electronic devices are different from each other.
In this way, each electronic device can communicate with the local server through the port of the port number allocated to each electronic device, and each electronic device can download the required resource from the local server through the port of the port number allocated to each electronic device. The electronic devices are not affected with each other, so that the interference among the electronic devices is reduced, and the communication and downloading reliability of the electronic devices and the local server is improved.
In one embodiment, messages are transmitted between the electronic devices and the local server in a multicast or broadcast manner in the same network, and for each electronic device, messages transmitted to other electronic devices by the local server may be received. Therefore, in order to enable the electronic device to accurately determine whether the received message belongs to the local device, the probe response message sent by the local server may also carry the MAC address.
The MAC address carried in the probe response message is the MAC address of the electronic device that receives the probe response message. For example, the MAC address carried in the probe response message 1 is 44-45-53-54-00-00, and the MAC address of the electronic device receiving the probe response message 1 is also 44-45-53-54-00-00.
After the step of receiving the probe response message sent by the local server, before the step of establishing a connection with the local server by using the server IP address and the device IP address, the following steps may be further included.
And the electronic equipment acquires the MAC address carried by the detection response message and judges whether the acquired MAC address is matched with the MAC address of the electronic equipment. If the detected message is matched with the local server, the electronic equipment indicates that the object receiving the detection response message is the electronic equipment, and the electronic equipment continues to execute the step of establishing connection with the local server by utilizing the server IP address and the equipment IP address.
If not, it indicates that the object receiving the probe response packet is not the electronic device, and the electronic device may discard the probe response packet. In the case that the acquired MAC address does not match the MAC address of the electronic device, the electronic device may process the MAC address in other manners besides the discarding manner, which is not limited herein.
Through the embodiment, the electronic equipment can judge whether the detection response message belongs to the electronic equipment according to the MAC address carried in the detection response message, so that each electronic equipment can only acquire the detection response message belonging to the electronic equipment, the processing of other detection response messages not belonging to the electronic equipment is avoided, the CPU resource of the electronic equipment is saved, and the processing efficiency of the detection response message is improved.
In one embodiment, before the step of downloading the target firmware from the local server through the port of the port number, the following step may be further included.
The electronic device may send an ARP message to the local server, where the ARP message includes a device IP address and an MAC address of the electronic device, and the device IP address included in the ARP message is the device IP address of the electronic device.
The sending of the ARP message by the electronic device may be performed before downloading the target firmware.
The local server stores an ARP table entry which records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment. After receiving the ARP packet sent by the electronic device, the local server may obtain the device IP address and the MAC address of the electronic device from the ARP packet, and update the stored ARP entry according to the device IP address and the MAC address. The updating of the ARP entry by the local server may be performed in an operating system of the local server.
By the embodiment, the ARP table entry in the local server can be kept in a new state, the aging of the ARP table entry is prevented, the longer the time is, the lower the trust degree of the local server on the ARP table entry is, and the problems that the communication connection between the electronic equipment and the local server is interrupted due to the aging of the ARP table entry and the like can be effectively reduced.
In an embodiment, the electronic device and the local server are in the same network, and the local server is in communication connection with the remote server, a method for recovering from a firmware exception provided in an embodiment of the present application is shown as a signaling diagram in fig. 4.
And the electronic equipment is used for acquiring the identification information (identification code, model and version number) of the target firmware and storing the identification information after the target firmware is successfully installed.
The electronic equipment is used for sending a detection request message to the local server after determining that the target firmware is abnormal, wherein the detection request message carries identification information of the target firmware;
the local server is used for receiving the detection request message sent by the local server; when the target firmware represented by the identification information is detected to be locally stored, acquiring the target firmware from the local; and when detecting that the target firmware represented by the identification information is not stored locally, sending a firmware request message containing the identification information to the remote server.
The remote server is used for receiving the firmware request message sent by the local server, acquiring the target firmware according to the identification information and sending the target firmware to the local server;
the local server is used for receiving the target firmware sent by the remote server and sending a detection response message to the electronic equipment, wherein the detection response message comprises: MAC address, server IP address of local server, device IP address and port number.
The electronic equipment is used for receiving the detection response message sent by the local server and acquiring the MAC address carried by the detection response message; and when the obtained MAC address is judged to be matched with the MAC address of the electronic equipment, setting an IP address and a port, and establishing connection with the local server by using the IP address of the server and the IP address of the equipment.
And the electronic equipment is used for sending an ACK request message to the local server.
And the local server is used for receiving the ACK request message and sending an ACK response message.
And the electronic equipment is used for receiving the ACK response message.
And the electronic equipment is used for sending an ARP message to the local server, wherein the ARP message comprises an equipment IP address and the MAC address of the electronic equipment.
And the local server is used for receiving the ARP message and updating the stored ARP list item according to the IP address and the MAC address of the equipment.
The electronic device is used for sending the target firmware request to the local server.
And the local server is used for receiving the target firmware request and sending the target firmware to the electronic equipment.
By the firmware abnormity recovery method provided by the embodiment of the application, when the electronic equipment confirms that the target firmware is abnormal, the electronic equipment can directly request the target firmware from the local server, so that a user does not need to manually search the target firmware and manually install the target firmware. Not only saves human resources, but also improves the convenience of searching and acquiring the target firmware.
Corresponding to the above firmware anomaly detection method embodiment, an embodiment of the present application further provides a firmware anomaly detection apparatus, as shown in fig. 5, where the firmware anomaly detection apparatus includes:
the first detecting module 510 is configured to detect whether a check file of the target firmware is stored in the electronic device, where the check file is a file that is generated after the target firmware is installed in the electronic device and is stored in the electronic device, and is used to indicate that the target firmware is successfully installed in the electronic device;
a first determining module 520, configured to determine that the target firmware is abnormal when the detection result of the first detecting module is negative.
Optionally, the first detecting module 510 is specifically configured to:
in an initialization stage of starting the electronic equipment, detecting whether a verification file of a target firmware is stored in the electronic equipment;
the apparatus may further include:
the reading module is used for reading the check value in the check file in the initialization stage when the detection result of the first detection module is positive;
and the second determining module is used for determining that the target firmware is abnormal when the read check value is a preset abnormal check value.
Optionally, the apparatus may further include:
the second detection module is used for adding a preset value to the read check value to obtain a new check value when the read check value is not the abnormal check value, and writing the new check value into the check file to serve as an updated check value of the check file; starting an operating system of the electronic equipment, and detecting whether the operating system is started successfully;
the writing module is used for writing the default check value into the check file as an updated check value of the check file when the detection result of the second detection module is yes;
and the updating module is used for restarting the initialization stage and triggering the reading module to execute the initialization stage when the detection result of the second detection module is negative, and reading the check value in the check file.
Optionally, the electronic device is in the same network as the local server, and the apparatus may further include:
the first sending module is used for sending a detection request message to the local server after the target firmware is determined to be abnormal, wherein the detection request message carries identification information of the target firmware, so that the local server can obtain the target firmware according to the identification information;
and the first acquisition module is used for acquiring the target firmware from the local server and installing the target firmware.
Optionally, the sending module is specifically configured to:
under the condition that the electronic equipment sends a detection request message to a local server, determining a time point of sending the detection request message last time as a first time point;
sending a detection request message to a local server at a second time point which is separated from the first time point by a first preset time length;
and sending a detection request message to the local server at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
Optionally, the apparatus may further comprise:
and the second acquisition module is used for acquiring the identification information of the target firmware and storing the identification information after the target firmware is successfully installed.
Optionally, the first obtaining module is specifically configured to:
receiving a detection response message sent by a local server, wherein the detection response message carries: a server IP address, a device IP address, and a port number of the local server;
establishing connection with a local server by using the IP address of the server and the IP address of the equipment;
and downloading the target firmware from the local server through the port of the port number.
Optionally, the probe response message also carries an MAC address; the apparatus may further include:
the third acquisition module is used for acquiring the MAC address carried by the detection response message;
the judging module is used for judging whether the obtained MAC address is matched with the MAC address of the electronic equipment or not; if yes, triggering the first acquisition module to execute and utilize the server IP address and the equipment IP address to establish connection with the local server.
Optionally, the apparatus may further include:
and the second sending module is used for sending an ARP message to the local server, wherein the ARP message comprises the equipment IP address and the MAC address of the electronic equipment, so that the local server updates the stored ARP table entry according to the equipment IP address and the MAC address, and the ARP table entry records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment.
Optionally, the electronic device obtains the device IP address according to the following manner:
the electronic equipment takes an IP address configured when the target firmware is installed as an equipment IP address;
the electronic equipment stores the IP address of the equipment in local;
the electronic device obtains the device IP address locally after determining that the target firmware is abnormal.
In the technical scheme provided by the embodiment of the application, whether a check file of the target firmware is stored in the electronic equipment is detected, wherein the check file is generated after the target firmware is successfully installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment; if not, determining that the target firmware is abnormal. According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.
Corresponding to the above firmware anomaly detection method embodiment, an electronic device is further provided in the embodiment of the present application, as shown in fig. 6, including a processor 610, a communication interface 620, a memory 630, and a communication bus 640, where the processor 610, the communication interface 620, and the memory 630 complete communication with each other through the communication bus 640;
a memory 630 for storing computer programs;
the processor 610, when executing the program stored in the memory 630, implements the following steps:
detecting whether a check file of the target firmware is stored in the electronic equipment, wherein the check file is a file which is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment;
if not, determining that the target firmware is abnormal.
In the technical scheme provided by the embodiment of the application, whether a check file of the target firmware is stored in the electronic equipment is detected, wherein the check file is generated after the target firmware is successfully installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment; if not, determining that the target firmware is abnormal. According to the technical scheme provided by the embodiment of the application, the verification file is used for representing the characteristic that the target firmware is successfully installed in the electronic equipment, so that the verification file exists when the target firmware is normal, and the verification file does not exist when the target firmware is abnormal. Therefore, whether the target firmware is abnormal or not is judged by detecting whether the target firmware exists in the electronic equipment, and the purpose of detecting the firmware abnormality is achieved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
Corresponding to the above firmware anomaly detection method embodiment, an embodiment of the present application further provides a machine-readable storage medium, where a computer program is stored in the machine-readable storage medium, and when the computer program is executed by a processor, the method implements any of the above firmware anomaly detection method steps.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the embodiments of the firmware anomaly detection apparatus, the electronic device and the machine-readable storage medium, since they are substantially similar to the embodiments of the firmware anomaly detection method, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (22)

1. A method for firmware exception detection, the method comprising:
detecting whether a check file of a target firmware is stored in electronic equipment, wherein the check file is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment and is used for indicating that the target firmware is successfully installed in the electronic equipment;
and if not, determining that the target firmware is abnormal.
2. The method of claim 1, wherein the detecting whether a verification file of target firmware is stored in the electronic device comprises:
detecting whether a verification file of a target firmware is stored in the electronic equipment or not in an initialization stage of starting the electronic equipment;
the method further comprises the following steps:
if a check file of the target firmware is stored in the electronic equipment, reading a check value in the check file in the initialization stage;
and when the read check value is a preset abnormal check value, determining that the target firmware is abnormal.
3. The method of claim 2, further comprising:
when the read check value is not the abnormal check value, adding a preset value to the read check value to obtain a new check value, and writing the new check value into the check file as an updated check value of the check file; starting an operating system of the electronic equipment, and judging whether the operating system is started successfully;
if so, writing a default check value into the check file as an updated check value of the check file;
if not, restarting the initialization stage, and returning to the step of reading the check value in the check file in the initialization stage.
4. The method of any of claims 1-3, wherein the electronic device is in the same network as a local server, the method further comprising:
after determining that the target firmware is abnormal, sending a detection request message to the local server, wherein the detection request message carries identification information of the target firmware, so that the local server acquires the target firmware according to the identification information;
and acquiring the target firmware from the local server and installing the target firmware.
5. The method of claim 4, wherein sending a probe request message to the local server comprises:
under the condition that the electronic equipment sends a detection request message to the local server, determining a time point of sending the detection request message last time as a first time point;
sending the detection request message to the local server at a second time point which is separated from the first time point by a first preset time length;
and sending the detection request message to the local server at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
6. The method of claim 4, further comprising:
and when the target firmware is successfully installed, acquiring the identification information of the target firmware and storing the identification information.
7. The method of claim 4, wherein the obtaining the target firmware from the local server and installing the target firmware comprises:
receiving a detection response message sent by the local server, wherein the detection response message carries: a server IP address, a device IP address, and a port number of the local server;
establishing connection with the local server by using the server IP address and the equipment IP address;
and downloading the target firmware from the local server through the port of the port number.
8. The method of claim 7, wherein the probe response message further carries a MAC address;
after the step of receiving the probe response packet sent by the local server, before the step of establishing a connection with the local server by using the server IP address and the device IP address, the method further includes:
acquiring the MAC address carried by the detection response message;
judging whether the obtained MAC address is matched with the MAC address of the electronic equipment or not;
and if so, executing the step of establishing connection with the local server by utilizing the server IP address and the equipment IP address.
9. The method of claim 7, further comprising, prior to the step of downloading the target firmware from the local server through the port of the port number:
and sending an Address Resolution Protocol (ARP) message to the local server, wherein the ARP message comprises the equipment IP address and the MAC address of the electronic equipment, so that the local server updates a stored ARP table entry according to the equipment IP address and the MAC address, and the ARP table entry records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment.
10. The method of claim 7, wherein the electronic device obtains the device IP address according to:
the electronic equipment takes an IP address configured when the target firmware is installed as the equipment IP address;
the electronic equipment stores the equipment IP address locally;
the electronic device locally obtains the device IP address after determining that the target firmware is abnormal.
11. An apparatus for detecting a firmware abnormality, the apparatus comprising:
the device comprises a first detection module, a second detection module and a control module, wherein the first detection module is used for detecting whether a check file of target firmware is stored in electronic equipment or not, the check file is generated after the target firmware is installed in the electronic equipment and is stored in the electronic equipment, and the check file is used for indicating that the target firmware is successfully installed in the electronic equipment;
and the first determining module is used for determining that the target firmware is abnormal when the detection result of the first detecting module is negative.
12. The apparatus of claim 11, wherein the first detection module is specifically configured to:
detecting whether a verification file of a target firmware is stored in the electronic equipment or not in an initialization stage of starting the electronic equipment;
the device further comprises:
the reading module is used for reading the check value in the check file in the initialization stage when the detection result of the first detection module is yes;
and the second determining module is used for determining that the target firmware is abnormal when the read check value is a preset abnormal check value.
13. The apparatus of claim 12, further comprising:
the second detection module is used for adding a preset value to the read check value to obtain a new check value when the read check value is not the abnormal check value, and writing the new check value into the check file to be used as an updated check value of the check file; starting an operating system of the electronic equipment, and detecting whether the operating system is started successfully;
the writing module is used for writing a default check value into the check file as an updated check value of the check file when the detection result of the second detection module is yes;
and the updating module is used for restarting the initialization stage and triggering the reading module to execute the initialization stage and read the check value in the check file when the detection result of the second detection module is negative.
14. The apparatus according to any of claims 11-13, wherein the electronic device is in the same network as a local server, the apparatus further comprising:
a first sending module, configured to send a probe request packet to the local server after determining that the target firmware is abnormal, where the probe request packet carries identification information of the target firmware, so that the local server obtains the target firmware according to the identification information;
and the first acquisition module is used for acquiring the target firmware from the local server and installing the target firmware.
15. The apparatus of claim 14, wherein the sending module is specifically configured to:
under the condition that the electronic equipment sends a detection request message to the local server, determining a time point of sending the detection request message last time as a first time point;
sending the detection request message to the local server at a second time point which is separated from the first time point by a first preset time length;
and sending the detection request message to the local server at a time point which is separated from the second time point by a second preset time length, wherein the second preset time length is greater than or equal to the first preset time length.
16. The apparatus of claim 14, further comprising:
and the second acquisition module is used for acquiring the identification information of the target firmware and storing the identification information after the target firmware is successfully installed.
17. The apparatus of claim 14, wherein the first obtaining module is specifically configured to:
receiving a detection response message sent by the local server, wherein the detection response message carries: a server IP address, a device IP address, and a port number of the local server;
establishing connection with the local server by using the server IP address and the equipment IP address;
and downloading the target firmware from the local server through the port of the port number.
18. The apparatus according to claim 17, wherein the probe response message further carries a MAC address; the device further comprises:
a third obtaining module, configured to obtain an MAC address carried in the probe response packet;
the judging module is used for judging whether the obtained MAC address is matched with the MAC address of the electronic equipment or not; if yes, triggering the first acquisition module to execute the connection with the local server by utilizing the server IP address and the equipment IP address.
19. The apparatus of claim 17, further comprising:
and the second sending module is used for sending an ARP message to the local server, wherein the ARP message comprises the equipment IP address and the MAC address of the electronic equipment, so that the local server updates a stored ARP table entry according to the equipment IP address and the MAC address, and the ARP table entry records the corresponding relation between the equipment IP address and the MAC address of the electronic equipment.
20. The apparatus of claim 17, wherein the electronic device obtains the device IP address according to:
the electronic equipment takes an IP address configured when the target firmware is installed as the equipment IP address;
the electronic equipment stores the equipment IP address locally;
the electronic device locally obtains the device IP address after determining that the target firmware is abnormal.
21. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-10 when executing a program stored in the memory.
22. A machine readable storage medium, characterized in that a computer program is stored in the machine readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-10.
CN201811216428.4A 2018-10-18 2018-10-18 Firmware abnormity detection method and device Active CN111083001B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811216428.4A CN111083001B (en) 2018-10-18 2018-10-18 Firmware abnormity detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811216428.4A CN111083001B (en) 2018-10-18 2018-10-18 Firmware abnormity detection method and device

Publications (2)

Publication Number Publication Date
CN111083001A true CN111083001A (en) 2020-04-28
CN111083001B CN111083001B (en) 2021-09-21

Family

ID=70309364

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811216428.4A Active CN111083001B (en) 2018-10-18 2018-10-18 Firmware abnormity detection method and device

Country Status (1)

Country Link
CN (1) CN111083001B (en)

Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050229250A1 (en) * 2004-02-26 2005-10-13 Ring Sandra E Methodology, system, computer readable medium, and product providing a security software suite for handling operating system exploitations
CN101610604A (en) * 2009-06-18 2009-12-23 中兴通讯股份有限公司 A kind of method for upgrading software and system
CN101610499A (en) * 2009-07-13 2009-12-23 中兴通讯股份有限公司 The upgrade method of wireless data card and system
CN101807152A (en) * 2009-02-13 2010-08-18 环旭电子股份有限公司 Basic output and input system for self verification of selection read only memory and verification method thereof
US8166338B2 (en) * 2009-06-04 2012-04-24 International Business Machines Corporation Reliable exception handling in a computer system
CN102982264A (en) * 2012-12-24 2013-03-20 上海斐讯数据通信技术有限公司 Method for protecting embedded type device software
CN102981881A (en) * 2012-12-10 2013-03-20 中兴通讯股份有限公司 Method and system for preventing mobile terminal from being updated to illegal firmware version
CN103116729A (en) * 2013-01-15 2013-05-22 厦门市美亚柏科信息股份有限公司 Method and system of automatic export of data of portable device
CN104090790A (en) * 2014-06-30 2014-10-08 飞天诚信科技股份有限公司 Two-chip scheme firmware updating method for safety terminal
CN104503814A (en) * 2015-01-20 2015-04-08 山东华芯半导体有限公司 Firmware program automatically downloading method of USB 3.0 data acquisition module
CN104572229A (en) * 2015-02-12 2015-04-29 西安诺瓦电子科技有限公司 Firmware upgrade method and firmware upgrade device for embedded system
CN104603792A (en) * 2012-08-29 2015-05-06 微软公司 Secure firmware updates
CN104636156A (en) * 2013-11-12 2015-05-20 沈阳新松机器人自动化股份有限公司 Firmware upgrading method and system
CN104731610A (en) * 2013-12-24 2015-06-24 杨高赟 Upgrading method and upgrading system for anti-piracy terminal firmware
CN106789373A (en) * 2017-03-02 2017-05-31 国电南瑞科技股份有限公司 A kind of method that remote upgrade is carried out to concentrator
CN107729198A (en) * 2017-10-18 2018-02-23 深圳合纵富科技有限公司 A kind of Android system firmware method of calibration and device
US9996374B2 (en) * 2015-06-16 2018-06-12 Assured Information Security, Inc. Deployment and installation of updates in a virtual environment
CN108234216A (en) * 2018-01-16 2018-06-29 广东乐心医疗电子股份有限公司 Method and device for downloading data message

Patent Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050229250A1 (en) * 2004-02-26 2005-10-13 Ring Sandra E Methodology, system, computer readable medium, and product providing a security software suite for handling operating system exploitations
CN101807152A (en) * 2009-02-13 2010-08-18 环旭电子股份有限公司 Basic output and input system for self verification of selection read only memory and verification method thereof
US8166338B2 (en) * 2009-06-04 2012-04-24 International Business Machines Corporation Reliable exception handling in a computer system
CN101610604A (en) * 2009-06-18 2009-12-23 中兴通讯股份有限公司 A kind of method for upgrading software and system
CN101610499A (en) * 2009-07-13 2009-12-23 中兴通讯股份有限公司 The upgrade method of wireless data card and system
CN104603792A (en) * 2012-08-29 2015-05-06 微软公司 Secure firmware updates
CN102981881A (en) * 2012-12-10 2013-03-20 中兴通讯股份有限公司 Method and system for preventing mobile terminal from being updated to illegal firmware version
CN102982264A (en) * 2012-12-24 2013-03-20 上海斐讯数据通信技术有限公司 Method for protecting embedded type device software
CN103116729A (en) * 2013-01-15 2013-05-22 厦门市美亚柏科信息股份有限公司 Method and system of automatic export of data of portable device
CN104636156A (en) * 2013-11-12 2015-05-20 沈阳新松机器人自动化股份有限公司 Firmware upgrading method and system
CN104731610A (en) * 2013-12-24 2015-06-24 杨高赟 Upgrading method and upgrading system for anti-piracy terminal firmware
CN104090790A (en) * 2014-06-30 2014-10-08 飞天诚信科技股份有限公司 Two-chip scheme firmware updating method for safety terminal
CN104503814A (en) * 2015-01-20 2015-04-08 山东华芯半导体有限公司 Firmware program automatically downloading method of USB 3.0 data acquisition module
CN104572229A (en) * 2015-02-12 2015-04-29 西安诺瓦电子科技有限公司 Firmware upgrade method and firmware upgrade device for embedded system
US9996374B2 (en) * 2015-06-16 2018-06-12 Assured Information Security, Inc. Deployment and installation of updates in a virtual environment
CN106789373A (en) * 2017-03-02 2017-05-31 国电南瑞科技股份有限公司 A kind of method that remote upgrade is carried out to concentrator
CN107729198A (en) * 2017-10-18 2018-02-23 深圳合纵富科技有限公司 A kind of Android system firmware method of calibration and device
CN108234216A (en) * 2018-01-16 2018-06-29 广东乐心医疗电子股份有限公司 Method and device for downloading data message

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
XUEYANG WANG: "Malicious Firmware Detection with Hardware Performance Counters", 《IEEE TRANSACTIONS ON MULTI-SCALE COMPUTING SYSTEMS》 *
朱琼: "基于嵌入式移动智能终端固件升级***的设计与实现", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
王鹏琪: "windows下固件的安全检测与防护研究", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
赵宇杰: "一种带非接触支付功能的USB Key硬件和固件设计与实现", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Also Published As

Publication number Publication date
CN111083001B (en) 2021-09-21

Similar Documents

Publication Publication Date Title
CN100525206C (en) Realizing method and system for automatic restoring equipment fault
WO2019076037A1 (en) Firmware updating method and device
CN106549789B (en) Method and system for realizing server installation
US20050278518A1 (en) Electronic system capable of using universal plug and play (upnp) protocol to update software program and method thereof
EP2456257B1 (en) Method and system for upgrading wireless data card
CN100419698C (en) Network equipment and a method for monitoring the start up of such equipment
US20080104442A1 (en) Method, device and system for automatic device failure recovery
CN106020875B (en) Firmware update management method and device of embedded terminal
CN103377094A (en) Abnormity monitoring method and abnormity monitoring device
CN101594613A (en) The method of terminal equipment and upgrading thereof, system
US20120124242A1 (en) Server and method for testing pxe function of network interface card
WO2014146256A1 (en) Upgrade method, intelligent terminal, and upgrade system
CN112612524A (en) Method, device and equipment for starting Linux system and storage medium
CN111273924B (en) Software updating method and device
CN110865819B (en) OS installation method, server and system
CN111026581A (en) Application program repairing method, device, system, storage medium and electronic device
CN113542318A (en) Equipment fault repairing method
CN105320534A (en) BOOT remote updating method, BOOT remote updating device and BOOT remote updating system for single board
CN110688136B (en) Application program updating method and device
EP2378416A1 (en) System and a method for updating an operating system image
CN111083001B (en) Firmware abnormity detection method and device
CN104580360A (en) System and method for updating firmware through heterogeneous network
CN108595292B (en) System optimization method, mobile terminal and computer storage medium
CN110688130A (en) Physical machine deployment method, physical machine deployment device, readable storage medium and electronic equipment
CN114237722B (en) System starting method, device, equipment and engineering vehicle

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant