CN109634645B - Firmware upgrading method and terminal - Google Patents

Firmware upgrading method and terminal Download PDF

Info

Publication number
CN109634645B
CN109634645B CN201811625351.6A CN201811625351A CN109634645B CN 109634645 B CN109634645 B CN 109634645B CN 201811625351 A CN201811625351 A CN 201811625351A CN 109634645 B CN109634645 B CN 109634645B
Authority
CN
China
Prior art keywords
partition
upgrade package
mirror image
upgraded
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.)
Active
Application number
CN201811625351.6A
Other languages
Chinese (zh)
Other versions
CN109634645A (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.)
Shenzhen Neoway Technology Co Ltd
Original Assignee
Shenzhen Neoway 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 Shenzhen Neoway Technology Co Ltd filed Critical Shenzhen Neoway Technology Co Ltd
Priority to CN201811625351.6A priority Critical patent/CN109634645B/en
Publication of CN109634645A publication Critical patent/CN109634645A/en
Application granted granted Critical
Publication of CN109634645B publication Critical patent/CN109634645B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses a firmware upgrading method, which comprises the following steps: determining a target partition in which an upgrade package is to be stored; executing backup operation of a file system stored in the target partition so as to backup the mirror image of the file system to a backup partition; acquiring state parameters stored by a configuration partition when the terminal executes restarting operation; if the state parameter of the configuration partition is the downloading completion state, executing the analysis operation of the upgrade package positioned in the target partition, and acquiring the mirror image to be upgraded contained in the upgrade package; judging whether the mirror image to be upgraded contains the mirror image of the target partition or not; if yes, when the mirror image in the corresponding storage partition is updated according to the mirror image to be updated contained in the upgrade package, the mirror image corresponding to the target partition in the upgrade package is controlled to be updated into the target partition finally. The invention also provides a terminal. The embodiment of the invention is beneficial to reducing the defect of overlarge occupied space in the upgrading process.

Description

Firmware upgrading method and terminal
Technical Field
The invention relates to the technical field of Internet of things, in particular to a firmware upgrading method and a terminal.
Background
The internet of things platform may run an operating system, where the operating system may include a plurality of modules stored in different partitions of a flash memory (flash). For example, the operating system includes a boot module, a power resource management module, a security module, an application operating system boot loading module, a kernel module (boot), a file system (system), and an air interface protocol module (modem), where the file system and the air interface protocol module are stored in the flash memory in a file system form, and other modules are stored in the flash memory in a mirror image manner. When The operating system needs to be upgraded, The upgrade is generally performed in a Firmware Over-The-Air (FOTA) mode.
However, when the FOTA is upgraded, the system needs to enter a Recovery (Recovery) mode, and therefore, the system needs to add a kernel module and a file system in the Recovery mode when the system is upgraded, and also needs to reserve enough storage space for performing upgrade power-down protection.
Disclosure of Invention
The embodiment of the invention provides a firmware upgrading method and a terminal, which are beneficial to reducing the defect of overlarge occupied space in the upgrading process.
The first aspect of the present invention provides a firmware upgrading method, applied to a terminal, including:
determining a target partition in which an upgrade package is to be stored;
executing backup operation of a file system stored in the target partition so as to backup the mirror image of the file system to a backup partition;
acquiring state parameters stored by a configuration partition when the terminal executes restarting operation;
if the state parameter of the configuration partition is the downloading completion state, executing the analysis operation of the upgrade package positioned in the target partition, and acquiring the mirror image to be upgraded contained in the upgrade package;
judging whether the mirror image to be upgraded contains the mirror image of the target partition or not;
if yes, when the mirror image in the corresponding storage partition is updated according to the mirror image to be updated contained in the upgrade package, the mirror image corresponding to the target partition in the upgrade package is controlled to be updated into the target partition finally.
A second aspect of the embodiments of the present invention provides a terminal, including a processor and a memory, where the memory stores computer instructions, and the computer instructions, when executed by the processor, implement some or all of the steps described in any one of the methods of the first aspect of the present invention.
According to the firmware upgrading method and the terminal, the traditional recovery mode can be removed by backing up the file system in the target partition to be stored by the upgrading packet into the backup partition, so that the space occupied by an internal module and the file system of the recovery mode is saved, the defect of overlarge occupied space in the upgrading process is favorably reduced, and the upgrading time is favorably saved.
Drawings
In order to more clearly illustrate the embodiments of the present invention 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 invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart illustrating steps of a firmware update method according to an embodiment of the present invention.
Fig. 2 is a schematic diagram of a storage format of an upgrade package in an embodiment of the present invention.
Fig. 3 is a schematic diagram of a storage format of header information within the upgrade package in fig. 2.
Fig. 4 is a block diagram of a hardware configuration of a terminal in the embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, 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 invention.
The terms "first," "second," and the like in the description and claims of the present invention and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The following describes embodiments of the present invention in detail.
Referring to fig. 1, a flowchart illustrating steps of a firmware updating method according to an embodiment of the invention is shown, where the firmware updating method includes the following steps:
the terminal may be an electronic Device such as a Mobile phone, a tablet computer, a Personal Digital Assistant (PDA), a Mobile Internet Device (MID), an Internet of things Device, and the like, which is not limited in the embodiments of the present invention.
When an existing system is upgraded, after a terminal is powered on, the system loads a Primary boot loader (PLB) and then loads a Secondary Boot Loader (SBL). And then, loading the power resource management module, the security module and the application operating system boot loading module through the secondary boot module, and loading the kernel module in the recovery mode by the application operating system boot loading module. Because the file system (system module) and the air interface protocol module (modem module) are file-based upgrading methods, the partition where the file system and the air interface protocol module are located needs to be mounted as a readable and writable file system before the file system and the air interface protocol module are upgraded. However, when the terminal suddenly loses power, the file system may be lost and damaged, and particularly when the file system is mounted as readable and writable, the file system may be damaged if the terminal suddenly loses power, and then the terminal cannot be normally started.
In order to reduce the defect that the file system may be damaged during system upgrade, the upgrade file system and the air interface protocol module in this embodiment are based on an image upgrade mode, where the image upgrade may be an upgrade that can be completed by writing an image file into a partition corresponding to the module.
Step 100, determining a target partition where the upgrade package is to be stored.
In this embodiment, because the file system in the terminal has a larger storage space, the partition where the file system is located may be multiplexed, and the upgrade package is directly stored in the partition where the file system is located, where the partition where the file system is located is the target partition.
For example, the storage device (e.g., flash memory) of the terminal may include a plurality of storage partitions, each of which is used to store a corresponding file system, e.g., the terminal may include first to ninth storage partitions, wherein the boot module may be stored in the first storage partition, the power resource management module may be stored in the second storage partition, the security module may be stored in the third storage partition, the application operating system boot load module may be stored in the fourth storage partition, the kernel module may be stored in the fifth storage partition, the file system may be stored in the sixth storage partition, the air interface protocol module may be stored in the seventh storage partition, the eighth storage partition may be used as a backup partition for storing an image of the file system of the target partition, the size of the image is slightly larger than that of the file system of the target partition, the ninth storage partition is used as a configuration information partition for storing the state parameters, its size may be 1 BLOCK (BLOCK).
Since system is the root file system and the partition where the user's file system is located, the storage partition where the file system is located (i.e. the system partition or the sixth storage partition) generally occupies a large space, and therefore, the downloaded upgrade package can reuse the entire space of the partition. When the upgrade package is downloaded, the file system of the system partition is mounted as read-only, so that other applications are prevented from writing the upgrade package, and then the downloaded upgrade package is directly stored in the partition. In other embodiments, since the storage partition in which the air interface protocol module is located also has a larger unused space, the upgrade package may also be stored in the storage partition in which the air interface protocol module is located.
In this embodiment, if the target partition stored by the upgrade package is the storage partition where the file system is located, it may be determined that the target partition is the sixth storage partition; and if the target partition stored by the upgrade package is the storage partition where the air interface protocol module is located, determining that the target partition is the seventh storage partition.
Step 102, executing a backup operation of the file system stored in the target partition to backup the mirror image of the file system to the backup partition.
In this embodiment, in order to update the file system and the air interface protocol module, if the upgrade package is also stored in the sixth storage partition where the file system is located or the seventh storage partition where the air interface protocol module is located, at this time, a backup operation needs to be performed on the mirror image of the file system in the sixth storage partition or the seventh storage partition.
For example, when it is determined that the sixth storage partition is the target partition, the content of the sixth storage partition needs to be backed up into the backup partition, for example, the mirror image of the sixth storage partition needs to be backed up into the backup partition; when it is determined that the seventh storage partition is the target partition, the content of the seventh storage partition needs to be backed up into the backup partition, for example, the mirror image of the seventh storage partition is backed up into the backup partition. In this embodiment, the size of the backup partition needs to be slightly larger than the size of the mirror image of the file system of the target partition. In addition, because the file system image occupies a much smaller space than the file system actually, the whole upgrading scheme only needs to additionally increase a space slightly larger than the file system image. If the size of the target partition is smaller than the largest upgrade package, the target partition needs to be enlarged a little to ensure that the target partition is larger than the largest upgrade package.
And 104, acquiring the state parameters stored in the configuration partition when the terminal executes the restarting operation.
The status parameter FOTA _ FLAG stored in the configuration partition may be one of a trigger upgrade status, a download start status, a download complete status, an upgrade complete status, and a clear status.
When the upgrade state is triggered, the state parameter FOTA _ FLAG may be set to 0x01 to indicate that an upgrade operation may be performed on the terminal.
In the download start state, the status parameter FOTA _ FLAG may be set to 0x02 to indicate whether the upgrade package stored remotely can be detected, and when the upgrade package is stored remotely, the upgrade package is downloaded.
In the download complete state, the state parameter FOTA _ FLAG may be set to 0x03 to indicate that the upgrade package at the remote end has been downloaded locally; in the upgrade complete state, the state parameter FOTA _ FLAG may be set to 0x04 to indicate that the upgrade operation for each partition has been completed.
When the state is cleared, the state parameter FOTA _ FLAG may be set to 0xFF to indicate that an upgrade operation is not to be performed.
In this embodiment, when the storage device is a flash memory, the size of the space occupied by the configuration partition may be one block (block), where a first page in the block may store a value of the status parameter FOTA _ FLAG.
In order to upgrade the power resource management module and the security module, the upgrade operation needs to be performed before the power resource management module and the security module are loaded. Therefore, in this embodiment, after the secondary boot module is loaded, the state parameter stored in the configuration partition is acquired in the boot program, so as to execute the upgrade operation according to the state parameter stored in the configuration partition, and further, other modules such as the power resource management module and the security module can be upgraded.
In this embodiment, after the terminal is restarted, if the state parameter of the configured partition is the trigger upgrade state, it indicates that the upgrade operation can be performed on the terminal. At this time, the file system that can mount the target partition is read-only. Because the sixth storage partition where the file system is located and the seventh storage partition where the air interface protocol module is located are both file systems, in the upgrading process, in order to avoid upgrading failure caused by the writing operation of other application programs except for downloading the upgrade package to the target partition, the target partition can be controlled to be in a read-only state, so that the writing operation of other application programs except for downloading the upgrade package application program to the target partition is prohibited. In an embodiment, when there is a write operation to the target partition by other application programs except the application program for downloading the upgrade package, the application program is controlled to exit, so as to ensure that only the application program for downloading the upgrade package can write the target partition.
When the state parameter in the configuration partition is the trigger upgrading state, after the computer is started, the application program for downloading the upgrading packet can check whether the upgrading packet exists at the far end. And if the remote end has the upgrade package, setting the state parameter of the configuration partition as a downloading starting state. And if the remote end does not have the upgrade package, setting the state parameter of the configuration partition to be a clearing state so as to represent that the terminal does not need to be upgraded, and then restarting the terminal.
In one embodiment, there may be a case where power is lost while the terminal downloads the upgrade package. In order to avoid that the terminal cannot be started due to power failure during terminal upgrading, after the terminal is restarted, if the state parameter of the configuration partition is detected to be a downloading starting state, the power failure during the downloading of the upgrade package of the terminal can be determined, and at the moment, the mirror image of the file system in the backup partition can be restored to the target partition so as to realize the restoration of the system. For example, when the target partition is the sixth storage partition where the file system is located, if the terminal detects that the state parameter of the configuration partition is the download start state after restarting, since the mirror image of the file system of the sixth storage partition is already backed up in the backup partition, at this time, only the mirror image of the file system in the backup partition needs to be written into the sixth storage partition, and then the state parameter of the configuration partition is set to be the clear state. Therefore, when the terminal is restarted again, the file system is recovered, and the possibility that the terminal cannot be started due to power failure in the upgrading process can be avoided.
And downloading the upgrade package into a target partition from a remote end, wherein the upgrade package is stored from the first page of the target partition.
Fig. 2 is a schematic diagram illustrating a storage format of an upgrade package according to an embodiment of the invention.
The upgrade package 40 includes header information 400 and one or more to-be-upgraded images 402, where the space occupied by the header information 400 may be one page in the flash memory, and the space occupied by each to-be-upgraded image 402 may be an integer multiple of the page, and the deficiency is compensated by 0 xff. Each image 402 to be upgraded is stored in sequence, and when upgrading is performed, the upgrading can be performed in sequence according to the storage sequence of the image 402 to be upgraded in the upgrade package 40. The upgrade package may not include the images of all storage partitions, for example, when the file system does not need to be updated or upgraded, the upgrade package may not include the image to be upgraded corresponding to the target partition; if the power resource management module and the security module need to be updated, the upgrade package may include the mirror image to be upgraded of the power resource management module and the security module.
Referring to fig. 3, a schematic diagram of a storage format of header information in the upgrade package in fig. 2 is shown. The header information 400 includes the number img _ cnt of the images to be upgraded, the storage partition name img _ name of each image to be upgraded, the size img _ size of each image to be upgraded, the offset address img _ addr stored in each image to be upgraded, and a Cyclic Redundancy Check (CRC) reference Check value img _ CRC of each image to be upgraded, and the structure thereof can be described as follows:
Figure BDA0001927865310000061
Figure BDA0001927865310000071
when the upgrade package 40 is completely downloaded, a verification operation may be performed on the upgrade package 40.
When the upgrade package 40 passes the verification operation, the status parameter of the configuration partition may be set to the download complete status. For example, the header information 400 included in the upgrade package 40 may be acquired, and the verification operation of each image to be upgraded 402 in the upgrade package 40 may be performed to obtain the comparison verification value of each image to be upgraded 402. It is determined whether there is at least one contrast check value of the image to be upgraded 402 different from the reference check value of the image to be upgraded stored in the header information 400. When the comparison check value of each image 402 to be upgraded in the upgrade package 40 is the same as the reference check value of the corresponding image to be upgraded stored in the header information 400, it indicates that the upgrade package download is completed, and at this time, the state parameter of the configuration partition is set to be a download completion state. And if the contrast check value of at least one mirror image 402 to be upgraded is different from the reference check value of the corresponding mirror image to be upgraded stored in the header information 400, controlling the terminal to execute a restart operation. When the terminal is restarted, because the state parameter in the configured partition is the downloading starting state, at the moment, the loading secondary starting module can restore the file system image of the backup area into the partition, and then after the terminal is normally started, the application program for downloading the upgrade package is operated to download again.
And 106, if the state parameter of the configuration partition is the downloading completion state, executing the analysis operation of the upgrade package positioned in the target partition, and acquiring the mirror image to be upgraded contained in the upgrade package.
In this embodiment, the upgrade package in fig. 2 may be analyzed, so that the image to be upgraded included in the upgrade package may be obtained.
When the status parameter of the configuration partition is the download complete status, it indicates that the upgrade package 40 stored in the target partition has passed the verification operation, and at this time, the system may be upgraded according to the upgrade package. And if the header information of the upgrade package is read from the first page of the target partition, then, updating each image to be upgraded of the upgrade package to the partition where the corresponding file system is located according to the header information, and finishing the image upgrade.
In an embodiment, if the power is lost during downloading the upgrade package, it indicates that the upgrade package is not successfully upgraded, and at this time, the upgrade can be performed again according to the header description of the download package.
Step 108, judging whether the mirror image to be upgraded contains the mirror image of the target partition, if so, executing step 110; if not, go to step 112.
The target partition is stored with the upgrade package, so that whether the upgrade package contains the to-be-upgraded mirror image corresponding to the target partition needs to be judged for successful upgrade, and if the upgrade package contains the to-be-upgraded mirror image corresponding to the target partition, the upgrade sequence of the to-be-upgraded mirror image needs to be adjusted; and if the upgrading packet does not contain the mirror image to be upgraded corresponding to the target partition, the mirror image in the corresponding storage partition can be upgraded according to the sequence of the mirror image to be upgraded contained in the control upgrading packet.
And step 110, when the mirror image in the corresponding storage partition is updated according to the mirror image to be updated contained in the upgrade package, controlling the mirror image to be updated corresponding to the target partition in the upgrade package to be updated into the target partition.
In an embodiment, if the target partition is a sixth storage partition where the file system is located, if the upgrade package includes the to-be-upgraded image corresponding to the sixth storage partition, at this time, an update operation of the to-be-upgraded image corresponding to the sixth storage partition included in the upgrade package needs to be finally performed, for example, the image corresponding to the sixth storage partition is finally updated to the sixth storage partition.
In this embodiment, when upgrading according to the sequence of the header information in the upgrade package, and when upgrading the to-be-upgraded image of the target partition is performed, the upgrade package may be controlled to update the to-be-upgraded image of the target partition, which includes the upgrade package, to the backup partition and the target partition, and set the state parameter of the configuration partition as the upgrade completion state. In an embodiment, there may be a power failure before the status parameter of the configuration partition is set to the upgrade complete status, and after the terminal is restarted, the execution is resumed from step 104, and the upgrade operation is resumed.
For example, the upgrade package includes three continuously stored images to be upgraded, which are a first image to be upgraded (corresponding to the first storage partition) located at the first position, a second image to be upgraded (corresponding to the sixth storage partition) located at the second position, and a third image to be upgraded (corresponding to the second storage partition) located at the third position, where the second image to be upgraded is an image to be upgraded of the corresponding target partition. At the moment, when the upgrading operation is executed, after the first image to be upgraded is upgraded and corresponds to the first storage partition at the first time, when the second image to be upgraded is updated at the second time, because the storage partition to be updated by the second image to be upgraded is the target partition, at the moment, the upgrading of the second image to be upgraded can be skipped, and the upgrading of the third image to be upgraded is executed, for example, the third image to be upgraded is updated to the second storage partition; and after the third image to be upgraded is upgraded, finally, the second image to be upgraded is upgraded, and if the second image to be upgraded is updated to the backup partition and the sixth storage partition, the goal of upgrading the upgrade package is achieved.
In an embodiment, there may be a case where the to-be-upgraded image of the target partition included in the upgrade package is updated to the backup partition, and the state parameter of the configuration partition is set to be an upgrade complete state. In order to avoid that the terminal cannot be started due to power failure during terminal upgrading, after the terminal is restarted, if the state parameter of the configuration partition is detected to be an upgrading completion state, the mirror image to be upgraded of the target partition in the backup partition can be written into the target partition. For example, when the target partition is the sixth storage partition where the file system is located, if the terminal detects that the state parameter of the configuration partition is in the upgrade complete state after restarting, since the to-be-upgraded mirror image of the target partition is written in the backup partition, at this time, only the to-be-upgraded mirror image corresponding to the target partition in the backup partition needs to be written in the sixth storage partition, and then the state parameter of the configuration partition is set to be the clear state. Therefore, when the terminal is restarted, the file system is updated, and the possibility that the terminal cannot be started due to power failure in the upgrading process can be avoided.
And step 112, controlling the sequence of the mirror images to be upgraded contained in the upgrade package to upgrade the mirror images in the corresponding storage partitions.
In an embodiment, if the target storage area is a sixth storage partition where the file system is located, if the upgrade package does not include the to-be-upgraded image corresponding to the sixth storage partition, the images in the corresponding storage partitions may be upgraded according to the to-be-upgraded image sequence included in the control upgrade package.
For example, the upgrade package includes three continuously stored images to be upgraded, which are a first image to be upgraded (corresponding to the first storage partition) located at the first position, a second image to be upgraded (corresponding to the fourth storage partition) located at the second position, and a third image to be upgraded (corresponding to the second storage partition) located at the third position. At the moment, when the upgrading operation is executed, the first mirror image to be upgraded is upgraded and corresponds to the first storage partition at the first time; at the second time, upgrading the second mirror image to be upgraded to correspond to the fourth storage partition; and at the third time, the third image to be upgraded is upgraded and corresponds to the second storage partition. In other embodiments, the updating may not be performed according to the storage order of the image to be updated, for example, the updating operation of the image to be updated may be randomly selected.
The firmware upgrading method can save space for upgrading: compared with the traditional full package upgrading, the recovery mode can be removed, the boot of the recovery mode and the space occupied by the file system are saved, and the space for storing the upgrading package and performing power failure protection is saved. In addition, the firmware upgrading method can prevent the defect of system damage caused by power loss: the modules are all upgraded based on the mirror image, so that the upgrading time is saved; when the terminal is powered off, corresponding operation can be executed according to the state parameters of the configured partition, for example, the backup stored in the backup partition is restored to the partition where the original file system is located, which is beneficial to avoiding the defect that the system cannot be started due to power failure. In addition, the firmware upgrading method can upgrade more modules: the traditional upgrading method is carried out in a recovery mode, modules such as a power resource management module and a safety module cannot be upgraded, if the modules are upgraded, after abnormal power failure, the power supply cannot be normally started and the recovery mode cannot be entered again for upgrading, but the power resource management module and the safety module can be upgraded, so that the convenience of upgrading the system is improved.
Referring to fig. 4, a block diagram of a hardware structure of a terminal according to an embodiment of the present invention is shown. As shown in fig. 4, the terminal may apply the above embodiments, and the terminal 50 provided by the present invention is described below, where the terminal 50 may further include a processor 500, a storage device 502, a display 504, and a computer program (instruction) stored in the storage device 502 and capable of running on the processor 500, and the terminal 50 may further include other hardware components, such as a key, a fingerprint acquisition module, a communication device, and a sensor (e.g., an acceleration sensor and a hall sensor), which are not described herein again. The processor 500 may exchange data with a storage device 502 and a display 504 via a bus 506.
The Processor 500 may be a Central Processing Unit (CPU), 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 device, discrete hardware component, etc. A general-purpose processor, which may be a microprocessor or the processor may be any conventional processor or the like, is the control center of the terminal 50 and connects the various parts of the overall terminal 50 using various interfaces and lines.
The storage device 502 may be used to store executable program codes and/or modules, and the processor 500 implements various functions of the firmware upgrade method by running or executing the executable program codes and/or modules stored in the storage device 502 and calling data stored in the storage device 502. The storage device 502 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like. In addition, the storage device 502 may include a high speed random access memory device, and may also include a non-volatile storage device such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one piece of magnetic disk storage, a Flash memory device, or other volatile solid state storage device.
The display 504 may display a User Interface (UI) or a Graphical User Interface (GUI) including interfaces of photos, videos, chat contents, and the like, and the display 504 may also be used as an input device and an output device, and the display may include at least one of a Liquid Crystal Display (LCD), a thin film transistor LCD (TFT-LCD), an Organic Light Emitting Diode (OLED) touch display, a flexible touch display, a three-dimensional (3D) touch display, an ink screen display, a flexible touch display, and the like.
The processor 500 runs a program corresponding to the executable program code by reading the executable program code stored in the storage device 502, so as to execute the firmware upgrade method executed by the terminal in any of the foregoing embodiments.
Processor 500 is configured to determine a target partition for the upgrade package to be stored.
In this embodiment, the upgrade package may be stored in the backup partition, and since the file system in the terminal has a larger storage space, the backup partition may reuse a part of the space in the partition where the file system is located, and at this time, the partition where the file system is located is the target partition.
For example, the storage device (e.g., flash memory) of the terminal may include a number of storage partitions, each for storing a corresponding file system, e.g., the terminal may include first through ninth storage partitions, wherein, the starting module can be stored in the first storage partition, the power resource management module can be stored in the second storage partition, the security module can be stored in the third storage partition, the application operating system starting and loading module can be stored in the fourth storage partition, the kernel module can be stored in the fifth storage partition, the file system can be stored in the sixth storage partition, the air interface protocol module can be stored in the seventh storage partition, the eighth storage partition can be used as the backup partition, for storing data of a size slightly larger than the image of the file system to be backed up, a ninth storage partition as a configuration information partition for storing status parameters, which may be 1 BLOCK (BLOCK) in size.
Since system is the root file system and the partition where the user's file system is located, the storage partition where the file system is located (i.e., the system partition or the sixth storage partition) generally occupies a large space, and thus, the downloaded upgrade package can reuse the space. When the upgrade package is downloaded, the processor 500 mounts the file system of the system partition as read-only to prevent other applications from writing to the file system, and then directly stores the downloaded upgrade package in the partition. In other embodiments, since the memory partition in which the air interface protocol module is located also has a larger unused space, the processor 500 may also store the upgrade packet in the memory partition in which the air interface protocol module is located.
In this embodiment, if the target partition stored in the upgrade package is the storage partition where the file system is located, the processor 500 may determine that the target partition is the sixth storage partition; if the target partition stored by the upgrade package is the storage partition where the air interface protocol module is located, the processor 500 may determine that the target partition is the seventh storage partition.
The processor 500 is configured to perform a backup operation of the file system stored in the target partition to backup an image of the file system to the backup partition.
In this embodiment, in order to update the file system and the air interface protocol module, if the upgrade package is also stored in the sixth storage partition where the file system is located or the seventh storage partition where the air interface protocol module is located, at this time, the processor 500 needs to perform a backup operation on the image of the file system in the sixth storage partition or the seventh storage partition.
For example, when the sixth storage partition is determined as the target partition, the processor 500 needs to backup the content of the sixth storage partition into the backup partition, for example, backup the mirror image of the sixth storage partition into the backup partition; when the seventh storage partition is determined to be the target partition, the processor 500 needs to backup the contents of the seventh storage partition into the backup partition, for example, backup the mirror image of the seventh storage partition into the backup partition. In this embodiment, the size of the backup partition may be slightly larger than the size of the mirror image of the file system of the target partition. In addition, because the file system image occupies a much smaller space than the file system actually, the whole upgrading scheme only needs to additionally increase a space slightly larger than the file system image.
The processor 500 is configured to obtain the state parameter stored in the configuration partition when the terminal performs a restart operation.
The status parameter FOTA _ FLAG stored in the configuration partition may be one of a trigger upgrade status, a download start status, a download complete status, an upgrade complete status, and a clear status.
When the upgrade state is triggered, the state parameter FOTA _ FLAG may be set to 0x01 to indicate that an upgrade operation may be performed on the terminal.
In the download start state, the status parameter FOTA _ FLAG may be set to 0x02 to indicate whether the upgrade package stored remotely can be detected, and when the upgrade package is stored remotely, the upgrade package is downloaded.
In the download complete state, the state parameter FOTA _ FLAG may be set to 0x03 to indicate that the upgrade package at the remote end has been downloaded locally; in the upgrade complete state, the state parameter FOTA _ FLAG may be set to 0x04 to indicate that the upgrade operation for each partition has been completed.
When the state is cleared, the state parameter FOTA _ FLAG may be set to 0xFF to indicate that an upgrade operation is not to be performed.
In this embodiment, when the storage device is a flash memory, the size of the space occupied by the configuration partition may be one block (block), where a first page in the block may store a value of the status parameter FOTA _ FLAG.
When the status parameter in the partition is configured to trigger the upgrade status, the processor 500 may detect whether the upgrade package exists at the remote end. If the upgrade package exists at the remote end, the processor 500 sets the status parameter of the configuration partition to the download start status. If the upgrade package does not exist at the remote end, the processor 500 sets the status parameter of the configuration partition to a clear status, so as to indicate that the upgrade operation does not need to be performed on the terminal.
In one embodiment, there may be a case where power is lost while the terminal downloads the upgrade package. In order to avoid that the terminal cannot be started due to power failure during terminal upgrade, after the terminal is restarted, if the processor 500 detects that the state parameter of the configuration partition is a download start state, it can be determined that power failure occurs during the terminal downloads the upgrade package, and at this time, the processor 500 can restore the mirror image of the file system in the backup partition to the target partition to realize system restoration. For example, when the target partition is the sixth storage partition where the file system is located, if the terminal detects that the state parameter of the configuration partition is the download start state after restarting, since the mirror image of the file system of the sixth storage partition is already backed up in the backup partition, at this time, only the mirror image of the file system in the backup partition needs to be written into the sixth storage partition, and then the state parameter of the configuration partition is set to be the clear state. Therefore, when the terminal is restarted again, the file system is recovered, and the possibility that the terminal cannot be started due to power failure in the upgrading process can be avoided. Processor 500 is also configured to download an upgrade package from a remote location into a target partition, wherein the upgrade package is stored starting with a first page of the target partition.
When the upgrade package 40 is completely downloaded, the processor 500 is further configured to perform a verification operation on the upgrade package 40, and when the upgrade package 40 passes the verification operation, the processor 500 is further configured to set the status parameter of the configurable partition to a download complete status. The processor 500 is further configured to determine whether there is at least one contrast check value of the image to be upgraded 402 different from a reference check value of the image to be upgraded stored in the header information 400. When the comparison check value of each image to be upgraded 402 in the upgrade package 40 is the same as the reference check value of the corresponding image to be upgraded stored in the header information 400, indicating that the upgrade package download is completed, at this time, the processor 500 is further configured to set the state parameter of the configuration partition to be a download complete state. If the contrast check value of at least one image to be upgraded 402 is different from the reference check value of the corresponding image to be upgraded stored in the header information 400, the processor 500 is further configured to control the terminal to perform a restart operation. When the terminal is restarted, because the state parameter in the configured partition is the downloading starting state, at the moment, the loading secondary starting module can restore the file system image of the backup area into the partition, and then after the terminal is normally started, the application program for downloading the upgrade package is operated to download again.
If the status parameter of the configuration partition is the download completion status, the processor 500 is further configured to execute an analysis operation of the upgrade package located in the target partition, and obtain the to-be-upgraded image included in the upgrade package.
When the status parameter of the configuration partition is the download complete status, indicating that the upgrade package 40 stored in the target storage area has passed the verification operation, the processor 500 may upgrade the system according to the upgrade package. And if the header information of the upgrade package is read from the first page of the target partition, then, updating each image to be upgraded of the upgrade package to the partition where the corresponding file system is located according to the header information, and finishing the image upgrade.
In an embodiment, it is determined during the restart that the status parameter of the configuration partition is the download complete status, which indicates that the terminal loses power when the upgrade package is downloaded, that is, the processor 500 determines that the upgrade package is not successfully upgraded, and at this time, the processor 500 may upgrade again according to the header description of the download package.
The processor 500 is further configured to determine whether the to-be-upgraded mirror image includes the mirror image of the target partition, and if so, the processor 500 is further configured to control the to-be-upgraded mirror image corresponding to the target partition in the upgrade package to be updated into the target partition finally when the mirror image in the corresponding storage partition is updated according to the to-be-upgraded mirror image included in the upgrade package; if not, the processor 500 is further configured to control the image to be upgraded included in the upgrade package to sequentially update the images in the corresponding storage partitions.
The target partition is stored with the upgrade package, so that whether the upgrade package contains the to-be-upgraded mirror image corresponding to the target partition needs to be judged for successful upgrade, and if the upgrade package contains the to-be-upgraded mirror image corresponding to the target partition, the upgrade sequence of the to-be-upgraded mirror image needs to be adjusted; and if the upgrading packet does not contain the mirror image to be upgraded corresponding to the target partition, the mirror image in the corresponding storage partition can be upgraded according to the sequence of the mirror image to be upgraded contained in the control upgrading packet.
The terminal can save the space for space upgrading when upgrading: compared with the traditional full package upgrading, the recovery mode can be removed, the boot of the recovery mode and the space occupied by the file system are saved, and the space for storing the upgrading package and performing power failure protection is saved. In addition, the terminal can prevent the power loss during upgrading to cause the defect of system damage: the modules are all upgraded based on the mirror image, so that the upgrading time is saved; when the terminal is powered off, corresponding operation can be executed according to the state parameters of the configured partition, for example, the backup stored in the backup partition is restored to the partition where the original file system is located, which is beneficial to avoiding the defect that the system cannot be started due to power failure. In addition, the terminal can be upgraded more modules: the traditional upgrading method is carried out in a recovery mode, modules such as a power resource management module and a safety module cannot be upgraded, if the modules are upgraded, after abnormal power failure, the power supply cannot be normally started and the recovery mode cannot be entered again for upgrading, but the power resource management module and the safety module can be upgraded, so that the convenience of upgrading the system is improved.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The above embodiments of the present invention are described in detail, and the principle and the implementation of the present invention are explained by applying specific embodiments, and the above description of the embodiments is only used to help understanding the method of the present invention and the core idea thereof; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A firmware upgrading method is applied to a terminal, and is characterized by comprising the following steps:
determining a target partition to be stored by an upgrade package, wherein the target partition is a storage partition in which a file system module is located or a storage partition in which an air interface protocol module is located;
executing backup operation of a file system stored in the target partition so as to backup the mirror image of the file system to a backup partition;
acquiring state parameters stored by a configuration partition when the terminal executes restarting operation;
if the state parameter of the configuration partition is the downloading completion state, executing the analysis operation of the upgrade package positioned in the target partition, and acquiring the mirror image to be upgraded contained in the upgrade package;
judging whether the mirror image to be upgraded contains the mirror image of the target partition or not;
if yes, when the mirror image in the corresponding storage partition is updated according to the mirror image to be updated contained in the upgrade package, the mirror image corresponding to the target partition in the upgrade package is controlled to be updated into the target partition finally.
2. The firmware upgrade method according to claim 1, wherein after determining whether the image to be upgraded includes the image of the target partition, the method further comprises:
and when the mirror image to be upgraded does not contain the mirror image of the target partition, controlling the sequence of the mirror image to be upgraded contained in the upgrade package to update the mirror image in the corresponding storage partition.
3. The firmware upgrading method according to claim 1, wherein the backup partition is located in a first storage partition where a file system module is located or in a second storage partition where an air interface protocol module is located, and when the backup partition is located in the first storage partition, the target partition is determined to be the first storage partition; when the backup partition is located in the second storage partition, determining that the target partition is the second storage partition.
4. The firmware upgrade method according to claim 1, wherein after obtaining the state parameters stored by the configuration partition, the method further comprises:
if the state parameter of the configuration partition is a trigger upgrading state, the file system mounted with the target partition is in a read-only state;
detecting whether the upgrade package exists at a remote end;
if so, setting the state parameter of the configuration partition to be a downloading starting state, and downloading the upgrade package into the target partition, wherein the upgrade package is stored from the first page of the target partition;
if not, setting the state parameter of the configuration partition as a clearing state.
5. The firmware upgrade method according to claim 4, wherein after the mounting of the file system of the target partition to a read-only state, the method comprises:
judging whether other application programs except the application program for downloading the upgrade package write the target partition or not;
and if so, controlling the other application programs except the application program for downloading the upgrade package to exit.
6. The firmware upgrade method according to claim 4, wherein after downloading the upgrade package into the target partition, further comprising:
performing a verification operation of the upgrade package, comprising:
acquiring header information contained in the upgrade package;
executing the verification operation of each mirror image to be upgraded in the upgrade package to obtain a comparison verification value of each mirror image to be upgraded;
judging whether a comparison check value of at least one mirror image to be upgraded is different from a reference check value of the corresponding mirror image to be upgraded stored in the header information;
if not, setting the state parameter of the configuration partition as a downloading completion state;
and if so, controlling the terminal to execute a restarting operation.
7. The firmware upgrade method according to any one of claims 1 to 6, further comprising, after obtaining the state parameters stored by the configuration partition:
and if the state parameter of the configuration partition is in a downloading starting state, controlling the backup of the mirror image of the file system stored in the backup partition to be written into the target partition, and setting the state parameter of the configuration partition to be in a clearing state.
8. The firmware upgrade method according to any one of claims 1 to 6, wherein the controlling that the image corresponding to the file system in the upgrade package is updated into the target partition last comprises:
and if the state parameter of the configuration partition is the downloading completion state, controlling to update the mirror image of the file system contained in the upgrade package to the backup partition, and setting the state parameter of the configuration partition as the upgrading completion state.
9. The firmware upgrade method of claim 8, wherein the controlling, after updating the upgrade package to the backup partition including the image of the file system, further comprises:
controlling the mirror image of the target partition stored in the backup partition to update the target partition;
and setting the state parameter of the configuration partition to be a clearing state.
10. A terminal comprising a processor and a memory, wherein the memory has stored therein computer instructions which, when executed by the processor, implement a firmware upgrade method as claimed in any one of claims 1 to 9.
CN201811625351.6A 2018-12-28 2018-12-28 Firmware upgrading method and terminal Active CN109634645B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811625351.6A CN109634645B (en) 2018-12-28 2018-12-28 Firmware upgrading method and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811625351.6A CN109634645B (en) 2018-12-28 2018-12-28 Firmware upgrading method and terminal

Publications (2)

Publication Number Publication Date
CN109634645A CN109634645A (en) 2019-04-16
CN109634645B true CN109634645B (en) 2022-03-22

Family

ID=66079082

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811625351.6A Active CN109634645B (en) 2018-12-28 2018-12-28 Firmware upgrading method and terminal

Country Status (1)

Country Link
CN (1) CN109634645B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134426A (en) * 2019-04-18 2019-08-16 深圳市致宸信息科技有限公司 A kind of embedded system upgrade method, device and terminal device
CN110780890B (en) * 2019-10-24 2023-06-06 百度在线网络技术(北京)有限公司 System upgrading method, device, electronic equipment and medium
CN111427718B (en) * 2019-12-10 2024-01-23 杭州海康威视数字技术股份有限公司 File backup method, file recovery method and file recovery device
CN111045712A (en) * 2019-12-17 2020-04-21 杭州涂鸦信息技术有限公司 Single system upgrading method and system with backup function
CN113225729B (en) * 2020-01-21 2022-07-12 荣耀终端有限公司 OTA (over the air) upgrading method and device and readable storage medium
CN111522566B (en) * 2020-04-23 2023-08-01 Oppo(重庆)智能科技有限公司 System upgrading method, terminal and storage medium
CN111694589B (en) * 2020-06-15 2023-09-29 Oppo(重庆)智能科技有限公司 Upgrade package generation method, device, server and computer readable storage medium
CN111813753A (en) * 2020-06-29 2020-10-23 深圳市元征科技股份有限公司 File saving method, file restoring method, device and terminal equipment
CN111857777B (en) * 2020-07-16 2024-02-27 南方电网数字电网科技(广东)有限公司 System updating method and device based on double-core intelligent ammeter and computer equipment
CN112148337A (en) * 2020-09-09 2020-12-29 杭州涂鸦信息技术有限公司 Firmware upgrading method and device
CN112463191A (en) * 2020-11-26 2021-03-09 北京沃东天骏信息技术有限公司 File updating method and device, equipment and storage medium
CN112860291B (en) * 2021-02-08 2023-05-12 杭州涂鸦信息技术有限公司 Firmware upgrading method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546809A (en) * 2012-07-13 2014-01-29 中兴通讯股份有限公司 Method and device for upgrading software of set top box
CN103677947A (en) * 2014-01-03 2014-03-26 深圳英飞拓科技股份有限公司 Equipment dual-system protection method and equipment dual-system upgrading method on basis of linux

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7493314B2 (en) * 2005-01-10 2009-02-17 Cyberlink Corp. System and method for providing access to computer files across computer operating systems

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546809A (en) * 2012-07-13 2014-01-29 中兴通讯股份有限公司 Method and device for upgrading software of set top box
CN103677947A (en) * 2014-01-03 2014-03-26 深圳英飞拓科技股份有限公司 Equipment dual-system protection method and equipment dual-system upgrading method on basis of linux

Also Published As

Publication number Publication date
CN109634645A (en) 2019-04-16

Similar Documents

Publication Publication Date Title
CN109634645B (en) Firmware upgrading method and terminal
US9507604B2 (en) Boot method and boot system
US8423991B2 (en) Embedded network device and firmware upgrading method
US9256744B2 (en) System-on-chip and booting method thereof
US8181007B2 (en) Electronic device and method for secure operating system update in embedded system
US7512777B2 (en) Method and system for maintaining system management BIOS
EP2375323A1 (en) Firmware image update and management
CN102722394B (en) Start upgrading method of embedded equipment
CN104123153A (en) Apparatus and method for firmware upgrade using USB
CN107678762B (en) System version upgrading method and device
CN109408122B (en) Equipment starting method, electronic equipment and computer storage medium
US11157264B2 (en) Electronic device and method for controlling update of electronic device
WO2019080840A1 (en) Method and device for repairing firmware
CN109753299A (en) A kind of method for upgrading system, device and computer storage medium
CN109582332B (en) System upgrading method and device for Internet camera
CN111045712A (en) Single system upgrading method and system with backup function
US20140258699A1 (en) Boot fault tolerant device and method thereof
CN115237647A (en) Firmware abnormity repairing method and device, electronic equipment and computer storage medium
CN115145650A (en) Information processing apparatus, storage medium, and information processing method
CN113138791A (en) Upgrade processing method and device based on embedded system and electronic equipment
CN113238790B (en) Firmware program updating method and system based on SD card and EEPROM
CN115951920A (en) Mobile equipment upgrading method and device, storage unit and mobile equipment
EP1710697A1 (en) Method and apparatus for executing application in system having NAND flash memory
CN112667444A (en) System upgrading method, storage medium and terminal equipment
CN113190244A (en) Method and device for upgrading wireless module, computer equipment 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
GR01 Patent grant
GR01 Patent grant