CN115309435A - Equipment firmware upgrading method and device and electronic equipment - Google Patents

Equipment firmware upgrading method and device and electronic equipment Download PDF

Info

Publication number
CN115309435A
CN115309435A CN202210942926.7A CN202210942926A CN115309435A CN 115309435 A CN115309435 A CN 115309435A CN 202210942926 A CN202210942926 A CN 202210942926A CN 115309435 A CN115309435 A CN 115309435A
Authority
CN
China
Prior art keywords
partition
file
upgrading
firmware
file system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210942926.7A
Other languages
Chinese (zh)
Inventor
冯琪琳
段小洋
李晓东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Lianji Technology Co ltd
Original Assignee
Hangzhou Lianji 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 Lianji Technology Co ltd filed Critical Hangzhou Lianji Technology Co ltd
Priority to CN202210942926.7A priority Critical patent/CN115309435A/en
Publication of CN115309435A publication Critical patent/CN115309435A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques

Abstract

The application is applicable to the technical field of firmware upgrading, and provides a method and a device for upgrading equipment firmware and electronic equipment, wherein the method comprises the following steps: acquiring a firmware upgrading file; upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file in the firmware upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition; and judging whether the file system partition is upgraded successfully or not according to the first upgrading result and the second upgrading result. By the embodiment of the application, whether the file system is upgraded successfully can be determined under the condition that the upgrade is abnormal and the user configuration in the file system is not changed, so that the normal starting of the system and the stability of equipment are ensured.

Description

Equipment firmware upgrading method and device and electronic equipment
Technical Field
The application belongs to the technical field of embedded software, and particularly relates to a method and a device for upgrading equipment firmware and electronic equipment.
Background
With the increase in complexity of the firmware of the embedded device and the change of the user requirements, the firmware of the embedded device needs to be upgraded in order to complete or add related functions.
At present, abnormal conditions such as power failure may occur in the firmware upgrading process, so that whether the firmware of the file system is written normally or not cannot be determined, the starting of the system is affected, and the stability of the equipment is poor.
Disclosure of Invention
The embodiment of the application provides an equipment firmware upgrading method and device and electronic equipment, and whether a file system is upgraded successfully or not can be determined under the conditions that upgrading is abnormal and user configuration in the file system is not changed, so that normal starting of the system and stability of the equipment are guaranteed.
In a first aspect, the present application provides a device firmware upgrading method, which may include:
acquiring a firmware upgrading file, wherein the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file;
upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition;
and judging whether the firmware of the file system partition is successfully upgraded or not according to the first upgrading result and the second upgrading result.
In a possible implementation manner of the first aspect, the presetting of the upgrade order includes:
after the firmware of the first partition is upgraded, upgrading the firmware of the file system partition;
and after the firmware of the file system partition is upgraded, upgrading the firmware of the second partition.
In a possible implementation manner of the first aspect, the determining, according to the first upgrade result and the second upgrade result, whether the firmware of the file system partition is upgraded successfully includes:
when the first upgrading result is verified successfully and the second upgrading result is verified successfully, determining that the firmware of the file system partition is successfully upgraded;
and when the first upgrading result is verification failure or the second upgrading result is verification failure, determining that the firmware upgrading of the file system partition fails.
In a possible implementation manner of the first aspect, the upgrading the firmware of the file system partition based on the file system partition upgrade file includes:
decompressing the file system partition upgrading file to a directory where the file system partition is located;
and covering the system configuration file in the decompressed file system partition upgrading file with the original system configuration file to finish upgrading the firmware of the file system partition.
In a possible implementation manner of the first aspect, the upgrading the firmware of the first partition and the firmware of the second partition based on the first partition upgrade file and the second partition upgrade file, and obtaining a first upgrade result corresponding to the first partition and a second upgrade result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition, includes:
reading the first partition upgrading file and the second partition upgrading file into a memory;
erasing the firmware of the first partition based on the first partition upgrade file and erasing the firmware of the second partition based on the second partition upgrade file;
respectively calculating a first check value corresponding to the erased first partition and a second check value corresponding to the second partition;
comparing the first check value with the check value of the first partition in the check partitions to obtain the first upgrading result;
and comparing the second check value with the check value of the second partition in the check partitions to obtain a second upgrading result.
In a possible implementation manner of the first aspect, the file system partition includes a plurality of system files, and after the firmware of the file system partition is upgraded based on the file system partition upgrade file, the method further includes:
compressing the system files in the file system partition to obtain a system compressed file;
taking the system compressed file as a backup system configuration file, and storing the system compressed file into a backup file system partition of a backup area;
and in the backup file system partition, generating an index file of the backup system configuration file, wherein the index file is used for recording the attribute information of the backup system configuration file.
In a possible implementation manner of the first aspect, after determining whether the file system partition is successfully upgraded according to the first upgrade result and the second upgrade result, the method further includes:
if the file system partition fails to be upgraded, calculating a third check value of the backup system configuration file based on the index file in the backup file system partition, and comparing the third check value with a fourth check value recorded in the index file;
if the third check value is the same as the fourth check value, restoring the firmware of the file system partition based on the backup system configuration file of the backup file system partition;
and checking whether the backup system configuration file is successfully restored or not based on the file size recorded by the index file and the size of the returned data after restoration.
In a second aspect, an embodiment of the present application provides an apparatus for upgrading a device firmware, where the apparatus may include:
the system comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a firmware upgrading file, and the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file;
the upgrading unit is used for upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining the check value of the first partition and the check value of the second partition in the check partition;
and the judging unit is used for judging whether the file system partition is upgraded successfully or not according to the first upgrading result and the second upgrading result.
In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the method of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to execute the method described in the first aspect.
It can be understood that, the beneficial effects of the second to fifth aspects can be referred to the relevant description of the first aspect, and are not described herein again.
Compared with the prior art, the application has the beneficial effects that: according to the application, the electronic equipment acquires a firmware upgrading file, wherein the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file; upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition; and judging whether the file system partition is upgraded successfully or not according to the first upgrading result and the second upgrading result. By the method and the device, the firmware of different partitions is upgraded according to the preset upgrading sequence and verified by combining the verification value of the verification partition, whether the file system is upgraded successfully can be determined under the conditions that the upgrade is abnormal and the user configuration in the file system is not changed, so that the normal starting of the system and the stability of the equipment are ensured; has stronger usability and practicability.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the embodiments or the prior art description will be briefly described below, and 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 may be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of a partition architecture of a storage medium of a system provided by an embodiment of the present application;
fig. 2 is a schematic implementation flow diagram of a device firmware upgrading method provided in an embodiment of the present application;
FIG. 3 is a schematic flowchart of packaged upgrade firmware provided by an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating an upgrade process of partitions according to an embodiment of the present application;
FIG. 5 is a block diagram of a file system partition according to an embodiment of the present disclosure;
FIG. 6 is a diagram illustrating contents of an index file provided in an embodiment of the present application;
FIG. 7 is a flowchart illustrating a method for restoring backup firmware according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an apparatus firmware upgrading device provided in an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Currently, the firmware of the device is upgraded to improve the functions of the device or add new functions to the device. However, in the process of upgrading the device, if abnormal conditions such as power failure occur, the firmware of the device is easily damaged, and other problems are easily caused, so that whether the device is upgraded successfully or not cannot be determined, and the use stability of the device is affected.
The existing upgrading mode is only suitable for the condition that the partition only contains system configuration; if the partition contains both system configuration and user configuration, the user configuration can be restored to default setting by adopting the existing upgrading mode, so that the related configuration items are required to be reset after each upgrading, the equipment firmware upgrading operation is complicated, and a lot of inconvenience is caused.
The upgrading package in the existing upgrading mode has strong pertinence, and has strong flexibility when upgrading a certain type of file or a certain partition, but when upgrading the plurality of or all the partitions, the plurality of upgrading packages need to be issued, the process is complicated, and which partition needs to be upgraded needs to be determined in advance, so that one-key upgrading cannot be realized.
The existing upgrading mode is to store the decompressed upgrading file for backup, so that the backup file occupies a large space, and the backup file is stored in the original partition, which also affects the starting speed of the equipment system to a certain extent.
In view of the above drawbacks, embodiments of the present application provide a method for upgrading a device firmware, which can determine whether a file system partition is successfully upgraded when abnormal conditions such as power failure occur in an upgrade process by adjusting an upgrade sequence of each partition and based on a check result of an upgrade process of other partitions, and upgrade only a system configuration in an upgrade file, so that a user configuration is not changed in the upgrade process, and related configuration items do not need to be set again; meanwhile, by adding a backup partition and backing up a system configuration file in the backup partition, the influence of a backup space on the starting speed of the system is reduced; and in order to fully utilize the storage space, a compression backup mode is adopted, and the burden of a storage medium is reduced.
The following describes an implementation process of device firmware upgrade according to a specific embodiment.
Referring to fig. 1, fig. 1 is a schematic diagram of a partition architecture of a system storage medium according to an embodiment of the present application. As shown in FIG. 1, the system storage media is divided into two types of partitions: a main partition and a backup partition; the main partition comprises a check partition, a Real Time Operation System (RTOS) partition, a System kernel partition, a file System partition and a System application program partition, and the backup partition comprises a backup check partition, a backup Real Time operating System partition, a backup System kernel partition, a backup file System partition and a backup System application program partition.
For example, in order to implement a function of quickly outflowing after a doorbell device captures a human face, when a system is started, an RTOS (real time operating system) of a real-time operating system is started first, and then the RTOS system guides a system kernel to start Linux. The file system partition comprises a system configuration file and a user configuration file; in the running process of the device, a user configuration file which is changed by a user according to the setting of the relevant configuration item can be received, the user configuration file can be related to the coding parameter of the device and the output image parameter, the real-time operating system RTOS and the system kernel can read the content of the file system partition, and the outflow parameter is adjusted according to the user configuration file in the file system partition. Accordingly, in addition to the file system partition, other partitions will only change when upgraded.
Illustratively, a structure is stored in the parity partition, and the structure includes the start offset address offset of each partition data, the length len of the data, and the parity value MD5; the check partition records the check value MD5 of the other partitions except the file system partition. When the firmware is packaged, the files of the corresponding partitions are read into the memory, and the check value MD5 corresponding to the data of the memory is calculated.
The backup partition is used for backing up the file content of each partition in the main partition, reading the file content of the main partition into the memory, compressing the file content, and writing the compressed file content into the corresponding backup partition.
Based on the partition architecture of the system storage medium, the following describes an implementation process of device firmware upgrade by using a specific embodiment.
Referring to fig. 2, fig. 2 is a schematic view illustrating an implementation flow of a method for upgrading a device firmware according to an embodiment of the present application. As shown in fig. 2, the method may include the steps of:
s201, obtaining a firmware upgrading file, wherein the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file.
In some embodiments, when the firmware of the device is upgraded, a firmware upgrade file is issued, and the firmware upgrade file may be issued as an upgrade package, which may include upgrade files of different partitions.
Illustratively, the file system partition upgrade files corresponding to the file system partitions are stored in the form of compressed packages. The file system partition defaults to upgrade the system configuration file without changing the user configuration file, and the corresponding file system partition upgrade file comprises the system configuration file. The first partition upgrade file may be an upgrade file corresponding to a system kernel partition, and the second partition upgrade file may be an upgrade file corresponding to a system application partition. The first partition upgrade file and the second partition upgrade file may also be upgrade files of other partitions besides the file system partition, such as an upgrade file of a check partition or an upgrade file of a real-time operating system partition.
S202, based on the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition according to a preset upgrading sequence, and combining the check value of the first partition and the check value of the second partition in the check partition to obtain a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition.
In some embodiments, a check partition in the main partition records check values of different partitions. In the upgrading process, the check value stored in the upgrading packet is compared with the check value stored in the check partition of the existing firmware, if the check value stored in the upgrading packet is different from the check value stored in the check partition of the existing firmware, the corresponding partition firmware is upgraded, and if the check values are the same, the partition firmware is not upgraded.
Wherein, the preset upgrading sequence may include: after the firmware of the first partition is upgraded, upgrading the firmware of the file system partition; and after the firmware of the file system partition is upgraded, upgrading the firmware of the second partition.
Illustratively, the upgrade of the file system partition is located between the first partition and the second partition upgrade. And packaging the upgrade files of the file system partitions in a compression mode.
As shown in fig. 3, a flowchart of packaged upgrade firmware provided in an embodiment of the present application is schematically illustrated. The upgrade file packaging process may include the steps of:
s301, packaging the system configuration file to generate a file system upgrading compression package.
As the file system partition only updates the system configuration file by default and does not modify the user configuration file, the update file of the file system partition only needs to pack the system configuration file and compresses and packs the system configuration file.
S302, reading the file system upgrading compression package to a memory; s303, reading rtos firmware of the real-time operating system to a memory; s304, reading the system kernel firmware to the memory; s305, reading the application program firmware to the memory.
When the device firmware is upgraded, the upgrade files of the partitions need to be read into the memory, so that the upgrade files can be called conveniently in the upgrading process.
S306, calculating check values of different partitions, and writing the check values into a memory; and S307, respectively writing the memory data into the upgrading files corresponding to different partitions.
The offset and len of each partition are saved in the configuration file, and when the upgrade file is packaged, the memory data can be saved in the check partition.
After the upgrade files of all the partitions are read into the memory, check values of the upgrade files in different partitions can be calculated. And comparing the check values of the upgrade file in different partitions with the check values stored in the check partitions to judge whether the corresponding partitions need to be upgraded or not. For example, if the check value of the upgrade file read into the memory in the corresponding partition is different from the check value stored in the check partition, upgrading the partition; if the partition is the same, the partition is not upgraded.
As shown in fig. 4, a schematic view of an upgrade flow of each partition provided in the embodiment of the present application. The upgrade flow diagram may include the following steps:
s401, mounting the file system. The file system needs to be mounted to a directory in the memory before the process can access the file system partition.
S402, issuing an upgrade package and reading the upgrade package into a memory. The upgrade package can comprise upgrade files of different partitions; the file system partition upgrading file is in a compressed package form, and upgrading files of other partitions are not in a compressed form.
S403, calling the upgrade file in the upgrade package, and erasing and writing the check partition in the flash memory flash; s404, calling an upgrade file in an upgrade package, and erasing a rtos partition of a real-time operating system in the flash; s405, calling the upgrade file in the upgrade package, and erasing and writing the system kernel partition in the flash.
S406, decompressing the file system upgrading compression package in the upgrading package to the directory where the file system is located by using the tar command, and covering the system configuration file of the file system upgrading compression package with the original system configuration file.
And S407, calling the upgrade file in the upgrade package, and erasing and writing the application program partition in the flash.
The firmware upgrade of other partitions except the file system partition in the device is realized by erasing flash. If the file system partition is upgraded in a flash-write manner, the user configuration file in the file system partition is lost, which causes the configuration item set by the user to be inconsistent with the configuration item set by the user when the device outputs the stream.
In some embodiments, upgrading firmware of the file system partition based on the file system partition upgrade file comprises:
decompressing the file system partition upgrading file to a directory where the file system partition is located; and covering the system configuration file in the decompressed file system partition upgrading file with the original system configuration file to finish upgrading the firmware of the file system partition.
As shown in FIG. 5, the file system partition may include a system profile and a user profile. Since the file system partition only modifies the system configuration file when upgrading the firmware. And decompressing the file system upgrading compression packet, and covering the system configuration file with the same name, so that the upgrading of the file system partition can be realized.
Illustratively, only the check value of the system configuration file can be stored in the file system upgrade compression package, and the check value stored in the check partition only contains the check value of the system configuration file; the file system partition also comprises a user configuration file, and a check value obtained after the file system partition in the flash is read to the memory comprises both the system configuration file and the user configuration file. Because the partition of the file system is partially upgraded, the configuration of a user can be modified at any time in the using process, so that the firmware upgrading of the partition of the file system cannot be directly verified based on the verification value of the verification partition, and whether the partition of the file system is successfully upgraded or not needs to be judged by virtue of the upgrading results of other partitions. Because the partition part of the file system is upgraded, the configuration of the user can be saved, and the user does not need to reset or modify after upgrading.
It should be noted that, the upgrade sequence of the partitions in fig. 4 is only schematically illustrated, and the upgrade sequence may also be a check partition, a first partition, a file system partition, and a second partition, for example, the check partition → a system kernel partition → a file system partition → a system application partition.
In some embodiments, upgrading the firmware of the first partition and the firmware of the second partition respectively based on the first partition upgrade file and the second partition upgrade file, and obtaining a first upgrade result corresponding to the first partition and a second upgrade result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition, includes:
reading the first partition upgrading file and the second partition upgrading file into a memory; erasing the firmware of the first partition based on the first partition upgrading file and erasing the firmware of the second partition based on the second partition upgrading file; respectively calculating a first check value corresponding to the erased first partition and a second check value corresponding to the erased second partition; comparing the first check value with the check value of the first partition in the check partitions to obtain the first upgrading result; and comparing the second check value with the check value of the second partition in the check partitions to obtain a second upgrading result.
For example, the other partitions judge whether the upgrade is successful by comparing the check value stored in the check partition with the check value actually read to the data in the memory, if the two check values are the same, the upgrade is successful, otherwise, the upgrade is failed.
Correspondingly, the first partition and the second partition are firmware upgrading realized by erasing flash, and the check value of the first partition and the check value of the second partition are recorded in the check partition. By calculating the erased check values of the first partition and the second partition and comparing the calculated check values with the check values recorded in the check partition, if the calculated check values are consistent, the firmware of the corresponding partition is upgraded successfully, and if the calculated check values are inconsistent, the upgrading fails. If the first check value is the same as the check value of the first partition in the check partitions, the first upgrading result is successful, otherwise, the first upgrading result is failed; and if the second check value is the same as the check value of the second partition in the check partitions, the second upgrading result is successful, otherwise, the second upgrading result is failed.
S203, judging whether the firmware of the file system partition is upgraded successfully or not according to the first upgrading result and the second upgrading result.
In some embodiments, based on the above-mentioned upgrading sequence, when the first partition and the second partition pass verification, it is determined that the file system partition is successfully upgraded, otherwise, as long as one of the first partition and the second partition fails verification, it is determined that the file system upgrade fails.
In some embodiments, the determining whether the firmware of the file system partition is successfully upgraded according to the first upgrade result and the second upgrade result includes:
when the first upgrading result is successful in verification and the second upgrading result is successful in verification, determining that the firmware of the file system partition is successfully upgraded; and when the first upgrading result is verification failure or the second upgrading result is verification failure, determining that the firmware upgrading of the file system partition fails.
For example, as shown in the upgrade flow diagram of fig. 4, if a power failure occurs during the upgrade process of the file system partition, that is, the power failure occurs during the process of decompressing the file system upgrade compressed packet through the tar command, the check value of the system kernel partition is the same as the value stored in the check partition, and the check value of the system application program partition is different from the value stored in the check partition, the upgrade of the system kernel partition is successful, the upgrade of the system application program partition is failed, and thus it is determined that the upgrade of the file system partition is failed.
In addition, based on the upgrading sequence, the file system partition upgrading failure can also be judged when the power failure condition occurs in the erasing and writing verification partition process; for example, if the check value stored in the check partition before the upgrade is the same as the actual check value of the first partition and the actual check value of the second partition, if the power is off during the erasing and writing process of the check partition, the check value stored in the check partition does not match the actual check value, which indicates that the upgrade has failed in this case. File system partition upgrade failures are also determined in cases where power down occurs at other partition upgrade nodes, such as before or during an application partition upgrade.
It should be noted that, in general, basically, a kernel partition and an application partition are upgraded every time a device is upgraded, and therefore, the upgrade of a file system partition is placed between the two partitions; while rtos partitions, not every time they are upgraded. The file system partition is placed between any two partitions needing to be upgraded, and verification of the upgrade of the file system partition can be indirectly achieved.
In some embodiments, the file system partition comprises a plurality of system files, and after the upgrading of the firmware of the file system partition based on the file system partition upgrade file, the method further comprises:
compressing a plurality of system files in the file system partition to obtain system compressed files; taking the system compressed file as a backup system configuration file, and storing the system compressed file into a backup file system partition of a backup area; and in the backup file system partition, generating an index file of the backup system configuration file, wherein the index file is used for recording the attribute information of the backup system configuration file.
Illustratively, after it is determined that the file system partition fails to be upgraded, a process of restoring the backup is performed to ensure that the system configuration in the file system is normal.
As shown in fig. 6, an architecture diagram of a backup partition provided in the embodiment of the present application is shown. And after the equipment is upgraded every time, storing the firmware upgraded by each partition to the corresponding backup partition. As shown in fig. 6 (a), the backup partitions include backup files corresponding to the respective partitions; for example, the backup check partition, the backup real-time operating system partition, the backup system kernel partition and the backup system application partition respectively include corresponding backup files; wherein the backup file system partition includes a backup system configuration file and an index file.
For example, as shown in (B) of fig. 6, in the backup file system partition, first traverse the original file system of the main partition, read all system configuration files into the memory, record the total file size and the check value, then compress a plurality of system configuration files (e.g., file 1 and file 2) into a backup file F, store the backup file F in the backup file system partition as the backup system configuration file, then record the original file size, the name and the check value (e.g., the size of file 1 is 2, the check value is a, the size of file 2 is 3, and the check value is B), generate an index file, store the index file in the backup file system, and the check value in the index file can determine whether the backup is successful.
The index file stores not only the name, size, and check value of each file in the original file system, but also the total file size and the check value of the total file (for example, the size of the total backup file is 5, and the check value is a + B). And after the backup file is written into the backup partition, reading the backup file into the memory again and decompressing, comparing the check value stored in the index file with the check value obtained by calculating the decompressed content, and judging whether the backup is successful.
Correspondingly, in the backup partition, one partition corresponds to one compressed file. And the other partitions can correspondingly read the content of the main partition into the memory, compress the content and write the compressed backup file into the corresponding backup partition.
In some embodiments, after said determining whether the file system partition is upgraded successfully according to the first upgrade result and the second upgrade result, the method further comprises:
if the file system partition fails to be upgraded, calculating a third check value of the backup system configuration file based on the index file in the backup file system partition, and comparing the third check value with a fourth check value recorded in the index file; if the third check value is the same as the fourth check value, restoring the firmware of the file system partition based on the backup system configuration file of the backup file system partition; and checking whether the backup system configuration file is successfully restored or not based on the file size recorded by the index file and the size of the returned data after restoration.
As shown in fig. 7, a flowchart of recovering backup firmware according to an embodiment of the present application is shown. The recovery process may include the steps of:
s701, decompressing the backup system configuration file in the backup file system partition into a memory;
s702, calculating the check value of the data at the corresponding position and the corresponding length in the memory according to the content of the index file;
s703, comparing the calculated check value with the check value recorded in the index file;
s704, if the check values of the two are the same, writing the backup system configuration file into a file system;
s705, if the size of the data returned by the write function is the same as the size recorded in the index file, the write is successful.
Illustratively, when the file system partition fails to be upgraded, the backup system configuration file in the backup file system is decompressed into the memory, and then written into the original file system according to the file name and size recorded in the index file, and meanwhile, whether the file is written successfully is judged by using the check value, so that the file is ensured to be restored to be normal. Before writing in the corresponding file of the original file system, calculating the check value of the data at the corresponding position and the corresponding length in the memory according to the content of the index file, comparing the calculated check value with the check value recorded in the index file, if the calculated check value is the same as the check value, writing the content in the file, and judging whether the size of the data returned by the writing function is the size of the recorded file, if the calculated check value is the same as the check value, the writing is successful.
In addition, if the other partitions fail to be upgraded, the normal operation of the equipment is ensured by restoring the original firmware files of the backup partitions.
According to the embodiment of the application, for the condition that the user configuration and the system configuration are in one partition, the embodiment of the application can only upgrade the system configuration during upgrading, only backup the system configuration during successful upgrading backup, only restore the system configuration during abnormal upgrading recovery, only change the user configuration by the user, achieve good user experience, and simplify upgrading operation without resetting after upgrading. By adjusting the upgrading sequence of the partitions and utilizing the verification results of other partitions, the problem that the partitions of the read-write file system cannot be verified is solved, and abnormal conditions can be timely found and processed. According to the embodiment of the application, a plurality of system configuration files are compressed into one file, so that the occupied space is small, the utilization efficiency of a storage medium can be improved, and the cost is saved; and the backup file is stored in the backup file system partition, so that the mounting and the use of the original file system are not influenced. According to the embodiment of the application, the index file is added in the partition of the backup file system, the file name, the size and the check value corresponding to the backed-up compressed file are recorded, whether the file backup is successful or not can be checked, and the reliability of the system is further improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Corresponding to the device firmware upgrading method described in the foregoing embodiment, fig. 8 shows a block diagram of a device firmware upgrading apparatus provided in the embodiment of the present application, and for convenience of description, only the relevant parts to the embodiment of the present application are shown.
Referring to fig. 8, the apparatus includes:
an obtaining unit 81, configured to obtain a firmware upgrade file, where the firmware upgrade file includes a first partition upgrade file, a second partition upgrade file, and a file system partition upgrade file;
an upgrading unit 82, configured to upgrade, according to a preset upgrading order, firmware of a first partition, firmware of a second partition, and firmware of a file system partition based on the first partition upgrading file, the second partition upgrading file, and the file system partition upgrading file, and obtain a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition;
and the determining unit 83 is configured to determine whether the file system partition is successfully upgraded according to the first upgrade result and the second upgrade result.
According to the method and the device, the firmware of different partitions is upgraded according to the preset upgrading sequence, the verification is carried out by combining the verification value of the verification partition, whether the file system is upgraded successfully or not can be determined under the condition that the upgrading is abnormal and the user configuration in the file system is not changed, and therefore the normal starting of the system and the stability of equipment are guaranteed.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the embodiment of the method of the present application, and specific reference may be made to the part of the embodiment of the method, which is not described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the foregoing method embodiments.
The embodiments of the present application provide a computer program product, which when running on a mobile terminal, enables the mobile terminal to implement the steps in the above method embodiments when executed.
Fig. 9 is a schematic structural diagram of an electronic device 9 according to an embodiment of the present application. As shown in fig. 9, the electronic apparatus 9 of this embodiment includes: at least one processor 90 (only one shown in fig. 9), a memory 91, and a computer program 92 stored in the memory 91 and executable on the at least one processor 90, the steps in the above embodiments being implemented when the processor 90 executes the computer program 92.
The electronic device 9 may include, but is not limited to, a processor 90, a memory 91. Those skilled in the art will appreciate that fig. 9 is merely an example of the electronic device 9, and does not constitute a limitation of the electronic device 9, and may include more or less components than those shown, or combine some of the components, or different components, such as an input-output device, a network access device, etc.
The Processor 90 may be a Central Processing Unit (CPU), and the Processor 90 may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. This electronic equipment 9 can be doorbell equipment such as visual doorbell, wireless doorbell, electronic doorbell and cat eye doorbell, also can be the electronic equipment that other storage media divide there are a plurality of subregion.
The memory 91 may in some embodiments be an internal storage unit of the electronic device 9, such as a hard disk or a memory of the electronic device 9. The memory 91 may also be an external storage device of the electronic device 9 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, provided on the electronic device 9. Further, the memory 91 may also include both an internal storage unit and an external storage device of the electronic device 9. The memory 91 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer programs. The memory 91 may also be used to temporarily store data that has been output or is to be output.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/terminal device, recording medium, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunication signals, and software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In some jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and proprietary practices.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other ways. For example, the above-described apparatus/network device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical function division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the embodiments of the present application, and they should be construed as being included in the present application.

Claims (10)

1. A method for upgrading device firmware, the method comprising:
acquiring a firmware upgrading file, wherein the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file;
upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition;
and judging whether the firmware of the file system partition is successfully upgraded or not according to the first upgrading result and the second upgrading result.
2. The method of claim 1, wherein the pre-set upgrade order comprises:
after the firmware of the first partition is upgraded, upgrading the firmware of the file system partition;
and after the firmware of the file system partition is upgraded, upgrading the firmware of the second partition.
3. The method of claim 2, wherein determining whether the firmware of the file system partition is successfully upgraded based on the first upgrade result and the second upgrade result comprises:
when the first upgrading result is verified successfully and the second upgrading result is verified successfully, determining that the firmware of the file system partition is successfully upgraded;
and when the first upgrading result is verification failure or the second upgrading result is verification failure, determining that the firmware upgrading of the file system partition fails.
4. The method of claim 1, wherein the upgrading the firmware of the file system partition based on the file system partition upgrade file comprises:
decompressing the file system partition upgrading file to a directory where the file system partition is located;
and covering the system configuration file in the decompressed file system partition upgrading file with the original system configuration file to finish upgrading the firmware of the file system partition.
5. The method of claim 1, wherein the upgrading the firmware of the first partition and the firmware of the second partition based on the first partition upgrade file and the second partition upgrade file, respectively, and obtaining a first upgrade result corresponding to the first partition and a second upgrade result corresponding to the second partition by combining a check value of the first partition and a check value of the second partition in a check partition, comprises:
reading the first partition upgrading file and the second partition upgrading file into a memory;
erasing the firmware of the first partition based on the first partition upgrade file and erasing the firmware of the second partition based on the second partition upgrade file;
respectively calculating a first check value corresponding to the erased first partition and a second check value corresponding to the second partition;
comparing the first check value with the check value of the first partition in the check partitions to obtain a first upgrading result;
and comparing the second check value with the check value of the second partition in the check partition to obtain the second upgrading result.
6. The method of any of claims 1 to 5, wherein the file system partition includes a plurality of system files, and after the upgrading of the firmware of the file system partition based on the file system partition upgrade file, the method further comprises:
compressing the system files in the file system partition to obtain a system compressed file;
taking the system compressed file as a backup system configuration file, and storing the system compressed file into a backup file system partition of a backup area;
and generating an index file of the backup system configuration file in the backup file system partition, wherein the index file is used for recording the attribute information of the backup system configuration file.
7. The method of claim 6, wherein after said determining whether the file system partition was upgraded successfully based on the first upgrade result and the second upgrade result, the method further comprises:
if the file system partition fails to be upgraded, calculating a third check value of the backup system configuration file based on the index file in the backup file system partition, and comparing the third check value with a fourth check value recorded in the index file;
if the third check value is the same as the fourth check value, restoring the firmware of the file system partition based on the backup system configuration file of the backup file system partition;
and checking whether the backup system configuration file is successfully restored or not based on the file size recorded by the index file and the size of the returned data after restoration.
8. An apparatus for upgrading firmware of a device, comprising:
the system comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a firmware upgrading file, and the firmware upgrading file comprises a first partition upgrading file, a second partition upgrading file and a file system partition upgrading file;
the upgrading unit is used for upgrading the firmware of the first partition, the firmware of the second partition and the firmware of the file system partition respectively according to a preset upgrading sequence on the basis of the first partition upgrading file, the second partition upgrading file and the file system partition upgrading file, and obtaining a first upgrading result corresponding to the first partition and a second upgrading result corresponding to the second partition by combining the check value of the first partition and the check value of the second partition in the check partition;
and the judging unit is used for judging whether the file system partition is upgraded successfully or not according to the first upgrading result and the second upgrading result.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executed by a processor to implement the method according to any one of claims 1 to 7.
CN202210942926.7A 2022-08-04 2022-08-04 Equipment firmware upgrading method and device and electronic equipment Pending CN115309435A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210942926.7A CN115309435A (en) 2022-08-04 2022-08-04 Equipment firmware upgrading method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210942926.7A CN115309435A (en) 2022-08-04 2022-08-04 Equipment firmware upgrading method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115309435A true CN115309435A (en) 2022-11-08

Family

ID=83859883

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210942926.7A Pending CN115309435A (en) 2022-08-04 2022-08-04 Equipment firmware upgrading method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115309435A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117539518A (en) * 2024-01-02 2024-02-09 江苏天华汽车电子科技有限公司 Application program upgrading method and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117539518A (en) * 2024-01-02 2024-02-09 江苏天华汽车电子科技有限公司 Application program upgrading method and electronic equipment

Similar Documents

Publication Publication Date Title
CN109032632B (en) FOTA upgrading method, wireless communication terminal and storage medium
US20050114852A1 (en) Tri-phase boot process in electronic devices
CN112783537B (en) Embedded linux operating system upgrading method and system based on MTD storage device
CN102541469B (en) Method, equipment and system for protecting data in firmware storage system
CN110442473B (en) Nonvolatile data storage method and device, electronic equipment and medium
CN112631516B (en) FLASH file management system with service life management function
CN113626256B (en) Virtual machine disk data backup method, device, terminal and storage medium
JP4583270B2 (en) Recording device
US20190227710A1 (en) Incremental data restoration method and apparatus
CN111858468B (en) Method, system, terminal and storage medium for verifying metadata of distributed file system
CN110333971B (en) SSD bad block table backup method and device, computer equipment and storage medium
CN102163155A (en) Upgrade controlling device and method for upgrading memory device
CN114116305A (en) BIOS firmware recovery method, system, terminal and storage medium based on PFR
CN115309435A (en) Equipment firmware upgrading method and device and electronic equipment
CN113311993A (en) Data storage method and data reading method
CN112306368B (en) Method and device for expanding user data partition by EMMC (enhanced multi-media card)
CN109582332B (en) System upgrading method and device for Internet camera
CN113641390B (en) System upgrading method, device, equipment and storage medium
CN116737466B (en) Backup processing method, device, system, electronic equipment and readable storage medium
CN110569058A (en) System upgrading method, device, terminal and computer readable storage medium
CN113419680A (en) Storage method and system
CN110729014A (en) Method and device for backing up erase count table in SSD (solid State disk) storage, computer equipment and storage medium
CN114625697A (en) File system recovery method and device, electronic equipment and storage medium
CN110795155B (en) System starting method and device, electronic equipment and storage medium
CN113778485A (en) System operation method and device of electronic chip, electronic chip and storage medium

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