Background technology
At present, in upgrade method to programmable logic device (PLD), because the inside of programmable logic device (PLD) has only a workspace, system's cisco unity malfunction when upgrading, system can not be used for upgrading again when work, that is to say that system does not support programmable logic device (PLD) can upgrade again in work.In addition, particularly in escalation process, if unexpected power down of system or cpu i/f occur when unusual, after re-powering or reset etc. system, system can not proceed upgrading, because in the time of system's power down, programmable logic device (PLD) can not be preserved the process of upgrading in real time, thereby can not be in the follow-up level of continuing rising that powers on.
And in the system applies of non-volatile programmable logical device (PLD, Programmable Logic Device), non-volatile PLD controls the resetting of CPU, Bootrom chip selection signal etc. by output pin, thereby influence starts the reset signal of CPU.In power down in this case, non-volatile PLD these signal of interests in escalation process are in unsettled " three-state ", may cause CPU to handle is interrupted, therefore this situation is not suitable for non-volatile PLD logic by the CPU on-line software updating, can only use specific purpose tool that non-volatile PLD is carried out field upgrade by the slip-stick artist, safeguard inconvenience thereby cause.
Please refer to Fig. 1, in the prior art non-volatile programmable logical device being carried out the synoptic diagram of the method for online upgrading.Its implementation procedure is:
In non-volatile PLD escalation process, in order not influence the PLD output pin state of control CPU key signal, increase the control circuit 13 that band presets ' 0 ', ' 1 ' function and keeps function in loaded circuit 12 back of non-volatile PLD11 in advance, as shown in Figure 1, non-volatile PLD pin output signal is controlled by four control signals, be respectively: 1) preset ' 0 ' control signal, if be provided with then PLD pin output signal is ' 0 '; 2) preset ' 1 ' control signal, if be provided with then PLD pin output signal is ' 1 '; 3) retentive control signal is if be provided with then PLD pin output remains the level before loading; 4) control signal of combined testing action group (JTAG, Joint Test ActionGroup), by jtag instruction control the PLD pin be output as ' 0 ', ' 1 ' or high resistant.
When the above control signal was not provided with, PLD pin output signal was just exported the PLD internal output enable signal.If in described control signal, preset ' 0 ' control signal, preset ' 1 ' control signal, the retentive control signal all is to generate the file destination that can move by the special-purpose programmed environment of non-volatile PLD to choose in advance, the deviser can select any setting according to the design needs.JTAG control is the control signal that jtag instruction produces, and JTAG is a kind of boundary scan technique that meets the IEEE1149.1 standard.
By said method as can be known, along with non-volatile PLD uses widely, though releasing some non-volatile PLD output pin support, each producer keeps function, state before promptly pin keeps loading in non-volatile PLD logic online upgrading process, owing to can not have influence on the state of the CPU key signal of PLD output pin control, therefore can guarantee the online upgrading success.Though but described method can not cause cpu reset because of the cpu reset signal instability can avoid CPU that non-volatile PLD is carried out online upgrading the time.This has increased the reliability of online upgrading to a certain extent.But, for in described non-volatile PLD escalation process, if cause upgrading to be interrupted because factor such as unusual appears in system's power down or cpu i/f, then re-power or watchdog reset after non-volatile PLD owing to do not load complete code and can not revert to original logical code, and cause CPU to crash.
Therefore, the shortcoming of prior art is: in the process of CPU to non-volatile PLD online upgrading, owing to have only a workspace among the non-volatile PLD, can not work when upgrading, and can not upgrade when work.When the unexpected power down of system or cpu i/f occur when unusual, non-volatile PLD can't operate as normal owing to do not load fully, then re-powering the back system can be because non-volatile PLD work be undesired and irrecoverable, thereby can not guarantee that the non-volatile programmable logic transfers electricity or cpu i/f the normal upgrading in back to occur re-powering when unusual in system.
Summary of the invention
The technical matters that the present invention solves provides a kind of method and device to the upgrading of non-volatile programmable logic device on-line, to solve in to non-volatile PLD online upgrading process, because system's power down or cpu i/f occur when unusual, re-power the back or problem that the back non-volatile programmable logical device that resets again can not be upgraded normally.
The present invention has also solved in the process of non-volatile PLD upgrading, owing to increased the watchdog circuit that directly links to each other with system processor CPU, system is directly resetted, thereby can not influence the state of system processor cpu bus by the OE control end/key signals such as DIR control end of the bus buffer between non-volatile PLD and the BOOTROM.
For addressing the above problem, the invention provides and a kind of the non-volatile programmable logical device is carried out the method for online upgrading, be used for processor the non-volatile programmable logical device is carried out online upgrading, comprise step:
A, the inner structure of non-volatile programmable logical device is divided into backup area, workspace and flag at least;
B, fresh code is loaded into backup area, judges whether described loading procedure is finished,, and copy described fresh code to workspace if then flag is set to current up-to-date code at backup area;
C, judge whether described copy procedure is finished, if then described flag is set to current up-to-date code in the workspace, and the operation fresh code, finish online upgrading.
When the non-volatile programmable logical device occurs in loading procedure when unusual, after then system re-powers or resets, judge whether the flag of non-volatile programmable logical device is set to current up-to-date code in the workspace, if, illustrate that then the workspace normally moves, restart loading procedure.
When the non-volatile programmable logical device occurs in copy procedure when unusual, after then system re-powers, whether the flag of judging the non-volatile programmable logical device is set to current up-to-date code at backup area, if, illustrate that then the workspace is damaged, restart copy procedure, be set to current fresh code in the workspace until flag, and the fresh code of operation workspace, finish online upgrading.
Described system reset utilizes reset circuit, and this reset circuit comprises a watchdog circuit at least, and described watchdog circuit links to each other with processor, is used for directly to system reset.
Described processor has the memory interface of synchronous random access memory, synchronous DRAM or Double Data transmitting synchronous dynamic RAM.
In addition, the present invention also provides a kind of programmable logic device (PLD) is carried out the device of online upgrading, comprises processor and non-volatile programmable logical device, and described non-volatile programmable logical device comprises at least:
Two kinds of storage unit, wherein a kind of storage unit is as the working cell, by the current operation code of processor or non-volatile programmable logical device operation, have at least one to be designated as the software upgrading code that is used to store loading when the software upgrading in the another kind of storage unit as backup units; The software upgrading code is copied in the described working cell after loading;
Judging unit links to each other respectively with two kinds of storage unit, is used to judge whether the loading of software upgrading code and copy procedure are finished;
The flag unit links to each other with judging unit, is used for identifying the run location of the described software upgrading code that non-volatile programmable logic device on-line escalation process downloads.
Described device also comprises reset circuit, and described reset circuit links to each other with processor, is used for occurring making system reset when unusual when system.
Described reset circuit is a watchdog circuit.
Described processor has the memory interface of synchronous random access memory, synchronous DRAM or Double Data transmitting synchronous dynamic RAM.
Compared with prior art, the present invention has following beneficial effect: the present invention is divided into the workspace, backs up and go and flag by the loading zone with the non-volatile programmable logical device, be loaded in the backup area by fresh code upgrading, copy in the workspace at fresh code then, realize the implementation method of the high reliability of online upgrading backup area.The present invention combines the various situations that may run in the online upgrading process, and such as in loading or copy procedure, unexpected power down of system or cpu i/f occur unusual, thereby causes the online upgrading failure, has proposed to the property of the present invention is directed to solution.With guarantee the unexpected power down of system or cpu i/f occur system when unusual power on or reset after can continue the process of online upgrading.The present invention has simultaneously also proposed different solutions at different abnormal conditions, thereby online upgrading is realized high reliability.
Embodiment
Core of the present invention is that the loading zone with non-volatile programmable logical device (PLD, Programmable LogicDevice) is divided into two spaces, and one is backup area, and one is workspace and flag.Worked by the workspace code in the workspace of described non-volatile PLD, backup area is used for loading new code.Behind the new code loaded of backup area, flag is set to current fresh code at backup area, and, non-volatile PLD copies the fresh code that loads to workspace from backup area automatically, when copy is finished, described flag is set to current fresh code in the workspace, and the fresh code of operation workspace.So just finished the online upgrading of workspace code.But, when appearance in the escalation process at non-volatile PLD is unusual (system's power down or cpu i/f occur unusual), re-power or system reset after, judge that by flag current fresh code is in the workspace or at backup area, if current fresh code is in the workspace, then restart the loading procedure of fresh code, if current fresh code is at backup area, then the code of workspace is damaged, copy procedure is not activated, and non-volatile PLD just restarts copy procedure, is set to current fresh code in the workspace until flag, and the fresh code of workspace moved, promptly finish online upgrading.
Among the present invention, the process that fresh code is loaded into backup area calls loading procedure, and fresh code is called copy procedure from the process that backup area copies the workspace to.No matter be loading procedure or copy procedure, before start-up loading or copy procedure, all can dispose original old code.
Below in conjunction with accompanying drawing, the present invention is described further.
Please refer to Fig. 2, programmable logic device (PLD) is carried out the process flow diagram of the method for online upgrading for the present invention; Processor carries out online upgrading to FPGA (Field Programmable Gate Array) in described method, comprises step:
Step S10: the inner structure in the programmable logic device (PLD) is divided into backup area, workspace and flag at least;
Step S11: processor is loaded into backup area with fresh code;
Step S12: judge whether described loading procedure is finished;
Step S13: if then described flag is set to current up-to-date code at backup area, and the fresh code that backup area is loaded copies the workspace to;
Step S14: otherwise loading is interrupted, and system occurs unusual, is system power-up or system reset again, judges whether described flag is set to current fresh code in the workspace;
Step S15: if, illustrating that then the workspace normally moves, execution in step S11 promptly restarts loading procedure;
Step S16: judge whether described copy procedure is finished;
Step S17:, and, finish online upgrading at workspace operation fresh code if then described flag is set to current up-to-date code in the workspace;
Step S18: otherwise, be system power-up or system reset again, judge whether described flag is set to current up-to-date code at backup area;
Step S19: if, illustrating that then the workspace is damaged, execution in step S13 promptly restarts copy procedure, is set to current fresh code in the workspace until flag, and the fresh code of operation workspace, finishes online upgrading.
The method of the invention is applied in the online upgrade system of CPU to the non-volatile programmable logical device, solved that the non-volatile programmable logical device re-powers or the watchdog circuit expendable defective of back logic that resets appears when unusual in cpu i/f after the power down of when upgrading, thereby proposed the non-volatile programmable logical device is divided into three parts, i.e. backup area, workspace and flag.That is to say that the present invention increases backup area and two spaces of zone bit on existing P LD inner structure, the workspace is consistent with existing P LD internal work district, and backup area and zone bit all are at the inner storer that increases of PLD.By increasing the inner corresponding logical process of backup area and zone bit and PLD, can realize the PLD remote online upgrade function of high reliability.The workspace of described non-volatile PLD is to be worked by the workspace code, is used to move current operation code or program; Described backup area is to be used for loading new code.Behind the fresh code loaded of backup area, non-volatile PLD copies the fresh code that loads to workspace from backup area automatically, and the code of operation workspace, has so just finished the upgrading of workspace code.
In the present invention, the process that fresh code is loaded into backup area calls loading procedure, and code is called copy procedure from the process that backup area copies the workspace to.No matter be loading procedure or copy procedure, before start-up loading or copy procedure, all can dispose original old code.But, the present invention is in the online upgrading process to the non-volatile programmable logical device, if it is unusual, described system's power down or the cpu i/f of being generally unusually occurs unusual, unusual in order to handle, usually after resetting by system power-up or startup watchdog circuit, judge by the zone bit that uses in the non-volatile programmable logical device again to power on or the back current working state that resets that described flag is used to indicate current up-to-date code at backup area " still be " current up-to-date code is in the workspace ".Described flag is at least 1bit, but is not limited to 1bit, can be provided with according to actual needs.After system occurs re-powering when unusual or resets, if flag indicates current up-to-date code at backup area, illustrate that then fresh code has been loaded into backup area fully, and the code of described workspace is because power down or cpu i/f are unusual etc. is damaged, and copy procedure is not activated, then, copy procedure resets automatically in the inside of non-volatile programmable logical device, indicate current up-to-date code in the workspace until zone bit, and the operation operation code, upgrading finished.Its concrete implementation procedure is as described below.
If in the online upgrading process of CPU to the non-volatile programmable logical device, occur in the unusual absence, the implementation procedure of the method for the invention is:
After non-volatile PLD online upgrading starts, at first carry out the loading procedure (referring to that CPU downloads to backup area to fresh code) of online upgrading, behind the loaded, zone bit is set to " current up-to-date code is at backup area ", and startup copies the fresh code of backup area to the copy procedure of workspace, after copy finished, described flag was set to " current up-to-date code is in the workspace ".This is that CPU is to the online upgrading process of non-volatile PLD under normal situation.The code operation of workspace is unaffected in the described loading procedure that fresh code is loaded into backup area, because two different processes when downloading the code operation of fresh code and workspace; Equally, in the process of copy fresh code, the original code in workspace is eliminated, and the PLD pin is in " high-impedance state " at this moment.But in actual applications, tend to break down in the process of online upgrading, situations such as unusual appear such as system's power down or cpu i/f, this unusual condition generally appear at fresh code be loaded into occur in the process of backup area unusual, or the fresh code that backup is gone is copied to occur in the work of workspace unusual, at this unusual condition, the present invention proposes following solution.
In the online upgrading process of CPU to non-volatile PLD, if in loading procedure if interrupt, then enter the first abnormality processing flow process; Unusually then enter the second abnormality processing flow process if in copy procedure, occur.Below the treatment scheme of these two kinds of abnormal conditions will be described respectively:
The described first abnormality processing flow process: the loading procedure of upgrading when the non-volatile programmable logic device on-line (described is that the appearance of system's power down or cpu i/f is unusual unusually) occur unusually and causes loading to proceed, and then loading can't be finished.This moment, zone bit still was set to " current up-to-date code is in the workspace ", illustrated that the workspace still can operate as normal.When (described unusual releasing re-powers after being meant power down or the unusual back startup watchdog circuit of cpu i/f makes system reset) after the unusual releasing,, illustrate that the workspace still can operate as normal because zone bit still is set to " current up-to-date code is in the workspace ".That is to say that the PLD workspace still can operate as normal, CPU can control the operate as normal of non-volatile PLD system normally.When CPU received the online upgrading order that remote upgrade initiation system sends, CPU restarted the upgrading order, completes successfully up to upgrading.
The described second abnormality processing flow process: when appearance unusual (described unusual may be system's power down) caused copy to proceed in the copy procedure of non-volatile programmable logic device on-line upgrading, then copy can't be finished.The zone bit of this moment still is set to " current up-to-date code is at backup area ", and the workspace is destroyed.When (described unusual releasing re-powers after being power down) after the unusual releasing, PLD internal judgment zone bit is set to " current up-to-date code is at backup area ", then, illustrate that fresh code has been loaded into backup area fully, non-volatile PLD can start copy procedure automatically, be set to " current up-to-date code is in the workspace " up to zone bit, but this moment is because the destroyed CPU in PLD workspace can't operate as normal.After copy was finished, the PLD workspace was working properly, and CPU is owing to watchdog reset operate as normal again.
What need explanation a bit is, unusual situation appearred in cpu i/f when the present invention may occur in the non-volatile programmable logic device on-line escalation process that for solving fresh code is loaded into backup area, the reset circuit that loads CPU must directly use watchdog circuit, and can not carry out conversion by the non-volatile programmable logical device of preparing to load.Otherwise occur in the loading procedure causing watchdog circuit inoperative unusually, system can't restart and crash.
More than be the implementation procedure of CPU of the present invention, comprise normal escalation process, and the solution process under the abnormal conditions in escalation process, occurs non-volatile PLD online upgrading method.Non-volatile programmable logic device on-line upgrade method of the present invention, be applied to the online upgrade system of CPU to the non-volatile programmable logical device, solved non-volatile programmable logic device on-line when upgrading owing to re-power after system's power down or cpu i/f causes the expendable defective of logic behind the watchdog reset unusually, thereby make re-power the back or system reset after, can proceed to the upgrading of non-volatile programmable logic device on-line, until finishing online upgrading.
In addition, the present invention also provides a kind of online upgrading device to programmable logic device (PLD), this schematic representation of apparatus as shown in Figure 3, described device comprises: comprise processor CPU21 and programmable logic device (PLD) 22, and described programmable logic device (PLD) 22 comprises at least:
Two kinds of storage unit, link to each other with processor respectively, wherein a kind of storage unit is as working cell 221, move current operation code by processor or programmable logic device (PLD), have one (or a plurality of storage unit) at least as redundant memory cell 222 in the another kind of storage unit, described redundant memory cell 222 is designated when software upgrading to be used for the software upgrading code that storage loads (download); Certainly, described redundant memory cell also can have a plurality of.But must guarantee will have a storage unit to be set to the work storage unit in that two kinds of storage unit kinds of described programmable logic device (PLD) are minimum, one is set to redundant memory cell.
Judging unit 223 links to each other respectively with two kinds of storage unit, is used to judge whether the loading of fresh code and copy procedure are finished;
Flag unit 224 links to each other respectively with judging unit with two kinds of storage unit, is used for identifying the run location that the device for on-line upgrading of programmable logic process is downloaded fresh code.
In conjunction with describing with reference to figure 4, described Fig. 4 is the structural representation of the most preferred embodiment of device of the present invention in the lump.Described device comprises: CPU21, programmable logic device (PLD) 22, synchronous DRAM SDRAM23, BOOTROM24, bus buffer (245) 25, watchdog circuit 26 and interface device 27.Described programmable logic device (PLD) 22 comprises at least: working cell 221, redundant memory cell 222, judging unit 223 and a flag unit 224.The annexation of described device is: CPU21 is electrically connected with working cell 221, watchdog circuit 26, synchronous DRAM SDRAM23, BOOTROM24, the bus buffer 25 of programmable logic device (PLD) 22 respectively, and BOOTROM24 is electrically connected with the working cell 221 of bus buffer 25, programmable logic device (PLD) 22 respectively.
It realizes that principle is: CPU is after receiving PLD upgrading order, start the PLD loading procedure, the loading clock and the loading data that show as PLD begin to transmit, the backup area that this moment, the PLD loading data all can be sent to PLD stores, the code of workspace is unaffected in loading procedure, and PLD is still by the leading operate as normal in workspace.After CPU loaded and finishes, the PLD internal condition loads the instruction of finishing and starts two work automatically: 1) PLD inner mark position was set to " being operated in backup area " automatically; 2) start copy work automatically, remove the former code of workspace earlier, then the fresh code of backup area is write the workspace.Wherein, 1) and 2) all be that the PLD internal logic is handled automatically, it is key content of the present invention that the PLD internal logic is handled.After PLD internal code copy is finished, activate the code of workspace automatically, this also is that the PLD internal logic is finished.But, usually in the process of upgrading, can occur unusual, such as, in the process that loads or copy, situations such as unusual appear in the unexpected power down of system or this cpu i/f, thereby influence the online upgrading of programmable logic device (PLD), therefore, the present invention also proposes at the solution that occurs in escalation process under the abnormal conditions, and it is as described below specifically to solve process:
Above-mentioned for the treatment scheme of the non-volatile PLD online upgrading of the present invention.The present invention is in the online upgrading device of high reliability, and the key signal that must guarantee to load the resetting of CPU, the choosing of Bootrom sheet can not be affected in escalation process, and as shown in Figure 4, the reset signal of CPU must directly be produced by watchdog circuit.The Bootrom chip selection signal then can produce by non-volatile PLD, but, in the process of this realization, also to increase some restrictive conditions, such as: when the non-volatile programmable logical device has been controlled the Bootrom sheet that loads CPU and is selected, require CPU to possess synchronous DRAM SDRAM under SRAM, the forms data transmission pattern or the memory interfaces such as synchronous DRAM DDR SDRAM under the Double Data transmission mode simultaneously, and externally on the circuit drawing on the Bootrom chip selection signal.And guarantee that the non-volatile programmable logical device is before upgrading, whole programs of Bootrom all copy in the internal memory, like this in escalation process, the Bootrom chip selection signal is drawn high, thereby can the cpu i/f that load not impacted, and because operation is program in the internal memory, the Bootrom chip selection signal all not have to influence no matter draw high or drag down.
Therefore, highly-reliable system design to the upgrading of non-volatile programmable logic device on-line of the present invention, be applied in the online upgrading method and apparatus of CPU to the non-volatile programmable logical device, solved non-volatile programmable logic device on-line when upgrading owing to re-power after the power down or because cpu i/f causes the expendable defective of logic behind the watchdog reset unusually.In addition, the present invention also provides a kind of external circuit to realize update device, does not influence the function of the OE control end/key signal states such as DIR control end of the bus buffer 245 between cpu bus and the Bootrom bus in the implementation procedure of this upgrading.
Implementation method to non-volatile programmable logic device on-line upgrading high reliability of the present invention combines the design proposal of the various situations of system in the online upgrading process, has proposed solution pointedly in the present invention program.Particularly consider the various possible abnormal conditions of system in the online upgrading process, in this invention scheme, proposed solution pointedly, thereby realize high reliability.
In addition, the backup area of described in the present invention non-volatile programmable logical device or redundant memory cell and workspace or working cell, described workspace or working cell have only one, and backup area or redundant memory cell can be designed to a plurality of zones as required.Equally, online upgrading process of the present invention must comprise two processes: loading procedure and copy procedure, these two processes can be designed to a plurality of processes as required.But, in escalation process, the fresh code of upgrading is loaded into the process of backup area or redundant memory cell from CPU, and fresh code copies workspace or working cell to from backup area or redundant memory cell process two processes that are absolutely necessary.In addition, the reset circuit of being mentioned among the present invention is not limited to watchdog circuit of the present invention, and a plurality of replacement schemes can also be arranged, and it mainly acts on so long as occur directly making processor reset when unusual when system; Also mention among the present invention on the Bootrom chip selection signal of CPU and draw processing, this treatment circuit also can have a plurality of replacement schemes, because these come public technology just to introduce no longer in detail here to those skilled in the art.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.