JP2004348546A - Device and method for switching control program - Google Patents

Device and method for switching control program Download PDF

Info

Publication number
JP2004348546A
JP2004348546A JP2003146221A JP2003146221A JP2004348546A JP 2004348546 A JP2004348546 A JP 2004348546A JP 2003146221 A JP2003146221 A JP 2003146221A JP 2003146221 A JP2003146221 A JP 2003146221A JP 2004348546 A JP2004348546 A JP 2004348546A
Authority
JP
Japan
Prior art keywords
control program
program
consistency
control
boot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2003146221A
Other languages
Japanese (ja)
Other versions
JP2004348546A5 (en
Inventor
Naohisa Obata
尚久 小畑
Shinichi Saijo
信一 西條
Moriyoshi Inaba
守巧 稲葉
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.)
Canon Finetech Nisca Inc
Original Assignee
Canon Finetech Inc
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 Canon Finetech Inc filed Critical Canon Finetech Inc
Priority to JP2003146221A priority Critical patent/JP2004348546A/en
Publication of JP2004348546A publication Critical patent/JP2004348546A/en
Publication of JP2004348546A5 publication Critical patent/JP2004348546A5/ja
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a control program switching device for automatically performing another control program prepared for emergency, when a certain fault occurs in a control program to be normally performed, and also to provide its method. <P>SOLUTION: The device includes a holding means for holding a boot program for booting a CPU and a plurality of control programs to be started by the boot program and operated; a means for verifying at least one kind of consistency in the control program. and a means for switching into another control program among a plurality of control programs held by the holding means, when at least one kind of consistency in the control program is not verified by the verifying means. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
本発明は制御プログラム切替え装置及びその方法に関し、例えば複数の制御プログラムを備えたシステムにおける制御プログラム切替え装置及びその方法に関する。
【0002】
【従来の技術】
従来のCPUを備えるシステムにおける制御プログラムは、ROM領域内で単一しか保持されず、ブートプログラムからは既定の制御プログラムが実行されていた。
【0003】
【発明が解決しようとしている課題】
しかしながら、何らかの原因により制御プログラムに障害が発生した場合、代替手段が存在しないため、そのシステムは動作不可能な状態に陥ってしまう。
【0004】
その場合、ROMに保持された制御プログラムを書き換えることが必要となるが、ROMライターで書き換える場合にはROMを取り外す必要があり、基板上に実装されたROMであれば取り外しに多くの労力が必要となる。仮にROMの取り外しを予め想定するのであれば、取り外しの容易なソケット上にROMを取り付ける方法が考えられるが、この場合基盤のコストが上昇するという問題がある。
【0005】
もしROMライターを使用せずに障害に対処しようとした場合には、基盤の交換が必要となってしまい、システムの修復に要するコストはさらに増大することとなる。
【0006】
本発明は上述した課題を解決するためになされたものであり、通常実行される制御プログラムに何らかの障害が発生した場合に、緊急用に用意された別の制御プログラムを自動的に実行することのできる、制御プログラム切替え装置及びその方法を提供することを目的とする。
【0007】
【問題を解決するための手段】
上述した目的を達成するため、本発明は、即ち、CPUをブートするためのブートプログラムと、前記ブートプログラムにより動作可能な複数の制御プログラムとを保持する保持手段と、前記制御プログラムの整合性を検証する手段と、前記保持手段に保持された複数の制御プログラムを切り替える切替え手段とを有することを特徴とする。
【0008】
上述した目的を達成するため、本発明は、例えば、前記保持手段はROMであることを特徴とする。
【0009】
上述した目的を達成するため、本発明は、例えば、前記保持手段に保持された制御プログラムのうち、1つは通常使用される既定制御プログラムであることを特徴とする。
【0010】
上述した目的を達成するため、本発明は、例えば、前記保持手段に保持された制御プログラムのうち、前記既定制御プログラムを除いたうちの1つは前記既定制御プログラムが機能しない場合にのみ使用される、冗長制御プログラムであることを特徴とする。
【0011】
上述した目的を達成するため、本発明は、例えば、前記ブートプログラムは、前記制御プログラムの整合性を検証する手段を実行し、前記既定制御プログラムの整合性が保証されない場合に、前記プログラム切替え手段を実行し、前記冗長制御プログラムを実行することを特徴とする。
【0012】
上述した目的を達成するため、本発明は、例えば、前記保持手段は、前記複数の制御プログラムにおける、それぞれの実行開始アドレスを保持することを特徴とする。
【0013】
上述した目的を達成するため、本発明は、例えば、前記制御プログラム切替え手段は、前記整合性を検証する手段の実行結果により、保持された前記実行開始アドレスを前記CPUのプログラムカウンタに書き込むことで制御プログラムを実行することを特徴とする。
【0014】
上述した目的を達成するため、本発明は、前記制御プログラム切替え手段は、前記既定制御プログラムの整合性が保証された場合であっても、前記既定制御プルグラムの前回の実行結果により、前記冗長制御プログラムに切り替えることを特徴とする。
【0015】
上述した目的を達成するため、本発明は、例えば、単一のブートプログラムに対して、複数の制御プログラムを保持し、ブートプログラムにより制御プログラムの整合性検証を行い、検証結果に基づいて適切な制御プログラムを選択し、切り替えて実行することを特徴とする。
【作用】
以上の構成により、通常実行される制御プログラムに何らかの障害が発生した場合に、別の制御プログラムを自動的に実行し、同等の機能を実現する、もしくは機能を制限した緊急用プログラムを実行し、最低限の機能を実現することが可能となる。
【0016】
【実施例】
以下、図面を参照して本発明に係る一実施例を詳細に説明する。
(第一の実施例)
図1は本発明を実現するために必要なハードウェア構成のブロック図である。
【0017】
図1において、CPU 101はメモリに記憶されているプログラムに基づいて制御・処理を実行する。FLASH ROM 102は、プログラムなどを記憶する。RAM 103a、RAM 104bは、プログラムやデータなどを記憶する。それぞれは、バスを介して接続されていおり、FLASH ROM 102は論理アドレス0hに割り当てられている。RAM 103a及びRAM 104aは、CPU 101からは連続した1個の領域として認識され、論理アドレスC000000hに割り当てられているものとする。CPU 101はプログラムを実行し、FLASH ROM 102にはシステムの制御に必要な各種プログラム及び後述する図3,4、6に示すフローに対応するブートプログラムが格納されている。
RAM 103a、RAM 103bは、CPU 101が前述のプログラムを実行する際のワークメモリとして使用される他、FLASH ROM 102と比較してアクセス速度が高速なことから、FLASH ROM 102に格納された前述のプログラムをコピーしておくことでプログラムのRead/Writeに必要な時間を短縮し、システムを高速に動作させる役割も持つ。
【0018】
本実施例においては1個のCPU、1個のFLASH ROM、2個のRAMを備えているが、本発明を適用するシステムの規模により、その個数は変動する場合がある。尚、図1においては本実施例に関係する構成のみを抜粋しており、例えば画像を記録するプリンタのようなシステムに本発明を適用する場合には、これらの他に、画像保持用メモリ、モータ及びモータドライバ、各種センサ、記録用ヘッド、ホストPCとのインターフェース制御部等の各種デバイスが必要となる。
【0019】
図2はFLASH ROM 102の物理アドレスに対するプログラムの格納状態を示したメモリマップである。本実施例におけるシステムには2MByteのFLASH ROMが装備されているものとする。FLASH ROM 102のボトム部(物理アドレス:0h)には32KByteのブートプログラム201が、物理アドレス6000hからは224KByteの非常用制御プログラム202が、物理アドレス40000hからは1792KByteの通常用制御プログラム203が格納されている。各プログラムの容量、格納アドレスについてはシステムにより異なり、この他に各種の設定情報を記録しておくための箇所を追加してもよい。各プログラムの先頭物理アドレスは、ブートプログラム201内にテーブルとして保存されており、ブートプログラム実行中はいつでも参照することが可能である。
【0020】
ブートプログラム201は、起動処理に必要なCPU 101のI/Oポート、メモリコントローラの初期化、FLASH ROM 102の内容をRAMへコピーする機能、各制御プログラムのSUMチェック機能、及びブートプログラム201から通常用制御プログラム203、もしくは非常用制御プログラム202に処理を移行させる機能等を持つ。
【0021】
通常用制御プログラム203はシステム全体の制御を行う、いわばメインのプログラムである。先ほどと同様にプリンタに本発明を適用したとして説明すると、センサの監視、モータ制御、記録ヘッド制御等、プリンタとしての機能を実現するためのプログラムは全て通常用制御プログラム203に収められている。
【0022】
非常用制御プログラム202は、FLASH ROM102の容量に十分余裕がある場合には通常用制御プログラム203と全く同じ内容で良いが、本実施例においては容量の制限から、障害の発生している通常用制御プログラム203を書き換えるだけの機能を持つものとする。これが例えばプリンタの場合であれば、ホストPCと通信可能な状態になる程度にハードウェアを初期化し、ホストPCから受信した通常用制御プログラムのデータをFLASH ROM 102に書き込む機能と説明することができる。
【0023】
本実施例においてFLASH ROM 102はCPU 101の論理アドレス0hに割り当てられており、システムの電源が投入され、CPU 101が動作を開始すると自動的にブートプログラム201が実行される。
【0024】
以上の構成からなる実施例の動作を図3を参照して説明する。
【0025】
図3のフローチャートを用いて、システム電源投入後の起動処理について説明する。起動処理は全てブートプログラムが実行する処理である。
CPU 101の起動後、まず、CPU101は、最初に各種I/Oポート及びバスの初期化を行う(302)。CPU 101がメモリコントローラを搭載する場合には、このときにメモリコントローラのレジスタ設定も行い、RAM 103a及びRAM 104aにアクセスすることが可能な状態としておく。
【0026】
次にCPU101は、RAM 103a、RAM 103bのRead/Writeチェックを行う(303)。これは、RAM上の任意のアドレスに特定のデータを書き込み、その後同じアドレスのデータを読み込むという処理を繰り返す。書き込んだデータと読み込んだデータが同じであれば、RAMの書き込みと読み込みが正しく行われていることが確認できる。
【0027】
RAM 103a、RAM 103bの正常なRead/Writeが確認できたら、FLASH ROM 102内のプログラムを全てRAMにコピーする(304)。RAM上で実行するのは通常用制御プログラム203、もしくは非常用制御プログラム202であるため、RAM容量に余裕の無い場合はブートプログラム201はコピーしなくてもよい。また、実際に実行されるのは通常用制御プログラム203、もしくは非常用制御プログラム202のどちらか一方であることから、より使用RAM容量を減らすため、あるいは起動処理時間を短縮するためには、実行する方の制御プログラムのみをコピーするという方法も考えられる。しかしながらこの後、各制御プログラムの整合性を確認するためチェックSUMの算出を行うため、制御プログラム全体に対してReadを行わなければならない。このときCPU 101は、制御プログラムの容量と同数のReadを繰り返すため、FLASH ROM 102よりアクセス速度の速いRAM 103a、RAM 103bに一度全制御プログラムをコピーしておいたほうが、結果的に起動処理時間を短縮することができるのである。本実施例においてはRAM容量に余裕があり、また起動処理を単純化してデバッグの効率化を図る目的のもと、FLASH ROM 102の内容を全てRAMにコピーしておくものとする。
【0028】
次に、以下の方法により通常用制御プログラム203のチェックSUMを算出する(305)。チェックサムの詳細を図4に示す。同図に示すように、以下のステップがある。
アドレスC040000hを変数aに記憶する(402)。
チェックSUM記憶用の変数bを用意し、0クリアしておく(403)。
aのアドレスが示す1Byteのデータを読み込み変数bに加算する(404)。
変数aを1増分する(405)。
変数aがC200000hになったら終了、満たなければ3に戻る(406)。
チェックSUMが算出できたら、次にその値が適正であるかどうかをCPUにより判断する(306)。
【0029】
SUM値は通常、0等の既定値、もしくは書き込まれたプログラムのバージョンと同値になるよう調整され、FLASH ROM 102に書き込まれている。本実施例では、各制御プログラムのSUM値は0になるよう調整されており、算出したSUM値が0であるかどうかで、制御プログラムの整合性を確認することができる。もしSUM値が0以外であった場合、FLASH ROM 102中の通常用制御プログラム203領域に何らかの障害が発生し、書き込まれたデータが失われた、あるいは素子の不良によりRead/Writeに不具合が発生したと判断することができる。
【0030】
SUM値が0となり、通常用制御プログラム203の整合性が確認できた場合には、CPU 101のプログラムカウンタをC040000hに書き換えることにより(307)、RAM上の通常用制御プログラム203を実行し、システム全体を起動する(309)。仮にシステムをプリンタと仮定した場合、メカ初期化、ホストPCとの通信等を開始し、受信データを印刷するといったプリンタとしての機能が、通常用制御プログラム203の実行によりはじめて利用できるようになる。
【0031】
もしSUM値が0以外の値となり、通常用制御プログラム203の整合性が確認できない場合には、プログラムカウンタをC006000hに書き換え(308)、RAM上から非常用制御プログラムを実行する(610)。この時、システムの操作者に通常用制御プログラム203が実行不可能であることを、LED表示、LCD表示、ブザー共鳴等、何らかの形で通知することが望ましい。
【0032】
前述のように、非常用制御プログラム202は、必要最小限のハードウェア初期化機能と、FLASH ROM 102内の通常用制御プログラム203領域(4000h〜1FFFFFh)を書き換える機能しか備わっていないため、正しい通常用制御プログラムを外部から受信する必要がある。データ受信のためには、基板上にシリアル通信ポートを装備するか、もしくはプリンタのように元々外部からデータを受信する手段が備わっていなければならない。例えばシステムがプリンタであった場合、非常用制御プログラム202の実行によりUSB、IEEE1284等のプリンタ−ホストPC間インターフェースの初期化を行い、ホストPCとデータ送受信が可能な状態にする。次にホストPC上で動作する制御プログラム転送用ソフトウェアを用意し、正しい制御プログラムをシステムに転送する。受信したデータはRAM 103a、RAM 103b上に展開し、チェックSUM等を用いて受信データを検証、通常用制御プログラム203領域を受信データで書き換える。その後システムを再起動することにより、ブートプログラム201を実行、通常用制御プログラム203のSUMチェックをパスできれば、外装の取り外し、基板交換、FLASH ROM 102の物理的交換等を行うことなく、システムを復旧させることが可能となる。
【0033】
また、プリンタ等のシステムであれば、出荷後に不具合を修正する必要に迫られたり、市場の要望により機能を追加したりすることがありうるが、こういった場合には通常用制御プログラム203を書き換えることで対応することが多い。このような制御プログラムの書き換えは前述のように、
ホストPCから制御プログラムを受信。
RAM上に展開しSUMチェックを実行。
書き換えるFLASH ROMの領域を消去。
消去した領域に受信データを書き込み。
行われる。
【0034】
例えばFLASH ROMの消去終了後、受信データ書き込み前に、停電もしくは人為的ミスにより電源が断たれたような場合、制御プログラムが格納されているべき領域は空白となり、システムの動作が不可能な状態になってしまう。
このときシステムに本発明を適用していたのであれば、通常用制御プログラムが完全に消去されたとしても、非常用制御プログラムの実行により通常用制御プログラムを復旧することが可能になるのである。
(第二の実施例)
次にその他の実施例を説明する、上述した第一の実施例におけるハードウェア構成と同様であるため、図1を参照して説明する。
【0035】
図5はFLASH ROM 102の物理アドレスに対するプログラムの格納状態を示したメモリマップである。本実施例におけるシステムは2ByteのFLASH ROMが装備されているものとする。FLASH ROM 102のボトム部(物理アドレス:0h)には128KByteのブートプログラム501が、物理アドレス20000hからは960KByteの第一制御プログラム502が、物理アドレス110000hからは第二制御プログラム503が格納されている。各プログラムの容量、格納アドレスについては、第一の実施例と同様、システムにより異なり、この他に各種の設定情報を記録しておくための箇所を追加してもよい。各プログラムの先頭物理アドレスは、ブートプログラム501内にテーブルとして保存されており、ブートプログラム実行中はいつでも参照することが可能である。
【0036】
ブートプログラム501は、起動処理に必要なCPU 101のI/Oポート、メモリコントローラの初期化、FLASH ROM 102の内容をRAMへコピーする機能、各制御プログラムのSUMチェック機能、及びブートプログラム501から第一制御プログラム502、もしくは第二制御プログラム503に処理を移行させる機能等を持つ。
【0037】
第一制御プログラム502はシステム全体の制御を行う、いわばメインのプログラムであり、第一の実施例における通常用制御プログラム203と同様のものであるため、説明を省略する。
【0038】
第二制御プログラム503は、第一制御プログラムと全く同じ内容であり、通常は使用されず、第一制御プログラムに障害が発生した場合にのみ起動する、いわばバックアッププログラムである。
【0039】
以上の構成からなる実施例の動作を図6を参照して説明する。
図6のフローチャートを用いて、システム電源投入後の起動処理について説明する。起動処理は全てブートプログラムが実行する処理である。 システム電源投入後の起動処理について説明するが、アドレス、制御プログラム名が異なるのみで、内容については第一の実施例における図3と同様であるため、詳細については省略する。
【0040】
CPU 101の起動後、各種I/Oポート及びバスの設定を行う(602)。
RAM 103a、RAM 103bのRead/Writeチェックを行い(603)、FLASH ROM 102の内容を全てRAMにコピーする(604)。
第一の実施例と同様の方法で第一制御プログラム502のSUMチェックを行い(605)、SUM値が0であるかどうかで第一制御プログラム502の整合性を確認する(606)。
【0041】
第一制御プログラム502の整合性が確認できた場合、CPU 101のプログラムカウンタをC020000hに書き換え(607)、RAM上の第一制御プログラム502を実行し、システム全体を起動する(609)。第一制御プログラム502はメインのプログラムであり、仮にシステムをプリンタと仮定した場合、第一制御プログラム502の実行により、プリンタとして全ての機能を利用できるようになる。
【0042】
もしSUM値が0以外の値となり、第一制御プログラム502の整合性が確認できない場合には、プログラムカウンタをC020000hに書き換え(608)、RAM上から第二制御プログラム503を実行する(610)。
【0043】
第二制御プログラム503は、前述のように第一制御プログラム502と全く同じ内容である。このため、何らかの障害発生により第一制御プログラム502が実行不能になったとしても、第二制御プログラム503の実行により通常通り、システムの全機能を利用することができるのである。
【0044】
ただし、この後第二制御プログラム503にも障害が発生してしまった場合は、システム全体が動作不能となってしまうので、第二制御プログラム503に処理が移行した時点で、システム操作者に何らかの方法で警告を与え、第一制御プログラム502の書き換えを促すことが望ましい。
【0045】
第一の実施例と同様、プリンタ等のシステムの場合、制御プログラムの更新を行わなければならない事態は十分ありえるのであるが、更新の度、FLASH ROM 102の書き換え失敗によりシステムが動作不能に陥る危険を伴う。
【0046】
こういったときに本発明を適用していれば、仮にFLASH ROMの書き換えに失敗してしまっても、バックアッププログラムの存在により、再度FLASH ROMの書き換えを行うことが可能となる。
(第三の実施例)
上述した第一の実施例、及び第二の実施例におけるハードウェア構成と同様であるため、図1を参照して説明する。
【0047】
また本実施例におけるFLASH ROM 102のメモリマップ、及び起動処理の内容についても第一の実施例と同様であるため、図2、図3を使用することで説明する
本実施例における通常用制御プログラム203は、処理の実行結果をブートプログラム201の領域中にログとして保存しておくことを特徴としている。
通常用制御プログラム203は、CPU 101のウォッチドッグタイマを監視する処理を定期的に行っており、制御プログラムの暴走等により、システムがフリーズするような状態に陥ると、そのログをFLASH ROM 102のブートプログラム201領域に書き出しておく。
【0048】
システムがフリーズしてしまった場合には再起動を行い復旧させることになるが、そのときブートプログラム201領域のログを確認し、システムの正常な起動が不可能と判断した場合には、SUMチェックにより通常用制御プログラム203の整合性が確認できたとしても、強制的に非常用制御プログラム202を実行する。
【0049】
これにより、制御プログラムのバグにより操作不能に陥ってしまった場合でも、非常用制御プログラム202の機能により通常用制御プログラム203の領域を書き換えることが可能となる。
【0050】
【発明の効果】
以上説明したように本発明によれば、例えば、ブートプログラムに対して、複数の制御プログラムを保持し、ブートプログラムにより制御プログラムの整合性検証を行い、検証結果に基づいて適切な制御プログラムを選択し、切り替えて実行することが可能となる。
【図面の簡単な説明】
【図1】実施例におけるハードウェア構成を示すブロック図
【図2】実施例におけるFLASH ROM 102のメモリマップを示す図
【図3】実施例における起動処理を表すフローチャート
【図4】実施例におけるチェックSUM算出方法を現すフローチャート
【図5】第二の実施例におけるFLASH ROM 102のメモリマップを示す図。
【図6】第二の実施例における起動処理を表すフローチャート
【符号の説明】
101 CPU
102 FLASH ROM
103a RAM
103b RAM
201 ブートプログラム
202 非常用制御プログラム
203 通常用制御プログラム
301 処理開始
302 CPU I/Oポート初期化処理
303 RAM Read/Writeチェック処理
304 制御プログラム RAMコピー処理
305 通常用制御プログラムSUM算出処理
306 SUM値確認処理
307 通常用制御プログラム移行処理
308 非常用制御プログラム移行処理
309 通常用制御プログラム実行処理
310 非常用制御プログラム実行処理
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a control program switching device and a method thereof, for example, a control program switching device and a method thereof in a system having a plurality of control programs.
[0002]
[Prior art]
In a system including a conventional CPU, only a single control program is held in a ROM area, and a predetermined control program is executed from a boot program.
[0003]
[Problems to be solved by the invention]
However, if a failure occurs in the control program for some reason, the system falls into an inoperable state because there is no alternative means.
[0004]
In that case, it is necessary to rewrite the control program stored in the ROM, but when rewriting with a ROM writer, it is necessary to remove the ROM, and if the ROM is mounted on a board, much effort is required to remove it. It becomes. If it is assumed that the ROM is to be removed in advance, a method of mounting the ROM on an easily removable socket is conceivable. However, in this case, there is a problem that the cost of the base increases.
[0005]
If an attempt is made to deal with a failure without using a ROM writer, replacement of the board is required, and the cost of repairing the system is further increased.
[0006]
The present invention has been made to solve the above-described problem, and is intended to automatically execute another control program prepared for emergency when some trouble occurs in a normally executed control program. It is an object of the present invention to provide a control program switching device and a control program switching method.
[0007]
[Means to solve the problem]
In order to achieve the above object, the present invention provides a boot program for booting a CPU, a holding unit for holding a plurality of control programs operable by the boot program, and a consistency of the control program. It is characterized by comprising a verification unit and a switching unit for switching a plurality of control programs stored in the storage unit.
[0008]
In order to achieve the above object, the present invention is characterized in that, for example, the holding means is a ROM.
[0009]
In order to achieve the above object, the present invention is characterized in that, for example, one of the control programs held in the holding means is a commonly used default control program.
[0010]
In order to achieve the above object, the present invention provides, for example, one of the control programs held in the holding unit, except for the default control program, which is used only when the default control program does not function. A redundancy control program.
[0011]
In order to achieve the above object, the present invention provides, for example, the boot program executes means for verifying the consistency of the control program, and when the consistency of the default control program is not guaranteed, the program switching means And executing the redundancy control program.
[0012]
In order to achieve the above object, the present invention is characterized in that, for example, the holding means holds respective execution start addresses in the plurality of control programs.
[0013]
In order to achieve the above object, the present invention provides, for example, the control program switching means which writes the held execution start address to a program counter of the CPU based on an execution result of the means for verifying the consistency. A control program is executed.
[0014]
In order to achieve the above-mentioned object, the present invention provides the above-mentioned control program switching means, wherein even if the consistency of the default control program is guaranteed, the control program switching means executes the redundant control according to a previous execution result of the default control program. It is characterized by switching to a program.
[0015]
To achieve the above object, the present invention provides, for example, a method in which a single boot program holds a plurality of control programs, performs consistency verification of the control programs with the boot program, and performs appropriate verification based on the verification result. A control program is selected, switched, and executed.
[Action]
With the above configuration, when a failure occurs in a normally executed control program, another control program is automatically executed to realize an equivalent function or execute an emergency program with limited functions, It is possible to realize the minimum functions.
[0016]
【Example】
Hereinafter, an embodiment according to the present invention will be described in detail with reference to the drawings.
(First embodiment)
FIG. 1 is a block diagram of a hardware configuration necessary for realizing the present invention.
[0017]
In FIG. 1, a CPU 101 performs control and processing based on a program stored in a memory. The FLASH ROM 102 stores programs and the like. The RAM 103a and the RAM 104b store programs, data, and the like. Each is connected via a bus, and the FLASH ROM 102 is assigned to a logical address 0h. It is assumed that the RAM 103a and the RAM 104a are recognized as one continuous area by the CPU 101 and are assigned to the logical address C000000h. The CPU 101 executes a program, and the FLASH ROM 102 stores various programs necessary for controlling the system and a boot program corresponding to the flow shown in FIGS.
The RAM 103a and the RAM 103b are used as a work memory when the CPU 101 executes the above-described program, and have a higher access speed than the FLASH ROM 102. Copying the program shortens the time required for Read / Write of the program, and also has the role of operating the system at high speed.
[0018]
In the present embodiment, one CPU, one FLASH ROM, and two RAMs are provided, but the number may vary depending on the scale of a system to which the present invention is applied. In FIG. 1, only the configuration related to the present embodiment is extracted. For example, when the present invention is applied to a system such as a printer that records an image, an image holding memory, Various devices such as a motor and a motor driver, various sensors, a recording head, and an interface control unit with a host PC are required.
[0019]
FIG. 2 is a memory map showing a storage state of a program with respect to a physical address of the flash ROM 102. It is assumed that the system in this embodiment is equipped with a 2 MByte FLASH ROM. The bottom part (physical address: 0h) of the FLASH ROM 102 stores a boot program 201 of 32 Kbytes, an emergency control program 202 of 224 Kbytes from a physical address 6000h, and a normal control program 203 of 1792 Kbytes from a physical address 40000h. ing. The capacity and storage address of each program differ depending on the system, and a location for recording various setting information may be added. The starting physical address of each program is stored as a table in the boot program 201, and can be referred to at any time during the execution of the boot program.
[0020]
The boot program 201 includes an I / O port of the CPU 101 required for the boot process, initialization of the memory controller, a function of copying the contents of the flash ROM 102 to the RAM, a SUM check function of each control program, and a normal operation from the boot program 201. And a function of shifting the processing to the emergency control program 203 or the emergency control program 202.
[0021]
The normal control program 203 is a so-called main program for controlling the entire system. As described above, assuming that the present invention is applied to the printer, programs for realizing the functions of the printer, such as sensor monitoring, motor control, printhead control, etc., are all contained in the normal control program 203.
[0022]
The emergency control program 202 may have exactly the same contents as the normal control program 203 when the capacity of the FLASH ROM 102 is sufficient, but in the present embodiment, the capacity of the normal It is assumed that the control program 203 has a function of simply rewriting the control program 203. If this is the case of a printer, for example, the function can be described as a function of initializing hardware to such an extent that it can communicate with the host PC, and writing the data of the normal control program received from the host PC into the FLASH ROM 102. .
[0023]
In the present embodiment, the flash ROM 102 is assigned to the logical address 0h of the CPU 101, and when the system is turned on and the CPU 101 starts operating, the boot program 201 is automatically executed.
[0024]
The operation of the embodiment having the above configuration will be described with reference to FIG.
[0025]
With reference to the flowchart of FIG. 3, a startup process after turning on the system power will be described. The startup processing is all processing executed by the boot program.
After the activation of the CPU 101, the CPU 101 first initializes various I / O ports and buses (302). When the CPU 101 has a memory controller, the register setting of the memory controller is also performed at this time so that the RAM 103a and the RAM 104a can be accessed.
[0026]
Next, the CPU 101 performs a Read / Write check of the RAM 103a and the RAM 103b (303). This repeats a process of writing specific data to an arbitrary address on the RAM and then reading data at the same address. If the written data and the read data are the same, it can be confirmed that the writing and reading of the RAM are performed correctly.
[0027]
When normal Read / Write of the RAM 103a and the RAM 103b can be confirmed, all the programs in the FLASH ROM 102 are copied to the RAM (304). Since the normal control program 203 or the emergency control program 202 is executed on the RAM, the boot program 201 does not need to be copied if the RAM capacity is insufficient. In addition, since only the normal control program 203 or the emergency control program 202 is actually executed, in order to further reduce the used RAM capacity or to shorten the start-up processing time, execute It is also conceivable to copy only the control program to be used. However, thereafter, in order to calculate the check SUM in order to confirm the consistency of each control program, it is necessary to perform a read on the entire control program. At this time, since the CPU 101 repeats the same number of Reads as the capacity of the control program, it is better to copy the entire control program once to the RAM 103a and the RAM 103b which have a higher access speed than the FLASH ROM 102. Can be shortened. In the present embodiment, it is assumed that the contents of the FLASH ROM 102 are all copied to the RAM for the purpose of simplifying the start-up process and improving the efficiency of debugging by providing sufficient RAM capacity.
[0028]
Next, a check SUM of the normal control program 203 is calculated by the following method (305). The details of the checksum are shown in FIG. As shown in the figure, there are the following steps.
The address C040000h is stored in the variable a (402).
A variable b for storing the check SUM is prepared and cleared to 0 (403).
The data of 1 Byte indicated by the address of a is read and added to the variable b (404).
The variable a is incremented by 1 (405).
The process ends when the variable a reaches C200000h, and returns to 3 when the variable a is not satisfied (406).
Once the check SUM has been calculated, the CPU next determines whether the value is appropriate (306).
[0029]
The SUM value is usually adjusted to a default value such as 0 or the same value as the version of the written program, and is written in the flash ROM 102. In the present embodiment, the SUM value of each control program is adjusted to be 0, and the consistency of the control program can be confirmed based on whether the calculated SUM value is 0. If the SUM value is other than 0, some trouble occurs in the normal control program 203 area in the FLASH ROM 102, and the written data is lost, or the read / write failure occurs due to a defective element. It can be determined that it has been done.
[0030]
When the SUM value becomes 0 and the consistency of the normal control program 203 can be confirmed, the normal control program 203 on the RAM is executed by rewriting the program counter of the CPU 101 to C040000h (307). The whole is started (309). If it is assumed that the system is a printer, a function as a printer, such as starting mechanical initialization, communication with the host PC, and printing received data, can be used only by executing the normal control program 203.
[0031]
If the SUM value is a value other than 0 and the consistency of the normal control program 203 cannot be confirmed, the program counter is rewritten to C006000h (308), and the emergency control program is executed from the RAM (610). At this time, it is desirable to notify the operator of the system that the normal control program 203 is not executable in some form, such as an LED display, an LCD display, or buzzer resonance.
[0032]
As described above, the emergency control program 202 has only the minimum necessary hardware initialization function and the function of rewriting the normal control program 203 area (4000h to 1FFFFFh) in the FLASH ROM 102, so that the correct normal Control program from outside must be received. In order to receive data, a serial communication port must be provided on the board, or a means for receiving data from outside such as a printer must be provided. For example, when the system is a printer, the interface between the printer and the host PC, such as USB and IEEE1284, is initialized by executing the emergency control program 202, so that data can be transmitted and received with the host PC. Next, control program transfer software operating on the host PC is prepared, and a correct control program is transferred to the system. The received data is developed on the RAM 103a and the RAM 103b, the received data is verified using a check SUM or the like, and the area of the normal control program 203 is rewritten with the received data. After that, the system is restarted to execute the boot program 201. If the SUM check of the normal control program 203 can be passed, the system can be restored without removing the exterior, replacing the board, physically replacing the FLASH ROM 102, and the like. It is possible to do.
[0033]
Further, in the case of a system such as a printer, it may be necessary to correct a defect after shipment, or a function may be added according to a market request. It is often handled by rewriting. As described above, rewriting such a control program
Receive control program from host PC.
Expand on RAM and execute SUM check.
Erase the flash ROM area to be rewritten.
Write the received data to the erased area.
Done.
[0034]
For example, if the power is cut off due to a power failure or a human error after the flash ROM is erased and before the received data is written, the area where the control program should be stored becomes blank, and the system cannot operate. Become.
If the present invention is applied to the system at this time, even if the normal control program is completely erased, the normal control program can be restored by executing the emergency control program.
(Second embodiment)
Next, other embodiments will be described. Since the hardware configuration is the same as that of the above-described first embodiment, a description will be given with reference to FIG.
[0035]
FIG. 5 is a memory map showing a storage state of a program with respect to a physical address of the flash ROM 102. It is assumed that the system in this embodiment is equipped with a 2-byte FLASH ROM. The bottom part (physical address: 0h) of the FLASH ROM 102 stores a 128 Kbyte boot program 501, a 960K byte first control program 502 from a physical address 20000h, and a second control program 503 from a physical address 110000h. . As in the first embodiment, the capacity and storage address of each program differ depending on the system. In addition, a portion for recording various setting information may be added. The start physical address of each program is stored as a table in the boot program 501, and can be referred to at any time during the execution of the boot program.
[0036]
The boot program 501 includes an I / O port of the CPU 101 required for a boot process, initialization of a memory controller, a function of copying the contents of the flash ROM 102 to a RAM, a SUM check function of each control program, and a It has a function of shifting processing to one control program 502 or the second control program 503, and the like.
[0037]
The first control program 502 is a main program for controlling the entire system, so to speak, and is the same as the normal control program 203 in the first embodiment, and thus the description is omitted.
[0038]
The second control program 503 has exactly the same contents as the first control program, is not normally used, and is a backup program that is started only when a failure occurs in the first control program.
[0039]
The operation of the embodiment having the above configuration will be described with reference to FIG.
With reference to the flowchart of FIG. 6, a startup process after turning on the system power will be described. The startup processing is all processing executed by the boot program. The startup process after the system power is turned on will be described. However, only the address and the control program name are different, and the details are omitted since they are the same as those in FIG. 3 in the first embodiment.
[0040]
After the activation of the CPU 101, various I / O ports and buses are set (602).
A Read / Write check of the RAM 103a and the RAM 103b is performed (603), and the entire contents of the flash ROM 102 are copied to the RAM (604).
The SUM check of the first control program 502 is performed in the same manner as in the first embodiment (605), and the consistency of the first control program 502 is confirmed based on whether the SUM value is 0 (606).
[0041]
If the consistency of the first control program 502 can be confirmed, the program counter of the CPU 101 is rewritten to C020000h (607), the first control program 502 on the RAM is executed, and the entire system is started (609). The first control program 502 is a main program. If the system is assumed to be a printer, execution of the first control program 502 allows all functions to be used as a printer.
[0042]
If the SUM value becomes a value other than 0 and the consistency of the first control program 502 cannot be confirmed, the program counter is rewritten to C020000h (608), and the second control program 503 is executed from the RAM (610).
[0043]
The second control program 503 has exactly the same contents as the first control program 502 as described above. Therefore, even if the first control program 502 becomes unexecutable due to some kind of failure, all functions of the system can be used as usual by executing the second control program 503.
[0044]
However, if a failure also occurs in the second control program 503 thereafter, the entire system becomes inoperable. It is desirable to give a warning by a method to prompt rewriting of the first control program 502.
[0045]
As in the case of the first embodiment, in the case of a system such as a printer, it is quite possible that the control program needs to be updated. However, every time the system is updated, there is a risk that the system becomes inoperable due to failure to rewrite the flash ROM 102. Accompanied by
[0046]
If the present invention is applied in such a case, even if the rewriting of the FLASH ROM fails, the FLASH ROM can be rewritten again due to the presence of the backup program.
(Third embodiment)
Since the hardware configuration is the same as in the first embodiment and the second embodiment described above, a description will be given with reference to FIG.
[0047]
Since the memory map of the flash ROM 102 and the contents of the start-up processing in the present embodiment are the same as those in the first embodiment, the control program for normal use in the present embodiment which will be described with reference to FIGS. Reference numeral 203 denotes that the execution result of the process is stored as a log in the area of the boot program 201.
The normal control program 203 periodically performs a process of monitoring the watchdog timer of the CPU 101. If the system freezes due to a runaway of the control program or the like, the log is stored in the FLASH ROM 102. It is written in the boot program 201 area.
[0048]
If the system freezes, it will be restarted and restored, but at that time, check the log in the boot program area 201 and if it is determined that the system cannot be started normally, check the SUM. Thus, even if the consistency of the normal control program 203 can be confirmed, the emergency control program 202 is forcibly executed.
[0049]
As a result, even if the operation becomes impossible due to a bug in the control program, the area of the normal control program 203 can be rewritten by the function of the emergency control program 202.
[0050]
【The invention's effect】
As described above, according to the present invention, for example, a plurality of control programs are held for a boot program, the consistency of the control program is verified by the boot program, and an appropriate control program is selected based on the verification result. Then, it can be switched and executed.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a hardware configuration according to an embodiment; FIG. 2 is a diagram illustrating a memory map of a flash ROM 102 according to an embodiment; FIG. 3 is a flowchart illustrating a start process according to the embodiment; FIG. 5 is a flowchart showing a SUM calculation method. FIG. 5 is a diagram showing a memory map of a flash ROM 102 according to a second embodiment.
FIG. 6 is a flowchart illustrating a startup process according to the second embodiment.
101 CPU
102 FLASH ROM
103a RAM
103b RAM
201 Boot program 202 Emergency control program 203 Normal control program 301 Processing start 302 CPU I / O port initialization processing 303 RAM Read / Write check processing 304 Control program RAM copy processing 305 Normal control program SUM calculation processing 306 SUM value confirmation Process 307 Normal control program shift process 308 Emergency control program shift process 309 Normal control program execution process 310 Emergency control program execution process

Claims (9)

CPUをブートするためのブートプログラムと、前記ブートプログラムで起動される動作可能な複数の制御プログラムとを保持する保持手段と、前記制御プログラムの少なくとも1つの整合性を検証する手段と、前記検証手段で前記制御プログラムの少なくとも1の整合性が検証されなかった場合、前記保持手段に保持された複数の制御プログラムのうちの他の制御プログラムに切り替える切替え手段とを有することを特徴とする制御プログラム切替え装置。Holding means for holding a boot program for booting a CPU, a plurality of operable control programs started by the boot program, means for verifying at least one consistency of the control program, and the verification means Switching means for switching to another control program among the plurality of control programs held in the holding means when at least one consistency of the control program is not verified in the control program. apparatus. 前記保持手段はROMであることを特徴とする請求項1に記載の制御プログラム切替え装置。2. The control program switching device according to claim 1, wherein said holding means is a ROM. 前記保持手段に保持された複数の制御プログラムのうち、1つは通常使用される既定制御プログラムであることを特徴とする請求項1に記載の制御プログラム切替え装置。2. The control program switching device according to claim 1, wherein one of the plurality of control programs stored in the holding unit is a commonly used default control program. 前記保持手段に保持された複数の制御プログラムは、前記既定制御プログラムと前記既定制御プログラムが機能しない場合にのみ使用される、冗長制御プログラムとを含むことを特徴とする請求項1に記載のプログラム切替え装置。2. The program according to claim 1, wherein the plurality of control programs stored in the holding unit include the default control program and a redundancy control program used only when the default control program does not function. Switching device. 前記ブートプログラムは、前記制御プログラムの整合性を検証する手段を実行し、前記既定制御プログラムの整合性が保証されない場合に、前記プログラム切替え手段を実行し、前記冗長制御プログラムを実行することを特徴とする請求項1に記載の制御プログラム切替え装置。The boot program executes means for verifying the consistency of the control program, and when the consistency of the default control program is not guaranteed, executes the program switching means and executes the redundancy control program. The control program switching device according to claim 1, wherein 前記保持手段は、前記複数の制御プログラムにおける、それぞれの実行開始アドレスを保持することを特徴とする請求項1に記載の制御プログラム切替え装置。2. The control program switching device according to claim 1, wherein the holding unit holds respective execution start addresses in the plurality of control programs. 前記制御プログラム切替え手段は、前記整合性を検証する手段の実行結果により、保持された前記実行開始アドレスを前記CPUのプログラムカウンタに書き込むことで制御プログラムを実行することを特徴とする請求項1に記載の制御プログラム切替え装置。2. The control program switching means according to claim 1, wherein the control program switching means executes the control program by writing the held execution start address to a program counter of the CPU according to an execution result of the means for verifying the consistency. The control program switching device according to the above. 前記制御プログラム切替え手段は、前記既定制御プログラムの整合性が保証された場合であっても、前記既定制御プログラムの前回の実行結果により、前記冗長制御プログラムに切り替えることを特徴とする請求項1に記載の制御プログラム切替え装置。2. The control program switching unit according to claim 1, wherein even when the consistency of the default control program is guaranteed, the control program switching unit switches to the redundant control program according to a previous execution result of the default control program. The control program switching device according to the above. 前記ブートプログラムに対して、複数の制御プログラムを保持し、前記ブートプログラムにより制御プログラムの整合性検証を行い、検証結果に基づいて適切な制御プログラムを選択し、切り替えて実行することを特徴とする制御プログラム切替え方法。A plurality of control programs are held for the boot program, the consistency of the control program is verified by the boot program, an appropriate control program is selected based on the verification result, and the control program is switched and executed. Control program switching method.
JP2003146221A 2003-05-23 2003-05-23 Device and method for switching control program Pending JP2004348546A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003146221A JP2004348546A (en) 2003-05-23 2003-05-23 Device and method for switching control program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003146221A JP2004348546A (en) 2003-05-23 2003-05-23 Device and method for switching control program

Publications (2)

Publication Number Publication Date
JP2004348546A true JP2004348546A (en) 2004-12-09
JP2004348546A5 JP2004348546A5 (en) 2006-07-13

Family

ID=33533141

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003146221A Pending JP2004348546A (en) 2003-05-23 2003-05-23 Device and method for switching control program

Country Status (1)

Country Link
JP (1) JP2004348546A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10108499B2 (en) 2015-03-24 2018-10-23 Mitsubishi Electric Corporation Information processing device with watchdog timer
US11599631B2 (en) 2018-11-02 2023-03-07 Renesas Electronics Corporation Semiconductor device, semiconductor system and program

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10108499B2 (en) 2015-03-24 2018-10-23 Mitsubishi Electric Corporation Information processing device with watchdog timer
US11599631B2 (en) 2018-11-02 2023-03-07 Renesas Electronics Corporation Semiconductor device, semiconductor system and program

Similar Documents

Publication Publication Date Title
JP4668416B2 (en) Protecting boot block code when enabling write access to the boot block
JP2008084291A (en) Storage apparatus, control method, and control device
US20040153738A1 (en) Redundancy management method for BIOS, data processing apparatus and storage system for using same
JP6543122B2 (en) INFORMATION PROCESSING APPARATUS, METHOD OF INITIALIZING NONVOLATILE STORAGE DEVICE BY THE INFORMATION PROCESSING APPARATUS, AND PROGRAM
JP2000090011A (en) Memory rewriting method and computer system
JP2005071303A (en) Program starting device
JPH10307726A (en) System for firmware recovery at time of start error
JP3805195B2 (en) Program rewriting apparatus and program rewriting method
JP2008009799A (en) Image forming device
JP2004348546A (en) Device and method for switching control program
JP2003157204A (en) Device and method for rewriting data and storage medium
JP2004054616A (en) Information processor with function to automatically restore firmware
JP2003345617A (en) Apparatus and method for information processing, ic card, and program
JP2001344156A (en) Device with flash memory and data rewriting method
JP2004192329A (en) Program rewriting method and terminal device
JP2002351687A (en) Updating system for firmware of printer
JPH0784894A (en) Method for writing nonvolatile memory
JP3498028B2 (en) Boot program rewriting system
JPH1011277A (en) Computer device with electrically rewritable nonvolatile memory and nonvolatile semiconductor memory
JP2853593B2 (en) Download device
JP4165423B2 (en) System board with core I / O card
JPH08161160A (en) Method for updating firmware of optical disk reproducing device
JPH09305395A (en) Electronic equipment
JP2009238071A (en) Built-in system
JP6781803B2 (en) Information processing device and its control method

Legal Events

Date Code Title Description
A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20060522

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060522

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20090526

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20091001