JP2008165729A - Microcomputer - Google Patents
Microcomputer Download PDFInfo
- Publication number
- JP2008165729A JP2008165729A JP2007200839A JP2007200839A JP2008165729A JP 2008165729 A JP2008165729 A JP 2008165729A JP 2007200839 A JP2007200839 A JP 2007200839A JP 2007200839 A JP2007200839 A JP 2007200839A JP 2008165729 A JP2008165729 A JP 2008165729A
- Authority
- JP
- Japan
- Prior art keywords
- rewrite
- memory
- program
- partial
- area
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 description 46
- 230000008569 process Effects 0.000 description 42
- 238000012545 processing Methods 0.000 description 13
- 238000010586 diagram Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 6
- 230000008859 change Effects 0.000 description 5
- 230000004913 activation Effects 0.000 description 4
- 230000002159 abnormal effect Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000005764 inhibitory process Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 239000000758 substrate Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Abstract
Description
本発明は、アプリケーションプログラムが記憶される書換え可能な不揮発性の第1メモリの書換えを、オンボード若しくはオンチップ上で実行可能に構成されるマイクロコンピュータに関する。 The present invention relates to a microcomputer configured to be able to execute rewriting of a rewritable nonvolatile first memory in which an application program is stored on board or on chip.
図12は、車両制御用のECU(Electronic Control Unit)を示すものである。ECU1は、基板2上にマイクロコンピュータ3やその他の図示しない周辺回路が搭載されて構成されている。そのマイコン3の制御プログラムは、フラッシュメモリ4のように書換え可能な不揮発性メモリに格納されている場合がある。そして、CPU5により実行されるフラッシュメモリ4上の制御プログラムは、デバッグやバージョンアップのため必要に応じて書換えを行うようにしている。
FIG. 12 shows an ECU (Electronic Control Unit) for vehicle control. The ECU 1 is configured by mounting a
フラッシュメモリ4の書換えを行う場合は、マイコン3を書換え用のモードに設定してリセットすることで、例えばマイコン3上のROM6に格納されている書換え用プログラムを起動し、CPU5が図示しない外部の書換え装置より転送されたデータを書き込む。例えば、特許文献1には、上記のようなフラッシュメモリの書換えに関する技術が開示されている。
ところで、マイコンに対して外部よりリセットをかけることが可能な構成であれば、フラッシュメモリの書換えを行っている途中に電源電圧が低下したり、書換え装置との間の通信線が断線するなどして書換えが失敗しても、マイコンをリセットすることで書換え用プログラムを起動し、同じ手順を繰り返すことで書換えを再試行すれば良い。
しかしながら、フィールドにおいて実際にECUが動作している場合は外部よりリセット制御を行う必要はないことから、リセットを行うための端子を余分に設けるのは冗長であり、コストの増大に繋がる。そこで、ECUについてはパワーオンリセットのみが作用するように構成するのが好ましい。
By the way, if the microcomputer can be reset from the outside, the power supply voltage drops while the flash memory is being rewritten, or the communication line to the rewrite device is disconnected. Even if rewriting fails, it is sufficient to start the rewriting program by resetting the microcomputer and retry the rewriting by repeating the same procedure.
However, when the ECU is actually operating in the field, it is not necessary to perform reset control from the outside. Therefore, providing an extra terminal for resetting is redundant, leading to an increase in cost. Therefore, it is preferable to configure the ECU so that only the power-on reset acts.
そして、ECUは、フィールドでは車両のバッテリからの電源供給を常時受けている状態にあるため、基本的にパワーオンリセットが発生することもない。また、リセットが発生しなければ、マイコンの動作モードを「書換えモード」等に切換える機会もないことから、モード切替え用の端子も不要となるはずである。
ところが、上記のような構成を想定すると、フラッシュメモリの書換えが途中で失敗すると書換えプログラムを起動する手段がなくなるため、フラッシュメモリの書換えを再度行うことができなくなってしまう。
And since ECU is in the state which always receives the power supply from the battery of a vehicle in a field, a power-on reset does not generate | occur | produce fundamentally. Further, if no reset occurs, there is no opportunity to switch the operation mode of the microcomputer to “rewrite mode” or the like, so that a terminal for mode switching should be unnecessary.
However, assuming the configuration as described above, if rewriting of the flash memory fails in the middle, there is no means for starting the rewriting program, so that rewriting of the flash memory cannot be performed again.
例えば、ECUがフラッシュメモリに書き込まれているアプリケーションプログラムを実行している通常動作状態で、外部の書込み装置より書換え指令が与えられたことを認識して書換えプログラムを起動すれば、1回は書換えを行うことができる。しかし、上記の書換えが途中で失敗すれば、それ以降アプリケーションプログラムは正常に実行されなくなるので、ECU上のCPUは書換え指令を認識することもできなくなる。従って、実際にはマイコンの端子数を減らすことが困難であった。 For example, in the normal operation state where the ECU is executing the application program written in the flash memory, if the rewriting program is started upon recognizing that the rewriting command is given from the external writing device, the rewriting is performed once. It can be performed. However, if the above rewriting fails midway, the application program will not be executed normally thereafter, and the CPU on the ECU will not be able to recognize the rewriting command. Therefore, it was actually difficult to reduce the number of terminals of the microcomputer.
本発明は上記事情に鑑みてなされたものであり、その目的は、不揮発性メモリの書換えが失敗した場合に、外部端子を介してモード切替えを行わずとも書換えプログラムを再起動できるマイクロコンピュータを提供することにある。 The present invention has been made in view of the above circumstances, and an object thereof is to provide a microcomputer capable of restarting a rewriting program without switching modes via an external terminal when rewriting of a nonvolatile memory fails. There is to do.
請求項1記載のマイクロコンピュータによれば、CPUにより書換えプログラムが実行されると、最初に第1メモリの書換えチェック領域をクリアしてから当該メモリの全領域の書換えを行ない、最後に書換えチェック領域に書換え完了コードを書込む。そして、CPUにより判定プログラムが実行されると、最初に第1メモリの書換えチェック領域を読出す。
ここで、書換えチェック領域のデータが書換え完了コードに一致する場合は、第1メモリの書換えは正常に完了していることを示すので、CPUはアプリケーションプログラムを実行する。一方、前記データが書換え完了コードに一致しない場合は、第1メモリの書換えが途中で失敗したことを示すので、CPUは書換えプログラムを再度実行する。
According to the microcomputer of claim 1, when the rewrite program is executed by the CPU, the rewrite check area of the first memory is cleared first, then the entire area of the memory is rewritten, and finally the rewrite check area Write the rewrite completion code in. When the determination program is executed by the CPU, first, the rewrite check area of the first memory is read.
Here, if the data in the rewrite check area matches the rewrite completion code, this indicates that the rewrite of the first memory has been completed normally, and the CPU executes the application program. On the other hand, if the data does not match the rewrite completion code, it indicates that the rewriting of the first memory has failed in the middle, so the CPU executes the rewriting program again.
即ち、例えばマイクロコンピュータのパワーオンリセットが解除されると、CPUが最初に判定プログラムを実行するように設定しておけば、書換えチェック領域を参照することで第1メモリのアプリケーションプログラムが正常に書き換えられているか否かを判定でき、書換えが失敗していた場合は再試行することができる。従って、第1メモリの書換えを再試行するために、マイコンの外部端子としてリセット端子やモード設定用の端子を設ける必要がなくなり、マイコンのパッケージを小型化してコストの低下を図ることができる。 That is, for example, when the power-on reset of the microcomputer is released, if the CPU is set to execute the determination program first, the application program in the first memory can be rewritten normally by referring to the rewrite check area. Whether rewriting has failed or not can be retried. Accordingly, it is not necessary to provide a reset terminal or a mode setting terminal as an external terminal of the microcomputer in order to retry the rewriting of the first memory, and the microcomputer package can be downsized to reduce the cost.
請求項2記載のマイクロコンピュータによれば、CPUにより書換えプログラムが実行されると、第1メモリの2つの書換え許可ID領域に同一のIDコードが書込まれる。そして、CPUが判定プログラムを実行した場合に、書換えチェック領域より読み出されたデータが書換え完了コードに一致しなければ第1,第2書換え許可ID領域を夫々読出し、両者のデータが共に前記IDコードに一致すれば書換えプログラムを実行する。即ち、上記のようにIDコードが一致すれば、当該メモリに書き込みを行った主体は第1メモリに対する正当なアクセス権を有していることが確認されるので、不正な書き込みを防止することができる。 According to the microcomputer of the second aspect, when the rewrite program is executed by the CPU, the same ID code is written in the two rewrite permission ID areas of the first memory. Then, when the CPU executes the determination program, if the data read from the rewrite check area does not match the rewrite completion code, the first and second rewrite permission ID areas are read, and both the data are the ID If it matches the code, the rewriting program is executed. That is, if the ID codes match as described above, it is confirmed that the subject who has written to the memory has a legitimate access right to the first memory, so that unauthorized writing can be prevented. it can.
請求項3記載のマイクロコンピュータによれば、CPUにより書換えプログラムが実行されると、第1メモリの2つのブロックに設定される第1,第2書換え許可ID領域に、同一のIDコードを書込み、CPUが判定プログラムを実行した場合に書換えチェック領域より読み出されたデータが書換え完了コードに一致しなければ、2つのブロックについて、第1,第2書換え許可ID領域を夫々読出す。そして、何れか一方のブロックにおける両者の読出しデータが共にIDコードに一致すれば書換えプログラムを実行する。
According to the microcomputer of
即ち、第1メモリの2つのブロックについては、同時に消去や書き込みが行われることはない。そして、第1メモリの書換えが途中で失敗すると、そのタイミングによっては一方のブロックが書換えられていない場合が想定されるので、IDコードが確認できなくなる。そこで、書換えプログラムにおいて、2つのブロックに対して同じようにIDコードを書き込むようにして、各ブロック毎にIDコードの一致を判定すれば、何れか一方のブロックで確実に一致を確認することができる。 That is, the two blocks of the first memory are not erased or written at the same time. If rewriting of the first memory fails in the middle, depending on the timing, it is assumed that one block has not been rewritten, and therefore the ID code cannot be confirmed. Therefore, in the rewriting program, if the ID code is written to the two blocks in the same manner and the ID code match is determined for each block, the match can be reliably confirmed in either one of the blocks. it can.
請求項4記載のマイクロコンピュータによれば、CPUにより部分書換えプログラムが実行されると、最初に第1メモリの部分書換えチェック領域をクリアしてから当該メモリの書換えを開始位置から前記終了位置まで行ない、最後に部分書換えチェック領域に部分書換え完了コードを書込む。そして、CPUが判定プログラムを実行し、書換えチェック領域より読み出したデータが書換え完了コードに一致する場合は、続いてフラグ格納領域を参照し、許可が設定されていれば第1メモリの部分書換えチェック領域を読出す。
その読み出しデータが部分書換え完了コードに一致する場合はアプリケーションプログラムを実行し、前記データが部分書換え完了コードに一致しない場合は部分書換えプログラムを実行する。従って、第1メモリの一部だけを書換えている途中でその書換えが失敗した場合についても、請求項1と同様の効果を得ることができる。
According to the microcomputer of
When the read data matches the partial rewrite completion code, the application program is executed, and when the data does not match the partial rewrite completion code, the partial rewrite program is executed. Therefore, the same effect as in claim 1 can be obtained even when rewriting fails while rewriting only a part of the first memory.
請求項5記載のマイクロコンピュータによれば、CPUが書換えプログラムを実行すると、第1メモリの第1,第2書換え許可ID領域に同一のIDコードを書込むと共に、フラグ格納領域への部分書換えの許可/禁止設定,開始位置及び終了位置の書き込み設定も行う。そして、CPUが判定プログラムを実行し、書換えチェック領域より読み出したデータが書換え完了コードに一致すれば、第1,第2書換え許可ID領域を夫々読出し、両者の読出しデータが共にIDコードに一致すればフラグ格納領域を参照する。従って、第1メモリの部分書き換えを行なう場合についても、IDコードの一致確認を行うことができる。 According to the microcomputer of claim 5, when the CPU executes the rewrite program, the same ID code is written in the first and second rewrite permission ID areas of the first memory, and the partial rewrite to the flag storage area is performed. Enable / disable setting, write setting of start position and end position are also performed. When the CPU executes the determination program and the data read from the rewrite check area matches the rewrite completion code, the first and second rewrite permission ID areas are read out, and both read data match the ID code. Refer to the flag storage area. Therefore, even when partial rewriting of the first memory is performed, ID code matching can be confirmed.
請求項6記載のマイクロコンピュータによれば、請求項1における書換えチェック領域を全書換えチェック領域として、第1メモリには、請求項4における部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とが、前記全書換えチェック領域と共に当該第1メモリについて定められている最小書込み単位内のサイズで設定される。また、第1メモリの全書換え,部分書き換えについては、夫々請求項1,4と同様に実行される。ここで、「最小書込み単位」とは、1回のライトサイクルにおいて第1メモリに書き込まれるデータの最小サイズであり、マイクロコンピュータの設計仕様に応じて定められる。
According to the microcomputer of
そして、CPUにより判定プログラムが実行されると、最初に第1メモリの全書換えチェック領域を読出し、そのデータが全書換え完了コードに一致しない場合は全書換えプログラムを実行する。また、前記データが全書換え完了コードに一致すれば続いてフラグ格納領域を参照し、許可が設定されていれば部分書換えチェック領域を読出し、そのデータが部分書換え完了コードに一致すればアプリケーションプログラムを実行し、前記データが部分書換え完了コードに一致しない場合は部分書換えプログラムを実行する。
即ち、第1メモリの部分書き換えに関する情報は、少なくとも全書換えが1回完了した後に意味を成すので、部分書き換え情報を、全書換えチェック領域と共に最小書込み単位内のサイズで持たせれば、情報量を低減して有効に利用できる。その結果、判定プログラムの実行をより短時間内に完了することができる。
When the determination program is executed by the CPU, first, the entire rewrite check area of the first memory is read, and if the data does not match the complete rewrite completion code, the complete rewrite program is executed. If the data matches the complete rewrite completion code, the flag storage area is referred to.If permission is set, the partial rewrite check area is read. If the data matches the partial rewrite completion code, the application program is read. If the data does not match the partial rewrite completion code, the partial rewrite program is executed.
That is, the information related to the partial rewrite of the first memory is meaningful at least after the complete rewrite is completed once. Therefore, if the partial rewrite information has the size within the minimum write unit together with the full rewrite check area, the amount of information is reduced. Reduced and can be used effectively. As a result, the execution of the determination program can be completed within a shorter time.
請求項7記載のマイクロコンピュータによれば、部分書換えチェック領域に、その次に部分書き換えを行なう対象とする領域について、部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とを最小書込み単位内のサイズで設定し、その部分書換えチェック領域を1つ以上配置する。従って、部分書換えを、アドレスが不連続となる複数の領域についても行なうことができる。 According to the microcomputer of the seventh aspect, in the partial rewrite check area, for the area to be subjected to partial rewrite next, the storage area of the flag for setting permission / prohibition of partial rewrite, the start position, and the end position Is set to a size within the minimum writing unit, and one or more partial rewrite check areas are arranged. Therefore, partial rewriting can be performed for a plurality of areas where the addresses are discontinuous.
請求項8記載のマイクロコンピュータによれば、CPUは、判定プログラムを、リセット時に実行するので、第1メモリに対する書き込みが正常に行なわれているか否かをリセットが解除された場合にチェックすることで、誤った書込み或いはデータ化けなどが発生している場合にユーザプログラムの実行を停止して、プログラムの暴走を未然に防止することができる。 According to the microcomputer of the eighth aspect, since the CPU executes the determination program at the time of resetting, the CPU checks whether or not the writing to the first memory is normally performed when the reset is released. When an erroneous writing or data corruption occurs, the execution of the user program can be stopped to prevent the program from running out of control.
請求項9記載のマイクロコンピュータによれば、CPUは、判定プログラムを、低消費電力モードが解除された時点(ウエイクアップ時)に実行するので、第1メモリに対する書き込みが正常に行なわれているか否かをウエイクアップ時にチェックすることで、誤った書込み或いはデータ化けなどが発生している場合にユーザプログラムの実行を停止して、プログラムの暴走を未然に防止することができる。 According to the microcomputer of the ninth aspect, since the CPU executes the determination program when the low power consumption mode is canceled (during wake-up), whether or not writing to the first memory is normally performed. By checking this at the time of wakeup, the execution of the user program can be stopped and the program runaway can be prevented beforehand when erroneous writing or data corruption occurs.
(第1実施例)
以下、本発明の第1実施例について図1乃至図5を参照して説明する。図5は、本発明のマイクロコンピュータ11の構成を示すブロック図である。マイコン11は、例えば、マイコン3と同様に車両制御用ECUを構成するもので、CPU12を中心として、ROM(第2メモリ)13,RAM14,フラッシュメモリ(第1メモリ)15,フラッシュコントローラ16,通信回路17などを備えており、これらはアドレスバス18及びデータバス19を介して接続されている。
(First embodiment)
Hereinafter, a first embodiment of the present invention will be described with reference to FIGS. FIG. 5 is a block diagram showing the configuration of the
フラッシュメモリ15には、CPU12によって実行されるECUとしての制御プログラムであるユーザプログラム20が記憶されるようになっている。ROM13には、フラッシュメモリ15にユーザプログラム20を書き込むための書換えプログラム21と、ユーザプログラム20,書換えプログラム21の何れを実行するかを決定するため、フラッシュメモリ15のステータスを判定する判定プログラム22が記憶されている。フラッシュコントローラ16は、CPU12がフラッシュメモリ15にアクセスする場合に、フラッシュメモリ15のブロック管理やエラー訂正処理などを行なうものである。
The
通信回路17は、例えば、UARTやその他のシリアル通信、又はCAN等の車内LANなどのプロトコルに対応した通信インターフェイスであり、フラッシュメモリ15のユーザ(アプリケーション)プログラム20を書換える場合には、外部の書換え装置23との間で通信を行うようになっている。そして、書換え装置23より転送された書換えデータ24は、RAM14に書き込まれる。
The
次に、本実施例の作用について図1乃至図3も参照して説明する。尚、フラッシュメモリ15に対するユーザプログラム20の最初の書き込みは、ROMライタなどを使用して予め行われていることを前提とする(或いは、後述する図1のステップS6において「NO」と判断された場合に、ユーザプログラム20に分岐することに替えて書換えプログラム21に分岐させることで、フラッシュメモリ15に対する最初の書き込みを行なわせることも可能である)。
Next, the operation of this embodiment will be described with reference to FIGS. Note that the initial writing of the
図2は、フラッシュメモリ15のメモリマップを示すもので、図3は、書換えプログラム21による全書換え処理の手順、及びその書換え処理に伴うフラッシュメモリ15の状態変化を示すものである。図2に示すように、フラッシュメモリ15は、例えば、64Kバイトを単位とするブロック0〜nに分割されており、書換え処理もブロックを単位として行われる。
そして、先頭ブロック0には、「全書換え」の完了を示す「FLASHステータス0(書換えチェック領域)」と「ID領域2」とが配置され、終了ブロックnには「ID領域1」が配置されるようになっている。また、ブロック6は、一例として「部分書換え」が行われる場合の先頭ブロックに設定されており、「部分書換え」の完了を示す「FLASHステータス1(部分書換えチェック領域)」が配置されている。
FIG. 2 shows a memory map of the
Then, “FLASH status 0 (rewrite check area)” and “
「FLASHステータス0」には、全書換え処理が完了した段階で、所定のデータ、例えば55AA…55AAHが書き込まれる。「FLASHステータス1」も同様に、部分書換え処理が完了した段階で、例えば「55AA…55AA(以下、データ値はHEXで示す)」が書き込まれる。「ID領域2」と「ID領域1」には同じデータが書き込まれるようになっており、後述する照合確認のために使用される。
これらの「ID領域」には、フラッシュメモリ15の書換えを許可するIDやパスワードなどが格納され、当該領域の先頭と末尾には、同一のIDステータス(IDコード)1,2が書き込まれる。また、部分書換えの許可/禁止を設定するためのフラグ格納領域と、部分書換えの開始ブロック番号,終了ブロック番号を格納する領域や、その他プログラムIDやパスワードなどが格納される。
In the “
In these “ID areas”, IDs and passwords that permit rewriting of the
<全書換え処理>
図3に示す全書換え処理において、CPU12は、最初にブロック0の「FLASHステータス0」にデータ「0000…0000」を書き込んでクリアしてから、各ブロック0,…,6,…,n毎に、「消去」、「書込み」、「ベリファイ」を順次行ってゆく。そして、最後に「FLASHステータス0」にデータ「55AA…55AA」を書き込んで処理を終了する。
尚、ID領域2,1の「部分書換え」に関するデータは、後に「部分書換え」を行なうケースがあるか否かに応じて、この段階で許可/禁止の設定や、開始,終了ブロック番号の設定を書き込んでおくようにする。
<All rewrite processing>
In the all-rewrite process shown in FIG. 3, the
It should be noted that the data related to “partial rewrite” in the
また、図3には、全書換え処理の進行に伴い、「FLASHステータス0,1」,ID領域2,1の「IDステータス1,2」の書き込みデータが変化する状態を示している。フラッシュメモリ15に既に書き込みが行われていると、「FLASHステータス0」のデータは「55AA…55AA」になっている。そして、最初にデータ「0000…0000」が書き込まれるが、次のブロック0の消去で「FFFF…FFFF」に変化し、次の「書込み」では「FLASHステータス0」の書き込みは行わないようにして、上記データ値を維持する。そして、最後の書込み処理で「55AA…55AA」に戻る。従って、全書換え処理中の「FLASHステータス0」は、「55AA…55AA」以外の値になっている。
Further, FIG. 3 shows a state in which the write data of “
また、「FLASHステータス1」も、既に書き込みが行われている状態では初期値が「55AA…55AA」になっているが、ブロック6の消去で「FFFF…FFFF」に変化し、次の「書込み」で「55AA…55AA」に書き戻される。ID領域2の「IDステータス2_1,2_2」も、初期値は「55AA…55AA」、ブロック0の消去で「FFFF…FFFF」、次の「書込み」で「55AA…55AA」に書き戻される。ID領域1の「IDステータス1_1,1_2」も、同様に初期値は「55AA…55AA」、ブロックnの消去で「FFFF…FFFF」、次の「書込み」で「55AA…55AA」に書き戻される。
In addition, “FLASH status 1” has an initial value of “55AA... 55AA” in a state where writing has already been performed, but changes to “FFFF... FFFF” by erasing
尚、全書換え処理中の「ベリファイ」において書込みエラーが検出されると、CPU12はその時点で内部リセットを発生させてリセットベクタから実行を開始し、判定プログラム22、即ち、図1に示すフラッシュステータス判定処理を実行するようになっている。また、例えば、全書換え処理を開始してから終了するまでの時間をタイマによりカウントし、所定時間内に処理が終了しない場合(タイムアウト)に内部リセットを発生させても良い。図1において、CPU12は、フラッシュメモリ15の「FLASHステータス0」を読み出して、そのデータ値が書換え完了コード「55AA…55AA」に一致するかどうかを判定する(ステップS1)。
When a write error is detected in “verify” during the entire rewrite process, the
「FLASHステータス0」のデータ値が書換え完了コードに一致しなければ(「NO」)、CPU12は、ID領域2の「IDステータス2_1,2_2」が何れも正常コード「55AA…55AA」であるか否かを判断する(ステップS5)。そして、何れも正常コードであれば(「YES」)、ID領域2に書き込まれているIDやパスワードは有効であると判定し、書換えプログラム21の実行を開始する。この場合、書換えプログラム21は、ID領域2に書き込まれているIDやパスワードについて認証を行い、その認証結果が「OK」であれば図3のフローチャートの処理を開始する。
If the data value of “
また、ステップS5において「NO」と判断すると、CPU12はステップS6に移行し、ID領域1の「IDステータス1_1,1_2」が何れも正常コード「55AA…55AA」であるか否かを判断する。そして、何れも正常コードであれば(「YES」)、ID領域1に書き込まれているIDやパスワードは有効であると判定し、書換えプログラム21の実行を開始する。
即ち、図3に示すように、ID領域2,1の何れか一方について、正しく書き込みが行われない状態で全書換え処理が終了すると、そのIDステータスは「FFFF…FFFFF」となっており、正常なデータが書き込まれていない。しかし、他方のID領域には必ず正常なデータが書き込まれているので、何れか有効な方を選択するようにしている。
If “NO” is determined in the step S5, the
That is, as shown in FIG. 3, when the entire rewriting process is completed in a state where writing is not correctly performed for either one of the
また、ID領域2,1の何れも正常なデータでない場合(ステップS6,「NO」)、CPU12はユーザプログラム20を実行する。この場合は、何らかの理由により、ユーザプログラム20に対する一番最初の書き込みが正常に行われていなかったか、或いはフラッシュメモリ15の一部やバス18,19に故障が発生した、といったような異常状態と推定される。
従って、このまま書換えを実行すると、フラッシュメモリ15に異常なデータが書き込まれるおそれがあることから、ユーザプログラム20に分岐する。そして、当該プログラム20に用意されているメモリチェックルーチンが正常であれば、そのチェックルーチンによりフラッシュメモリ15のチェックサムを計算する。その結果、異常が判定されればエラー処理を行う。この場合、フラッシュメモリ15に正常な書き込みを行うことは不能であるから、必要に応じて部品交換などの処置を行うようにする。
If neither of the
Therefore, if rewriting is executed as it is, abnormal data may be written to the
<部分書換え処理>
また、図4は、フラッシュメモリ15の部分書換え処理を示す。部分書換え処理については、前述したように、フィールドにおいてECU−マイコン11に電源が投入された状態のまま、ユーザプログラム20の一部を書換えてバージョンアップを行う場合を想定している。従って、マイコン11がユーザプログラム20を実行している状態で、書換え装置23を接続し、その書換え装置23が部分書換え指令を発行すると、ユーザプログラム20中においてその部分書換え指令を認識し、図4の部分書換え処理を実行する。また、フラッシュメモリ15のブロック0は、部分書換えの対象としないように予め決定されている。
<Partial rewrite processing>
FIG. 4 shows a partial rewriting process of the
図4は、ブロック6の部分書換えを行なう場合であり、ID領域の開始ブロック番号,終了ブロック番号は何れも「6」に設定されている。尚、部分書換えプログラムは、書換えプログラム21の一部となっている。CPU12は、最初にブロック6の「FLASHステータス1」にデータ「0000…0000」を書き込んでクリアしてから、ブロック6の「消去」、「書込み」、「ベリファイ」を順次行う。そして、最後に「FLASHステータス1」にデータ「55AA…55AA」を書き込んで処理を終了する。
FIG. 4 shows a case where partial rewriting of the
また、図4には、部分書換え処理の進行に伴い、「FLASHステータス1」の書き込みデータが変化する状態を示している。尚、ブロック6のみしか書換えを行なわないため、「FLASHステータス0」,ID領域2,1の「IDステータス1,2」のデータは「55AA…55AA」のままである。
FIG. 4 shows a state in which the write data of “FLASH status 1” changes with the progress of the partial rewriting process. Since only the
この場合、フラッシュメモリ15に既に書き込みが行われているので、「FLASHステータス1」のデータは「55AA…55AA」になっている。そして、最初にデータ「0000…0000」が書き込まれるが、次のブロック6の消去で「FFFF…FFFF」に変化し、次の「書込み」では「FLASHステータス1」の書き込みは行わず、上記データ値を維持する。そして、最後の書込み処理で「55AA…55AA」に戻る。従って、部分書換え処理中の「FLASHステータス0」は、「55AA…55AA」以外の値になっている。
In this case, since the
また、部分書換えにおけるブロック6の「ベリファイ」において書込みエラーが検出された場合も、CPU12は同様にその時点で内部リセットを発生させてリセットベクタから実行を開始し、図1に示すフラッシュステータス判定処理を実行する。この場合、「FLASHステータス0」のデータ値は書換え完了コードに一致するので、CPU12はステップS1で「YES」と判定し、ステップS5と同様にID領域2の「IDステータス2_1,2_2」が何れも正常コードであるか否かを判断する(ステップS2)。
Further, when a write error is detected in the “verify” of the
ID領域2のステータスが正常コードであれば(「YES」)、CPU12は同領域において部分書換えが「許可」に設定されているか否かを判断する(ステップS3)。そして、「許可」に設定されていれば(「YES」)、ブロック6の「FLASHステータス1」を読出し、データ値が書換え完了コード「55AA…55AA」に一致するか否かを判断する(ステップS4)。書換え完了コードに一致しなければ(「NO」)書換えプログラム21に分岐し、図4の部分書換え処理を再試行する。
If the status of the
尚、部分書換え処理の場合、ブロック0は書換え対象より外されているので、基本的にステップS2では「YES」と判断されるはずであり、「NO」と判断されるのは、ステップS6で「NO」と判断される場合と同様に異常な状態である。従って、同様にユーザプログラム20に分岐し、メモリチェックルーチンを実行する。また、ステップS5,S6のように、ブロックnのID領域1の確認を重ねて行う必要はない。
In the case of the partial rewriting process, since
また、CPU12における内部リセットの発生は、その他、ウォッチドックタイマなどにより暴走を検知した場合やバスエラーなどによっても発生するので、その場合も図1の判定処理は実行される。この時、フラッシュメモリ15の書換えが正常に行われていれば、判定処理ではステップS1〜S4において何れも「YES」と判定されるので、CPU12は判定処理を抜けてユーザプログラム20へ分岐し、当該プログラム20を実行する。また、ステップS3において、部分書換え処理が「禁止」に設定されている場合も(「NO」)、ユーザプログラム20に分岐する。
In addition, the occurrence of an internal reset in the
以上のように本実施例によれば、マイコン11のCPU12により書換えプログラム21が実行されると、最初にフラッシュメモリ15のFLASHステータス0をクリアしてから当該メモリ15の全領域の書換えを行ない、最後にFLASHステータス0に書換え完了コード「55AA…55AA」を書込む。そして、CPU12が判定プログラム22を実行すると、最初にフラッシュメモリ15のFLASHステータス0を読出し、そのデータが書換え完了コードに一致しない場合、CPU12は書換えプログラム21を再度実行する。
As described above, according to this embodiment, when the
即ち、CPU12が判定プログラム22を実行してFLASHステータス0を参照すれば、フラッシュメモリ15のユーザプログラム20が正常に書き換えられているか否かを判定でき、書換えが失敗していた場合は再試行できる。従って、フラッシュメモリ15の書換えを再試行するために、マイコン11の外部端子としてリセット端子やモード設定用の端子を設ける必要がなくなり、マイコン11のパッケージを小型化してコストの低下を図ることができる。
That is, if the
また、CPU12が書換えプログラム21を実行すると、フラッシュメモリ15の2つのIDステータス2_1,2_2に同一のIDコードを書込み、判定プログラム22を実行した場合に、FLASHステータス0のデータが書換え完了コードに一致しなければIDステータス2_1,2_2を夫々読出し、両者のデータが共に前記IDコードに一致すれば書換えプログラム21を実行するので、メモリ15に書き込みを行った主体が正当なアクセス権を有していることを確認して、不正な書き込みを防止できる。
Further, when the
更に、フラッシュメモリ15の2つのブロック0,nに設定されるIDステータス2,1に同一のIDコードを書込み、CPU12が判定プログラム22を実行し、FLASHステータス0のデータが書換え完了コードに一致しなければ、2つのブロック0,nについてIDステータス2,1を夫々読出し、何れか一方のブロックで両者の読出しデータが共にIDコードに一致すれば書換えプログラム21を実行する。従って、フラッシュメモリ15の書換えが途中で失敗した場合でも、何れか一方のブロックで確実にIDコードの一致を確認できる。
Further, the same ID code is written to the
また、CPU12により書換えプログラム21の一部である部分書換えプログラムが実行されると、最初にフラッシュメモリ15のFLASHステータス1をクリアし、当該メモリの書換えを開始位置から終了位置まで行ない、最後に部分FLASHステータス1に部分書換え完了コード「55AA…55AA」を書込む。
そして、CPU12が判定プログラム22を実行し、FLASHステータス1のデータが書換え完了コードに一致する場合は、続いてフラグ格納領域を参照し、許可が設定されていればFLASHステータス1を読出す。その読み出しデータが部分書換え完了コードに一致しない場合は部分書換えプログラムを実行するので、フラッシュメモリ15の一部だけを書換えている途中でその書換えが失敗した場合について、全領域書換えの場合と同様の効果を得ることができる。例えば、フィールドにおいてユーザプログラム20の一部を書換えてバージョンアップを図る場合などに有効である。
When the partial rewrite program which is a part of the
Then, when the
加えて、CPU12が書換えプログラム21を実行すると、フラッシュメモリ15のIDステータス2_1,2_2に同一のIDコードを書込むと共にフラグ格納領域への部分書換えの許可/禁止設定,開始位置及び終了位置の書き込み設定も行う。そして、CPU12が判定プログラム22を実行し、FLASHステータス0より読み出したデータが書換え完了コードに一致すれば、IDステータス2_1,2_2を夫々読出し、両者の読出しデータが共にIDコードに一致すればFLASHステータ1を参照するので、フラッシュメモリ15の部分書き換えを行なう場合についても、IDコードの一致確認を行うことができる。
In addition, when the
更にまた、CPU12は、判定プログラム22を、リセット時に実行するので、フラッシュメモリ15に対する書き込みが正常に行なわれているか否かをリセットが解除された場合にチェックすることで、誤った書込み或いはデータ化けなどが発生している場合にユーザプログラム20の実行を停止して、プログラム20の暴走を未然に防止することができる。
Furthermore, since the
(第2実施例)
図6乃至図9は本発明の第2実施例を示すものであり、第1実施例と同一部分には同一符号を付して説明を省略し、以下異なる部分について説明する。図6は、第1実施例の図2相当図である。第2実施例では、先頭ブロック0の冒頭16バイトに、「FLASHステータス0」と共に、部分書換えの許可/禁止を設定するためのフラグ格納領域と、部分書換えの開始ブロック番号,終了ブロック番号を格納する領域とが配置されている。そして、「ID領域2」,「ID領域1」は削除されている。また、終了ブロックnについては、第1実施例と異なり、格別な領域設定は行われていない。ブロック6は、第1実施例と同様に「部分書換え」が行われる場合の先頭ブロックに設定され、「FLASHステータス1」が配置されている。
(Second embodiment)
6 to 9 show a second embodiment of the present invention. The same parts as those in the first embodiment are denoted by the same reference numerals and the description thereof will be omitted. Hereinafter, different parts will be described. FIG. 6 is a diagram corresponding to FIG. 2 of the first embodiment. In the second embodiment, in the first 16 bytes of the
尚、16バイトは、フラッシュコントローラ16がフラッシュメモリ15に対してデータの書込みを行う場合の最小書込み単位として設定されているサイズである。即ち、CPU12がフラッシュメモリ15に1バイトのデータを書き込む場合でも、フラッシュコントローラ16はエラーチェックを行なうため、上記1バイトデータのアドレスを含む連続した16バイトのデータを単位として、書込み(リード・モディファイ・ライト)を行なうようになっている。
The 16 bytes is a size set as a minimum writing unit when the flash controller 16 writes data to the
次に、第2実施例の作用について説明する。
<全書換え処理>
図7に示す全書換え処理において、部分書換え許可禁止フラグは「許可」=「01H」,部分書換え開始ブロック/終了ブロックは「0006H」に設定されている。CPU12は、最初にブロック0の「FLASHステータス0」にデータ「0000…0000」を書き込んでクリアすると共に、部分書換え許可禁止フラグ,部分書換え開始ブロック/終了ブロックの格納領域もゼロクリアする。そして、第1実施例と同様に、各ブロック0,…,6,…,n毎に、「消去」、「書込み」、「ベリファイ」を順次行ってゆく。そして、最後に「FLASHステータス0」にデータ「55AA…55AA」を書き込むと共に、部分書換え許可禁止フラグを「01H」に、部分書換え開始ブロック/終了ブロックに「0006H」を書き込んで処理を終了する。すなわち、「FLASHステータス0,1」に関しては、データ値の変化は第1実施例と全く同様である。
Next, the operation of the second embodiment will be described.
<All rewrite processing>
In the full rewrite process shown in FIG. 7, the partial rewrite permission prohibition flag is set to “permitted” = “01H”, and the partial rewrite start block / end block is set to “0006H”. The
<部分書換え処理>
また、図8は、フラッシュメモリ15の部分書換え処理を示す。部分書換え処理についても、「FLASHステータス1」に関するデータ値の変化は第1実施例と全く同様である。そして、「FLASHステータス0」,部分書換え許可禁止フラグの状態、並びに部分書換え開始ブロック/終了ブロックの値は初期値のまま変化しない。
図9は、図1相当のフラッシュステータス判定処理であり、ステップS1,S3,S4のみとなっている。すなわち、第2実施例ではIDステータスが正常コードであるか否かをチェックしないため、判定処理が簡単になっている。
<Partial rewrite processing>
FIG. 8 shows a partial rewriting process of the
FIG. 9 shows the flash status determination process corresponding to FIG. 1 and includes only steps S1, S3 and S4. That is, in the second embodiment, since it is not checked whether the ID status is a normal code, the determination process is simplified.
以上のように第2実施例によれば、部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とを、全書換えチェック領域と共にフラッシュメモリ15の最小書込み単位のサイズで設定した。即ち、フラッシュメモリ15の部分書き換えに関する情報は、少なくとも全書換えが1回完了した後に意味を成すので、部分書き換え情報を、全書換えチェック領域と共に最小書込み単位のサイズで持たせれば、情報量を低減した上で有効に利用することができる。
As described above, according to the second embodiment, the storage area of the flag for setting the permission / prohibition of partial rewriting, the area for writing the start position and the end position, and the minimum rewrite unit of the
また、本発明に関連する従来技術の1つに、国際公開第WO2004/031966号パンフレットに開示されているものがある。この従来技術では、複数のブロック(最小消去単位)からなるメモリについて、どのブロックが消去済みであるかを判断するため、各ブロックにフラグを設けてそのフラグの状態を判定することで、消去済みであるか否かを決定するようにしている。しかしながら、マイコンの起動時に各ブロック毎に設けられているフラグの状態を判定すると、判定に時間を要するためプログラムの起動が遅れることになり、その起動遅れは、メモリのブロック数が増加するのに伴って大きくなってしまう。 Further, one of the prior arts related to the present invention is disclosed in International Publication No. WO 2004/031966. In this prior art, in order to determine which block has been erased in a memory composed of a plurality of blocks (minimum erase unit), each block is provided with a flag, and the state of the flag is determined. It is determined whether or not. However, when the state of the flag provided for each block is determined when the microcomputer is activated, the activation of the program is delayed because the determination takes time, and this activation delay increases the number of memory blocks. Along with it.
データメモリとしての用途では、起動時にはそのメモリを使用するホストマイコン自体が初期化を行なうため、その間にメモリの判定を行うことも可能である。ところが、プログラムメモリとしての用途では、メモリの処理により起動が遅れることは、プログラム,即ち、マイコン自体の起動が遅れることに繋がってしまう。
これに対して、第2実施例によれば、フラッシュメモリ15について第1実施例のようにIDコードをチェックしないので、判定プログラムの実行をより短時間内に完了することができる。
In use as a data memory, since the host microcomputer itself using the memory initializes at the time of startup, it is possible to determine the memory during that time. However, in use as a program memory, a delay in activation due to processing of the memory leads to a delay in activation of the program, that is, the microcomputer itself.
On the other hand, according to the second embodiment, since the ID code is not checked for the
(第3実施例)
図10及び図11は本発明の第3実施例を示すものであり、第2実施例と異なる部分のみ説明する。第3実施例は、部分書換えを行うブロックが複数ある場合に対応した処理を示す。図10に示すように、部分書換えを行うブロックが「6,11」の2ブロックであるとする。この場合、ブロック0のFLASHステータス0には、第2実施例と同様にブロック6の部分書換え(1)を行うための情報が配置され、ブロック6のFLASHステータス1には、ブロック11の部分書換え(2)を行うための情報,すなわち、部分書換え(2)の許可/禁止を設定するためのフラグ格納領域と、部分書換えの開始ブロック番号,終了ブロック番号を格納する領域とが計16バイトで配置されている。
(Third embodiment)
10 and 11 show a third embodiment of the present invention, and only the parts different from the second embodiment will be described. The third embodiment shows processing corresponding to a case where there are a plurality of blocks to be partially rewritten. As shown in FIG. 10, it is assumed that the blocks to be partially rewritten are two blocks “6, 11”. In this case, in the
そして、ブロック11には、部分書換えチェック領域としてFLASHステータス2が配置されており、そのFLASHステータス2と共に、更に続けて部分書換えを行う場合に対応して、部分書換え(3)を行うための情報が計16バイトで配置されている。部分書換え(3)を行わない場合、許可/禁止設定フラグは「禁止」に設定される。
図11は、図9相当図であり、図9におけるステップS3,S4が、部分書換え(1)に対応するステップS3’,S4’となっている。続いて、部分書換え(2)に対応する判断ステップが、ステップS11,S12として配置されている。
In
FIG. 11 is a diagram corresponding to FIG. 9, and steps S3 and S4 in FIG. 9 are steps S3 ′ and S4 ′ corresponding to partial rewriting (1). Subsequently, determination steps corresponding to partial rewriting (2) are arranged as steps S11 and S12.
尚、部分書換えが最大2ブロックまでと規定されている場合は図11に示す判定処理で対応すれば良く、部分書換えが最大3ブロックまで行われる場合は、ステップS12に続いて、部分書換え(3)に対応する判断ステップを、ステップS13,S14として配置すれば良い。その場合、第3実施例のケースでは、部分書換え(3)の許可/禁止設定フラグが「禁止」に設定されるため、ステップS13で(NO)と判断してユーザプログラムに移行することになる。 If the partial rewriting is defined as a maximum of 2 blocks, the determination process shown in FIG. 11 may be used. If the partial rewriting is performed up to a maximum of 3 blocks, the partial rewriting (3 The determination step corresponding to) may be arranged as steps S13 and S14. In this case, in the case of the third embodiment, since the permission / prohibition setting flag for partial rewriting (3) is set to “prohibited”, it is determined (NO) in step S13 and the process proceeds to the user program. .
以上のように第3実施例によれば、ブロック6の部分書換えチェック領域に、その次に部分書き換えを行なう対象とする領域について、部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とを最小書込み単位のサイズで設定し、その部分書換えチェック領域を1つ以上配置するので、部分書換えを、アドレスが不連続となる複数のブロックについても行なうことができる。
As described above, according to the third embodiment, in the partial rewrite check area of the
本発明は上記し又は図面に記載した実施例にのみ限定されるものではなく、以下のような変形が可能である。
ブロックnに、ブロック0と同じID領域を設け、ステップS5,S6で二重にチェックする処理は、必要に応じて行えば良い。また、ブロック0におけるIDコードのチェックも、必要に応じて行えば良い。
FLASHステータス0,1やID領域2,1をフラッシュメモリ15のどこに配置するかは、適宜変更して実施しても良い。
書換え完了コードやIDコードのデータ値についても、適宜変更して実施可能である。
ブロック0を、部分書き換えの対象としても良い。
フラッシュメモリ15のブロック容量は、64Kバイトに限らない。
第1メモリは、ブロック単位で書換えを行うものに限ることはない。また、書き換えを行なう際に、「ベリファイ」処理はメモリの仕様に応じて実施すれば良い。
更に、ステップS2におけるチェックも必要に応じて行えば良い。
部分書換え処理についても、仕様上必要とされる場合に実施すれば良い。
書換えデータ24は、RAM14に一括転送される場合に限らず、書換え装置23より順次送信されるデータを受信しながら書換えを行っても良い。
The present invention is not limited to the embodiments described above or shown in the drawings, and the following modifications are possible.
The same ID area as that of
Where the
The data value of the rewrite completion code and ID code can be changed as appropriate.
The block capacity of the
The first memory is not limited to one that is rewritten in units of blocks. Further, when performing the rewriting, the “verify” process may be performed according to the specifications of the memory.
Furthermore, the check in step S2 may be performed as necessary.
The partial rewriting process may also be performed when required by the specifications.
The
マイコン11が、動作用クロックの供給を停止した状態で待機する低消費電力モード(スリープ,ストップモード)を実行可能に構成されている場合、CPU12は、判定プログラム22を、低消費電力モードの解除(ウエイクアップ)時に実行するようにしても良い。斯様に構成すれば、フラッシュメモリ15に対する書き込みが正常に行なわれているか否かをウエイクアップ時にもチェックすることで、誤った書込み或いはデータ化けなどが発生している場合にユーザプログラム20の実行を停止して、プログラム20の暴走を未然に防止することができる。
最小書き込み単位は、16バイトに限ることはなく、マイクロコンピュータの個別の仕様に応じて適宜変更すれば良い。
フラッシュコントローラ16も、必要に応じて設ければ良く、CPU12が直接フラッシュメモリ15に書き込みを行っても良い。
第2,第3実施例における「FLASHステータス0,1」等と、部分書換えに関する情報との合計サイズは、最小書き込み単位より小さくても良い。
車両制御用のECUを構成するマイクロコンピュータに限ることなく、書換え可能な不揮発性メモリを備えているマイクロコンピュータであれば適用可能である。
When the
The minimum writing unit is not limited to 16 bytes, and may be appropriately changed according to the individual specifications of the microcomputer.
The flash controller 16 may be provided as necessary, and the
The total size of “
The present invention is not limited to the microcomputer constituting the vehicle control ECU, and any microcomputer having a rewritable nonvolatile memory can be applied.
図面中、11はマイクロコンピュータ、12はCPU、13はROM(第2メモリ)、15はフラッシュメモリ(第1メモリ)、20はユーザプログラム(アプリケーションプログラム)、21は書換えプログラム(部分書換えプログラム)を示す。 In the drawing, 11 is a microcomputer, 12 is a CPU, 13 is a ROM (second memory), 15 is a flash memory (first memory), 20 is a user program (application program), and 21 is a rewrite program (partial rewrite program). Show.
Claims (9)
前記CPUにより前記書換えプログラムが実行されると、最初に前記第1メモリの書換えチェック領域をクリアしてから当該メモリの全領域の書換えを行ない、最後に前記書換えチェック領域に書換え完了コードを書込み、
前記CPUにより前記判定プログラムが実行されると、最初に前記第1メモリの書換えチェック領域を読出し、読み出されたデータが前記書換え完了コードに一致する場合は前記アプリケーションプログラムを実行し、前記データが前記書換え完了コードに一致しない場合は前記書換えプログラムを実行することを特徴とするマイクロコンピュータ。 A rewritable non-volatile first memory in which an application program is stored, a rewriting program for rewriting the first memory, and a determination program for performing rewriting determination of the first memory are stored. In a microcomputer comprising a second memory and a CPU that reads and executes each program,
When the rewrite program is executed by the CPU, the rewrite check area of the first memory is first cleared and then the entire area of the memory is rewritten, and finally the rewrite completion code is written in the rewrite check area.
When the determination program is executed by the CPU, the rewrite check area of the first memory is read first, and when the read data matches the rewrite completion code, the application program is executed, and the data is A microcomputer that executes the rewriting program when it does not match the rewriting completion code.
前記CPUにより前記判定プログラムが実行され、前記第1メモリの書換えチェック領域より読み出されたデータが前記書換え完了コードに一致しない場合は、前記第1,第2書換え許可ID領域を夫々読出し、両者の読出しデータが共に前記IDコードに一致する場合は、前記書換えプログラムを実行することを特徴とする請求項1記載のマイクロコンピュータ。 When the rewrite program is executed by the CPU, the same ID code is written in the first and second rewrite permission ID areas of the first memory,
When the determination program is executed by the CPU and the data read from the rewrite check area of the first memory does not match the rewrite completion code, the first and second rewrite permission ID areas are read respectively. 2. The microcomputer according to claim 1, wherein said rewriting program is executed when both of the read data coincide with said ID code.
前記CPUにより前記書換えプログラムが実行されると、前記第1メモリの2つのブロックに設定される第1,第2書換え許可ID領域に、同一のIDコードを書込み、
前記CPUにより前記判定プログラムが実行され、前記第1メモリの書換えチェック領域より読み出されたデータが前記書換え完了コードに一致しない場合は、前記2つのブロックについて、前記第1,第2書換え許可ID領域を夫々読出し、何れか一方のブロックにおける両者の読出しデータが共に前記IDコードに一致する場合は、前記書換えプログラムを実行することを特徴とする請求項2記載のマイクロコンピュータ。 When the first memory is rewritten in units of a predetermined capacity block,
When the rewrite program is executed by the CPU, the same ID code is written in the first and second rewrite permission ID areas set in the two blocks of the first memory,
When the CPU executes the determination program and the data read from the rewrite check area of the first memory does not match the rewrite completion code, the first and second rewrite permission IDs for the two blocks 3. The microcomputer according to claim 2, wherein each of the areas is read, and when both read data in any one of the blocks match the ID code, the rewriting program is executed.
前記第1メモリには、前記部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とが設定され、
前記CPUにより前記部分書換えプログラムが実行されると、最初に前記第1メモリの部分書換えチェック領域をクリアしてから当該メモリの書換えを前記開始位置から前記終了位置まで行ない、最後に前記部分書換えチェック領域に部分書換え完了コードを書込み、
前記CPUにより前記判定プログラムが実行され、前記第1メモリの書換えチェック領域より読み出されたデータが前記書換え完了コードに一致する場合は、続いて前記フラグ格納領域を参照し、前記許可が設定されていれば前記部分書換えチェック領域を読出し、読み出されたデータが前記部分書換え完了コードに一致する場合は前記アプリケーションプログラムを実行し、前記データが前記部分書換え完了コードに一致しない場合は前記部分書換えプログラムを実行することを特徴とする請求項1乃至3の何れかに記載のマイクロコンピュータ。 The second memory also stores a partial rewriting program for performing partial rewriting of the first memory,
In the first memory, a flag storage area for performing the partial rewrite permission / prohibition setting and an area for writing a start position and an end position are set.
When the partial rewrite program is executed by the CPU, the partial rewrite check area of the first memory is first cleared, then the memory is rewritten from the start position to the end position, and finally the partial rewrite check is performed. Write the partial rewrite completion code in the area,
When the CPU executes the determination program and the data read from the rewrite check area of the first memory matches the rewrite completion code, the permission is set by referring to the flag storage area. If so, the partial rewrite check area is read. If the read data matches the partial rewrite completion code, the application program is executed. If the data does not match the partial rewrite completion code, the partial rewrite check area is executed. The microcomputer according to any one of claims 1 to 3, wherein the program is executed.
前記CPUにより前記判定プログラムが実行され、前記書換えチェック領域より読み出されたデータが前記書換え完了コードに一致する場合は、前記第1,第2書換え許可ID領域を夫々読出し、両者の読出しデータが共に前記IDコードに一致すると、前記フラグ格納領域を参照することを特徴とする請求項4記載のマイクロコンピュータ。 When the rewrite program is executed by the CPU, the same ID code is written in the first and second rewrite permission ID areas of the first memory, and the partial rewrite permission / prohibition setting in the flag storage area; Write setting of the start position and end position,
When the determination program is executed by the CPU and the data read from the rewrite check area matches the rewrite completion code, the first and second rewrite permission ID areas are read respectively, and both read data are 5. The microcomputer according to claim 4, wherein when both coincide with the ID code, the flag storage area is referred to.
前記CPUにより前記全書換えプログラムが実行されると、最初に前記第1メモリの全書換えチェック領域をクリアしてから当該メモリの全領域の書換えを行ない、最後に前記書換えチェック領域に全書換え完了コードを書込み、
前記第2メモリには、前記第1メモリの部分書換えを行なうための部分書換えプログラムも記憶されており、
前記第1メモリには、前記部分書換えの許可/禁止設定を行うフラグの格納領域と、開始位置及び終了位置を書き込む領域とが、前記全書換えチェック領域と共に当該第1メモリについて定められている最小書込み単位内のサイズで設定され、
前記CPUにより前記部分書換えプログラムが実行されると、最初に前記第1メモリの部分書換えチェック領域をクリアしてから当該メモリの書換えを前記開始位置から前記終了位置まで行ない、最後に前記部分書換えチェック領域に部分書換え完了コードを書込み、
前記CPUにより前記判定プログラムが実行されると、最初に前記第1メモリの全書換えチェック領域を読出し、読み出されたデータが前記全書換え完了コードに一致しない場合は前記全書換えプログラムを実行し、前記データが前記全書換え完了コードに一致する場合は、続いて前記フラグ格納領域を参照し、前記許可が設定されていれば前記部分書換えチェック領域を読出し、読み出されたデータが前記部分書換え完了コードに一致する場合は前記アプリケーションプログラムを実行し、前記データが前記部分書換え完了コードに一致しない場合は前記部分書換えプログラムを実行することを特徴とするマイクロコンピュータ。 A rewritable nonvolatile first memory in which an application program is stored, a total rewrite program for performing a complete rewrite of the first memory, and a determination program for performing a rewrite determination of the first memory are stored. A microcomputer comprising: a second memory; and a CPU that reads and executes each of the programs,
When the all-rewrite program is executed by the CPU, first the all-rewrite check area of the first memory is cleared and then all the areas of the memory are rewritten, and finally the all-rewrite completion code is stored in the rewrite check area. Write
The second memory also stores a partial rewriting program for performing partial rewriting of the first memory,
In the first memory, a storage area for a flag for setting the permission / prohibition of partial rewriting and an area for writing a start position and an end position are defined for the first memory together with the all-rewrite check area. It is set by the size within the writing unit,
When the partial rewrite program is executed by the CPU, the partial rewrite check area of the first memory is first cleared, then the memory is rewritten from the start position to the end position, and finally the partial rewrite check is performed. Write the partial rewrite completion code in the area,
When the determination program is executed by the CPU, first, the entire rewrite check area of the first memory is read, and when the read data does not match the complete rewrite completion code, the complete rewrite program is executed, If the data matches the complete rewrite completion code, the flag storage area is subsequently referred to, and if the permission is set, the partial rewrite check area is read, and the read data is the partial rewrite complete. The microcomputer executes the application program when the code matches the code, and executes the partial rewrite program when the data does not match the partial rewrite completion code.
前記部分書換えチェック領域を1つ以上備えることを特徴とする請求項6記載のマイクロコンピュータ。 In the partial rewrite check area, a storage area for a flag for setting permission / prohibition of partial rewrite and an area for writing a start position and an end position for the area to be subjected to partial rewrite next, and a minimum write area It is set with the size within the unit,
7. The microcomputer according to claim 6, further comprising one or more partial rewrite check areas.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2007200839A JP4743182B2 (en) | 2006-12-07 | 2007-08-01 | Microcomputer |
US12/000,001 US7934050B2 (en) | 2006-12-07 | 2007-12-06 | Microcomputer for flash memory rewriting |
Applications Claiming Priority (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006330799 | 2006-12-07 | ||
JP2006330799 | 2006-12-07 | ||
JP2007200839A JP4743182B2 (en) | 2006-12-07 | 2007-08-01 | Microcomputer |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2008165729A true JP2008165729A (en) | 2008-07-17 |
JP4743182B2 JP4743182B2 (en) | 2011-08-10 |
Family
ID=39695088
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2007200839A Expired - Fee Related JP4743182B2 (en) | 2006-12-07 | 2007-08-01 | Microcomputer |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4743182B2 (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013021423A1 (en) * | 2011-08-10 | 2013-02-14 | トヨタ自動車株式会社 | Reprogramming system and reprogramming method |
JP2014164596A (en) * | 2013-02-26 | 2014-09-08 | Denso Corp | Control system |
EP3057101A1 (en) | 2015-02-10 | 2016-08-17 | Toyota Jidosha Kabushiki Kaisha | Microcomputer apparatus, program rewriting system and rewriting program |
DE102017202282A1 (en) | 2016-02-17 | 2017-08-17 | Denso Corporation | VEHICLE CONTROL DEVICE AND VEHICLE NETWORK WITH VEHICLE CONTROL DEVICE |
WO2023127516A1 (en) * | 2021-12-27 | 2023-07-06 | ソニーグループ株式会社 | Replacement device, information processing method, and information processing device |
CN112395122B (en) * | 2019-08-16 | 2023-08-29 | 慧荣科技股份有限公司 | Flash memory controller and method thereof |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2000105694A (en) * | 1998-09-28 | 2000-04-11 | Nec Ic Microcomput Syst Ltd | Flash memory, microcomputer equipped with flash memory, and method for storing program in flash memory |
JP2003015929A (en) * | 2001-06-28 | 2003-01-17 | Matsushita Electric Ind Co Ltd | Control method for nonvolatile memory |
JP2004102893A (en) * | 2002-09-12 | 2004-04-02 | Matsushita Electric Ind Co Ltd | Remote downloader and remote download method |
JP2005321843A (en) * | 2004-05-06 | 2005-11-17 | Hitachi Ltd | Rewriting method for firmware |
JP2006268176A (en) * | 2005-03-22 | 2006-10-05 | Denso Corp | Data validity/invalidity deciding method for flash eeprom |
-
2007
- 2007-08-01 JP JP2007200839A patent/JP4743182B2/en not_active Expired - Fee Related
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2000105694A (en) * | 1998-09-28 | 2000-04-11 | Nec Ic Microcomput Syst Ltd | Flash memory, microcomputer equipped with flash memory, and method for storing program in flash memory |
JP2003015929A (en) * | 2001-06-28 | 2003-01-17 | Matsushita Electric Ind Co Ltd | Control method for nonvolatile memory |
JP2004102893A (en) * | 2002-09-12 | 2004-04-02 | Matsushita Electric Ind Co Ltd | Remote downloader and remote download method |
JP2005321843A (en) * | 2004-05-06 | 2005-11-17 | Hitachi Ltd | Rewriting method for firmware |
JP2006268176A (en) * | 2005-03-22 | 2006-10-05 | Denso Corp | Data validity/invalidity deciding method for flash eeprom |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013021423A1 (en) * | 2011-08-10 | 2013-02-14 | トヨタ自動車株式会社 | Reprogramming system and reprogramming method |
JP2014164596A (en) * | 2013-02-26 | 2014-09-08 | Denso Corp | Control system |
EP3057101A1 (en) | 2015-02-10 | 2016-08-17 | Toyota Jidosha Kabushiki Kaisha | Microcomputer apparatus, program rewriting system and rewriting program |
JP2016148930A (en) * | 2015-02-10 | 2016-08-18 | トヨタ自動車株式会社 | Microcomputer device |
US9798658B2 (en) | 2015-02-10 | 2017-10-24 | Toyota Jidosha Kabushiki Kaisha | Microcomputer apparatus, program rewriting system and non-transitory computer-readable information recording medium |
DE102017202282A1 (en) | 2016-02-17 | 2017-08-17 | Denso Corporation | VEHICLE CONTROL DEVICE AND VEHICLE NETWORK WITH VEHICLE CONTROL DEVICE |
DE102017202282B4 (en) | 2016-02-17 | 2023-12-07 | Denso Corporation | ON-VEHICLE CONTROL DEVICE AND ON-VEHICLE NETWORK WITH THE ON-VEHICLE CONTROL DEVICE |
CN112395122B (en) * | 2019-08-16 | 2023-08-29 | 慧荣科技股份有限公司 | Flash memory controller and method thereof |
WO2023127516A1 (en) * | 2021-12-27 | 2023-07-06 | ソニーグループ株式会社 | Replacement device, information processing method, and information processing device |
Also Published As
Publication number | Publication date |
---|---|
JP4743182B2 (en) | 2011-08-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10509568B2 (en) | Efficient secure boot carried out in information processing apparatus | |
US7197613B2 (en) | Nonvolatile memory | |
JP7022809B2 (en) | Computer systems, their safety management methods, and computer software products | |
JP4743182B2 (en) | Microcomputer | |
JP4227149B2 (en) | Information storage method for electronic control unit | |
US6587916B2 (en) | Microcomputer with built-in programmable nonvolatile memory | |
JP2990181B1 (en) | Flash memory, microcomputer having flash memory, and method of storing program in flash memory | |
JP5576557B2 (en) | Processor system and control method thereof | |
CN107015878B (en) | System repair method and system for computer | |
US7934050B2 (en) | Microcomputer for flash memory rewriting | |
JP7091486B2 (en) | Electronic control device, security verification method for electronic control device | |
US20100185927A1 (en) | Microprocessor System for Controlling at Least Partly Safety-Critical Processes | |
JP6622360B2 (en) | Information processing device | |
JP6708596B2 (en) | Electronic control device and control program verification method | |
JPH11265283A (en) | Correction method for firmware in storage device, and storage device | |
US20040210751A1 (en) | Method for booting computer system with basic input-output system memory and structure thereof | |
CN115454517B (en) | Method, system, storage medium, device and chip for multi-medium secure boot | |
TWI726436B (en) | Method for repairing basic input/output system bios and a computer system using the same | |
TWI446351B (en) | Data writing method and computer system | |
JP2001331382A (en) | Method and device for managing nonvolatile memory | |
TW202136995A (en) | Memory apparatus and memory management method for safe power-up | |
CN113495808A (en) | Memory device and memory management method for safe startup | |
JP2024044708A (en) | Semiconductor storage device and memory system | |
CN117348910A (en) | BootLoader upgrading method and system of intelligent cabin MCU | |
JP5720206B2 (en) | Microprocessor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20090707 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20100125 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20100330 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20100510 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110201 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20110322 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20110412 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20110425 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140520 Year of fee payment: 3 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 4743182 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140520 Year of fee payment: 3 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
LAPS | Cancellation because of no payment of annual fees |