JP2009070303A - Program rewriting method in erasing reset vector - Google Patents

Program rewriting method in erasing reset vector Download PDF

Info

Publication number
JP2009070303A
JP2009070303A JP2007240226A JP2007240226A JP2009070303A JP 2009070303 A JP2009070303 A JP 2009070303A JP 2007240226 A JP2007240226 A JP 2007240226A JP 2007240226 A JP2007240226 A JP 2007240226A JP 2009070303 A JP2009070303 A JP 2009070303A
Authority
JP
Japan
Prior art keywords
program
reset vector
reset
rewriting
normal operation
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.)
Withdrawn
Application number
JP2007240226A
Other languages
Japanese (ja)
Inventor
Jun Shindo
準 進藤
Kazuhisa Fujikawa
和寿 藤川
Takahiro Shinagawa
貴宏 品川
Masataka Tanno
真敬 丹野
Yuichi Chiba
祐一 千葉
Shigenori Suzuki
重範 鈴木
Masato Sato
將人 佐藤
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.)
Fujitsu Semiconductor Ltd
Original Assignee
Fujitsu Semiconductor Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Semiconductor Ltd filed Critical Fujitsu Semiconductor Ltd
Priority to JP2007240226A priority Critical patent/JP2009070303A/en
Publication of JP2009070303A publication Critical patent/JP2009070303A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a program rewriting method in erasing a reset vector for performing the stable rewriting processing of a normal operation service program from the erasure of the reset vector to writing completion by starting a normal operation service program rewriting program, and to provide a program. <P>SOLUTION: The program rewriting method includes the erasure of the reset vector of a system including a CPU and an electrically erasable nonvolatile memory. When a reset occurs, it is discriminated whether the value of the reset vector mounted on the electrically erasable nonvolatile memory is electrically erased or not. When the reset vector is erased, the program is arranged, which is for rewriting the service program being the program to be performed in the normal operation from an address which is indicated by an erased state reset vector mounted on an in-operation unerasable area. <P>COPYRIGHT: (C)2009,JPO&INPIT

Description

本発明は、CPUとメモリを備えるシステムのメモリに記録されているプログラムの書換えに係り、特に、電気的に消去可能な不揮発性メモリに記録されているプログラム書換えの技術に関する。   The present invention relates to rewriting of a program recorded in a memory of a system including a CPU and a memory, and more particularly to a technique of rewriting a program recorded in an electrically erasable nonvolatile memory.

CPUとフラッシュメモリ(電気的に消去可能な不揮発性メモリ)を備えたシステムでは、処理開始前に、CPUがフラッシュメモリ内に記録されているリセットベクタに基づいて必要なプログラムを読み込み、そのプログラムに従って実行される。   In a system including a CPU and a flash memory (an electrically erasable nonvolatile memory), the CPU reads a necessary program based on a reset vector recorded in the flash memory before starting the processing, and follows the program. Executed.

このようなシステムの運用中にフラッシュメモリに記録されているプログラムの書換えが必要になる場合があり、書換え方法として次のような提案がされている。
特許文献1によれば、ディスクドライブ装置のディスクアクセスおよびインタフェース制御用の処理プログラムを含むアプリケーションプログラムの全部または一部を効率的に修正できるようにする提案がされている。
There are cases where it is necessary to rewrite the program recorded in the flash memory during the operation of such a system, and the following proposal has been made as a rewriting method.
According to Japanese Patent Laid-Open No. 2004-260, a proposal is made to efficiently modify all or part of an application program including a processing program for disk access and interface control of a disk drive device.

特許文献2によれば、EPROMにはBOOTプログラム、運用プログラム、予備プログラムを格納する各プログラム領域および切替えフラグが設けられている。マイクロプロセッサはROMに格納されているプログラムに従って処理を実行し、内蔵するRAMには、BOOTプログラムおよび運用プログラムを起動するために参照される割込みベクタを設けている。切替回路は切替えフラグに基づくマイクロプロセッサからの切替え制御信号に応答して運用プログラム領域と予備プログラム領域のアドレスを交換する。BOOTプログラムは、最新のプログラムをダウンロードするときは、割込みベクタをBOOTプログラム用に書き換えて予備プログラム領域にダウンロードするとともに切替えフラグを反転し、一方、通常動作時は割込みベクタを運用プログラム用に書き換える。通常処理を行いながらダウンロード処理を実施することを可能にする提案がされている。   According to Patent Literature 2, each EPROM is provided with a program area for storing a BOOT program, an operation program, and a spare program, and a switching flag. The microprocessor executes processing according to the program stored in the ROM, and the built-in RAM is provided with an interrupt vector that is referred to for starting the BOOT program and the operation program. The switching circuit exchanges the addresses of the operation program area and the spare program area in response to a switching control signal from the microprocessor based on the switching flag. When the latest program is downloaded, the BOOT program rewrites the interrupt vector for the BOOT program and downloads it to the spare program area and inverts the switching flag. On the other hand, during normal operation, the BOOT program rewrites the interrupt vector for the operation program. There has been a proposal that makes it possible to perform download processing while performing normal processing.

特許文献3によれば、システムROMは、複数のブート可能なフラッシュ・イメージを格納するとともにプログラム不可能なブート・ブロックを含み、不揮発性RAMがフラッシュ・イメージのどれが選択されたかを示すステータス情報を格納する。CPUは、選択されたイメージの完全性をテストし、完全である場合に該イメージを実行し、不完全である場合に他のフラッシュ・イメージを選択する。そして、完全性をテストし、完全である場合に該イメージを実行する。これにより、不完全フラッシュ・イメージが実行されず、自動的にシステムのリカバリが可能となる。起動プロセス中に発生するシステム・エラーを適切に回復させる提案がされている。   According to Patent Document 3, the system ROM stores a plurality of bootable flash images and includes a non-programmable boot block, and status information indicating which flash image is selected by the nonvolatile RAM. Is stored. The CPU tests the integrity of the selected image, executes the image if it is complete, and selects another flash image if it is incomplete. It then tests for completeness and executes the image if it is complete. As a result, the incomplete flash image is not executed, and the system can be automatically recovered. Proposals have been made to properly recover from system errors that occur during the boot process.

しかしながら、特許文献1や特許文献2では電気的に消去可能な不揮発性メモリの一部へ割付けられているリセットベクタを書換えようとした場合、リセットベクタ領域の消去から書換え完了までの間にリセットが発生すると、リセットベクタの値が不定なため、プログラム書換え処理への移行ができなくなることやプログラムが暴走するという問題がある。   However, in Patent Document 1 and Patent Document 2, when the reset vector assigned to a part of the electrically erasable nonvolatile memory is to be rewritten, the reset is performed between the erasing of the reset vector area and the completion of the rewriting. When this occurs, there are problems that the value of the reset vector is indefinite, so that the program rewriting process cannot be performed, and the program runs out of control.

また、特許文献3ではリセット発生後、最初に動作させるプログラムを決定する場合、電源供給が必要な不揮発性RAMに対する電源供給が途絶えると不揮発性RAMの値が消え、リセット発生後、最初に起動させるプログラムを決定する情報(BIOSパラメータ)の値が保障されないため、期待しているプログラムが起動できなくなるという問題がある。
国際公開第97/38367号パンフレット 特開2005−332228号公報 特開平11−316687号公報
Further, in Patent Document 3, when determining the first program to be operated after a reset occurs, the value of the non-volatile RAM disappears when the power supply to the non-volatile RAM that requires power supply is interrupted, and is activated first after the reset occurs. Since the value of the information (BIOS parameter) for determining the program is not guaranteed, there is a problem that the expected program cannot be started.
International Publication No. 97/38367 Pamphlet JP 2005-332228 A Japanese Patent Laid-Open No. 11-316687

本発明は上記のような実情に鑑みてなされたものであり、通常動作サービスプログラム書換えプログラムが起動することにより、リセットベクタ消去から書込み完了まで安定した通常動作サービスプログラムの書換え処理を実行するリセットベクタ消去時プログラム書換え方法とプログラムを提供することを目的とする。   The present invention has been made in view of the above circumstances, and a reset vector that executes stable normal operation service program rewrite processing from reset vector erase to write completion when the normal operation service program rewrite program is started. An object is to provide a program rewriting method and program at the time of erasure.

本発明であるCPUと電気的に消去可能な不揮発性メモリを備えるシステムのリセットベクタ消去時プログラム書換え方法により、リセット発生時、前記電気的に消去可能な不揮発性メモリに実装されたリセットベクタの値が電気的に消去されたかを判別し、前記リセットベクタが消去されているとき、運用中消去不可能な領域に実装された消去状態時リセットベクタの示すアドレスから、通常動作時に実行されるプログラムであるサービスプログラムを書換えるプログラムを配置する。   The reset vector value mounted on the electrically erasable non-volatile memory when a reset occurs by the reset vector erasing program rewriting method of the system including the CPU and the electrically erasable non-volatile memory according to the present invention. A program that is executed during normal operation from the address indicated by the reset vector in the erased state installed in an area that cannot be erased during operation when the reset vector is erased. A program for rewriting a service program is arranged.

好ましくは、通常動作時に実行される前記サービスプログラムを書換えるプログラムは、前記リセットベクタと前記サービスプログラムを有する前記電気的に消去可能な不揮発性メモリブロックの消去をし、前記サービスプログラムを書き込んだのち、前記リセットベクタを書き込んでもよい。   Preferably, the program for rewriting the service program executed during normal operation erases the electrically erasable nonvolatile memory block having the reset vector and the service program, and writes the service program. The reset vector may be written.

上記方法により、リセットベクタを含む電気的に消去可能な不揮発性メモリの消去から、リセットベクタ再書込み完了までの間にリセットが発生した場合でも、通常動作サービスプログラム書換えプログラムを再起動できるようにする。   By the above method, the normal operation service program rewriting program can be restarted even when a reset occurs between the erasure of the electrically erasable nonvolatile memory including the reset vector and the completion of the reset vector rewriting. .

好ましくは、リセット発生時、前記リセットベクタの値が電気的に消去された値以外と認識された場合、ウォッチドッグタイマのクリアパターンとして、第1のウォッチドッグクリアパターンを選択し、リセット発生時、前記リセットベクタの値が電気的に消去された値と認識された場合、ウォッチドッグタイマのクリアパターンとして、第2のウォッチドッグクリアパターンを選択してもよい。   Preferably, when the reset vector value is recognized to be other than an electrically erased value when a reset occurs, the first watchdog clear pattern is selected as the watchdog timer clear pattern, and when the reset occurs, When the reset vector value is recognized as an electrically erased value, a second watchdog clear pattern may be selected as the watchdog timer clear pattern.

好ましくは、前記サービスプログラムの書換えプログラムは、前記リセットベクタの示すアドレスからの読出し確認を行い、前記リセットベクタの値が電気的に消去された値以外と認識された場合、前記第1のウォッチドッグクリアパターンに基づいてウォッチドッグタイマをクリアし、前記リセットベクタの値が電気的に消去された値と認識された場合、前記第2のウォッチドッグクリアパターンに基づいてウォッチドッグタイマをクリアしてもよい。   Preferably, the rewriting program of the service program performs read confirmation from the address indicated by the reset vector, and when the value of the reset vector is recognized to be other than an electrically erased value, the first watchdog If the watchdog timer is cleared based on the clear pattern and the reset vector value is recognized as an electrically erased value, the watchdog timer may be cleared based on the second watchdog clear pattern. Good.

上記方法によりリセットベクタが消去状態であった場合でも、想定外に残存するプログラムが動作し、第1のウォッチドッグクリアパターンを使用してウォッチドッグタイマをクリアしようとしても実際にはウォッチドッグタイマがクリアされない。つまり、ウォッチドッグタイマがオーバフローを繰返すことによりプログラムの書換えができたものと誤認識することを抑止する。   Even if the reset vector is erased by the above method, an unexpectedly remaining program operates, and even if you try to clear the watchdog timer using the first watchdog clear pattern, the watchdog timer It is not cleared. That is, the watchdog timer is prevented from erroneously recognizing that the program has been rewritten by repeating overflow.

好ましくは、前記リセットベクタの消去状態であり、前記サービスプログラムの書換え中にリセットが発生したとき、前記サービスプログラムの書換えプログラムを起動し、前記サービスプログラムの書換えを行ってもよい。   Preferably, the reset vector is in an erased state, and when a reset occurs during rewriting of the service program, the service program rewriting program may be activated to rewrite the service program.

本発明によれば、通常動作サービスプログラム書換えプログラムが起動することにより、リセットベクタ消去から書込み完了まで安定した通常動作サービスプログラムの書換え処理を実行することができる。   According to the present invention, when the normal operation service program rewriting program is started, it is possible to execute a stable normal operation service program rewriting process from reset vector erasing to writing completion.

(原理説明)
リセット発生時に、リセットベクタの値が、電気的に消去された値かを判別する。
例えば、電気的に消去可能な不揮発性メモリ(フラッシュメモリなど)において、メモリ内容が電気的な消去がされたかの判定は、メモリ上の値が全て「1」になることを利用して行う。リセット発生時にリセットベクタの値が消去値であると判定された場合、リセットベクタの代わりに使用される消去状態時リセットベクタを設け、消去状態時リセットベクタにプログラム開始アドレスを設定する(消去状態時リセットベクタには、電気的に消去可能な不揮発性メモリブロックの境界アドレスが格納される)。
(Principle explanation)
When a reset occurs, it is determined whether the value of the reset vector is an electrically erased value.
For example, in an electrically erasable non-volatile memory (such as a flash memory), whether or not the memory contents are electrically erased is determined using the fact that all the values on the memory are “1”. If it is determined that the reset vector value is the erase value when a reset occurs, a reset vector is used instead of the reset vector in the erase state, and the program start address is set in the reset vector in the erase state (in the erase state) The reset vector stores the boundary address of the electrically erasable nonvolatile memory block).

また、消去状態時リセットベクタは、書換え不可能な領域(レジスタや運用中消去不可能なメモリなど)に実装される。
利用者は、消去状態時リセットベクタの指し示す先頭アドレスに、通常動作時に実行されるプログラムであるサービスプログラムを書換えるプログラム(通常動作サービスプログラム書換えプログラム)を配置する。
In addition, the reset vector in the erased state is mounted in a non-rewritable area (such as a register or a memory that cannot be erased during operation).
The user places a program (normal operation service program rewriting program) for rewriting a service program, which is a program executed during normal operation, at the start address indicated by the reset vector in the erase state.

サービスプログラム(通常動作サービスプログラム)は、書換えに移行する条件が成立したかを定期的に監視して判定を行い、書換え条件成立時には、消去状態時リセットベクタ値と同じアドレスへジャンプする。また、ウォッチドッグタイマのクリアパターンとしてウォッチドッグクリアパターンA(第1のウォッチドッグクリアパターン)を使用する。   The service program (normal operation service program) periodically monitors to determine whether or not the condition for shifting to rewrite is satisfied, and jumps to the same address as the reset vector value in the erased state when the rewrite condition is satisfied. In addition, a watchdog clear pattern A (first watchdog clear pattern) is used as a clear pattern of the watchdog timer.

また、リセット発生時にリセットベクタの値が消去値以外であると判定された場合、ウォッチドッグタイマのクリアパターンとして、ウォッチドッグクリアパターンAを選択する。   When it is determined that the reset vector value is other than the erase value when a reset occurs, the watchdog clear pattern A is selected as the clear pattern of the watchdog timer.

通常動作サービスプログラム書換えプログラムは、初期設定において、プログラム起動要因が、リセット発生かつ、リセットベクタの値が消去値であると判定された場合のみ有効なウォッチドッグタイマのクリアパターンとしてウォッチドッグクリアパターンB(第2のウォッチドッグクリアパターン)を使用する。   The normal operation service program rewrite program is a watchdog clear pattern B as a clear pattern of the watchdog timer that is valid only when the program activation factor is a reset occurrence and it is determined that the reset vector value is an erase value. (Second watchdog clear pattern) is used.

次に、通常動作サービスプログラムの書換え順序として、下記の処理を実施する。
リセットベクタを含む電気的に消去可能な不揮発性メモリブロックの消去をする。その後、通常動作サービスプログラムを消去する。次に、通常動作サービスプログラムの書込みをし、リセットベクタの書込みを行う。
Next, the following processing is performed as the rewriting order of the normal operation service program.
Erasing an electrically erasable nonvolatile memory block including a reset vector. Thereafter, the normal operation service program is deleted. Next, the normal operation service program is written, and the reset vector is written.

上記のようにすることで、リセットベクタの書換えが可能となる。また、リセットベクタが期待外(消去値)であることによるプログラム開始アドレスの不定にともなうプログラム暴走、プログラム的な復旧不可状態に陥ることを抑止することが可能となる。   By doing so, the reset vector can be rewritten. In addition, it is possible to prevent program runaway due to an undefined program start address due to an unexpected reset vector (erase value), and falling into a program-like unrecoverable state.

通常動作サービスプログラム書換えプログラムが再起動されることにより通常動作サービスプログラムの書換え処理を再度実行することができる。
また、プログラム書換え用の特別な回路および冶具が不要であることから、プログラムの書換えを大多数の製品取扱い拠点ごとにて実施することができ、コストを削減すること
ができる。
When the normal operation service program rewrite program is restarted, the normal operation service program rewrite process can be executed again.
In addition, since a special circuit and jig for rewriting a program are not required, the rewriting of the program can be performed at most product handling bases, and the cost can be reduced.

以下図面に基づいて、本発明の実施形態について詳細を説明する。
(構成)
図1に示すオンボード基板1には、CPU2(マイコンなど)、フラッシュメモリ3(電気的に消去可能な不揮発性メモリ)、通信インタフェース4などが実装されている。そして、オンボード基板1は、通信回線5を介して通信インタフェース接続装置6と接続されている。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
(Constitution)
On the on-board substrate 1 shown in FIG. 1, a CPU 2 (such as a microcomputer), a flash memory 3 (an electrically erasable nonvolatile memory), a communication interface 4 and the like are mounted. The on-board substrate 1 is connected to the communication interface connection device 6 via the communication line 5.

CPU2は、フラッシュメモリ3内に格納される通常動作サービスプログラムおよび、通常動作サービスプログラム書換えプログラムを実行する。
フラッシュメモリ3は、通常動作サービスプログラム、通常動作サービスプログラム書換えプログラムおよびリセットベクタが格納されている。また、電気的に消去可能な不揮発性メモリは、オンボード基板1上に実装されていてもかまわないし、CPU2内部に設けられたものであってもよい。
The CPU 2 executes a normal operation service program and a normal operation service program rewriting program stored in the flash memory 3.
The flash memory 3 stores a normal operation service program, a normal operation service program rewriting program, and a reset vector. The electrically erasable non-volatile memory may be mounted on the on-board substrate 1 or may be provided in the CPU 2.

通信インタフェース4はオンボード基板1と通信インタフェース接続装置6とを接続する。通常動作サービスプログラムの書換え時に、CPU2により通信インタフェース4を介して通信インタフェース接続装置6との通信が制御され、通信インタフェース接続装置6から通常動作サービスプログラムを取得してフラッシュメモリ3の書換えを行う。   The communication interface 4 connects the on-board substrate 1 and the communication interface connection device 6. When the normal operation service program is rewritten, the CPU 2 controls communication with the communication interface connection device 6 via the communication interface 4, acquires the normal operation service program from the communication interface connection device 6, and rewrites the flash memory 3.

通信インタフェース接続装置6は、通常動作サービスプログラム書換え時に、通信回線5を介してオンボード基板1に通常動作サービスプログラムを送信する。
なお、通常動作サービスプログラムは、フラッシュメモリ3にマッピングされるユーザアプリケーションプログラムなどである。
(メモリマップ)
図2は、電気的に消去可能な不揮発性メモリのメモリマップの例を示す。
The communication interface connection device 6 transmits the normal operation service program to the on-board substrate 1 via the communication line 5 when rewriting the normal operation service program.
The normal operation service program is a user application program mapped to the flash memory 3.
(Memory map)
FIG. 2 shows an example of a memory map of an electrically erasable nonvolatile memory.

電気的に消去可能な不揮発性メモリブロック#0から電気的に消去可能な不揮発性メモリブロック#2(アドレス空間0x00400000〜0x009FFFFF)には、通常動作サービスプログラムが実装される。   A normal operation service program is installed in the electrically erasable nonvolatile memory block # 0 to the electrically erasable nonvolatile memory block # 2 (address space 0x00400000 to 0x009FFFFF).

電気的に消去可能な不揮発性メモリブロック#3から電気的に消去可能な不揮発性メモリブロック#4(アドレス空間0x00A00000〜0x00DFFFFF)には、通常動作サービスプログラム書換えプログラムが実装される。   A normal operation service program rewriting program is mounted in the electrically erasable nonvolatile memory block # 3 to the electrically erasable nonvolatile memory block # 4 (address space 0x00A00000 to 0x00DFFFFF).

電気的に消去可能な不揮発性メモリブロック#5(アドレス空間0x00E00000〜0x00FFFFFF)は、リセットベクタ(アドレス空間0x00FFFFFC〜0x00FFFFFF)を含む領域である。
消去状態時リセットベクタは、リセット発生時に、電気的に消去可能な不揮発性メモリブロック#5内のリセットベクタの値が消去値の場合に、リセットベクタの代わりに使用される。
The electrically erasable nonvolatile memory block # 5 (address space 0x00E00000 to 0x00FFFFFF) is an area including a reset vector (address space 0x00FFFFFC to 0x00FFFFFF).
In the erase state, the reset vector is used instead of the reset vector when the reset vector value in the electrically erasable nonvolatile memory block # 5 is an erase value when a reset occurs.

消去状態時リセットベクタは、書換え不可能なレジスタなどの領域に実装され、消去状態時リセットベクタの値は、電気的に消去可能な不揮発性メモリの消去単位の境界を示す値である。図2では消去状態時リセットベクタの値は、電気的に消去可能な不揮発性メモリブロック#3の先頭アドレス(0x00A00000)である。   The reset vector in the erase state is mounted in an area such as a non-rewritable register, and the value of the reset vector in the erase state is a value indicating the boundary of the erase unit of the electrically erasable nonvolatile memory. In FIG. 2, the value of the reset vector in the erased state is the leading address (0x00A00000) of the electrically erasable nonvolatile memory block # 3.

また、電気的に消去可能な不揮発性メモリブロック#5が電気的に未消去状態の場合には、電気的に消去可能な不揮発性メモリブロック#0の先頭アドレス(0x00400000)を示すものとする。   Further, when the electrically erasable nonvolatile memory block # 5 is in an electrically unerased state, the head address (0x00400000) of the electrically erasable nonvolatile memory block # 0 is indicated.

電気的に消去可能な不揮発性メモリブロック#5が電気的に消去状態の場合には、全ての値が「1」になる(0xFFFFFFFF)。
(リセット発生からプログラム開始までの動作説明)
図3は、リセット発生からプログラム開始までのハードウェアの動作を示す。
When the electrically erasable nonvolatile memory block # 5 is electrically erased, all values are “1” (0xFFFFFFFF).
(Description of operation from reset generation to program start)
FIG. 3 shows the hardware operation from the occurrence of reset to the start of the program.

ステップS1では、リセットベクタ読出しリセットが発生した場合、CPU2はプログラム開始アドレスを確定するため、リセットベクタ(実施例では、電気的に消去可能な不揮発性メモリブロック#5内、0x00FFFFFC〜0x00FFFFFF番地)を読出した後、ステップS2へ遷移する。   In step S1, when the reset vector read reset occurs, the CPU 2 determines the program start address, so that the reset vector (in the embodiment, the electrically erasable nonvolatile memory block # 5, addresses 0x00FFFFFC to 0x00FFFFFF) is used. After reading, the process proceeds to step S2.

ステップS2ではリセットベクタ値が消去値(0xFFFFFFFF)以外か判定する。リセットベクタの値が消去値以外であればステップS3に遷移する。読出したリセットベクタの値が消去値であればステップS5へ遷移する。   In step S2, it is determined whether the reset vector value is other than the erase value (0xFFFFFFFF). If the value of the reset vector is other than the erase value, the process proceeds to step S3. If the value of the read reset vector is an erase value, the process proceeds to step S5.

ステップS3では、ウォッチドッグクリアパターンとしてウォッチドッグクリアパターンA(例えば0x5555)を選択する。リセットベクタが未消去状態であった場合、CPU2はウォッチドッグタイマのクリアパターンとして、ウォッチドッグクリアパターンAを選択し、ステップS4へ遷移する。   In step S3, a watchdog clear pattern A (for example, 0x5555) is selected as the watchdog clear pattern. If the reset vector is in an unerased state, the CPU 2 selects the watchdog clear pattern A as the watchdog timer clear pattern, and the process proceeds to step S4.

ステップS4ではプログラム開始アドレスとしてリセットベクタを選択する。リセットベクタが未消去状態であった場合、CPU2はプログラム開始アドレスとして、リセットベクタ値(実施例では、電気的に消去可能な不揮発性メモリブロック#0(0x00400000番地))を選択し、ステップS7へ遷移する。   In step S4, a reset vector is selected as the program start address. When the reset vector is in an unerased state, the CPU 2 selects a reset vector value (in the embodiment, an electrically erasable nonvolatile memory block # 0 (address 0x00400000)) as a program start address, and proceeds to step S7. Transition.

ステップS5では、ウォッチドッグクリアパターンとしてウォッチドッグクリアパターンB(例えば0xAAAA)を選択する。リセットベクタが消去状態であった場合、CPU2はウォッチドッグタイマのクリアパターンとして、ウォッチドッグクリアパターンBを選択し、ステップS6へ遷移する。   In step S5, a watchdog clear pattern B (for example, 0xAAAA) is selected as the watchdog clear pattern. If the reset vector is in the erased state, the CPU 2 selects the watchdog clear pattern B as the watchdog timer clear pattern, and proceeds to step S6.

ステップS6では、プログラム開始アドレスとして消去状態時リセットベクタを選択する。リセットベクタが消去状態であった場合、CPU2はプログラム開始アドレスとして、消去状態時リセットベクタ値(実施例では、電気的に消去可能な不揮発性メモリブロック#3(0x00400000番地))を選択し、ステップS7に遷移する。   In step S6, the reset vector in the erase state is selected as the program start address. If the reset vector is in the erased state, the CPU 2 selects the reset vector value in the erased state (in the embodiment, electrically erasable nonvolatile memory block # 3 (address 0x00400000)) as the program start address, and the step Transition to S7.

ステップS7では、リセットベクタの状態(消去または、未消去)によって選択されたプログラムの開始アドレスへジャンプする。
ここで、ウォッチドッグタイマクリアパターンは、ウォッチドッグタイマのクリアパターンとして、ウォッチドッグクリアパターンAまたは、ウォッチドッグクリアパターンBのどちらかを選択する。
In step S7, the program jumps to the start address of the program selected according to the state of the reset vector (erased or not erased).
Here, the watchdog timer clear pattern selects either the watchdog clear pattern A or the watchdog clear pattern B as the watchdog timer clear pattern.

また、リセットベクタが消去状態であった場合、想定外に残存するプログラムが動作し、通常使用するウォッチドッグクリアパターンAによってウォッチドッグタイマをクリアができてしまうとプログラムの書換えをおこなったものと誤認識してしまう可能性がある。そこで、リセットベクタが消去状態であった場合のウォッチドッグクリアパターンBを新たに設ける。   In addition, if the reset vector is in the erased state, an unexpectedly remaining program operates, and if the watchdog timer can be cleared by the normally used watchdog clear pattern A, it is mistaken that the program has been rewritten. There is a possibility of recognizing. Therefore, a watchdog clear pattern B is newly provided when the reset vector is in the erased state.

リセットベクタが消去状態であった場合、想定外に残存するプログラムが動作し、ウォッチドッグクリアパターンAを使用してウォッチドッグタイマをクリアしようとしても実際にはウォッチドッグタイマがクリアされない。つまり、ウォッチドッグクリアパターン
Bを設けることにより、ウォッチドッグタイマがオーバフローを繰返すことによりプログラムの書換えができたものと誤認識することを抑止する。
If the reset vector is in an erased state, an unexpected program operates, and even if an attempt is made to clear the watchdog timer using the watchdog clear pattern A, the watchdog timer is not actually cleared. In other words, by providing the watchdog clear pattern B, it is possible to prevent the watchdog timer from erroneously recognizing that the program has been rewritten due to repeated overflow.

また、通常動作サービスプログラム書換えプログラムを使用し、通常動作サービスプログラムを書換える処理において、リセットベクタを含む電気的に消去可能な不揮発性メモリの消去から、リセットベクタ再書込み完了までの間にリセットが発生した場合、リセットベクタ値が不定となり通常動作サービスプログラム書換えプログラムさえも再起動できない状況に陥る可能性がある。   In the process of rewriting the normal operation service program using the normal operation service program rewriting program, the reset is performed between the erasure of the electrically erasable nonvolatile memory including the reset vector and the completion of the reset vector rewriting. If it occurs, the reset vector value becomes indefinite and even the normal operation service program rewrite program may not be restarted.

そこで、消去状態時リセットベクタを新たに設け、リセットベクタが消去値である場合に消去状態時リセットベクタをリセットベクタの代わりにプログラム開始アドレスとする。   Therefore, a reset vector is newly provided in the erase state, and when the reset vector is an erase value, the reset vector in the erase state is used as a program start address instead of the reset vector.

さらに、消去状態時リセットベクタ値として、通常動作サービスプログラム書換えプログラムの開始アドレスとすることにより、リセットベクタを含む電気的に消去可能な不揮発性メモリの消去から、リセットベクタ再書込み完了までの間にリセットが発生した場合でも、通常動作サービスプログラム書換えプログラムを再起動できるようにする。
(通常動作サービスプログラム書換えの動作説明)
図4A〜図4Gは、通常動作サービスプログラム書換えプログラムの通常動作サービスプログラム書換えのフローを示す図である。
In addition, by setting the reset vector value in the erase state as the start address of the normal operation service program rewrite program, the period between the erasure of the electrically erasable nonvolatile memory including the reset vector and the completion of the reset vector rewrite Even if a reset occurs, the normal operation service program rewriting program can be restarted.
(Explanation of normal operation service program rewriting)
4A to 4G are diagrams showing the normal operation service program rewriting flow of the normal operation service program rewriting program.

通常動作サービスプログラム書換えプログラムは、リセットベクタ消去状態でリセットが発生して消去状態時リセットベクタから起動するか、または通常動作サービスプログラムのプログラム書換えモード条件を検出したことのいずれかをきっかけとして起動される。   The normal operation service program rewrite program is started when either a reset occurs in the reset vector erase state and it starts from the reset vector in the erase state, or when the program rewrite mode condition of the normal operation service program is detected. The

図2では、通常動作サービスプログラム書換えプログラムが電気的に消去可能な不揮発性メモリブロック#3から電気的に消去可能な不揮発性メモリブロック#4(アドレス空間0x00A00000〜0x00DFFFFF)の領域に実装されている。   In FIG. 2, the normal operation service program rewrite program is mounted in the area of electrically erasable nonvolatile memory block # 3 to electrically erasable nonvolatile memory block # 4 (address space 0x00A00000 to 0x00DFFFFF). .

図4AのステップS01では初期設定を行う。通常動作サービスプログラム書換えプログラムが起動されると、最初に初期設定をして割込み禁止、通信インタフェース設定などを行う。   Initial setting is performed in step S01 of FIG. 4A. When the normal operation service program rewrite program is started, the initial setting is first performed to disable interrupts and set the communication interface.

割込み禁止初期設定は、通常動作サービスプログラムに使用する割込みベクタの値が電気的に消去可能な不揮発性メモリ内に残存または、消去状態において割込みが発生した場合に、通常動作サービスプログラム書換えプログラムの動作および、通常動作サービスプログラム書換えが正しく行われなくなるのを防ぐために行う。   Interrupt disable initial setting is the operation of the normal operation service program rewrite program when the interrupt vector value used for the normal operation service program remains in the electrically erasable nonvolatile memory or an interrupt occurs in the erased state. Also, it is performed to prevent the normal operation service program from being rewritten correctly.

通信インタフェース初期設定は、通信インタフェース4と通信回線5を介して通信インタフェース接続装置6より通常動作サービスプログラムを受信可能にするために行う。
ステップS02ではリセットベクタの読出しをする。つまり、通常動作サービスプログラムの書換えをするために、必要となるリセットベクタ値(0xFFFFFFFC〜0xFFFFFFFF番地)を読出す。
The communication interface initial setting is performed so that the normal operation service program can be received from the communication interface connection device 6 via the communication interface 4 and the communication line 5.
In step S02, the reset vector is read. That is, a reset vector value (addresses 0xFFFFFFFC to 0xFFFFFFFF) necessary for rewriting the normal operation service program is read.

ステップS03ではリセット情報レジスタの読出しをする。通常動作サービスプログラム書換えプログラムの起動要因を解析するために必要となるリセット情報レジスタを読出す。リセット情報レジスタには、リセット発生の有無、リセットの発生要因の情報が含まれる。   In step S03, the reset information register is read. Reads the reset information register necessary for analyzing the activation factor of the normal operation service program rewriting program. The reset information register includes information on whether or not a reset has occurred and information on the cause of the reset.

ステップS04では、リセットベクタ値が消去値であって、かつリセット情報レジスタのリセットの発生要因が、リセットによるものか判定する。
読出したリセットベクタ値とリセット情報レジスタ値より、通常動作サービスプログラム書換えプログラムがどのようなきっかけで起動されたかを解析し、ウォッチドッグタイマのクリアパターンを導き出す。
In step S04, it is determined whether the reset vector value is an erasure value and the cause of reset of the reset information register is due to reset.
Based on the read reset vector value and the reset information register value, it is analyzed how the normal operation service program rewriting program is started, and a clear pattern of the watchdog timer is derived.

リセットベクタ値が消去値であり、かつリセット情報レジスタ値の発生要因がリセットにより起動する場合に、ステップS05へ遷移する。
リセットベクタ値が消去値以外、またはリセット情報レジスタ値の発生要因がリセットによる起動以外の場合には、ステップS06へ遷移する。
If the reset vector value is an erasure value and the generation factor of the reset information register value is activated by reset, the process proceeds to step S05.
If the reset vector value is other than the erase value, or if the cause of generation of the reset information register value is other than activation by reset, the process proceeds to step S06.

ステップS05では、ウォッチドッグクリアパターンとしてウォッチドッグクリアパターンBをウォッチドッグクリアパターン変数へ設定する。
ステップS06では、ウォッチドッグクリアパターンとしてウォッチドッグクリアパターンAをウォッチドッグクリアパターン変数へ設定する。
In step S05, a watchdog clear pattern B is set as a watchdog clear pattern variable as a watchdog clear pattern.
In step S06, the watchdog clear pattern A is set as the watchdog clear pattern in the watchdog clear pattern variable.

上記のようにしてウォッチドッグタイマのクリアパターンをウォッチドッグクリアパターン変数に設定する。
図4Bに示すステップS07では通常動作サービスプログラム書換えプログラムが使用する変数情報の無効設定を行う。
Set the watchdog timer clear pattern to the watchdog clear pattern variable as described above.
In step S07 shown in FIG. 4B, invalid setting of variable information used by the normal operation service program rewriting program is performed.

無効にする変数情報は、リセットベクタ書込み情報電文受信フラグ、最終データ電文受信フラグである。
リセットベクタ書込み情報電文受信フラグは、通信インタフェース接続装置6よりリセットベクタ書込み情報を受信無し(未受信状態)を設定する。
The variable information to be invalidated is a reset vector write information message reception flag and a final data message reception flag.
The reset vector write information message reception flag sets no reception of reset vector write information from the communication interface connection device 6 (non-reception state).

最終データ電文受信フラグは、通信インタフェース接続装置6より電気的に消去可能な不揮発性メモリ書込み情報の最終電文を受信無し(未受信状態)を設定する。
ステップS08では、CPU2(通常動作サービスプログラム書換えプログラムの実装)は、通信インタフェース4を制御し、通信インタフェース接続装置6に対して、通信回線5を経由して通信インタフェース接続確立要求電文を送信する。
The final data message reception flag sets the reception of the final message of the nonvolatile memory write information that can be electrically deleted from the communication interface connection device 6 (not received).
In step S08, the CPU 2 (implementing the normal operation service program rewriting program) controls the communication interface 4 and transmits a communication interface connection establishment request message to the communication interface connection device 6 via the communication line 5.

ステップS09では、CPU2は、通信インタフェース接続装置6からの通信インタフェース接続確立応答電文の待ち状態となる。例えば、通信インタフェース接続確立応答電文の待ち状態ではループ処理により待ち受けをする。   In step S09, the CPU 2 waits for a communication interface connection establishment response message from the communication interface connection device 6. For example, in a waiting state of a communication interface connection establishment response message, it waits by loop processing.

ステップS10では、ウォッチドッグクリアパターン変数を使用してウォッチドッグタイマをクリアする。
ステップS11では、通信インタフェース接続装置6から送信された通信インタフェース接続確立応答電文の受信判定を行う。
In step S10, the watchdog timer is cleared using the watchdog clear pattern variable.
In step S11, it is determined whether or not the communication interface connection establishment response message transmitted from the communication interface connection device 6 is received.

通信インタフェース接続確立応答電文が、通常動作サービスプログラム書換えプログラムで受信された場合に、図4CのステップS14へ遷移する。通信インタフェース接続確立応答電文が受信されなかった場合には、ステップS12へ遷移する。   When the communication interface connection establishment response message is received by the normal operation service program rewriting program, the process proceeds to step S14 in FIG. 4C. If a communication interface connection establishment response message has not been received, the process proceeds to step S12.

ステップS12では、通信インタフェース接続装置6からの通信インタフェース接続確立応答電文の受信待ち時間のタイムアウトの判定を行う。
タイムアウト(受信期限切れ)の場合にはステップS08へ遷移し、ステップS08で再び通信インタフェース接続確立要求電文を送信する。
In step S12, the communication interface connection establishment response message from the communication interface connection device 6 is determined for timeout of reception waiting time.
In the case of time-out (reception expiration), the process proceeds to step S08, and a communication interface connection establishment request message is transmitted again in step S08.

タイムアウトでない場合(受信期限切れ以外)の場合には、ステップS09へ遷移する。
ステップS13では、通信インタフェース接続装置6が通常動作サービスプログラム書換えプログラムのステップS08で送信された通信インタフェース接続確立要求電文を受信すると、通信インタフェース接続確立応答電文を生成して通信回線5を介してCPU2へ送信する。これにより、CPU2と通信インタフェース接続装置6間の接続が確立する。
If it is not time-out (other than reception expiration), the process proceeds to step S09.
In step S13, when the communication interface connection device 6 receives the communication interface connection establishment request message transmitted in step S08 of the normal operation service program rewriting program, it generates a communication interface connection establishment response message and sends it to the CPU 2 via the communication line 5. Send to. Thereby, the connection between the CPU 2 and the communication interface connection device 6 is established.

図4CのステップS14では、リセットベクタ領域を含む電気的消去可能メモリブロック#5(アドレス空間0x00E00000〜0x00FFFFFF)の消去処理を起動し、ステップS15へ遷移する。   In step S14 of FIG. 4C, the erasing process of the electrically erasable memory block # 5 (address space 0x00E00000 to 0x00FFFFFF) including the reset vector area is started, and the process proceeds to step S15.

最初に電気的消去可能メモリブロック#5の電気的消去を行う理由は、リセットベクタを最初に消去してしまうことにより、以降リセットが発生しても、消去状態時リセットベクタにより通常動作サービスプログラム書換えプログラムが再起動できるようにするためである。   The reason why the electrically erasable memory block # 5 is electrically erased first is that the reset vector is erased first, so that even if a reset occurs thereafter, the normal operation service program is rewritten by the reset vector in the erased state. This is so that the program can be restarted.

ステップS15では、電気的に消去可能な不揮発性メモリの消去完了待ちループ処理となり、ウォッチドッグクリアパターン変数を使用し、ウォッチドッグタイマをクリアして、ステップS16へ遷移する。   In step S15, an electrically erasable non-volatile memory erasure completion waiting loop process is performed, the watchdog clear pattern variable is used to clear the watchdog timer, and the process proceeds to step S16.

ステップS16では、電気的に消去可能な不揮発性メモリの消去完了を監視する。
消去未完了の場合にはステップS15へ遷移する。消去完了の場合には、ステップS17へ遷移する。
In step S16, completion of erasure of the electrically erasable nonvolatile memory is monitored.
If the erasure is not completed, the process proceeds to step S15. If erasure is complete, the process proceeds to step S17.

ステップS17では、通常動作サービスプログラム格納領域となる電気的消去可能メモリブロック#0〜#2(アドレス空間0x00400000〜0x009FFFFF)の消去を起動し、ステップS18へ遷移する。   In step S17, erasure of the electrically erasable memory blocks # 0 to # 2 (address space 0x00400000 to 0x009FFFFF) serving as the normal operation service program storage area is activated, and the process proceeds to step S18.

ステップS18では、電気的に消去可能な不揮発性メモリの消去完了待ちループ処理となることから、ウォッチドッグクリアパターン変数を使用し、ウォッチドッグタイマをクリアしてステップS19へ遷移する。   In step S18, an electrically erasable non-volatile memory erasure completion waiting loop process is performed. Therefore, the watchdog clear pattern variable is used to clear the watchdog timer, and the process proceeds to step S19.

ステップS19では、電気的に消去可能な不揮発性メモリの消去完了を監視する。
消去未完了の場合にはステップS18へ遷移する。消去完了の場合には図4DのステップS20へ遷移する。
In step S19, completion of erasure of the electrically erasable nonvolatile memory is monitored.
If the erasure is not completed, the process proceeds to step S18. If erasure is complete, the process proceeds to step S20 in FIG. 4D.

図4DのステップS20では、通信インタフェース4を制御し、通信インタフェース接続装置6に対して、通信回線5を経由して通常動作サービスプログラム書込み情報転送要求電文を送信する。   In step S20 in FIG. 4D, the communication interface 4 is controlled, and a normal operation service program write information transfer request message is transmitted to the communication interface connection apparatus 6 via the communication line 5.

ステップS21では、通信インタフェース接続装置6からの通常動作サービスプログラム書込み情報の応答待ち状態となる。通常動作サービスプログラム書込み情報転送応答電文の応答待ち状態では、ループ処理となりステップS22へ遷移する。   In step S21, a response waiting state for the normal operation service program write information from the communication interface connection device 6 is awaited. In a response waiting state of the normal operation service program write information transfer response message, a loop process is performed and the process proceeds to step S22.

ステップS22では、ウォッチドッグクリアパターン変数を使用し、ウォッチドッグタイマをクリアして、ステップS23へ遷移する。
ステップS23では、通信インタフェース接続装置6からの通常動作サービスプログラム書込み情報転送応答電文が受信されたか判定を行う。ステップS25によって送信された応答電文が、受信された場合には、図4EのステップS26へ遷移する。受信されなか
った場合には、ステップS24へ遷移する。
In step S22, the watchdog clear pattern variable is used to clear the watchdog timer, and the process proceeds to step S23.
In step S23, it is determined whether a normal operation service program write information transfer response message from the communication interface connection device 6 has been received. When the response message transmitted in step S25 is received, the process proceeds to step S26 in FIG. 4E. If not received, the process proceeds to step S24.

ステップS24では、通信インタフェース接続装置6からの受信期限切れ判定を行う。
通常動作サービスプログラム書込み情報転送応答の受信期限切れの場合には、図4BのステップS07へ遷移する。
In step S24, the expiration date of reception from the communication interface connection device 6 is determined.
If the reception period of the normal operation service program write information transfer response has expired, the process proceeds to step S07 in FIG. 4B.

通常動作サービスプログラム書込み情報転送応答の受信期限切れ以外の場合には、ステップS21へ遷移する。
ステップS25では、通信インタフェース接続装置6が、通常動作サービスプログラム書換えプログラムのステップS20の通常動作サービスプログラム書込み情報転送要求電文送信処理によって送信された要求電文を受信した場合、ステップS25で通常動作サービスプログラム書込み情報転送応答電文の生成をして電文送信を行う。
When the normal operation service program write information transfer response is not expired, the process proceeds to step S21.
In step S25, when the communication interface connection device 6 receives the request message transmitted by the normal operation service program write information transfer request message transmission process in step S20 of the normal operation service program rewriting program, in step S25, the normal operation service program Generate a write information transfer response message and send a message.

通常動作サービスプログラム書込み情報転送応答電文には、書込みアドレス、プログラムデータ、データ長、最終データ判定情報を有する。
書込みアドレスは、電気的に消去可能な不揮発性メモリの書込みアドレス情報である。
The normal operation service program write information transfer response message has a write address, program data, data length, and final data determination information.
The write address is write address information of an electrically erasable nonvolatile memory.

プログラムデータは、電気的に消去可能な不揮発性メモリへ書込まれる通常動作サービスプログラム本体データである。
データ長は、電気的に消去可能な不揮発性メモリへの書込みデータ長情報である。
The program data is normal operation service program main body data written to an electrically erasable nonvolatile memory.
The data length is information on the length of data written to the electrically erasable nonvolatile memory.

最終データ判定情報は、通常動作サービスプログラム書込み情報転送応答電文の最終電文判定用情報である。
図4EのステップS26では、ステップS25の通常動作サービスプログラム書込み情報転送応答電文送信処理によって送信された応答電文の内容妥当性確認を実施する(書込みアドレス情報が、電気的消去可能メモリブロック領域外かなど)。
The final data determination information is final message determination information of a normal operation service program write information transfer response message.
In step S26 of FIG. 4E, the content validity check of the response message transmitted by the normal operation service program write information transfer response message transmission process of step S25 is performed (whether the write address information is outside the electrically erasable memory block area). Such).

ステップS27では、通常動作サービスプログラム書込み情報転送応答電文に異常があるか判定する。
ステップS25の通常動作サービスプログラム書込み情報転送応答電文送信処理によって送信された応答電文に異常があった場合、図4BのステップS07へ遷移する。
In step S27, it is determined whether there is an abnormality in the normal operation service program write information transfer response message.
When there is an abnormality in the response message transmitted by the normal operation service program write information transfer response message transmission process in step S25, the process proceeds to step S07 in FIG. 4B.

ステップS25の処理によって送信された応答電文に異常がなかった場合、ステップS28へ遷移する。
ステップS28では、受信電文最終データ判定情報が最終データか判定する。
When there is no abnormality in the response message transmitted by the process of step S25, the process proceeds to step S28.
In step S28, it is determined whether the received telegram final data determination information is final data.

受信電文が最終データ情報の場合はステップS29へ遷移する。受信電文が最終データ情報以外の場合はステップS31へ遷移する。
ステップS29では、最終データ電文受信フラグ情報が無効な場合、ステップS30へ遷移する。最終データ電文受信フラグ情報が有効(多重最終データ電文受信)な場合、図4BのステップS07へ遷移する。
If the received message is final data information, the process proceeds to step S29. If the received message is other than the final data information, the process proceeds to step S31.
In step S29, when the final data message reception flag information is invalid, the process proceeds to step S30. When the final data message reception flag information is valid (multiple final data message reception), the process proceeds to step S07 in FIG. 4B.

ステップS30では、最終データ電文正常受信と判断して最終データ電文正常受信ラグ情報を有効設定する。
ステップS31では、通常動作サービスプログラム書込み情報転送応答電文が、リセットベクタ書込み情報か判定する。
In step S30, it is determined that the final data message normal reception is normal, and the final data message normal reception lag information is enabled.
In step S31, it is determined whether the normal operation service program write information transfer response message is reset vector write information.

受信電文がリセットベクタ書込み情報の場合、ステップS32へ遷移する。受信電文がリセットベクタ書込み情報以外の場合、図4FのステップS34へ遷移する。
ステップS32では、リセットベクタ書込み情報電文受信フラグが無効な場合、ステッ
プS33へ遷移する。
If the received message is reset vector write information, the process proceeds to step S32. If the received message is other than reset vector write information, the process proceeds to step S34 in FIG. 4F.
In step S32, when the reset vector write information message reception flag is invalid, the process proceeds to step S33.

リセットベクタ書込み情報電文受信フラグ情報が有効な場合(多重リセットベクタ書込み電文を受信)、図4BのステップS07へ遷移する。
ステップS33では、リセットベクタ書込み情報電文受信フラグを有効に設定し、リセットベクタ書込み情報を退避する。
When the reset vector write information message reception flag information is valid (multiple reset vector write message is received), the process proceeds to step S07 in FIG. 4B.
In step S33, the reset vector write information message reception flag is set valid, and the reset vector write information is saved.

最終データ電文正常受信と判断しリセットベクタ書込み情報電文受信フラグを有効に設定し、電文内のリセットベクタ書込み情報を退避し、図4FのステップS34へ遷移する。   It is determined that the final data message is normally received, the reset vector write information message reception flag is set to be valid, the reset vector write information in the message is saved, and the process proceeds to step S34 in FIG. 4F.

ステップS34では、最終データ電文受信フラグが有効設定であり、かつリセットベクタ書込み情報電文受信フラグが無効設定の場合に、最終データ電文を受信したがリセットベクタ書込み情報電文が受信できていない場合、図4BのステップS07へ遷移する。   In step S34, when the final data message reception flag is valid and the reset vector write information message reception flag is invalid, the final data message is received but the reset vector write information message is not received. The process proceeds to step S07 in 4B.

最終データ電文受信フラグが有効設定以外、またはリセットベクタ書込み情報電文受信フラグが無効設定以外の場合、ステップS35へ遷移する。
ステップS35では、最終データ電文受信フラグが無効設定であり、かつリセットベクタ書込み情報電文受信フラグが有効設定の場合、ステップS36へ遷移する。
If the final data message reception flag is other than valid setting or the reset vector write information message reception flag is other than invalid setting, the process proceeds to step S35.
In step S35, if the final data message reception flag is invalid and the reset vector write information message reception flag is valid, the process proceeds to step S36.

最終データ電文受信フラグが無効設定以外、またはリセットベクタ書込み情報電文受信フラグが有効設定以外の場合、ステップS37へ遷移する。
ステップS36では、受信電文がリセットベクタ書込みの場合、リセットベクタ領域を最後に書換えるため、次の電文受信処理となる図4DのステップS20へ遷移する。
If the final data message reception flag is not set to invalid or the reset vector write information message reception flag is not set to valid, the process proceeds to step S37.
In step S36, when the received message is reset vector write, the process proceeds to step S20 in FIG. 4D, which is the next message reception process, in order to rewrite the reset vector area last.

受信電文が、リセットベクタ書込み以外の場合、電気的に消去可能な不揮発性メモリ書込みのため、図4GのステップS39へ遷移する。
ステップS37では、最終データ電文受信フラグが有効設定であり、かつリセットベクタ書込み情報電文受信フラグが有効設定の場合、ステップS38へ遷移する。
If the received telegram is other than reset vector writing, the process proceeds to step S39 in FIG. 4G for electrically erasable nonvolatile memory writing.
In step S37, when the final data message reception flag is set to valid and the reset vector write information message reception flag is set to valid, the process proceeds to step S38.

最終データ電文受信フラグが有効設定以外、またはリセットベクタ書込み情報電文受信フラグが有効設定以外の場合、図4GのステップS39へ遷移する。
ステップS38では、受信電文が、リセットベクタ書込みの場合、リセットベクタ領域の最終書換え条件が成立しているため、図4GのステップS43の退避リセットベクタ書込みデータを電気的消去可能メモリへの書込み起動処理へ遷移する。
If the final data message reception flag is not valid setting or the reset vector write information message reception flag is other than valid setting, the process proceeds to step S39 in FIG. 4G.
In step S38, if the received telegram is a reset vector write, the final rewrite condition of the reset vector area is satisfied, so the write reset processing of the saved reset vector write data in step S43 in FIG. 4G to the electrically erasable memory Transition to.

受信電文が、リセットベクタ書込み以外の場合、電気的に消去可能な不揮発性メモリ書込みのため、図4GのステップS39へ遷移する。
ステップS39では、電気的に消去可能な不揮発性メモリへの電文データ(通常動作サービスプログラム本体)の書込みを行う。
If the received telegram is other than reset vector writing, the process proceeds to step S39 in FIG. 4G for electrically erasable nonvolatile memory writing.
In step S39, the message data (normal operation service program main body) is written in the electrically erasable nonvolatile memory.

ステップS40では、電気的に消去可能な不揮発性メモリへの書込み完了待ちループ処理となることから、ウォッチドッグクリアパターン変数を使用し、ウォッチドッグタイマをクリアする。   In step S40, the process is a loop process for waiting for completion of writing to the electrically erasable nonvolatile memory, so the watchdog timer is cleared using the watchdog clear pattern variable.

ステップS41では、電気的に消去可能な不揮発性メモリへの書込み完了を監視する。
書込み未完了の場合には、ステップS40へ遷移する。書込み完了の場合には、ステップS42へ遷移する。
In step S41, completion of writing to the electrically erasable nonvolatile memory is monitored.
If writing has not been completed, the process proceeds to step S40. If the writing is completed, the process proceeds to step S42.

ステップS42では、最終データ電文受信フラグが有効設定、かつ、リセットベクタ書
込み情報電文受信フラグが有効設定の場合、リセットベクタ領域の最終書換え条件成立と判断し、ステップS43へ遷移する。最終データ電文受信フラグ有効設定以外、または、リセットベクタ書込み情報電文受信フラグが有効設定以外の場合、リセットベクタ領域の最終書換え条件不成立と判断し、次の電文受信処理となる図4DのステップS20へ遷移する。
In step S42, if the final data message reception flag is set valid and the reset vector write information message reception flag is set valid, it is determined that the final rewrite condition of the reset vector area is satisfied, and the process proceeds to step S43. If the final data message reception flag is not valid, or if the reset vector write information message reception flag is not valid, it is determined that the final rewrite condition in the reset vector area is not satisfied, and the process proceeds to step S20 in FIG. Transition.

ステップS43では、リセットベクタ書換え条件成立により、退避しておいたリセットベクタ書込みデータの書込みを行い、ステップS44へ遷移する。
ステップS44では、電気的に消去可能な不揮発性メモリへの書込み完了待ちループ処理となることから、ウォッチドッグクリアパターン変数を使用し、ウォッチドッグタイマをクリア、ステップS45へ遷移する
ステップS45では、通常動作サービスプログラム書換えプログラムは、電気的に消去可能な不揮発性メモリへの書込み完了を監視する。
In step S43, when the reset vector rewrite condition is satisfied, the saved reset vector write data is written, and the process proceeds to step S44.
In step S44, the write completion wait process for the electrically erasable non-volatile memory is performed. Therefore, the watchdog clear pattern variable is used to clear the watchdog timer, and the process proceeds to step S45. The operation service program rewriting program monitors the completion of writing to the electrically erasable nonvolatile memory.

書込み未完了の場合には、ステップS44へ遷移する。書込み完了の場合には、ステップS46へ遷移する。
ステップS46では、全ての電文データ書込みが完了したため、通信インタフェース接続装置6に対して、全書込み終了電文を送信し、ステップS47へ遷移する。
If writing has not been completed, the process proceeds to step S44. If the writing is completed, the process proceeds to step S46.
In step S46, since all message data writing has been completed, an all-write end message is transmitted to the communication interface connection device 6, and the process proceeds to step S47.

ステップS47では、自身のプログラムが格納されているオンボード基板1へ自律リセット起動を行い、書込みが完了した通常動作サービスプログラムをリセットベクタより開始させ、処理を終了する。   In step S47, autonomous reset activation is performed on the on-board board 1 storing its own program, the normal operation service program for which writing has been completed is started from the reset vector, and the process is terminated.

なお、上記実施例のフローに示した制御処理は、その制御処理を遂行させる命令が記述されたプログラムをコンピュータに実行させることにより実現することができる。
このプログラムをCD−ROMなどの記憶媒体に記憶しておけば、コンピュータ(CPU、FPGA、CPLDなどのプログラマブルな演算処理デバイス)に、そのプログラムをインストールすることにより、制御処理を実現することができる。また、このプログラムを通信ネットワークを介してコンピュータにダウンロードしてもよい。
Note that the control processing shown in the flow of the above embodiment can be realized by causing a computer to execute a program in which an instruction for performing the control processing is described.
If this program is stored in a storage medium such as a CD-ROM, control processing can be realized by installing the program in a computer (a programmable arithmetic processing device such as a CPU, FPGA, or CPLD). . Further, this program may be downloaded to a computer via a communication network.

また、本発明は、上記実施の形態に限定されるものでなく、本発明の要旨を逸脱しない範囲内で種々の改良、変更が可能である。   The present invention is not limited to the above-described embodiment, and various improvements and modifications can be made without departing from the gist of the present invention.

本発明における実施例にて動作するハードウェア構成を示す図である。It is a figure which shows the hardware constitutions which operate | move in the Example in this invention. 電気的に消去可能な不揮発性メモリのメモリマップの例を示す図である。It is a figure which shows the example of the memory map of the non-volatile memory which can be erased electrically. リセット発生から、プログラム開始に至るまでのハードウェア動作を示すフロー図である。It is a flowchart which shows the hardware operation | movement from reset generation to a program start. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention. 本発明における実施例の通常動作サービスプログラム書換えプログラム動作を示すフロー図である。It is a flowchart which shows normal operation service program rewriting program operation | movement of the Example in this invention.

符号の説明Explanation of symbols

1 オンボード基板
2 CPU
3 フラッシュメモリ
4 通信インタフェース
5 通信回線
6 通信インタスェース接続装置
1 On-board board 2 CPU
3 Flash memory 4 Communication interface 5 Communication line 6 Communication interface connection device

Claims (5)

CPUと電気的に消去可能な不揮発性メモリを備えるシステムのリセットベクタ消去を含むプログラム書換え方法であって、
リセット発生時、前記電気的に消去可能な不揮発性メモリに実装されたリセットベクタの値が電気的に消去されたかを判別し、
前記リセットベクタが消去されているとき、運用中消去不可能な領域に実装された消去状態時リセットベクタの示すアドレスから、通常動作時に実行されるプログラムであるサービスプログラムを書換えるプログラムを配置する、
ことを特徴とするリセットベクタ消去時プログラム書換え方法。
A program rewriting method including reset vector erasing of a system including a CPU and an electrically erasable nonvolatile memory,
When a reset occurs, determine whether the value of the reset vector mounted in the electrically erasable nonvolatile memory is electrically erased,
When the reset vector is erased, a program for rewriting a service program, which is a program executed during normal operation, is arranged from the address indicated by the reset vector in the erased state implemented in an area that cannot be erased during operation.
A method of rewriting a program when erasing a reset vector.
通常動作時に実行される前記サービスプログラムを書換えるプログラムは、
前記リセットベクタと前記サービスプログラムを有する前記電気的に消去可能な不揮発性メモリブロックの消去をし、
前記サービスプログラムを書き込んだのち、前記リセットベクタを書込むことを特徴とする請求項1に記載のリセットベクタ消去時プログラム書換え方法。
A program for rewriting the service program executed during normal operation is:
Erasing the electrically erasable nonvolatile memory block having the reset vector and the service program;
2. The reset vector erasing program rewriting method according to claim 1, wherein the reset vector is written after the service program is written.
リセット発生時、前記リセットベクタの値が電気的に消去された値以外と認識された場合、ウォッチドッグタイマのクリアパターンとして、第1のウォッチドッグクリアパターンを選択し、
リセット発生時、前記リセットベクタの値が電気的に消去された値と認識された場合、ウォッチドッグタイマのクリアパターンとして、第2のウォッチドッグクリアパターンを選択することを特徴とする請求項2に記載のリセットベクタ消去時プログラム書換え方法。
When a reset occurs, if the reset vector value is recognized to be other than an electrically erased value, the first watchdog clear pattern is selected as the watchdog timer clear pattern,
3. The second watchdog clear pattern is selected as a watchdog timer clear pattern when the reset vector value is recognized as an electrically erased value when a reset occurs. Program rewrite method at the time of reset vector erase described.
前記サービスプログラムの書換えプログラムは、
前記リセットベクタ値の読出し確認を行い、前記リセットベクタの値が電気的に消去された値以外と認識された場合、前記第1のウォッチドッグクリアパターンに基づいてウォッチドッグタイマをクリアし、
前記リセットベクタの値が電気的に消去された値と認識された場合、前記第2のウォッチドッグクリアパターンに基づいてウォッチドッグタイマをクリアする、
ことを特徴とする請求項3に記載のリセットベクタ消去時プログラム書換え方法。
The service program rewrite program is:
Performing read confirmation of the reset vector value, and if the reset vector value is recognized to be other than an electrically erased value, clear the watchdog timer based on the first watchdog clear pattern,
If the reset vector value is recognized as an electrically erased value, the watchdog timer is cleared based on the second watchdog clear pattern;
The method of rewriting a program at the time of reset vector erasing according to claim 3.
前記リセットベクタの消去状態であり、前記サービスプログラムの書換え中にリセットが発生したとき、前記サービスプログラムの書換えプログラムを起動可能とし、前記サービスプログラムの書換えを行うことを特徴とする請求項1に記載のリセットベクタ消去時プログラム書換え方法。   2. The service program rewrite according to claim 1, wherein when the reset vector is in an erased state and a reset occurs during rewriting of the service program, the service program rewrite program can be activated and the service program is rewritten. To rewrite the program when the reset vector is erased.
JP2007240226A 2007-09-14 2007-09-14 Program rewriting method in erasing reset vector Withdrawn JP2009070303A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007240226A JP2009070303A (en) 2007-09-14 2007-09-14 Program rewriting method in erasing reset vector

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007240226A JP2009070303A (en) 2007-09-14 2007-09-14 Program rewriting method in erasing reset vector

Publications (1)

Publication Number Publication Date
JP2009070303A true JP2009070303A (en) 2009-04-02

Family

ID=40606454

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007240226A Withdrawn JP2009070303A (en) 2007-09-14 2007-09-14 Program rewriting method in erasing reset vector

Country Status (1)

Country Link
JP (1) JP2009070303A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013021423A1 (en) * 2011-08-10 2013-02-14 トヨタ自動車株式会社 Reprogramming system and reprogramming method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013021423A1 (en) * 2011-08-10 2013-02-14 トヨタ自動車株式会社 Reprogramming system and reprogramming method

Similar Documents

Publication Publication Date Title
EP2638466B1 (en) Software updating process for an embedded device
JP4768237B2 (en) Portable electronic device and method for controlling portable electronic device
JP4784100B2 (en) Processing device and firmware download method thereof.
EP1647885A2 (en) Rewriting a non-volatile memory
JP2008009799A (en) Image forming device
KR20070044268A (en) Apparatus and method of processing booting in main board
JP2009070303A (en) Program rewriting method in erasing reset vector
JP2002189609A (en) System and method for updating software adapted to accident
JP2004192329A (en) Program rewriting method and terminal device
JP2002175193A (en) Device and method for rewriting program
JP4076113B2 (en) Electronic control unit
JP6334776B1 (en) Electronic control unit
JP5158883B2 (en) Firmware update method and firmware update apparatus
JP5341947B2 (en) IC card, control method of IC card, and control method of portable electronic device
JP2001344156A (en) Device with flash memory and data rewriting method
JP2009193511A (en) Controller, image processor, memory information storage control method, memory information storage control program, and storage medium
JP2008182327A (en) Programmable device controller, and method thereof
JP2002032238A (en) Program rewritable computer interface device for stencil printer and program rewriting method to be used for the same
JP2007069514A (en) Ink-jet recording device
US20240134651A1 (en) Download method of program to settlement terminal and settlement terminal
JP2005228225A (en) Memory card adaptor
JP2003122575A (en) Information processing unit
JP2009080592A (en) Firmware rewriting method
JP2004078294A (en) Signal processor
JP2004220474A (en) Electronic device, system returning method, program, and recording medium

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20101207