CN109634645A - Firmware upgrade method and terminal - Google Patents

Firmware upgrade method and terminal Download PDF

Info

Publication number
CN109634645A
CN109634645A CN201811625351.6A CN201811625351A CN109634645A CN 109634645 A CN109634645 A CN 109634645A CN 201811625351 A CN201811625351 A CN 201811625351A CN 109634645 A CN109634645 A CN 109634645A
Authority
CN
China
Prior art keywords
mirror image
subregion
upgrade package
upgraded
partition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811625351.6A
Other languages
Chinese (zh)
Other versions
CN109634645B (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

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

Abstract

The embodiment of the invention discloses a kind of firmware upgrade methods, comprising: determines the upgrade package target partition to be stored;The backup operation for executing the file system that the target partition is stored, by the mirror back-up of the file system to backing up subregion;The state parameter of configuration partitioned storage is obtained when the terminal executes reboot operation;If the state parameter of the configuration subregion is downloading completion status, the parsing operation for the upgrade package for being located at the target partition is executed, the mirror image to be upgraded that the upgrade package is included is obtained;Judge in the mirror image to be upgraded whether include the target partition mirror image;If so, being controlled in the mirror image final updating to the target partition for corresponding to the target partition in the upgrade package when the mirror image to be upgraded for being included according to the upgrade package updates the mirror image in corresponding partition holding.The present invention also provides a kind of terminals.The embodiment of the present invention advantageously reduces the excessive deficiency of occupied space in escalation process.

Description

Firmware upgrade method and terminal
Technical field
The present invention relates to internet of things field, and in particular to a kind of firmware upgrade method and terminal.
Background technique
Platform of internet of things can run operating system, wherein operating system may include it is multiple be stored in flash memory (flash) difference Module in subregion.For example, operating system includes starting module, power resources management module, security module, application operating system Start-up loading module, kernel module (boot), file system (system) and air protocol module (modem) etc., wherein file System and air protocol module are stored in flash memory in the form of file system, and other modules are then stored in a mirror-image fashion In flash memory.It is needing to upgrade operating system, general upgrading is by FOTA (Firmware Over-The-Air, firmware Aerial upgrade) mode upgraded.
However, system, which needs to enter, restores (Recovery) mode, and therefore, system is upgrading when carrying out FOTA upgrading When need to increase kernel module and file system under recovery mode, it is also necessary to reserve enough memory spaces to carry out upgrading and fall Electric protection.
Summary of the invention
The embodiment of the invention provides a kind of firmware upgrade method and terminal, occupied space in escalation process is advantageously reduced Excessive deficiency.
First aspect present invention provides a kind of firmware upgrade method, is applied to terminal, comprising:
Determine the upgrade package target partition to be stored;
The backup operation for executing the file system that the target partition is stored, by the mirror back-up of the file system To backup subregion;
The state parameter of configuration partitioned storage is obtained when the terminal executes reboot operation;
If the state parameter of the configuration subregion is downloading completion status, the upgrade package for being located at the target partition is executed Parsing operation, obtains the mirror image to be upgraded that the upgrade package is included;
Judge in the mirror image to be upgraded whether include the target partition mirror image;
If so, when the mirror image to be upgraded for being included according to the upgrade package updates the mirror image in corresponding partition holding, control It makes in the mirror image final updating to the target partition for corresponding to the target partition in the upgrade package.
Second aspect of the embodiment of the present invention provides a kind of terminal, including processor and memory, storage in the memory There is computer instruction, realizes when the computer instruction is executed by the processor such as institute in first aspect present invention either method Some or all of description step.
Above-mentioned firmware upgrade method and terminal pass through the file system backup in the target partition to be stored upgrade package To backup subregion, traditional recovery mode can be eliminated, saves the internal module and file of recovery mode System is taken up space, and the excessive deficiency of occupied space in escalation process is advantageously reduced, and is also beneficial to save the time of upgrading.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is the step flow chart of the firmware update in one embodiment of the invention.
Fig. 2 is the schematic diagram of the storage format of the upgrade package in the embodiment of the present invention.
Fig. 3 is the schematic diagram of the storage format of the header information in Fig. 2 in upgrade package.
Fig. 4 is the hardware block diagram of the terminal in the embodiment of invention.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art Every other embodiment obtained without creative efforts, shall fall within the protection scope of the present invention.
Description and claims of this specification and term " first " in above-mentioned attached drawing, " second " etc. are for distinguishing Different objects, are not use to describe a particular order.In addition, term " includes " and " having " and their any deformations, it is intended that It is to cover and non-exclusive includes.Such as the process, method, system, product or equipment for containing a series of steps or units do not have It is defined in listed step or unit, but optionally further comprising the step of not listing or unit, or optionally also wrap Include other step or units intrinsic for these process, methods, product or equipment.
Referenced herein " embodiment " is it is meant that a particular feature, structure, or characteristic described can wrap in conjunction with the embodiments Containing at least one embodiment of the present invention.Each position in the description occur the phrase might not each mean it is identical Embodiment, nor the independent or alternative embodiment with other embodiments mutual exclusion.Those skilled in the art explicitly and Implicitly understand, embodiment described herein can be combined with other embodiments.
It describes in detail below to the embodiment of the present invention.
Referring to Fig. 1, the step flow chart for the firmware update showing in one embodiment of the invention, the firmware is more New method includes the following steps:
Terminal can for cell phone, tablet computer, personal digital assistant (Personal Digital Assistant, PDA), the electronic equipments such as mobile internet device (Mobile Internet Device, MID), internet of things equipment, the present invention are real It applies example and this is not construed as limiting.
Existing system is in upgrading, at the terminal after electricity, main starting guiding module (the Primary boot of system loads Loader, PLB), reload time starting guiding module (Second boot loader, SBL).Later, it is guided by secondary starting Module loading power resources management module, security module and application operating system start-up loading module, and by application operating system The kernel module etc. united under start-up loading module loading recovery mode.Due to file system (system module), air protocol mould Block (modem module) is upgrade method file-based, is needed before upgrading to file system, air protocol module by file system Subregion carry where system, air protocol module is read-write file system.However, when the unexpected power down of terminal, it may Cause file system occur file lose and file system corruption situation, especially will it is file system mounted be it is read-write when, if Unexpected power down, it is possible that the case where file system corruption, then cause terminal can not normal boot-strap.
It may cause the deficiency of file system corruption when system upgrade to reduce, upgrade file system in the present embodiment, Air protocol module is then the mode based on image upgrade, wherein image upgrade is represented by image file writing module pair The upgrading that can be completed in the subregion answered.
Step 100, the upgrade package target partition to be stored is determined.
In the present embodiment, since the file system in terminal has biggish memory space, file system can be multiplexed Subregion where system, subregion where upgrade package is directly stored in file system, at this point, the subregion where file system is target Subregion.
For example, the storage device (such as flash memory) of terminal may include several partition holdings, each partition holding is for storage pair The file system answered, for example, terminal may include the first to the 9th partition holding, wherein starting module can be stored in the first storage Subregion, power resources management module can be stored in the second partition holding, and security module can be stored in third partition holding, using behaviour Making system start-up loading module can be stored in the 4th partition holding, and kernel module can be stored in the 5th partition holding, file system It can be stored in the 6th partition holding, air protocol module can be stored in the 7th partition holding, and the 8th partition holding can be used as backup Subregion, the mirror image of the file system for storing target partition, size is more bigger than the mirror image of the file system of target partition, the Nine partition holdings are used for storage state parameter, size can be 1 block (BLOCK) as configuration information subregion.
Since system is subregion where the file system of root file system and user, so the storage where file system Subregion (i.e. system subregion or the 6th partition holding) can generally occupy very large space, and therefore, the upgrade package of downloading can be with It is multiplexed the entire space of the subregion.When downloading upgrade package, the file system mounted to be read-only of system subregion prevents other Write operation is carried out using to it, then directly the upgrade package of downloading is stored in this subregion, in the present embodiment, upgrade package It stores and FLASH read-write interface can be used to be stored, the mode for being not based on file is stored.In other embodiments, by Also have the biggish space being not used by, therefore, can also deposit by upgrade package in the partition holding where air protocol module Storage is in the partition holding where air protocol module.
In the present embodiment, if when partition holding of the target partition of upgrade package storage where file system, it may be determined that mesh Mark subregion is the 6th partition holding;If, can when partition holding of the target partition of upgrade package storage where air protocol module Determine that target partition is the 7th partition holding.
Step 102, the backup operation for executing the file system that the target partition is stored, by the file system Mirror back-up is to backing up subregion.
In the present embodiment, in order to be updated to file system and air protocol module, if upgrade package is also stored in file The 6th partition holding where system or the 7th partition holding where air protocol module, at this time, it may be necessary to the 6th storage point The mirror image of the file system of area or the 7th partition holding carries out backup operation.
For example, then needing the content backup to the 6th partition holding when determining the 6th partition holding as target partition It, such as will be in the mirror back-up of the 6th partition holding to backup subregion to backup subregion;When determining the 7th partition holding as mesh When marking subregion, then need in content backup to the backup subregion to the 7th partition holding, it is such as that the mirror image of the 7th partition holding is standby In part to backup subregion.In the present embodiment, the size for backing up subregion needs the mirror image of the file system slightly larger than target partition Size.In addition, since file system mirror the space occupied practical than file system can be much smaller, so entire upgrading scheme is only It needs additionally to increase the space for being slightly larger than file system mirror.If target partition size is smaller than maximum upgrade package, need Target partition is tuned up a bit, to guarantee that target partition is bigger than maximum upgrade package.
Step 104, the state parameter of configuration partitioned storage is obtained when the terminal executes reboot operation.
The state parameter FOTA_FLAG for configuring partitioned storage can complete for triggering upgrade status, downloading beginning state, downloading One in state, upgrading completion status and removing state.
When triggering upgrade status, 0x01 can be set by state parameter FOTA_FLAG, to indicate that terminal can be risen Grade operation.
When downloading beginning state, 0x02 can be set by state parameter FOTA_FLAG, to indicate can detect whether distal end The upgrade package of storage, and in remote storage upgrade package, download upgrade package.
When downloading completion status, 0x03 can be set by state parameter FOTA_FLAG, to indicate the upgrading by distal end Local is loaded under packet;When upgrading completion status, 0x04 can be set by state parameter FOTA_FLAG, it is each to indicate to be completed The updating operation of subregion.
In the state of removing, 0xFF can be set by state parameter FOTA_FLAG, to indicate not having to carry out updating operation.
In the present embodiment, when storage device is flash memory, configuring space size shared by subregion can be a block (block), wherein first page in block can storage state parameter FOTA_FLAG value.
In order to enable power resources management module, security module can also be upgraded, therefore, it is necessary in power resources management Updating operation is executed before module, security module load.Therefore, it in the present embodiment, after load time starting guiding module, is opening In dynamic bootstrap, the state parameter of configuration partitioned storage is obtained, to execute liter according to the state parameter of configuration partitioned storage Grade operation, and then other modules such as power resources management module, security module load can be upgraded.
In the present embodiment, after terminal is restarted, if the state parameter of configuration subregion is triggering upgrade status, expression can be right Terminal carries out updating operation.At this point, can carry target partition file system be it is read-only.The 6th as where file system deposits Store up subregion, the 7th partition holding where air protocol module is file system, therefore, during upgrading, to avoid except downloading The other applications of upgrade package cause upgrading to fail to the write operation of target partition, and controllable target partition is in read-only shape State, to forbid except write operation of the other applications to the target partition for downloading upgrade package application program.In an embodiment In, when existing except the write operation carried out except the other applications for carrying upgrade package application program to target partition, described in control It is exited using journey, to guarantee that the application program of only downloading upgrade package can carry out write operation to target partition.
When configuring state parameter in subregion is triggering upgrade status, after booting, the application program for downloading upgrade package can be examined Distal end is looked into the presence or absence of upgrade package.If there are upgrade package for distal end, the state parameter of configuration subregion is set for downloading beginning state. If upgrade package is not present in distal end, the state parameter that configuration subregion is arranged is removing state, to indicate without executing liter to terminal Grade operation, then restarts.
In one embodiment, it is understood that there may be the case where power down occur in terminal downloads upgrade package.To avoid by terminal liter Grade when power down and cause terminal that can not start, after terminal is restarted, if detect configuration subregion state parameter for downloading start State, it may be determined that power down occur when terminal downloads upgrade package, at this point, the mirror image of the file system in backup subregion can be restored To target partition, to realize the reduction of system.For example, when target partition be file system where six partition holdings when, if Terminal detects the state parameter of configuration subregion for downloading beginning state, due to the file system of the 6th partition holding after restarting Mirror image has backed up in backup subregion, at this point, only the 6th partition holding need to be written in the mirror image of the file system in backup subregion , the state parameter that configuration subregion is arranged again later is removing state.In this way, when terminal is restarted again, due to file system System has restored, and then can avoid the possibility for causing terminal that can not start due to power down in escalation process.
By upgrade package from being distally downloaded in target partition, wherein upgrade package is since the first page of the target partition Storage.
Referring to Figure 2 together, it show the schematic diagram of the storage format of the upgrade package in the embodiment of the present invention.
Upgrade package 40 includes header information 400 and one or more mirror images 402 to be upgraded, wherein shared by header information 400 Space can be one page in flash memory, space shared by each mirror image 402 to be upgraded can be the integral multiple of page, and insufficient section is mended 0xff.Each mirror image to be upgraded 402 successively stores, can depositing according to mirror image 402 to be upgraded in upgrade package 40 when being upgraded Storage sequence is in turn upgraded.Upgrade package may not include the mirror image of all partition holdings, for example, when file system does not need more When new or upgrading, mirror image to be upgraded corresponding to target partition can not be included in upgrade package;If power resources management module, safety It then may include the mirror image to be upgraded of power resources management module, security module when module needs to be updated, in upgrade package.
Also referring to Fig. 3, the schematic diagram of the storage format of the header information in upgrade package is shown in Fig. 2.Head letter Breath 400 contain the quantity img_cnt of mirror image to be upgraded, the partition holding name img_name of each mirror image to be upgraded, each to Upgrade image size img_size, the offset address img_addr of each mirrored storage to be upgraded and each mirror image to be upgraded CRC (Cyclic Redundancy Check, cyclic redundancy check) refers to check value img_crc, and structural body can describe such as Under:
After the completion of the downloading of upgrade package 40, verification operation can be executed to upgrade package 40.
The state parameter of settable configuration subregion is downloading completion status after 40 verification operation of upgrade package passes through.For example, The header information 400 that upgrade package 40 is included can be obtained, and executes the verification behaviour of each mirror image 402 to be upgraded in upgrade package 40 Make, to obtain the comparison check value of each mirror image to be upgraded 402.Judge whether there is the comparison of at least one mirror image 402 to be upgraded The reference check value of the corresponding mirror image to be upgraded stored in check value and the header information 400 is not identical.When in upgrade package 40 The reference school of the corresponding mirror image to be upgraded stored in the comparison check value of each mirror image to be upgraded 402 and the header information 400 Test value it is all the same when, indicate upgrade package downloading is completed, at this point, setting configuration subregion state parameter be downloading completion status. The corresponding mirror image to be upgraded stored in the comparison check value of at least one mirror image 402 to be upgraded and the header information 400 if it exists Reference check value it is not identical, controlling terminal execute reboot operation.When terminal is restarted, due to the state parameter in configuration subregion To download beginning state, at this point, loading time starting module can revert to the file system mirror of backup area in subregion, then just After normally opened machine, the application program of operation downloading upgrade package is re-downloaded.
Step 106, it if the state parameter of the configuration subregion is downloading completion status, executes and is located at the target partition The parsing of upgrade package operates, and obtains the mirror image to be upgraded that the upgrade package is included.
In the present embodiment, parsing operation can be carried out to upgrade package in Fig. 2, so can be obtained that upgrade package included it is to be upgraded Mirror image.
When the state parameter for configuring subregion is downloading completion status, the upgrade package 40 being stored in target partition has been indicated By verification operation, at this point, can be upgraded according to upgrade package to system.Upgrading is read such as from first page of target partition Then the header information of packet updates each mirror image to be upgraded of upgrade package to where respective file system according to header information Image upgrade can be completed in subregion.
In one embodiment, if indicating that upgrade package does not upgrade successfully, at this point, can weigh in upgrade package downloading when power down New root is upgraded according to the head description of download package.
Step 108, judge whether include the mirror image of the target partition in the mirror image to be upgraded, if so, executing step 110;If it is not, executing step 112.
Due to storing upgrade package in target partition, in order to upgrade successfully, whether target point is included for upgrade package Mirror image to be upgraded corresponding to area is judged, if upgrade package includes mirror image to be upgraded corresponding to target partition, is needed Adjust the sequence of image upgrade to be upgraded;If upgrade package does not include mirror image to be upgraded corresponding to target partition, can root The mirror image to be upgraded sequence for being included according to control upgrade package upgrades the mirror image in corresponding partition holding.
Step 110, when the mirror image to be upgraded for being included according to the upgrade package updates the mirror image in corresponding partition holding, It controls in the mirror image final updating to the target partition to be upgraded for corresponding to the target partition in the upgrade package.
In one embodiment, if target partition is the 6th partition holding where file system, if containing in upgrade package Mirror image to be upgraded corresponding to 6th partition holding, at this time, it may be necessary to finally execute the include in upgrade package the 6th storage point The update operation of mirror image to be upgraded corresponding to area, is such as finally updated to the 6th for mirror image corresponding to the 6th partition holding and stores Subregion.
In the present embodiment, when being upgraded according to the sequence of header information in upgrade package, in the to be upgraded of performance objective subregion When the upgrading of mirror image, the controllable mirror image to be upgraded for including target partition for upgrade package is updated to the backup subregion and target point Area, and the state parameter of configuration subregion is set for upgrading completion status.In one embodiment, it is understood that there may be configure subregion in setting State parameter be upgrading completion status before when power down the case where, can be held since step 104 again after terminal is restarted Row, re-starts updating operation.
For example, in upgrade package include three Coutinuous stores mirror image to be upgraded, respectively positioned at first position first to Upgrade image (corresponding first partition holding), positioned at the second mirror image (corresponding 6th partition holding) to be upgraded of the second position and position In the third of the third place mirror image to be upgraded (corresponding second partition holding), wherein the second mirror image to be upgraded is corresponding target point The mirror image to be upgraded in area.At this point, when executing updating operation, it is at the first time, executing that the first image upgrade to be upgraded is corresponding extremely After first partition holding, when executing the second mirror image to be upgraded of update in the second time, since the second mirror image to be upgraded will update Partition holding be target partition, at this point, can skip the upgrading of the second mirror image to be upgraded, execute the liter of third mirror image to be upgraded Grade, is such as updated to the second partition holding for third mirror image to be upgraded;After the completion of third image upgrade to be upgraded, then last execution Second mirror image to be upgraded is such as updated in backup subregion and the 6th partition holding, in this way, reaching by the upgrading of the second mirror image to be upgraded To the target for completing upgrade package upgrading.
In one embodiment, it is understood that there may be the mirror image to be upgraded that upgrade package includes target partition is updated to the backup point Area, and the case where configuring power down when the state parameter of subregion is upgrading completion status, is set.To avoid by power down when terminal upgrade And cause terminal that can not start, after terminal is restarted, if detecting, the state parameter of configuration subregion for upgrading completion status, can be incited somebody to action The mirror image to be upgraded of target partition in backup subregion is written to target partition.For example, where target partition is file system Six partition holdings when, if terminal detected after restarting configuration subregion state parameter for upgrading completion status, due to target The mirror image to be upgraded of subregion has been written into backup subregion, at this point, only need to by corresponding to the target partition in backup subregion to The 6th partition holding is written in upgrade image, and the state parameter that configuration subregion is arranged again later is removing state.In this way, when eventually When end is restarted again, since file system has updated, and then it can avoid causing terminal that can not open due to power down in escalation process Dynamic possibility.
Step 112, it controls the mirror image to be upgraded sequence that the upgrade package is included and upgrades the mirror image corresponded in partition holding.
In one embodiment, if target storage is the 6th partition holding where file system, if not wrapping in upgrade package Containing mirror image to be upgraded corresponding to the 6th partition holding, at this point, the mirror image to be upgraded that can included according to control upgrade package is suitable Sequence upgrades the mirror image in corresponding partition holding.
For example, in upgrade package include three Coutinuous stores mirror image to be upgraded, respectively positioned at first position first to Upgrade image (corresponding first partition holding), positioned at the second mirror image (corresponding 4th partition holding) to be upgraded of the second position and position In the third of the third place mirror image to be upgraded (corresponding second partition holding).At this point, execute updating operation when, at the first time, It executes the first image upgrade to be upgraded is corresponding to the first partition holding;In the second time, execute the second mirror image liter to be upgraded Grade is corresponding to the 4th partition holding;In the third time, execute third image upgrade to be upgraded is corresponding to the second partition holding.? In other embodiments, it can not also be executed according to the sequence of the storage of mirrored storage to be upgraded, can such as randomly choose mirror to be upgraded The updating operation of picture.
Above-mentioned firmware upgrade method can save the space of air upgrading: only need to reserve a backup Area-Specific Archive file system System and a very small partitioned storage configuration parameter, the traditional full packet upgrading of relative contrast, can eliminate recovery mould Formula, the boot and file system for saving recovery mode are taken up space, and storage upgrade package and progress power down protection Space.In addition, above-mentioned firmware upgrade method can power down preventing lose and the deficiency of the damage that brings system: module is all based on mirror image Upgrading mode, be also conducive to save upgrading time;When terminal power down, can be executed according to the state parameter of configuration subregion Corresponding operation, the subregion as where will back up the Backup and Restore to original file system of partitioned storage, is conducive to avoid because of power down And the deficiency for causing system that can not start.In addition, above-mentioned firmware upgrade method it is scalable multiple modules it is more: traditional upgrading Method is carried out in recovery mode, can not be upgraded to modules such as power resources management module, security modules, because such as Fruit is to these module upgrades, after abnormal power-down, just can not normal boot-strap be re-introduced into recovery mode and upgraded, And the application can then upgrade power resources management module, security module, be conducive to the convenience for improving system upgrade.
Referring to Fig. 4, the hardware block diagram for the terminal showing in the embodiment of the present invention.As shown in figure 4, the end End can apply above-mentioned each embodiment, terminal 50 provided by the present invention be described below, terminal 50 may also include place Device 500, storage device 502 and display screen 504 are managed, and is stored in the storage device 502 and can be to the processor 500 The computer program (instruction) of upper operation, the terminal 50 can also include other hardware components, such as key, fingerprint collecting Mould group, communication device, sensor (such as acceleration transducer, Hall sensor), details are not described herein.The processor 500 Data exchange can be carried out by bus 506 and storage device 502 and display screen 504.
The processor 500 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor Deng the processor is the control centre of the terminal 50, utilizes each portion of various interfaces and the entire terminal 50 of connection Point.
The storage device 502 can be used for storing executable program code and/or module, and the processor 500 passes through fortune Row executes the executable program code and/or module being stored in the storage device 502, and calls and be stored in storage dress The data in 502 are set, realize the various functions of the firmware upgrade method.The storage device 502 can mainly include storage journey Sequence area and storage data area, wherein storing program area can application program needed for storage program area, at least one function etc.. In addition, storage device 502 may include high random access storage device, it can also include non-volatile memory device, such as Hard disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card), at least one disk storage device part, flush memory device or other volatibility Solid-state storage device part.
The display screen 504, can show user interface (UI) or graphic user interface (GUI), including photo, video, The interfaces such as chat content, display screen 504 are also used as input unit and output device, and display screen may include liquid crystal display (LCD), thin film transistor (TFT) LCD (TFT-LCD), Organic Light Emitting Diode (OLED) touch display, flexible touch display, three Tie up at least one of (3D) touch display, ink panel type display, flexible touch display screen etc..
The processor 500 run by the executable program code stored in read storage device 502 with it is described can The corresponding program of program code is executed, for executing firmware upgrade method performed by terminal in any embodiment of front.
Processor 500 is for determining the upgrade package target partition to be stored.
In the present embodiment, upgrade package be can be stored in backup subregion, and since the file system in terminal is with biggish Memory space therefore can be by a part of space in the subregion where backup subregion reusable file system, at this point, file system Subregion where system is target partition.
For example, the storage device (such as flash memory) of terminal may include several partition holdings, each partition holding is for storage pair The file system answered, for example, terminal may include the first to the 9th partition holding, wherein starting module can be stored in the first storage Subregion, power resources management module can be stored in the second partition holding, and security module can be stored in third partition holding, using behaviour Making system start-up loading module can be stored in the 4th partition holding, and kernel module can be stored in the 5th partition holding, file system It can be stored in the 6th partition holding, air protocol module can be stored in the 7th partition holding, and the 8th partition holding can be used as backup Subregion, the mirror image for storing the file system that its comparable size to be backed up is bigger, and the 9th partition holding is as configuration information point Area is used for storage state parameter, and size can be 1 block (BLOCK).
Since system is subregion where the file system of root file system and user, so the storage where file system Subregion (i.e. system subregion or the 6th partition holding) can generally occupy very large space, and therefore, the upgrade package of downloading can be with It is multiplexed this space.When downloading upgrade package, the file system mounted to be read-only of system subregion is prevented it by processor 500 Its application carries out write operation to it, and then directly the upgrade package of downloading is stored in this subregion, in the present embodiment, upgrade package Storage can be used FLASH read-write interface stored, the mode for being not based on file is stored.In other embodiments, Since the partition holding where air protocol module also has the biggish space being not used by, processor 500 also can be Upgrade package is stored in the partition holding where air protocol module.
In the present embodiment, if when partition holding of the target partition of upgrade package storage where file system, processor 500 It can determine that target partition is the 6th partition holding;If the target partition of upgrade package storage is the storage point where air protocol module Qu Shi, processor 500 can determine that target partition is the 7th partition holding.
Processor 500 is used to execute the backup operation for the file system that the target partition is stored, by the file The mirror back-up of system is to backing up subregion.
In the present embodiment, in order to be updated to file system and air protocol module, if upgrade package is also stored in file The 6th partition holding where system or the 7th partition holding where air protocol module, at this point, processor 500 is needed to The mirror image of the file system of six partition holdings or the 7th partition holding carries out backup operation.
For example, processor 500 is then needed to the 6th partition holding when determining the 6th partition holding as target partition It, such as will be in the mirror back-up of the 6th partition holding to backup subregion in content backup to backup subregion;When determine the 7th storage point When area is as target partition, processor 500 then needs in content backup to the backup subregion to the 7th partition holding, such as by the 7th In the mirror back-up of partition holding to backup subregion.In the present embodiment, the size for backing up subregion may be slightly larger than the text of target partition The size of the mirror image of part system.In addition, since file system mirror the space occupied practical than file system can be much smaller, so Entire upgrading scheme only needs additionally to increase the space for being slightly larger than file system mirror.
Processor 500 is used to obtain the state parameter of configuration partitioned storage when the terminal executes reboot operation.
The state parameter FOTA_FLAG for configuring partitioned storage can complete for triggering upgrade status, downloading beginning state, downloading One in state, upgrading completion status and removing state.
When triggering upgrade status, 0x01 can be set by state parameter FOTA_FLAG, to indicate that terminal can be risen Grade operation.
When downloading beginning state, 0x02 can be set by state parameter FOTA_FLAG, to indicate can detect whether distal end The upgrade package of storage, and in remote storage upgrade package, download upgrade package.
When downloading completion status, 0x03 can be set by state parameter FOTA_FLAG, to indicate the upgrading by distal end Local is loaded under packet;When upgrading completion status, 0x04 can be set by state parameter FOTA_FLAG, it is each to indicate to be completed The updating operation of subregion.
In the state of removing, 0xFF can be set by state parameter FOTA_FLAG, to indicate not having to carry out updating operation.
In the present embodiment, when storage device is flash memory, configuring space size shared by subregion can be a block (block), wherein first page in block can storage state parameter FOTA_FLAG value.
When state parameter is triggering upgrade status in configuration subregion, at this point, the detectable distal end of processor 500 is with the presence or absence of liter Grade packet.If distal end, there are upgrade package, the state parameter of configuration subregion is arranged as downloading beginning state in processor 500.If distal end There is no upgrade package, the state parameter that configuration subregion is then arranged in processor 500 is removing state, to indicate without executing to terminal Updating operation.
In one embodiment, it is understood that there may be the case where power down occur in terminal downloads upgrade package.To avoid by terminal liter Grade when power down and cause terminal that can not start, after terminal is restarted, if processor 500 detect configuration subregion state parameter be Download beginning state, it may be determined that power down occur when terminal downloads upgrade package, at this point, processor 500 can will be in backup subregion The mirror image of file system is restored to target partition, to realize the reduction of system.For example, where target partition is file system When six partition holdings, if terminal detects that the state parameter of configuration subregion for downloading beginning state, is deposited due to the 6th after restarting The mirror image for storing up the file system of subregion has backed up in backup subregion, at this point, only need to be by the mirror of the file system in backup subregion As the 6th partition holding of write-in, and then the state parameter of setting configuration subregion is removing state.In this way, working as terminal again It is secondary when restarting, since file system has been restored, and then can avoid causing terminal that can not start due to power down in escalation process Possibility.Processor 500 is also used to upgrade package from being distally downloaded in target partition, wherein upgrade package is from the target point The first page in area starts to store.
After the completion of the downloading of upgrade package 40, processor 500 is also used to execute verification operation to upgrade package 40, when upgrade package 40 After verification operation passes through, processor 500 is also used to the state parameter of settable configuration subregion as downloading completion status.Processor 500 are also used to judge whether there is and store in the comparison check value and the header information 400 of at least one mirror image 402 to be upgraded The reference check value of corresponding mirror image to be upgraded is not identical.When mirror image 402 to be upgraded each in upgrade package 40 comparison check value with When the reference check value of the correspondence mirror image to be upgraded stored in the header information 400 is all the same, indicate that upgrade package downloading is complete At at this point, processor 500 is also used to be arranged the state parameter of configuration subregion as downloading completion status.At least one wait rise if it exists The reference check value of the corresponding mirror image to be upgraded stored in the comparison check value of class mirror-image 402 and the header information 400 not phase Together, processor 500 is also used to controlling terminal and executes reboot operation.When terminal is restarted, due to the state parameter in configuration subregion To download beginning state, at this point, loading time starting module can revert to the file system mirror of backup area in subregion, then just After normally opened machine, the application program of operation downloading upgrade package is re-downloaded.
If the state parameter of the configuration subregion is downloading completion status, processor 500, which is also used to execute, is located at the mesh The parsing operation for marking the upgrade package of subregion, obtains the mirror image to be upgraded that the upgrade package is included.
When the state parameter for configuring subregion is downloading completion status, the upgrade package 40 being stored in target storage is indicated Verification operation is passed through, at this point, processor 500 can upgrade system according to upgrade package.Such as from first of target partition The header information of upgrade package is read in page, then, is updated each mirror image to be upgraded of upgrade package to correspondence according to header information Subregion where file system, can be completed image upgrade.
In one embodiment, the state parameter that configuration subregion is determined in restarting is downloading completion status, indicates that terminal exists Power down when upgrade package is downloaded, i.e. processor 500 determine that upgrade package does not upgrade successfully, at this point, processor 500 can be again under The head description for carrying packet is upgraded.
Processor 500 is also used to judge in the mirror image to be upgraded whether include the mirror image of the target partition, if so, locating Reason device 500 is also used to the control when the mirror image to be upgraded for being included according to the upgrade package updates the mirror image in corresponding partition holding It makes in the mirror image final updating to the target partition to be upgraded for corresponding to the target partition in the upgrade package;If it is not, processing Device 500 is also used to control the mirror image sequential update to be upgraded that the upgrade package is included and corresponds to mirror image in partition holding.
Due to storing upgrade package in target partition, in order to upgrade successfully, whether target point is included for upgrade package Mirror image to be upgraded corresponding to area is judged, if upgrade package includes mirror image to be upgraded corresponding to target partition, is needed Adjust the sequence of image upgrade to be upgraded;If upgrade package does not include mirror image to be upgraded corresponding to target partition, can root The mirror image to be upgraded sequence for being included according to control upgrade package upgrades the mirror image in corresponding partition holding.
Above-mentioned terminal can save the space of air upgrading in upgrading: only need to reserve a backup Area-Specific Archive file system System and the traditional full packet of a very small partitioned storage configuration parameter relative contrast upgrade, and can eliminate recovery mould Formula, the boot and file system for saving recovery mode are taken up space, and storage upgrade package and progress power down protection Space.In addition, above-mentioned terminal in upgrading can power down preventing lose and the deficiency of the damage that leads to system: module is all based on mirror image Upgrading mode, be also conducive to save upgrading time;When terminal power down, can be executed according to the state parameter of configuration subregion Corresponding operation, the subregion as where will back up the Backup and Restore to original file system of partitioned storage, is conducive to avoid because of power down And the deficiency for causing system that can not start.In addition, above-mentioned terminal it is scalable multiple modules it is more: traditional upgrade method be Recovery mode carries out, and can not upgrade to modules such as power resources management module, security modules, because if several to this A module upgrade, after abnormal power-down, just can not normal boot-strap be re-introduced into recovery mode and upgraded, and the application Power resources management module, security module can then be upgraded, be conducive to the convenience for improving system upgrade.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment Point, reference can be made to the related descriptions of other embodiments.
The embodiment of the present invention has been described in detail above, specific case used herein to the principle of the present invention and Embodiment is expounded, and the above description of the embodiment is only used to help understand the method for the present invention and its core ideas; At the same time, for those skilled in the art can in specific embodiments and applications according to the thought of the present invention There is change place, in conclusion the contents of this specification are not to be construed as limiting the invention.

Claims (10)

1. a kind of firmware upgrade method, it is applied to terminal, which is characterized in that the firmware upgrade method includes:
Determine the upgrade package target partition to be stored;
The backup operation for executing the file system that the target partition is stored, by the mirror back-up of the file system to standby Part subregion;
The state parameter of configuration partitioned storage is obtained when the terminal executes reboot operation;
If the state parameter of the configuration subregion is downloading completion status, the parsing for being located at the upgrade package of the target partition is executed Operation, obtains the mirror image to be upgraded that the upgrade package is included;
Judge in the mirror image to be upgraded whether include the target partition mirror image;
If so, controlling institute when the mirror image to be upgraded for being included according to the upgrade package updates the mirror image in corresponding partition holding It states in the mirror image final updating to the target partition for corresponding to the target partition in upgrade package.
2. firmware upgrade method as described in claim 1, which is characterized in that described to judge whether wrap in the mirror image to be upgraded After mirror image containing the target partition, further includes:
When not including the mirror image of the target partition in the mirror image to be upgraded, control that the upgrade package included is to be upgraded Mirror image sequential update corresponds to the mirror image in partition holding.
3. firmware upgrade method as described in claim 1, which is characterized in that the backup subregion is located at file system module institute The first partition holding or air protocol module where the second partition holding, described first deposited when the backup subregion is located at When storing up subregion, determine that the target partition is first partition holding;When the backup subregion is located at second storage point Qu Shi determines that the target partition is second partition holding.
4. firmware upgrade method as described in claim 1, which is characterized in that the state parameter for obtaining configuration partitioned storage Later, further includes:
If the state parameter of the configuration subregion is triggering upgrade status, the file system of target partition described in carry is read-only shape State;
Detection distal end whether there is the upgrade package;
If so, the state parameter of the setting configuration subregion is downloading beginning state, the upgrade package is downloaded to the target point In area, wherein the upgrade package is stored since the first page of the target partition;
If it is not, the state parameter of the setting configuration subregion is removing state.
5. firmware upgrade method as claimed in claim 4, which is characterized in that the control target partition is in read-only shape After state, comprising:
It judges whether there is except the other applications of downloading upgrade package application program carry out write operation to the target partition;
If so, the control other applications except downloading upgrade package application program exit.
6. firmware upgrade method as claimed in claim 4, which is characterized in that the downloading upgrade package to the target point After in area, further includes:
Execute the verification operation of the upgrade package, comprising:
Obtain the header information that the upgrade package is included;
The verification operation of each mirror image to be upgraded in the upgrade package is executed, to obtain the comparison verification of each mirror image to be upgraded Value;
Judge whether there is stored in the comparison check value and the header information of at least one mirror image to be upgraded it is corresponding to be upgraded The reference check value of mirror image is not identical;
If it is not, the state parameter of the setting configuration subregion is downloading completion status;
If so, controlling the terminal executes reboot operation.
7. the firmware upgrade method as described in any one of claim 1 to 6, which is characterized in that the acquisition configures subregion After the state parameter of storage, further includes:
If the state parameter of the configuration subregion is downloading beginning state, the file system of the backup partitioned storage storage is controlled The target partition is written in the backup of mirror image, and the state parameter that the configuration subregion is arranged is removing state.
8. the firmware upgrade method as described in any one of claim 1 to 6, which is characterized in that the control upgrading It is corresponded in packet in the mirror image final updating to the target partition of the file system, comprising:
If the state parameter of the configuration subregion is downloading completion status, the upgrade package is included the file system by control Mirror image is updated to the backup subregion, and the state parameter of the configuration subregion is arranged as upgrading completion status.
9. firmware upgrade method as claimed in claim 8, which is characterized in that the upgrade package is included the text by the control The mirror image of part system is updated to after the backup subregion, further includes:
Control the mirror image update target partition that the backup partitioned storage stores up the target partition;
The state parameter that the configuration subregion is arranged is removing state.
10. a kind of terminal, including processor and memory, which is characterized in that be stored with computer instruction, institute in the memory It states when computer instruction is executed by the processor and realizes firmware upgrade method as in one of claimed in any 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 true CN109634645A (en) 2019-04-16
CN109634645B 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)

Cited By (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
CN110780890A (en) * 2019-10-24 2020-02-11 百度在线网络技术(北京)有限公司 System upgrading method and device, electronic equipment and medium
CN111045712A (en) * 2019-12-17 2020-04-21 杭州涂鸦信息技术有限公司 Single system upgrading method and system with backup function
CN111427718A (en) * 2019-12-10 2020-07-17 杭州海康威视数字技术股份有限公司 File backup method, recovery method and device
CN111522566A (en) * 2020-04-23 2020-08-11 Oppo(重庆)智能科技有限公司 System upgrading method, terminal and storage medium
CN111694589A (en) * 2020-06-15 2020-09-22 Oppo(重庆)智能科技有限公司 Upgrade package generation method and 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
CN111857777A (en) * 2020-07-16 2020-10-30 南方电网数字电网研究院有限公司 System updating method and device based on double-core intelligent electric meter and computer equipment
CN112148337A (en) * 2020-09-09 2020-12-29 杭州涂鸦信息技术有限公司 Firmware upgrading method and device
CN112860291A (en) * 2021-02-08 2021-05-28 杭州涂鸦信息技术有限公司 Firmware upgrading method and device
CN113225729A (en) * 2020-01-21 2021-08-06 荣耀终端有限公司 OTA (over the air) upgrading method and device and readable storage medium
WO2022111097A1 (en) * 2020-11-26 2022-06-02 北京沃东天骏信息技术有限公司 File update method and apparatus, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060155669A1 (en) * 2005-01-10 2006-07-13 Cyberlink Corp. System and method for providing access to computer files across computer operating systems
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

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060155669A1 (en) * 2005-01-10 2006-07-13 Cyberlink Corp. System and method for providing access to computer files across computer operating systems
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

Cited By (17)

* 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
CN110780890A (en) * 2019-10-24 2020-02-11 百度在线网络技术(北京)有限公司 System upgrading method and device, electronic equipment and medium
CN111427718A (en) * 2019-12-10 2020-07-17 杭州海康威视数字技术股份有限公司 File backup method, recovery method and device
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
CN113225729A (en) * 2020-01-21 2021-08-06 荣耀终端有限公司 OTA (over the air) upgrading method and device and readable storage medium
CN113225729B (en) * 2020-01-21 2022-07-12 荣耀终端有限公司 OTA (over the air) upgrading method and device and readable storage medium
CN111522566A (en) * 2020-04-23 2020-08-11 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
CN111694589A (en) * 2020-06-15 2020-09-22 Oppo(重庆)智能科技有限公司 Upgrade package generation method and 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
CN111857777A (en) * 2020-07-16 2020-10-30 南方电网数字电网研究院有限公司 System updating method and device based on double-core intelligent electric meter and computer 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
WO2022111097A1 (en) * 2020-11-26 2022-06-02 北京沃东天骏信息技术有限公司 File update method and apparatus, device and storage medium
CN112860291A (en) * 2021-02-08 2021-05-28 杭州涂鸦信息技术有限公司 Firmware upgrading method and device
CN112860291B (en) * 2021-02-08 2023-05-12 杭州涂鸦信息技术有限公司 Firmware upgrading method and device

Also Published As

Publication number Publication date
CN109634645B (en) 2022-03-22

Similar Documents

Publication Publication Date Title
CN109634645A (en) Firmware upgrade method and terminal
US8423991B2 (en) Embedded network device and firmware upgrading method
CN104572229B (en) The firmware upgrade method and device for upgrading firmware of embedded system
CN103207797B (en) Capsule type custom-made updating method based on unified extensible firmware interface firmware system
CN110134426A (en) A kind of embedded system upgrade method, device and terminal device
CN104025047B (en) Information processor, information processing method and computer program
US20110283274A1 (en) Firmware image update and management
US20140310698A1 (en) Apparatus and method for upgrading firmware of mobile terminal
EP1591893A1 (en) Method and system for fail-safe updating of boot code
CN101188516B (en) A highly reliable and self-adapted remote update method for network device software system
CN101650662A (en) Memory device of embedded system and staring method and upgrading of firmware
CN103299276A (en) Software updating process for an embedded device
CN109032632A (en) A kind of FOTA upgrade method, wireless communication terminal and storage medium
CN112631625B (en) System upgrading method and device for embedded equipment and embedded equipment
CN104915226A (en) Network device software starting method, device and network device
CN111045712A (en) Single system upgrading method and system with backup function
US20140258699A1 (en) Boot fault tolerant device and method thereof
CN103455750B (en) The high peace verification method of a kind of embedded device and device
CN114780019A (en) Electronic device management method and device, electronic device and storage medium
CN107066361A (en) The method and apparatus that a kind of utilization BMC disables corrupted internal memory
CN113238790B (en) Firmware program updating method and system based on SD card and EEPROM
CN105825126A (en) File protecting method and device
CN106959906A (en) Information processing method, information processor and electronic equipment
CN110458989A (en) Support the intelligent lock system of masterslave switchover and the starting method of masterslave switchover
CN106933604A (en) A kind of method for upgrading system and device

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