Background technology
The composition of embedded device is based on embedded processing chip, coordinates relevant supporting hardware and application program,
A software and hardware is collectively constituted in the equipment that can work independently of one.It is set compared to mobile phone or the contour intelligence of tablet computer
Standby, so-called embedded device is often more simple miniaturized electronics, does not have high intelligent operating system, but still may be used
To realize many utility functions by built-in application program.For example, heart rate band/pulsometer or similar small-sized wearable electricity
Sub- equipment, belongs to embedded device.
The upgrading of application program in embedded device needs to download using starter (bootloader) triggering in system
Flow, make system start download application program firmware upgrade packet.In addition in some cases, starter is also required to down in itself
Update is carried, but starter is typically maintained in the flash memory of embedded chip, belongs to a part for system, once it wipes in a flash memory
System can collapse;So conventional system is difficult to complete the update replacement of itself.
Some existing embedded devices, select starter being stored in RAM, are avoided wiping during starting and upgrading device
Except the components of system as directed in flash memory, lead to the situation of system crash;The update for enabling the system to complete starter is replaced.But this
The defects of kind scheme, is that, once equipment accident power down in starter escalation process, will cause starter to be lost, system is again
Starter is lost after the power is turned on, can equally cause to collapse.Namely there are huge risks for the upgrading of starter.
Other existing embedded devices are by the way of double starters are set.Accordingly even when in escalation process one open
Dynamic device is lost, another spare starter can still maintain system operation, and safety is higher.But this scheme is scarce
It is that double starters cause system excessively complicated, and the upgrading frequency of starter is extremely low to fall into, and setting double starters cause system not
It obtains and does not have unnecessary redundancy.
It can be seen that the defects of prior art, is, and it can not be under the premise of system complexity not be increased, stable realization starts
Device upgrades, and is not influenced by power down.It in the prior art can be simple and direct and safe there is no the system of embedded device
Realize the upgrading of starter.
Invention content
In view of this, the purpose of the present invention is to provide a kind of firmware upgrade method of embedded device and embedded systems
System, by reconfiguring the overall structure of embedded system, so as to upgrading that is simple and direct and securely achieving starter.
To achieve the above object, there is following technical solution:
A kind of firmware upgrade method of embedded device, the method includes:
The start bit that powers on of self-embedding formula chip flash memory marks off trigger region;Starter is decomposed into trigger and download
The trigger is saved in the trigger region by device;
Erasable independently of one another download area and application area are marked off from embedded chip flash memory;The downloader is preserved
To download area;Application program is preserved to the application area, and guiding device is preserved in the application area;
When there is the download instruction for application area, then the downloader update application that trigger is triggered in the download area is solid
Part;When there is the download instruction for download area, then the trigger triggers the guiding device update downloader in the application area
Firmware.
Download area erasable independently of one another is marked off in the flash memory from embedded chip and application area is specially:
The firstth area is marked off from embedded chip flash memory as download area, and the address range of the download area is sent
To trigger;
The secondth area is marked off from embedded chip flash memory as application area, and the address range of the application area is sent
To trigger.
The downloader that the trigger is triggered in the download area updates application firmware:
Trigger calls the downloader from the address range of the download area, and enables the downloader according to application area
Download instruction, carry out the download of application firmware.
The guiding device that the trigger is triggered in the application area updates downloader firmware:
Trigger calls the guiding device from the address range of the application area, and enables the guiding device according to download area
Download instruction, be downloaded the download of device firmware.
The method further includes:
Third area is marked off from embedded chip flash memory as driving area, and the address range in the driving area is sent
To trigger;Driver is preserved to the driving area;
When there is the download instruction for driving area, trigger calls the download from the address range of the download area
Device, and the downloader is enabled to be driven the download of firmware according to the download instruction in driving area.
A kind of embedded system, the system are specially:
Trigger region is marked off in the start bit that powers on of embedded chip flash memory;Starter is decomposed into trigger and download
The trigger is saved in the trigger region by device;Download erasable independently of one another is marked off from embedded chip flash memory
Area and application area;The downloader is preserved to download area;Application program is preserved to the application area, and in the application area
Middle preservation guiding device;
The trigger is used for, and when there is the download instruction for application area, triggers the downloader in the download area
Update application firmware;Or when there is the download instruction for download area, the guiding device triggered in the application area is more newly downloaded
Device firmware.
The system also includes:
Division module marks off trigger region for the start bit that powers in embedded chip flash memory;From embedded chip
The firstth area is marked off in flash memory as download area, and the address range of the download area is sent to trigger;From embedded core
The secondth area is marked off in piece flash memory as application area, and the address range of the application area is sent to trigger.
The downloader that the trigger is triggered in the download area updates application firmware:
Trigger calls the downloader from the address range of the download area, and enables the downloader according to application area
Download instruction, carry out the download of application firmware.
The guiding device that the trigger is triggered in the application area updates downloader firmware:
Trigger calls the guiding device from the address range of the application area, and enables the guiding device according to download area
Download instruction, be downloaded the download of device firmware.
The division module is additionally operable to:
Third area is marked off from embedded chip flash memory as driving area, and the address range in the driving area is sent
To trigger;Driver is preserved to the driving area;
Then the trigger is additionally operable to, when there is the download instruction for driving area, the address model from the download area
The middle calling downloader is enclosed, and the downloader is enabled to be driven the download of firmware according to the download instruction in driving area.
As seen through the above technical solutions, advantageous effect existing for the present invention is:By rebuilding system, by trigger
It is stored in the trigger region for powering on start bit, avoids the generation of system crash, and do not increase the complexity of system;It is independent
Erasable download area and application area can realize that phase mutual designation downloads more new procedures, realize stable application program update and download
Device updates.
Specific embodiment
Purpose, technical scheme and advantage to make the embodiment of the present invention are clearer, below in conjunction with the embodiment of the present invention
In attached drawing, the technical solution in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
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
All other embodiments obtained without making creative work shall fall within the protection scope of the present invention.
To realize the starter upgrading of safety and stability in embedded device, prevent the favorite outer power down of escalation process from leading to system
Collapse, and the complexity of not additional increase system;The structure of embedded system has been carried out again in the present embodiment
Design and construction.It is shown in Figure 1, it is the specific embodiment of embedded system described in the embodiment of the present invention.In the present embodiment
The system concrete structure is as described below:
First, the starter (bootloader) is split as trigger (boot) and downloader in the present embodiment
(loader) two parts.The starter is originally used for the flow that triggering is downloaded, and system is made to start to download the firmware of application program
Upgrade package;And after splitting, the trigger will be used for triggering download flow and start, the process that downloader is then downloaded for guiding.
Simultaneously triggering will be marked off in the present embodiment using the start bit that powers on of division module self-embedding formula chip flash memory
The trigger is saved in the trigger region by area.It is described to power on start bit, it is exactly to be first begin to transport after flash memory re-powers
Capable storage location.In the present embodiment since being powered on start bit, continuous several memory spaces are taken as trigger region, it is described to touch
The size of trigger should be not less than by sending out the size in area;And the trigger region is independently erasable, it ensure that preserved in trigger region
Trigger will not be wiped free of when flash memory other content updates.
Because the trigger is the starting point for system operation, the upgrading flow of system operation and firmware is by trigger
Triggering is opened, once so trigger is wiped free of in flash memory, system can collapse.This is also in the prior art, various to cause
Where the main reason for system crash situation.And in general starter escalation process, mainly under in starter
It carries device to be upgraded, trigger does not often change in itself.
So in the present embodiment, starter is split, and being stored in the trigger independence in trigger region, produced
There are two raw influences:First, trigger is stored in an independent trigger region, it ensure that trigger is not deleted accidentally, make to touch
The safety of hair device is protected, and is not influenced by other any flash memory wiping/writing operations;Second is that trigger region, which is located at, powers on start bit,
Once so system electrification, trigger can be just performed automatically, without come the position of querying triggering device, being made by other programs
The execution for obtaining trigger is not limited by other programs.
So, any erasable operation no matter is performed in flash memory or unexpected power down occurs leads to losing for any program
It loses, trigger is safe always to be stored in trigger region, can be effectively executed once re-powering.Pass through in the present embodiment
The risk of system crash has been evaded in above-mentioned design.
Then, it will also be marked off from embedded chip flash memory using division module in the present embodiment erasable independently of one another
Download area and application area.Another part of the starter --- downloader is stored in the download area;And in system
Application program is by early there are in application area.The download area and application area are also erasable independently of one another.
Since download area and application area have the characteristics of erasable independently of one another, so can be with using the downloader in download area
The application program in application area is downloaded in guiding, completes the erasable and program update of content in application area;This point is essentially identical to
The principle of application firmware upgrading in the prior art.
, whereas if one guiding device of preservation additional in the application area, can also realize and draw described in utilization simultaneously
The downloader in the device guiding download download area is led, completes the erasable and program update of content in download area.
In the present embodiment, substantially traditional starter is integrally upgraded, develops into the upgrading to downloader in starter.
And in the escalation process of the downloader, These characteristics can be utilized, the guiding device in application area is called to complete downloader
Upgrading.This is also the principle that downloader firmware upgrade is realized in the present embodiment.
Specifically from realization method for, the division module in system marked off from embedded chip flash memory the firstth area work
For download area, and the address range of the download area is sent to trigger;The secondth area is marked off from embedded chip flash memory
Trigger is sent to as application area, and by the address range of the application area.So, trigger just specify it is described under
The specific address of area and the application area is carried, so as to be directly realized by for being guided in downloader in download area or application area
The calling of device.
In addition, in the present embodiment other than marking off download area and application area in a flash memory, acceptable additional division
Go out a driving area, for preserving various drivers.The driving area is non-with the effect of application area in overall technical architecture
It is often similar.Third area is marked off from embedded chip flash memory namely by the use of division module as driving area, and by the drive
The address range in dynamic area is sent to trigger;Driver is preserved to the driving area.
Rebuilding for the system is realized in the present embodiment as a result, that is, marks off four erasable areas of independence
Domain, trigger region, which is located at, powers on start bit, for preserving trigger, prevents system crash;Download area, application area and the ground for driving area
Location range is sent in trigger;Downloader is preserved in download area, can be guided and be completed application area and drive area's Program
Download update;Otherwise guiding device can also be preserved in application area or driving area, downloader in completion download area that can be reversed
Program update.
As seen through the above technical solutions, advantageous effect is existing for system described in the present embodiment:By rebuilding
Trigger is stored in the trigger region for powering on start bit by system, avoids the generation of system crash, and does not increase system
Complexity;Independent erasable download area and application area can realize that phase mutual designation downloads more new procedures, realize stable application
Program updates and downloader update.
Based on system described in above example, subsequent embodiment will be described specifically in above system, specific implementation
The method flow of firmware upgrade.
It is shown in Figure 2, it is the specific embodiment of firmware upgrade method of the present invention, is realized based on above system
The tool flow of both application program and downloader firmware upgrade.So weight is no longer carried out in the present embodiment to the structure of the system
Multiple description.Method described in the present embodiment includes the following steps:
Step 201, system electrification, startup trigger.
Since what the trigger region was located at flash memory powers on start bit, so after system electrification, it is stored in and powers on start bit
Trigger is read at once, and then is started automatically.Trigger after startup can receive the instruction from system.
Step 202 judges whether downloader is normal, and generation is for the download instruction of download area if downloader is abnormal.
The startup of trigger ensure that the normal operation of system, the collapse of the system avoided.But to ensure that system is normal
Function it is perfect, it is also necessary to ensure that exception does not occur in downloader.So after flip-flop toggle, need first whether judge downloader
Normally.
If downloader occurs abnormal either loss because of situations such as the favorite outer power down of previous escalation process or downloads
Device needs to carry out firmware upgrade update, then must re-download the downloader of right version first.To realize that right version is downloaded
The download of device will generate a download instruction for being directed to download area in system.
Otherwise if downloader is normal, is directly entered step 204.
Step 203, trigger call the guiding device from the address range of the application area, and enable the guiding device root
According to the download instruction of download area, it is downloaded the download of device firmware.
In the present embodiment, since download area is with erasable applied to independence, so the abnormal conditions in download area have no effect on
The normal operation of application area.So downloading for downloader can guide completion with the guiding device of application area.Occur for download area
After download instruction, trigger just calls the guiding device from the address range of the application area, to be directed under download area
Carry the download that instruction controls the guiding device to be downloaded device firmware.
Downloader firmware after download is saved in again in the download area, and the downloader restores normal.
Step 204, when there is the download instruction for application area, trigger calls from the address range of the download area
The downloader.
After downloader is normal, application program can be read in system, and embedded device is made to realize corresponding function.And it is answered described
In the case of needing firmware upgrade with program, system can also generate a download instruction for being directed to application area, and journey is applied to open
The firmware upgrade process of sequence.
At this point, trigger calls the downloader from the address range of the download area, using under download area
The download that instruction controls the downloader to carry out application firmware is carried, and then completes the update of application program.
Step 205, when there is the download instruction for driving area, trigger calls from the address range of the download area
The downloader, and the downloader is enabled to be driven the download of firmware according to the download instruction in driving area.
In the present embodiment, the update for driver in driving area can be similarly realized.
As seen through the above technical solutions, advantageous effect existing for the present embodiment is:It specifically describes independent erasable
Download area and application area realize that phase mutual designation downloads the process of more new procedures so that overall technical architecture of the present invention is more complete,
It is open more abundant.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications also should
It is considered as protection scope of the present invention.