JP2012248094A - Electronic equipment - Google Patents

Electronic equipment Download PDF

Info

Publication number
JP2012248094A
JP2012248094A JP2011120787A JP2011120787A JP2012248094A JP 2012248094 A JP2012248094 A JP 2012248094A JP 2011120787 A JP2011120787 A JP 2011120787A JP 2011120787 A JP2011120787 A JP 2011120787A JP 2012248094 A JP2012248094 A JP 2012248094A
Authority
JP
Japan
Prior art keywords
data
nonvolatile memory
flash rom
element data
byte
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2011120787A
Other languages
Japanese (ja)
Inventor
Takuro Ikeda
卓朗 池田
Ryo Fukaya
亮 深谷
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.)
Denso Corp
Original Assignee
Denso Corp
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 Denso Corp filed Critical Denso Corp
Priority to JP2011120787A priority Critical patent/JP2012248094A/en
Publication of JP2012248094A publication Critical patent/JP2012248094A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a technique for efficiently writing data to a flash ROM.SOLUTION: An MPU of an electronic controller divides data to be written to a flash ROM 13 into one-byte data (byte data) (S130), and selects the respective byte data constituting the data to be written as data to be processed in order (S140). Then the MPU compares the data to be processed with byte data corresponding to the data to be processed which is stored in the flash ROM (S150), and writes the data to be processed to the flash ROM in an additional writing manner (S160) when the data to be processed is obtained by altering the contents of data stored in the flash ROM (Yes at S150). When the data to be processed is not the data obtained by altering the contents of the data stored in the flash ROM (No at S150), the data to be processed is not written to the flash ROM.

Description

本発明は、電気的にデータ書換可能な不揮発性メモリを備え、この不揮発性メモリに対してデータの書込を行う電子機器に関する。   The present invention relates to an electronic device that includes an electrically rewritable nonvolatile memory and writes data to the nonvolatile memory.

従来、電気的にデータ書換可能な不揮発性メモリとしては、EEPROMやフラッシュROMが知られている。この種のメモリは、電源供給なしでデータを記憶保持することができるため、近年、学習データや設定情報等の記憶に広く利用されている。   Conventionally, EEPROM and flash ROM are known as nonvolatile memories capable of electrically rewriting data. Since this type of memory can store and hold data without power supply, it has been widely used in recent years for storing learning data and setting information.

ところで、EEPROMやフラッシュROMのような不揮発性メモリのデータ消去回数には、限界がある。このため、不要なデータ書込や消去等を抑えてメモリの長寿命化を図るための技術が、従来から研究されている。   By the way, there is a limit to the number of times data can be erased from a nonvolatile memory such as an EEPROM or a flash ROM. For this reason, a technique for extending the life of the memory by suppressing unnecessary data writing and erasing has been studied.

例えば、従来技術としては、EEPROMへのデータ書込の際に、EEPROMへの書込対象データが、EEPROMに既に書き込まれている旧データに対して変更されたものであるか否かを判断し、変更されたものでない場合には、EEPROMに対してデータ書込を行わないことで、メモリの長寿命化を図る技術が知られている(特許文献1参照)。   For example, in the prior art, when writing data to the EEPROM, it is determined whether or not the data to be written to the EEPROM has been changed from the old data already written in the EEPROM. In the case where it has not been changed, a technique for extending the life of the memory by not writing data to the EEPROM is known (see Patent Document 1).

特開平11−141391号公報Japanese Patent Laid-Open No. 11-141391

しかしながら、従来技術は、書込対象データが、その一部でも旧データから変更されたものである場合には、書込対象データ全体を、EEPROMに書き込むものであるため、不揮発性メモリ(EEPROMやフラッシュROM)に対するデータ書込を十分に効率化できているとは言えなかった。   However, in the prior art, when the write target data is partly changed from the old data, the entire write target data is written to the EEPROM. It could not be said that the data writing to the flash ROM) was sufficiently efficient.

本発明は、こうした問題に鑑みなされたものであり、EEPROMやフラッシュROM等の電気的にデータ書換可能な不揮発性メモリに対し、効率的にデータ書込可能な技術を提供することを目的とする。   The present invention has been made in view of these problems, and an object of the present invention is to provide a technique for efficiently writing data to an electrically rewritable nonvolatile memory such as an EEPROM or a flash ROM. .

上記目的を達成するためになされた本発明は、電気的にデータ書換可能な不揮発性メモリを備える電子機器であって、比較手段と、書込制御手段と、を備えるものである。比較手段は、不揮発性メモリに対する書込対象データが生じると、書込対象データと不揮発性メモリが記憶する書込対象データに対応する旧データとを比較し、書込対象データを構成する要素データ群の内、上記旧データから内容変更された要素データを特定する。一方、書込制御手段は、書込対象データを構成する要素データ群の内、比較手段により特定された旧データから内容変更された要素データ群を選択的に、不揮発性メモリに書き込む。これによって、書込対象データを不揮発性メモリに書き込む。   In order to achieve the above object, the present invention is an electronic apparatus including a nonvolatile memory capable of electrically rewriting data, and includes a comparison unit and a write control unit. The comparison means compares the write target data with the old data corresponding to the write target data stored in the nonvolatile memory when the write target data for the nonvolatile memory is generated, and element data constituting the write target data In the group, element data whose contents are changed from the old data is specified. On the other hand, the write control means selectively writes the element data group whose contents have been changed from the old data specified by the comparison means among the element data groups constituting the write target data to the nonvolatile memory. As a result, the write target data is written to the nonvolatile memory.

この電子機器(請求項1)によれば、書込対象データを構成する要素データ群の内、旧データから内容変更された要素データ群を選択的に不揮発性メモリに書き込むので、書込対象データが、その一部でも旧データから変更されたものである場合には、書込対象データ全体を不揮発性メモリに書き込む従来技術と比較して、不揮発性メモリに対するデータ書込量を抑えることができる。そして、データ書込量を抑えることができれば、データ消去回数についても抑えることができ、不揮発性メモリの寿命を長くすることができる。即ち、この電子機器によれば、データ消去回数を抑えて不揮発性メモリの寿命を長くすることができるように、不揮発性メモリに対して効率的にデータ書込をすることができる。   According to this electronic device (claim 1), among the element data group constituting the write target data, the element data group whose contents are changed from the old data is selectively written to the nonvolatile memory. However, when even a part of the data is changed from the old data, the amount of data written to the nonvolatile memory can be reduced as compared with the conventional technique in which the entire data to be written is written to the nonvolatile memory. . If the data write amount can be reduced, the number of data erasures can be reduced, and the lifetime of the nonvolatile memory can be extended. That is, according to this electronic device, data can be efficiently written into the nonvolatile memory so that the number of times of data erasure can be suppressed and the lifetime of the nonvolatile memory can be extended.

尚、上記比較手段は、不揮発性メモリに対する書込要求が生じると、この書込要求にて指定された書込対象データを、不揮発性メモリが記憶する書込対象データに対応する旧データと比較し、書込対象データを構成する要素データ群の内、旧データから内容変更された要素データを特定する構成にすることができ、書込制御手段は、上記書込要求が生じると、書込対象データを構成する要素データ群の内、比較手段により特定された上記旧データから内容変更された要素データ群を、不揮発性メモリに書き込む構成にすることができる。   When the write request for the nonvolatile memory is generated, the comparing means compares the write target data specified by the write request with the old data corresponding to the write target data stored in the nonvolatile memory. In the element data group constituting the write target data, the element data whose contents have been changed from the old data can be specified. When the write request is generated, the write control means Of the element data group constituting the target data, the element data group whose contents are changed from the old data specified by the comparing means can be written in the nonvolatile memory.

また、上記電子機器は、読出要求が生じると、読出要求にて指定された読出対象データを構成する要素データ毎の上記不揮発性メモリが記憶する最新データを読み出して、読み出した各要素データの最新データを、上記読出対象データとして読出要求元に提供する読出制御手段を備えた構成とすることができる(請求項2)。   In addition, when a read request occurs, the electronic device reads the latest data stored in the nonvolatile memory for each element data constituting the read target data specified by the read request, and updates the latest element data read out. It is possible to employ a configuration including a read control means for providing data to the read request source as the read target data.

更に、上記読出制御手段は、上記読み出した各要素データの最新データを結合して、この結合データを、上記読出対象データとして読出要求元に提供する構成にすることができる。このように電子機器を構成すれば、読出要求元では、不揮発性メモリに記憶されたデータを要素データ毎に管理する必要がなく、大変便利である。   Further, the read control unit can combine the latest data of the read element data and provide the combined data to the read request source as the read target data. If the electronic device is configured in this way, the read request source does not need to manage the data stored in the nonvolatile memory for each element data, which is very convenient.

ところで、上記不揮発性メモリが、要素データ複数個分に対応する予め定められたエリア単位でのデータ消去が必要なメモリである場合には、各要素データを個別に一つずつ不揮発性メモリから消去することができない。このため、データ消去を行って不揮発性メモリ内に空きスペースを確保する際に、何ら工夫しなければ、エリア内に旧データ(不要データ)と共に最新データが含まれることで、そのエリアを消去対象とすることができないといった問題や、データ消去動作と共に、消去すべきでない最新データまでもが不揮発性メモリから消えてしまうといった問題が発生する可能性がある。   By the way, if the nonvolatile memory is a memory that needs to be erased in units of predetermined areas corresponding to a plurality of element data, each element data is individually erased from the nonvolatile memory one by one. Can not do it. For this reason, when erasing data to secure free space in the nonvolatile memory, the area contains the latest data along with old data (unnecessary data) unless it is devised. In addition to the data erasing operation, the latest data that should not be erased may be erased from the nonvolatile memory.

従って、上記電子機器は、次のように構成されるとよい。即ち、上記電子機器は、空きスペースを確保するために、不揮発性メモリが記憶する要素データ群を、エリア単位で消去する一方、消去に際しては、消去対象のエリアにおいて記憶される要素データ群の内、最新データに対応する要素データ群を、消去対象のエリアに該当しない不揮発性メモリ内の他のエリアに書き込んで退避させる消去制御手段を備える構成にされるとよい(請求項3)。   Therefore, the electronic device may be configured as follows. That is, the electronic device erases the element data group stored in the non-volatile memory in units of areas in order to secure an empty space, while the element data group stored in the area to be erased is erased. The element data group corresponding to the latest data may be provided with an erasure control means for writing and evacuating to other areas in the non-volatile memory that do not correspond to the area to be erased.

このように電子機器を構成すれば、上記種類の問題が発生するのを回避しつつ、適切にエリア単位で不揮発性メモリ内のデータを消去して、不揮発性メモリ内に空きスペースを確保することができる。尚、消去制御手段は、不揮発性メモリ内において、空きスペースとなっているエリアが規定数未満となる等の所定条件が満足されると、不揮発性メモリ内の複数エリアの一つを、消去対象のエリアとして選択して、このエリアのデータを消去する構成にすることができる。   By configuring the electronic device in this manner, it is possible to appropriately erase the data in the nonvolatile memory in units of areas and secure an empty space in the nonvolatile memory while avoiding the occurrence of the above-mentioned types of problems. Can do. The erasure control means deletes one of the plurality of areas in the non-volatile memory when a predetermined condition such that the number of empty areas in the non-volatile memory is less than a prescribed number is satisfied. This area can be selected and data in this area can be erased.

また、要素データの夫々に、予め固有の識別コードが割り当てられる場合、上記電子機器の書込制御手段及び比較手段は、次のように構成することができる。即ち、書込制御手段は、不揮発性メモリに要素データを書き込む際、この要素データと関連付けて当該要素データに割り当てられた識別コードを不揮発性メモリに書き込む構成にすることができる。そして、比較手段は、書込対象データを不揮発性メモリが記憶する旧データと比較する際、書込対象データを構成する要素データ毎に、この要素データと、当該要素データに割り当てられた識別コードと同一の識別コードに関連付けて不揮発性メモリが記憶する要素データとを比較して、書込対象データを構成する要素データ群の内、旧データから内容変更された要素データを特定する構成にすることができる(請求項4)。   When a unique identification code is assigned in advance to each element data, the writing control means and the comparison means of the electronic device can be configured as follows. That is, when writing element data in the nonvolatile memory, the write control means can be configured to write the identification code assigned to the element data in association with the element data in the nonvolatile memory. The comparing means compares the element data and the identification code assigned to the element data for each element data constituting the writing object data when the writing object data is compared with the old data stored in the nonvolatile memory. Compared with the element data stored in the nonvolatile memory in association with the same identification code, the element data group constituting the write target data is identified with the element data whose contents have been changed from the old data. (Claim 4).

このようにして識別コードを利用すれば、書込対象データの各要素データと、不揮発性メモリに記憶された旧データの各要素データとを、容易に比較することができる。
また、上述した要素データは、不揮発性メモリに書込可能な最小単位のデータとして定義することができる。即ち、各要素データは、不揮発性メモリに書込可能な最小のデータ単位で、書込対象データを区画化して表される各区画のデータとして定義することができる(請求項5)。
If the identification code is used in this way, each element data of the write target data and each element data of the old data stored in the nonvolatile memory can be easily compared.
The element data described above can be defined as the minimum unit data that can be written to the nonvolatile memory. That is, each element data can be defined as the data of each partition expressed by partitioning the write target data in the minimum data unit that can be written to the nonvolatile memory.

この他、不揮発性メモリがバイト単位でデータを書込可能なものである場合、各要素データの夫々は、バイト単位で書込対象データを区画化して表される各区画のデータとして定義することができる(請求項6)。   In addition, when the nonvolatile memory can write data in units of bytes, each element data should be defined as data of each section expressed by partitioning the write target data in units of bytes. (Claim 6).

また、上述した不揮発性メモリとしては、EEPROMやフラッシュROMを挙げることができるが、本発明は、電気的にデータ書換可能な不揮発性メモリとしてフラッシュROMを備えた電子機器に適用されると、特に好ましい(請求項7)。フラッシュROMは、EEPROMよりも更に少ないデータ消去回数で寿命を迎えてしまうため、このような電子機器に本発明を提供されると不揮発性メモリの長寿命化による効果が一層発揮される。   In addition, examples of the nonvolatile memory described above include an EEPROM and a flash ROM. However, the present invention is particularly applied to an electronic device including a flash ROM as an electrically rewritable nonvolatile memory. Preferred (claim 7). Since the flash ROM reaches the end of its life with a smaller number of data erasures than the EEPROM, when the present invention is provided to such an electronic device, the effect of extending the lifetime of the nonvolatile memory is further exhibited.

この他、電子機器が備える各手段としての機能は、プログラムにより、コンピュータに実現させることができる。そして、上述の電子機器が備える各手段としての機能をコンピュータに実現させるためのプログラムは、コンピュータ読取可能な記録媒体に記録して、ユーザに提供することができる。記録媒体としては、ハードディスク等の磁気ディスク、CDやDVD等の光ディスク、及び、光磁気ディスク等の他、メモリカード等の半導体製メモリを挙げることができる。   In addition, the functions of each means included in the electronic device can be realized by a computer by a program. And the program for making a computer implement | achieve the function as each means with which the above-mentioned electronic device is provided can be recorded on a computer-readable recording medium, and can be provided to a user. Examples of the recording medium include a magnetic disk such as a hard disk, an optical disk such as a CD and a DVD, a magneto-optical disk, and a semiconductor memory such as a memory card.

電子制御装置1の構成を表すブロック図である。2 is a block diagram illustrating a configuration of an electronic control device 1. FIG. フラッシュROM13の構成(a)及び記憶ブロックの構成(b)を表す図である。It is a figure showing the structure (a) of flash ROM13, and the structure (b) of a storage block. MPU11が実行する書込制御処理を表すフローチャートである。It is a flowchart showing the write-control process which MPU11 performs. 管理テーブルの構成を表す図である。It is a figure showing the structure of a management table. 本実施例によるフラッシュROM13へのデータ書込態様(a)及び従来技術によるフラッシュROM13へのデータ書込態様(b)を説明した図である。It is the figure explaining the data write mode (a) to the flash ROM 13 by a present Example, and the data write mode (b) to the flash ROM 13 by a prior art. MPU11が実行する消去制御処理を表すフローチャートである。It is a flowchart showing the erasure | elimination control processing which MPU11 performs. 記憶ブロック内のデータを消去する際の手順について説明した図である。It is a figure explaining the procedure at the time of erasing the data in a storage block. MPU11が実行する読出制御処理を表すフローチャートである。It is a flowchart showing the read control process which MPU11 performs.

以下に本発明の実施例について、図面と共に説明する。
図1に示す本実施例の電子制御装置(ECU)1は、車両に搭載されて、車両各部を制御するものである。この電子制御装置1は、車両に搭載されたセンサ類5からの出力信号に基づき、制御対象3としての車両に搭載された各種アクチュエータを制御することによって、車両各部を制御する。電子制御装置1としては、例えば、エンジン制御を行う電子制御装置を挙げることができる。
Embodiments of the present invention will be described below with reference to the drawings.
An electronic control unit (ECU) 1 of this embodiment shown in FIG. 1 is mounted on a vehicle and controls each part of the vehicle. The electronic control device 1 controls each part of the vehicle by controlling various actuators mounted on the vehicle as the control target 3 based on output signals from the sensors 5 mounted on the vehicle. Examples of the electronic control device 1 include an electronic control device that performs engine control.

具体的に、この電子制御装置1は、マイクロプロセッサ(MPU)11と、フラッシュROM13と、入出力回路15と、を備える。MPU11は、各種プログラムに従う処理を実行することによって、車両制御を実現する。このMPU11は、上記各種プログラムを記憶するROM11aと、ROM11aに記憶されたプログラムに基づく各種処理の実行時に作業領域として使用されるRAM11bと、を備える。   Specifically, the electronic control device 1 includes a microprocessor (MPU) 11, a flash ROM 13, and an input / output circuit 15. MPU11 implement | achieves vehicle control by performing the process according to various programs. The MPU 11 includes a ROM 11a that stores the various programs, and a RAM 11b that is used as a work area when executing various processes based on the programs stored in the ROM 11a.

即ち、MPU11は、ROM11aに記憶された各種プログラムを実行することにより、入出力回路15を通じて、センサ類5からの出力信号を取得し、この出力信号に基づき、制御対象3への制御信号を生成し、これを入出力回路15を通じて、制御対象3に入力する。このような処理によって制御対象3を制御し、車両制御を実現する。   That is, the MPU 11 acquires various output signals from the sensors 5 through the input / output circuit 15 by executing various programs stored in the ROM 11a, and generates a control signal for the control target 3 based on the output signals. This is input to the controlled object 3 through the input / output circuit 15. Control object 3 is controlled by such processing, and vehicle control is realized.

一方、電気的にデータ書換可能な不揮発性メモリとして知られるフラッシュROM13は、車両制御に関わる種々のデータを記憶するものである。電子制御装置1がエンジン制御用の電子制御装置である場合、フラッシュROM13には、エンジン制御用の制御パラメータが記憶される。制御パラメータには、学習更新される制御パラメータ(以下、「学習パラメータ」と表現する。)が含まれる。学習パラメータは、その値がMPU11による車両制御の結果に従って学習更新されて、フラッシュROM13に書き込まれる。この他、フラッシュROM13には、電源投入回数が書き込まれる。例えば、アクセサリスイッチがオンされて、電子制御装置1に電源が投入される度に最新の電源投入回数が書き込まれる。   On the other hand, the flash ROM 13 known as an electrically rewritable nonvolatile memory stores various data relating to vehicle control. When the electronic control device 1 is an electronic control device for engine control, the flash ROM 13 stores control parameters for engine control. The control parameters include control parameters that are learned and updated (hereinafter referred to as “learning parameters”). The learning parameter value is learned and updated according to the result of vehicle control by the MPU 11 and written to the flash ROM 13. In addition, the power-on count is written in the flash ROM 13. For example, the latest power-on count is written each time the accessory switch is turned on and the electronic control device 1 is powered on.

このフラッシュROM13は、周知のフラッシュROMと同様、複数の記憶ブロックを備え(図2(a)参照)、1バイト単位でのデータ書込が可能であるものの、データ消去については記憶ブロック単位での消去が必要なものである。即ち、このフラッシュROM13は、最小の書込単位が1バイト単位であり、最小の消去単位が記憶ブロック単位である構成にされ、データ消去された状態の記憶ブロックには、新規データを1バイト単位で書き込むことができるものの、データが書き込まれた記憶ブロック内の領域に対しては、記憶ブロック全体に対してデータ消去動作を行わない限り、新たなデータを上書きすることができない構成にされている。   The flash ROM 13 includes a plurality of storage blocks as in the known flash ROM (see FIG. 2A). Although data can be written in units of 1 byte, data erasure is performed in units of storage blocks. It must be erased. That is, the flash ROM 13 is configured such that the minimum writing unit is 1 byte unit, the minimum erasing unit is a storage block unit, and new data is stored in 1 byte unit in the storage block in which data is erased. Although the data can be written in, the area in the storage block in which the data has been written cannot be overwritten with new data unless the data erase operation is performed on the entire storage block. .

このフラッシュROM13が備える各記憶ブロックは、先頭にブロックヘッダ領域を備え(図2(b)参照)、このブロックヘッダ領域に、ブロックIDやブロックの状態を表す情報等を記憶する。また、各記憶ブロックは、ブロックヘッダ領域に続く領域を、データヘッダ及びユーザデータを記憶するための領域として備える。データヘッダは、ユーザデータ管理用のデータである。一方、ユーザデータは、上述した制御パラメータや電源投入回数等のデータのことである。要するに、管理用のデータ以外のフラッシュROM13に記憶させる目的のデータは、ユーザデータとしてフラッシュROM13に記憶される。   Each storage block provided in the flash ROM 13 has a block header area at the head (see FIG. 2B), and stores information such as a block ID and a block state in the block header area. Each storage block includes an area following the block header area as an area for storing a data header and user data. The data header is data for user data management. On the other hand, the user data is data such as the control parameters and the number of times of power-on described above. In short, target data to be stored in the flash ROM 13 other than the management data is stored in the flash ROM 13 as user data.

但し、ユーザデータは、1バイトのデータとして定義されており、複数バイトのデータで構成される制御パラメータや電源投入回数等のデータは、1バイトのデータ(以下、「バイトデータ」と表現する。)に分割されて、ユーザデータとしてフラッシュROM13に書き込まれる。具体的に、ユーザデータは、図2(b)に示すように、上記ブロックヘッダ領域に続く領域において、その領域の後端から順に書き込まれる。   However, user data is defined as 1-byte data, and data such as control parameters and power-on counts composed of a plurality of bytes of data are expressed as 1-byte data (hereinafter referred to as “byte data”). ) And is written in the flash ROM 13 as user data. Specifically, as shown in FIG. 2B, user data is written in order from the rear end of the area in the area following the block header area.

一方、データヘッダは、対応するユーザデータのIDコード、このユーザデータの格納位置に対応するメモリアドレス(換言すれば、このユーザデータにアクセスするためのアドレスポインタ)、及び、このユーザデータの状態を表すフラグデータを含む。このデータヘッダは、図2(b)に示すように、上記ブロックヘッダ領域に続く領域において、その領域の先端から順に書き込まれる。   On the other hand, the data header indicates the ID code of the corresponding user data, the memory address corresponding to the storage location of the user data (in other words, the address pointer for accessing the user data), and the state of the user data. Contains flag data to represent. As shown in FIG. 2B, the data header is written in order from the leading end of the area in the area following the block header area.

即ち、MPU11は、制御データや電源投入回数等の書込対象データをフラッシュROM13に書き込む際には、これをバイトデータに分割し、書込対象データを構成するバイトデータの夫々を、このバイトデータに対応するデータヘッダと共に、フラッシュROM13に書き込む。この際、バイトデータについては、上記ブロックヘッダ領域に続く領域の後端側から書きこみ、データヘッダについては、上記ブロックヘッダ領域に続く領域の先端側から書き込む。   That is, when the MPU 11 writes the write target data such as the control data and the power-on count to the flash ROM 13, the MPU 11 divides the data into byte data, and each byte data constituting the write target data is converted to the byte data. Is written in the flash ROM 13 together with the data header corresponding to. At this time, the byte data is written from the rear end side of the area following the block header area, and the data header is written from the front end side of the area following the block header area.

但し、書込対象データを分割して当該書込対象データを構成するバイトデータの夫々を、データヘッダと共にフラッシュROM13に書き込む際には、書込対象データを構成する各バイトデータと、フラッシュROM13が記憶する当該書込対象データに対応する旧データを構成する各バイトデータとを比較し、旧データから内容変更のあったバイトデータを選択的に、フラッシュROM13に追記形式で書き込む。   However, when the write target data is divided and each of the byte data constituting the write target data is written to the flash ROM 13 together with the data header, each byte data constituting the write target data and the flash ROM 13 Each byte data constituting the old data corresponding to the write target data to be stored is compared, and the byte data whose contents are changed from the old data is selectively written to the flash ROM 13 in the additional write format.

ここで、旧データを削除せずに追記形式でバイトデータをフラッシュROM13に書き込むのは、フラッシュROM13では、データの上書きができず、内容変更のあったバイトデータについての旧データを消去するためには、記憶ブロック単位での消去が必要になるためである。   Here, the byte data is written to the flash ROM 13 in the write-once format without deleting the old data, because the flash ROM 13 cannot overwrite the data and erases the old data for the byte data whose contents are changed. This is because erasing in units of storage blocks is necessary.

詳述すれば、各記憶ブロックは、ユーザデータ(バイトデータ)のデータ量よりも十分大きい記憶容量に設定されており、複数バイト分のユーザデータ(バイトデータ)を記憶可能に構成されている。従って、書込対象データにおいて旧データから内容変更のあったバイトデータが存在することで、旧データから内容変更のあったバイトデータを、フラッシュROM13に書き込む度に、このバイトデータに対応するフラッシュROM13に記憶された旧データを、記憶ブロック単位でのデータ消去により、フラッシュROM13から削除していたのでは、データ消去の無駄が大きく、フラッシュROM13の寿命が早く到来してしまう。   More specifically, each storage block is set to a storage capacity sufficiently larger than the data amount of user data (byte data), and is configured to be able to store user data (byte data) for a plurality of bytes. Accordingly, since there is byte data whose contents have been changed from the old data in the write target data, every time the byte data whose contents have been changed from the old data is written to the flash ROM 13, the flash ROM 13 corresponding to this byte data. If the old data stored in is deleted from the flash ROM 13 by erasing data in units of storage blocks, the data erasure is wasted and the life of the flash ROM 13 will be shortened.

このため、本実施例では、旧データから内容変更のあった最新データを、フラッシュROM13を書き込む際、旧データをフラッシュROM13から消去せずに最新データをフラッシュROM13に追記することによって、この最新データを、旧データを残したままフラッシュROM13に記憶させるのである。このような追記動作の繰返しによれば、フラッシュROM13におけるデータ消去回数を抑えることができ、フラッシュROM13の長寿命化を図ることができる。   For this reason, in this embodiment, when writing the latest data whose contents have been changed from the old data into the flash ROM 13, the latest data is added to the flash ROM 13 without deleting the old data from the flash ROM 13. Is stored in the flash ROM 13 with the old data remaining. By repeating such additional recording operation, the number of data erasures in the flash ROM 13 can be suppressed, and the life of the flash ROM 13 can be extended.

但し、追記動作の繰返しによっては、記憶ブロックの空きスペースが次第に減ってしまう。このため、空きスペースのなくなった記憶ブロックについては、順次、この記憶ブロック内のデータを消去することによって、フラッシュROM13に必要な空きスペースを確保する。MPU11は、図2(a)に矢印で示すように、予め定められた順序で各記憶ブロックにデータを書き込むが、空きブロック(ユーザデータ及びデータヘッダが一つも登録されていない記憶ブロック)が規定数未満となる場合には、空きブロックでない記憶ブロックの内、データ書込時期が最も古い記憶ブロック内のデータを消去する。このようにして、MPU11は、空きスペースを確保する。   However, the free space of the storage block is gradually reduced by repeating the appending operation. For this reason, with respect to the storage block in which there is no free space, the free space necessary for the flash ROM 13 is secured by sequentially erasing the data in the storage block. The MPU 11 writes data to each storage block in a predetermined order as indicated by an arrow in FIG. 2A, but an empty block (a storage block in which no user data or data header is registered) is defined. If the number is less than the number, the data in the storage block with the oldest data writing time is erased from the storage blocks that are not empty blocks. In this way, the MPU 11 secures an empty space.

続いて、MPU11によるデータの書込動作、消去動作、及び、読出動作についての詳細を、フローチャートを用いて説明する。
MPU11は、フラッシュROM13に対する書込要求が生じると、図3に示す書込制御処理を実行し、書込要求にて指定された書込対象データを、フラッシュROM13に書き込む。書込要求は、例えば、車両制御の結果に従って学習パラメータを更新する処理タスクや電源投入回数をカウントアップする処理タスクから入力される。
Next, details of the data write operation, erase operation, and read operation by the MPU 11 will be described with reference to flowcharts.
When a write request to the flash ROM 13 is generated, the MPU 11 executes the write control process shown in FIG. 3 and writes the write target data specified by the write request to the flash ROM 13. The write request is input from, for example, a processing task for updating a learning parameter according to a result of vehicle control or a processing task for counting up the number of power-ons.

この書込制御処理を実行すると、MPU11は、書込要求元からフラッシュROM13への書込対象データを取得すると共に、書込対象データの種類を判別可能な識別コードであるIDコードを取得する(S110)。但し、ここで取得するIDコードは、上記データヘッダに用いられる上述のIDコードであってもよいし、書込要求元で管理される別のIDコードであってもよい。取得するIDコードが書込要求元で管理されるIDコードである場合には、これを上記データヘッダに用いるIDコードに変換する必要があるため、その変換テーブルを予めROM11a等に記憶させておく必要がある。   When this write control process is executed, the MPU 11 acquires the write target data from the write request source to the flash ROM 13 and also acquires an ID code that is an identification code that can determine the type of the write target data ( S110). However, the ID code acquired here may be the above-described ID code used in the data header, or another ID code managed by the write request source. If the ID code to be acquired is an ID code managed by the write request source, it is necessary to convert it to an ID code used for the data header, so that the conversion table is stored in the ROM 11a or the like in advance. There is a need.

S110での処理を終えると、MPU11は、上記取得した書込対象データが2バイト以上のデータであるか否かを判断し(S120)、2バイト以上のデータであると判断すると(S120でYes)、この書込対象データを1バイト毎のデータに分割する。即ち、この書込対象データを、バイトデータの一群に分割する(S130)。その後、S140に移行する。一方、書込対象データが1バイトのデータであると判断すると(S120でNo)、MPU11は、S130の処理を実行することなく、この書込対象データをバイトデータと取り扱って、S140に移行する。   When the processing in S110 is completed, the MPU 11 determines whether or not the acquired write target data is data of 2 bytes or more (S120), and determines that the data is data of 2 bytes or more (Yes in S120). ), This write target data is divided into data for each byte. That is, the write target data is divided into a group of byte data (S130). Thereafter, the process proceeds to S140. On the other hand, when determining that the write target data is 1-byte data (No in S120), the MPU 11 treats the write target data as byte data without executing the process of S130, and proceeds to S140. .

S140に移行すると、MPU11は、書込対象データを構成するバイトデータ群の中から、処理対象のバイトデータを一つ選択し、この処理対象のバイトデータが、フラッシュROM13に記憶されている旧データから内容変更されたものであるか否かを判断する(S150)。   After shifting to S140, the MPU 11 selects one byte data to be processed from the byte data group constituting the write target data, and this byte data to be processed is stored in the flash ROM 13 as the old data. It is determined whether or not the content has been changed (S150).

具体的には、処理対象のバイトデータと、当該処理対象のバイトデータに対して割り当てられたIDコードと同一のIDコードを有するデータヘッダに関連付けられてフラッシュROM13が記憶するバイトデータの内の最新データと、を比較することによって、処理対象のバイトデータが、フラッシュROM13に記憶されている旧データから内容変更されたものであるか否かを判断する(S150)。   Specifically, the latest byte data stored in the flash ROM 13 in association with the data header having the same ID code as the ID code assigned to the target byte data and the target byte data. By comparing the data with each other, it is determined whether or not the byte data to be processed has been changed from the old data stored in the flash ROM 13 (S150).

但し、本実施例では、電子制御装置1の起動時に、MPU11がフラッシュROM13全体を参照し、フラッシュROM13に記憶されているバイトデータに関して、IDコード毎の最新のバイトデータの格納先アドレスを表す管理テーブルを作成する。そして、これをRAM11bに記憶する。そして、フラッシュROM13に最新のバイトデータが書き込まれる度、そのバイトデータの格納先アドレスを管理テーブル内において更新する。   However, in this embodiment, when the electronic control unit 1 is started, the MPU 11 refers to the entire flash ROM 13, and the byte data stored in the flash ROM 13 represents the storage address of the latest byte data for each ID code. Create a table. And this is memorize | stored in RAM11b. Each time the latest byte data is written in the flash ROM 13, the storage address of the byte data is updated in the management table.

図4には、この管理テーブルの構成を示す。図4は、フラッシュROM13のアドレス「***3000H」に、第一のデータ(DATA1)を構成するバイトデータであってIDコードが「****0」のバイトデータの最新データが格納され、フラッシュROM13のアドレス「***3001H」に、第二のデータ(DATA2)を構成するバイトデータであってIDコードが「****1」である第二のデータの上位バイト(DATA2_H)についてのバイトデータの最新データが格納され、フラッシュROM13のアドレス「***3010H」に、第二のデータ(DATA2)を構成するバイトデータであってIDコードが「****2」である第二のデータの下位バイトDATA2_Lについてのバイトデータの最新データが格納されているときの、管理テーブルの構成を表すものである。第一及び第二のデータとしては、上述した学習パラメータや電源投入回数等のデータを挙げることができる。   FIG. 4 shows the configuration of this management table. FIG. 4 shows that the latest data of the byte data constituting the first data (DATA1) and having the ID code “*** 0” is stored in the address “*** 3000H” of the flash ROM 13. , The upper byte (DATA2_H) of the second data (ID2) that is the byte data constituting the second data (DATA2) at the address “*** 3001H” of the flash ROM 13 Is stored in the flash ROM 13 address “*** 3010H”, and the ID data is “*** 2” which is the byte data constituting the second data (DATA2). The structure of the management table when the latest byte data of the lower byte DATA2_L of the second data is stored. It is used to represent an. Examples of the first and second data include the above-described learning parameters and the number of times of power-on.

即ち、MPU11は、S150において、処理対象のバイトデータと、処理対象のバイトデータに対応するフラッシュROM13が記憶するバイトデータとを比較する際、データヘッダを介さずに、RAM11bが記憶する上記管理テーブルを参照して、処理対象のバイトデータに割り当てられたIDコードに対応するフラッシュROM13が記憶するバイトデータの最新データの格納先アドレスを特定する。そして、このアドレスに格納されたバイトデータを参照することで、比較対象のバイトデータにアクセスする。但し、MPU11は、このような方法に限らず、データヘッダのIDコードを参照して、比較対象のバイトデータをフラッシュROM13内において検索してもよい。   That is, when the MPU 11 compares the byte data to be processed with the byte data stored in the flash ROM 13 corresponding to the byte data to be processed in S150, the management table stored in the RAM 11b without using the data header. , The storage address of the latest data of the byte data stored in the flash ROM 13 corresponding to the ID code assigned to the byte data to be processed is specified. Then, the byte data to be compared is accessed by referring to the byte data stored at this address. However, the MPU 11 is not limited to such a method, but may search the flash ROM 13 for byte data to be compared with reference to the ID code of the data header.

MPU11は、このような比較動作を通じて、処理対象のバイトデータが、フラッシュROM13に記憶されている旧データ(フラッシュROM13に記憶されている同一IDコードのバイトデータの内、最新のもの)から内容変更されたものであると判断すると(S150でYes)、S160に移行し、処理対象のバイトデータをユーザデータとして、そのデータヘッダと共に、フラッシュROM13内のアクティブブロックに書き込む(S160)。   Through such a comparison operation, the MPU 11 changes the contents of the byte data to be processed from the old data stored in the flash ROM 13 (the latest data among the byte data of the same ID code stored in the flash ROM 13). If it is determined that the data has been processed (Yes in S150), the process proceeds to S160, and the processing target byte data is written as user data in the active block in the flash ROM 13 together with the data header (S160).

尚、ここで言うアクティブブロックとは、フラッシュROM13が有する複数の記憶ブロックの内、新たにバイトデータ(ユーザデータ)をフラッシュROM13に書き込む際の書込先ブロックのことを言う。MPU11は、上述したように、予め定められた順序で各記憶ブロックにデータを書き込むが、この動作は、アクティブブロックに空きがなくなった場合には、アクティブブロックを次ブロックに切り替えて、切替後のアクティブブロックに、新たなバイトデータを書き込むといった処理手順により実現される。   The active block referred to here is a write destination block for newly writing byte data (user data) to the flash ROM 13 among a plurality of storage blocks of the flash ROM 13. As described above, the MPU 11 writes data to each storage block in a predetermined order, but this operation switches the active block to the next block when there is no free space in the active block. This is realized by a processing procedure such as writing new byte data to the active block.

図2(a)に示す例によれば、MPU11は、第0記憶ブロック、第1記憶ブロック、第2記憶ブロック、…、第M記憶ブロックといった順序で、アクティブブロックを切り替え、書込順が最後の記憶ブロックである第M記憶ブロックに空きがなくなった場合には、次ブロックとしての第0記憶ブロックにアクティブブロックを切り替えて、バイトデータをデータヘッダと共に当該アクティブブロックに書き込む。このように、アクティブブロックは、第0から第M記憶ブロックをループするように順に切り替えられる。   According to the example shown in FIG. 2A, the MPU 11 switches the active block in the order of the 0th storage block, the 1st storage block, the 2nd storage block,. When there is no more free space in the Mth storage block, the active block is switched to the 0th storage block as the next block, and byte data is written in the active block together with the data header. In this way, the active block is sequentially switched so as to loop from the 0th to the Mth storage blocks.

このアクティブブロックに対し、処理対象のバイトデータ及びデータヘッダを書き込むと、MPU11は、続くS170(図3参照)にて、RAM11bが記憶する管理テーブルを更新する。即ち、処理対象のバイトデータのフラッシュROM13における書込先に応じて、RAM11bが記憶する管理テーブルにおける該当バイトデータの格納先アドレスを、その書込先のアドレスに更新する(S170)。その後、S180に移行する。   When the byte data and the data header to be processed are written into this active block, the MPU 11 updates the management table stored in the RAM 11b in the subsequent S170 (see FIG. 3). That is, according to the write destination of the byte data to be processed in the flash ROM 13, the storage address of the corresponding byte data in the management table stored in the RAM 11b is updated to the write destination address (S170). Thereafter, the process proceeds to S180.

また、S180に移行すると、MPU11は、書込対象データを構成する全バイトデータについて、これを処理対象のバイトデータに選択し、S150以降の処理を実行したか否かを判断する。そして、実行していないと判断すると(S180でNo)、S140に戻って、新たなバイトデータを処理対象のバイトデータに選択し、S150以降の処理を実行する。   When the process proceeds to S180, the MPU 11 selects all the byte data constituting the write target data as the process target byte data, and determines whether the processes after S150 have been executed. If it is determined that it is not executed (No in S180), the process returns to S140, and new byte data is selected as the byte data to be processed, and the processes after S150 are executed.

このようにして、書込対象データを構成する全バイトデータについてS150以降の処理を実行すると(S180でYes)、MPU11は、当該書込制御処理を終了する。MPU11は、このような手順により、書込対象データを1バイト単位のデータであるバイトデータの一群に分割し、これらバイトデータ群の内、フラッシュROM13が記憶するデータから内容変更のあったバイトデータ群のみを選択的に、フラッシュROM13に追記形式で書き込む。   In this way, when the processes after S150 are executed for all the byte data constituting the write target data (Yes in S180), the MPU 11 ends the write control process. The MPU 11 divides the data to be written into a group of byte data that is data in units of 1 byte by such a procedure, and among these byte data groups, the byte data whose contents are changed from the data stored in the flash ROM 13. Only the group is selectively written into the flash ROM 13 in a write-once format.

例えば、図5(a)に示すように、書込対象データが2バイトのデータであり、上位バイト(DATA_H)及び下位バイト(DATA_L)の内、下位バイト(DATA_L)のみが、フラッシュROM13に記憶されたデータから更新されたデータ(DATA_L*)である場合には、上位バイト及び下位バイトの内、下位バイトのバイトデータ(DATA_L*)のみを選択的に、フラッシュROM13に書き込む。   For example, as shown in FIG. 5A, the data to be written is 2-byte data, and only the lower byte (DATA_L) of the upper byte (DATA_H) and the lower byte (DATA_L) is stored in the flash ROM 13. In the case of data updated from the updated data (DATA_L *), only the lower byte data (DATA_L *) of the upper byte and lower byte is selectively written to the flash ROM 13.

尚、図5(a)は、本実施例によるフラッシュROM13へのデータ書込態様を表す図であり、図5(b)は、従来技術によるフラッシュROM13へのデータ書込態様を表す図である。従来技術によれば、図5(b)に示すように、下位バイト(DATA_L)のみが、フラッシュROM13に記憶されたデータから更新されたデータ(DATA_L*)であっても、書込対象データが2バイトのデータである場合には、これを、そのまま分割せずにフラッシュROM13に書き込む。このため、フラッシュROM13における空きスペースが早く失われ、データ消去回数を効率的に抑えることができない。本実施例によれば、このような従来技術と比較してデータ消去回数を効率的に抑えることができる。   FIG. 5A is a diagram showing a data writing mode to the flash ROM 13 according to the present embodiment, and FIG. 5B is a diagram showing a data writing mode to the flash ROM 13 according to the prior art. . According to the prior art, as shown in FIG. 5B, even if only the lower byte (DATA_L) is the data (DATA_L *) updated from the data stored in the flash ROM 13, the data to be written is If the data is 2-byte data, it is written into the flash ROM 13 without being divided. For this reason, the empty space in the flash ROM 13 is quickly lost, and the number of data erasures cannot be efficiently suppressed. According to the present embodiment, the number of data erasures can be efficiently suppressed as compared with such a conventional technique.

続いて、図6を用いて、フラッシュROM13に対するデータ消去動作について説明する。MPU11は、フラッシュROM13へのデータ書込が行われる度、図6に示す消去制御処理を実行する。   Next, a data erasing operation for the flash ROM 13 will be described with reference to FIG. The MPU 11 executes the erase control process shown in FIG. 6 every time data is written to the flash ROM 13.

消去制御処理を実行すると、MPU11は、まず、フラッシュROM13が次データの書込時に空きブロックが規定数(例えば、2個)未満となる状態であるか否かを判断する(S310)。そして、このような状態ではないと判断すると(S310でNo)、当該消去制御処理を終了する。   When the erase control process is executed, the MPU 11 first determines whether or not the flash ROM 13 is in a state where the number of empty blocks is less than a prescribed number (for example, 2) when the next data is written (S310). If it is determined that this is not the case (No in S310), the erasure control process is terminated.

図7の第一段に示す例は、1バイトのデータであるDATA1、2バイトのデータであるDATA2及びDATA3がフラッシュROM13に記憶されている状態を示すものである。図7に太実線で示す矩形は、記憶ブロックを表す。図7では、DATA2及びDATA3の上位バイトに対してサフィックス「_H」を付し、DATA2及びDATA3の下位バイトに対してサフィックス「_L」を付す。図7の第一段に示す状態では、アクティブブロックに空きがあり、フラッシュROM13が次データの書込時に空きブロックが規定数である2個未満となる状態ではないため、S310では、否定判断される。   The example shown in the first stage of FIG. 7 shows a state in which DATA 1-byte data DATA 2 and DATA 2 DATA 3 are stored in the flash ROM 13. A rectangle indicated by a thick solid line in FIG. 7 represents a storage block. In FIG. 7, the suffix “_H” is attached to the upper bytes of DATA2 and DATA3, and the suffix “_L” is attached to the lower bytes of DATA2 and DATA3. In the state shown in the first stage of FIG. 7, the active block is empty, and the flash ROM 13 is not in a state where the number of empty blocks is less than the prescribed number when writing the next data, so a negative determination is made in S310. The

一方、MPU11は、空きブロックが規定数未満となると判断すると(S310でYes)、S320に移行する。図7第二段は、図7第一段に示す状態から、アクティブブロックに新たなデータ(DATA1,DATA2_L)が書き込まれて、当該アクティブブロックに空きがなくなり、アクティブブロックが次ブロックに変更された状態を示すものである。この図7第二段に示す状態は、上記規定数が「2」である場合における、次データの書込時には、空きブロックが規定数(2個)未満となる状態に対応する。   On the other hand, when the MPU 11 determines that the number of free blocks is less than the specified number (Yes in S310), the process proceeds to S320. In the second stage of FIG. 7, from the state shown in the first stage of FIG. 7, new data (DATA1, DATA2_L) is written in the active block, the active block becomes empty, and the active block is changed to the next block. It shows the state. The state shown in the second stage of FIG. 7 corresponds to a state in which the number of empty blocks is less than the prescribed number (2) when the next data is written when the prescribed number is “2”.

このような状態となると、MPU11は、続くS320にて、空きブロックではない記憶ブロック(以下、「非空きブロック」と表現する。)の一群の内、最も早い時期に空きスペースのなくなった記憶ブロックを消去対象の記憶ブロック(以下、「消去対象ブロック」と表現する。)に選択する。図7に示す例では、最も右に示す記憶ブロックが消去対象ブロックに対応する。   In such a state, the MPU 11 in the subsequent S320, among the group of storage blocks that are not empty blocks (hereinafter referred to as “non-empty blocks”), storage blocks that have no free space at the earliest time. Are selected as storage blocks to be erased (hereinafter referred to as “erasure target blocks”). In the example shown in FIG. 7, the rightmost storage block corresponds to the erase target block.

その後、MPU11は、選択した消去対象ブロックが記憶するバイトデータ群の内、最新データに対応するバイトデータ群を特定する(S330)。図7第二段に示す例では、消去対象ブロックに、最新データとして、DATA3の上位バイト(DATA3_H)及びDATA2の上位バイト(DATA2_H)が記憶保持されているものとする。図7では、最新データを、塗り潰し画像により示す。   Thereafter, the MPU 11 specifies a byte data group corresponding to the latest data among the byte data groups stored in the selected erasure target block (S330). In the example shown in the second stage of FIG. 7, it is assumed that the upper byte (DATA3_H) of DATA3 and the upper byte (DATA2_H) of DATA2 are stored and held as the latest data in the block to be erased. In FIG. 7, the latest data is indicated by a filled image.

ここで、消去対象ブロックが記憶する上記最新データに対応するバイトデータの特定は、S150での処理と同様、RAM11bに記憶された管理テーブルを参照することにより実現することができる。上述したように管理テーブルには、IDコード毎に、そのIDコードに対応するバイトデータの最新データの格納先アドレスが記述されている。このため、管理テーブルにおいて消去対象ブロックに該当する格納先アドレスが記述されているIDコードに対応するバイトデータは、消去対象ブロックが記憶する上記最新データに対応するバイトデータに該当する。従って、S330では、管理テーブルにおいて、消去対象ブロックに該当する格納先アドレスが記述されたIDコードに対応するバイトデータの一群を、消去対象ブロックが記憶する上記最新データに対応するバイトデータ群として特定することができる。   Here, the specification of the byte data corresponding to the latest data stored in the erasure target block can be realized by referring to the management table stored in the RAM 11b, as in the processing in S150. As described above, in the management table, the storage address of the latest data of the byte data corresponding to the ID code is described for each ID code. Therefore, the byte data corresponding to the ID code in which the storage destination address corresponding to the erasure target block in the management table corresponds to the byte data corresponding to the latest data stored in the erasure target block. Therefore, in S330, in the management table, a group of byte data corresponding to the ID code in which the storage destination address corresponding to the erase target block is described is specified as a byte data group corresponding to the latest data stored in the erase target block. can do.

但し、別例として、MPU11は、フラッシュROM13内のバイトデータの配置を特定することで、消去対象ブロックが記憶する上記最新データに対応するバイトデータ群を特定されてもよい。即ち、同一IDコードのバイトデータが複数フラッシュROM13に記憶されている場合には、これら同一IDコードのバイトデータ群の内、フラッシュROM13における現時点での書込位置終端からデータ書込方向上流に遡ったときに最初に現れるバイトデータを、最新データであると判断し、同一IDコードのバイトデータが複数記憶されていないバイトデータについては、フラッシュROM13に記憶されている唯一のバイトデータを、最新データであると判断することで、消去対象ブロックに記憶されているバイトデータ群の内、最新データに対応するバイトデータ群を特定することができる。   However, as another example, the MPU 11 may specify the byte data group corresponding to the latest data stored in the erase target block by specifying the arrangement of the byte data in the flash ROM 13. In other words, when a plurality of byte data of the same ID code is stored in the flash ROM 13, the byte data group of the same ID code goes back upstream in the data writing direction from the current write position end in the flash ROM 13. The byte data that appears first is determined to be the latest data, and for byte data in which a plurality of byte data with the same ID code is not stored, the only byte data stored in the flash ROM 13 is replaced with the latest data. Therefore, it is possible to specify the byte data group corresponding to the latest data among the byte data groups stored in the erasure target block.

この他、データヘッダに、上記フラグデータとして、対応するバイトデータの更新回数(バージョン)を表すデータが書き込まれる場合には、このフラグデータを参照し、フラッシュROM13に記憶されている同一IDコードのバイトデータ群の内、更新回数が最大のバイトデータ(最新バージョンのバイトデータ)を、最新データと判断することが可能である。このような最新データの判断は、S150の処理にも採用することが可能である。   In addition, when data representing the update count (version) of the corresponding byte data is written as the flag data in the data header, this flag data is referred to and the same ID code stored in the flash ROM 13 is referred to. Of the byte data group, the byte data with the largest number of updates (the latest version of the byte data) can be determined as the latest data. Such determination of the latest data can also be adopted in the processing of S150.

また、データヘッダに、上記フラグデータとして、正常にバイトデータがフラッシュROM13に書き込まれたか否かを表す情報が書き込まれる場合には、このフラグデータを参照し、正常に書き込まれてないバイトデータについては、フラッシュROM13に記憶されていないものと形式的に取り扱って、最新データを特定されてもよい。この場合には、RAM11bの管理テーブルに対しても、上記正常に書き込まれていないバイトデータについてはフラッシュROM13に記憶されていないものと形式的に取り扱って、IDコード毎の最新データに対応する格納先アドレスを記述すればよい。   In addition, when information indicating whether or not byte data has been normally written to the flash ROM 13 is written in the data header as the flag data, the flag data is referred to and byte data that is not normally written is referred to. May be treated formally as not stored in the flash ROM 13 and the latest data may be specified. In this case, in the management table of the RAM 11b, the byte data that has not been normally written is treated formally as not stored in the flash ROM 13, and stored corresponding to the latest data for each ID code. What is necessary is just to describe a destination address.

S330の処理後、MPU11は、消去対象ブロックに記憶されているバイトデータ群の内、上記特定された最新データに対応するバイトデータの夫々を、前回のデータ書込時に更新された新たなアクティブブロックに、ユーザデータとして書き込むことで、これらバイトデータを、消去対象ブロックではない記憶ブロックに退避させる(S340)。勿論、この際には、これらバイトデータに対応するデータヘッダを、アクティブブロックに書き込む。図7第三段には、消去対象ブロックにおいて記憶保持される最新データ(DATA3_H,DATA2_H)が、アクティブブロックに退避された例を示す。   After the processing of S330, the MPU 11 sets each of the byte data corresponding to the specified latest data among the byte data group stored in the erasure target block as a new active block updated at the previous data writing. In addition, by writing as user data, these byte data are saved in a storage block that is not an erasure target block (S340). Of course, in this case, a data header corresponding to these byte data is written in the active block. The third row in FIG. 7 shows an example in which the latest data (DATA3_H, DATA2_H) stored and held in the erasure target block is saved in the active block.

その後、MPU11は、消去対象ブロック内のデータをブロック単位で消去して(S350)、当該消去制御処理を終了する。尚、消去対象ブロック内のデータを消去する際には、消去対象ブロックにおけるブロックヘッダ領域内のデータを、一旦RAM11bに退避させ、消去対象ブロック内のデータを消去した後、上記RAM11bに退避させたデータに基づき、消去後の記憶ブロックにおけるブロックヘッダ領域内に必要データを書き込む。   Thereafter, the MPU 11 erases the data in the erase target block in units of blocks (S350), and ends the erase control process. When erasing the data in the erasure target block, the data in the block header area in the erasure target block is temporarily saved in the RAM 11b, and the data in the erasure target block is erased and then saved in the RAM 11b. Based on the data, necessary data is written into the block header area in the storage block after erasure.

本実施例では、このような手順でフラッシュROM13内のデータを記憶ブロック単位で消去することによって、必要データがフラッシュROM13から消去されないようにする。   In this embodiment, the necessary data is not erased from the flash ROM 13 by erasing the data in the flash ROM 13 in units of storage blocks in such a procedure.

また、本実施例の電子制御装置1によれば、図8に示すようにして、フラッシュROM13に記憶されたデータを読み出す。即ち、MPU11は、フラッシュROM13に記憶されたデータの読出要求が生じると、図8に示す読出制御処理を実行する。読出要求は、例えば、読出対象データを必要とするタスクから入力される。   Further, according to the electronic control device 1 of the present embodiment, the data stored in the flash ROM 13 is read as shown in FIG. In other words, when a request for reading data stored in the flash ROM 13 is generated, the MPU 11 executes the read control process shown in FIG. The read request is input from, for example, a task that requires data to be read.

読出制御処理を開始すると、MPU11は、読出要求にて指定された読出対象データを構成する各バイトデータの最新データのフラッシュROM13における格納先アドレスを、読出要求元から通知される読出対象データに対応するIDコードの情報に基づいて特定する(S510)。具体的には、RAM11bが記憶する管理テーブルを参照することにより、特定することができる。尚、読出要求元から通知されるIDコードが、フラッシュROM13で用いられる上記IDコードと異なる場合には、上述したように変換テーブルに基づいて、読出対象データを構成する各バイトデータのIDコードを特定すればよい。   When the read control process is started, the MPU 11 corresponds to the read target data notified from the read request source, the storage destination address in the flash ROM 13 of the latest data of each byte data constituting the read target data specified by the read request. Identification based on the information of the ID code to be performed (S510). Specifically, it can be specified by referring to the management table stored in the RAM 11b. If the ID code notified from the read request source is different from the ID code used in the flash ROM 13, the ID code of each byte data constituting the read target data is set based on the conversion table as described above. You just have to specify.

その後、MPU11は、上記特定された各バイトデータの格納先アドレスを参照して、読出対象データを構成する各バイトデータについての最新データをフラッシュROM13から読み出し(S520)、読み出した各バイトデータを、そのIDコードに基づき、読出対象データにおけるバイトコードの配列順に結合する。これによって、読出対象データに対応する複数バイトデータを結合してなる結合データを生成する(S530)。その後、この結合データ(読出対象データ)を、読出要求元に提供し(S540)、当該読出制御処理を終了する。   Thereafter, the MPU 11 refers to the storage address of each specified byte data, reads the latest data for each byte data constituting the read target data from the flash ROM 13 (S520), and reads each read byte data. Based on the ID code, the data is combined in the order of arrangement of the byte codes in the read target data. Thereby, combined data formed by combining a plurality of bytes of data corresponding to the data to be read is generated (S530). Thereafter, the combined data (read target data) is provided to the read request source (S540), and the read control process is terminated.

このようにして読出制御処理を実行する本実施例の電子制御装置1によれば、フラッシュROM13から読み出されたバイトデータを読出要求元で結合する必要がないことから、制御パラメータや電源投入回数を取り扱うアプリケーションプログラム側の仕様を大幅に変更することなく、本発明に対応する処理を実現することができる。即ち、メモリドライバ(プログラム)を、上述した書込制御処理、消去制御処理及び読出制御処理を実行可能なプログラム構成とする程度で、本発明に対応する処理を実現することができる。   According to the electronic control apparatus 1 of the present embodiment that executes the read control process in this way, it is not necessary to combine byte data read from the flash ROM 13 at the read request source. The processing corresponding to the present invention can be realized without drastically changing the specifications on the application program side that handles. That is, the processing corresponding to the present invention can be realized by setting the memory driver (program) to a program configuration capable of executing the above-described write control processing, erase control processing, and read control processing.

そして、このようなプログラムをROM11aに組み込んで、MPU11にこれらの処理を実行させるように電子制御装置1を構成することで、利便性が高く、しかもフラッシュROM13に対するデータ書込量を減らしてフラッシュROM13の寿命を延長させることのできる電子制御装置1を構成することができる。   Then, by incorporating such a program into the ROM 11a and configuring the electronic control unit 1 to cause the MPU 11 to execute these processes, it is highly convenient and the amount of data written to the flash ROM 13 is reduced, thereby reducing the flash ROM 13 It is possible to configure the electronic control device 1 that can extend the life of the device.

以上、本発明の実施例について説明したが、本実施例によれば、例えば、電源投入回数を2バイトのデータとして、フラッシュROM13に記憶させるとき、次のような利点がある。即ち、電源投入回数については、電源投入毎に1インクリメントされるため、下位バイトについては毎回、その値が更新されるが、上位バイトについては、256回に1回しか更新されないことになる。従って、電源投入回数について256回の書込をフラッシュROM13に行ったとすると、従来技術によれば、その書込量の合計は、2バイト×256回=512バイトとなるが、本実施例によれば、その書込量の合計は、1バイト(下位バイト)×256回+1バイト(上位バイト)×1回=257バイトとなり、フラッシュROM13への書込量を大幅に低減することができる。よって、本実施例によれば、フラッシュROM13におけるデータ消去回数を低減することができ、その結果として、フラッシュROM13の長寿命化を実現することができる。   The embodiment of the present invention has been described above. According to this embodiment, for example, when the number of power-on times is stored in the flash ROM 13 as 2-byte data, the following advantages are obtained. That is, the number of times of power-on is incremented by 1 every time the power is turned on, so the value of the lower byte is updated every time, but the upper byte is updated only once every 256 times. Accordingly, assuming that 256 times of writing are performed on the flash ROM 13 with respect to the number of times of power-on, according to the prior art, the total amount of writing is 2 bytes × 256 times = 512 bytes. For example, the total writing amount is 1 byte (lower byte) × 256 times + 1 byte (upper byte) × 1 time = 257 bytes, and the writing amount to the flash ROM 13 can be greatly reduced. Therefore, according to the present embodiment, the number of data erasures in the flash ROM 13 can be reduced, and as a result, the life of the flash ROM 13 can be extended.

尚、上述した実施例においてMPU11が実行するS150の処理は、比較手段によって実現される処理の一例に対応し、MPU11が実行するS160の処理は、書込制御手段によって実現される処理の一例に対応し、MPU11が実行する読出制御処理は、読出制御手段によって実現される処理の一例に対応し、MPU11が実行する消去制御処理は、消去制御手段によって実現される処理の一例に対応する。   In the above-described embodiment, the process of S150 executed by the MPU 11 corresponds to an example of a process realized by the comparison unit, and the process of S160 executed by the MPU 11 is an example of a process realized by the write control unit. Correspondingly, the read control process executed by the MPU 11 corresponds to an example of a process realized by the read control means, and the erase control process executed by the MPU 11 corresponds to an example of a process realized by the erase control means.

また、本発明は、上記実施例に限定されるものではなく、種々の態様を採ることができる。
例えば、上記実施例では、フラッシュROM13を備える電子制御装置1に本発明を適用した例について説明したが、本発明は、フラッシュROM13に代えて、1バイト単位でのデータ消去が可能なEEPROMに適用されてもよい。本発明によれば、データ書込量を抑えることができるので、結果として、EEPROMにおいてもデータ消去回数を抑えることができ、EEPROMの長寿命化を実現することができる。但し、EEPROMでは数10万回程度のデータ消去が可能であるのに対し、フラッシュROMでは、1万回程度のデータ消去しかできないので、本発明は、フラッシュROMに適用されると、その効果が一層発揮される。
Further, the present invention is not limited to the above-described embodiments, and can take various forms.
For example, in the above embodiment, the example in which the present invention is applied to the electronic control device 1 including the flash ROM 13 has been described. However, the present invention is applied to an EEPROM capable of erasing data in units of 1 byte instead of the flash ROM 13. May be. According to the present invention, the amount of data written can be reduced. As a result, the number of data erasures can be reduced even in the EEPROM, and the life of the EEPROM can be extended. However, data can be erased several hundred thousand times with an EEPROM, whereas data erase only about 10,000 times with a flash ROM. Therefore, the present invention is effective when applied to a flash ROM. It is further demonstrated.

また、上記実施例では、本発明を、車両制御用の電子制御装置1に適用した例を説明したが、本発明は、その他の種々の電子機器に適用することが可能である。   Further, in the above-described embodiment, the example in which the present invention is applied to the electronic control device 1 for vehicle control has been described. However, the present invention can be applied to various other electronic devices.

1…電子制御装置、3…制御対象、5…センサ類、11…MPU、11a…ROM、11b…RAM、13…・フラッシュROM、15…入出力回路 DESCRIPTION OF SYMBOLS 1 ... Electronic control unit, 3 ... Control object, 5 ... Sensors, 11 ... MPU, 11a ... ROM, 11b ... RAM, 13 ... Flash ROM, 15 ... I / O circuit

Claims (7)

電気的にデータ書換可能な不揮発性メモリと、
前記不揮発性メモリに対する書込対象データが生じると、前記書込対象データと前記不揮発性メモリが記憶する前記書込対象データに対応する旧データとを比較して、前記書込対象データを構成する要素データ群の内、前記旧データから内容変更された要素データを特定する比較手段と、
前記書込対象データを構成する要素データ群の内、前記比較手段により特定された前記旧データから内容変更された要素データ群を選択的に、前記不揮発性メモリに書き込む書込制御手段と、
を備えることを特徴とする電子機器。
An electrically rewritable nonvolatile memory;
When data to be written to the nonvolatile memory is generated, the data to be written is configured by comparing the data to be written with old data corresponding to the data to be written stored in the nonvolatile memory. Comparison means for specifying element data whose contents have been changed from the old data in the element data group;
Write control means for selectively writing an element data group whose contents have been changed from the old data specified by the comparison means among the element data groups constituting the write target data, to the nonvolatile memory;
An electronic device comprising:
読出要求が生じると、読出要求にて指定された読出対象データを構成する要素データ毎の前記不揮発性メモリが記憶する最新データを読み出し、読み出した各要素データの最新データを、前記読出対象データとして前記読出要求元に提供する読出制御手段
を備えることを特徴とする請求項1記載の電子機器。
When a read request occurs, the latest data stored in the nonvolatile memory for each element data constituting the read target data designated by the read request is read, and the latest data of each read element data is used as the read target data. The electronic apparatus according to claim 1, further comprising: a read control unit that provides the read request source.
前記不揮発性メモリは、前記要素データ複数個分に対応する予め定められたエリア単位でのデータ消去が必要なメモリであり、
前記電子機器は、
空きスペースを確保するために、前記不揮発性メモリが記憶する前記要素データ群を前記エリア単位で消去する一方、前記消去に際しては、消去対象のエリアにおいて記憶される前記要素データ群の内、最新データに対応する要素データ群を、前記消去対象のエリアに該当しない前記不揮発性メモリ内の他のエリアに書き込んで退避させる消去制御手段
を備えることを特徴とする請求項1又は請求項2記載の電子機器。
The non-volatile memory is a memory that requires data erasing in a predetermined area unit corresponding to the plurality of element data,
The electronic device is
In order to secure an empty space, the element data group stored in the non-volatile memory is erased in units of the area, and when erasing, the latest data in the element data group stored in the area to be erased is deleted. 3. The electronic device according to claim 1, further comprising: an erasing control unit that writes and saves the element data group corresponding to 1 in another area in the nonvolatile memory that does not correspond to the area to be erased. machine.
前記要素データの夫々には、固有の識別コードが予め割り当てられており、
前記書込制御手段は、前記不揮発性メモリに前記要素データを書き込む際、前記要素データと関連付けて当該要素データに割り当てられた識別コードを前記不揮発性メモリに書き込み、
前記比較手段は、前記書込対象データを前記不揮発性メモリが記憶する旧データと比較する際、前記書込対象データを構成する要素データ毎に、この要素データと、当該要素データに割り当てられた識別コードと同一の識別コードに関連付けて前記不揮発性メモリが記憶する要素データとを比較して、前記書込対象データを構成する要素データ群の内、前記旧データから内容変更された要素データを特定すること
を特徴とする請求項1〜請求項3のいずれか一項記載の電子機器。
Each of the element data is pre-assigned a unique identification code,
The writing control means writes the identification code assigned to the element data in association with the element data to the nonvolatile memory when writing the element data to the nonvolatile memory,
When comparing the write target data with the old data stored in the nonvolatile memory, the comparing means is assigned to the element data and the element data for each element data constituting the write target data. The element data stored in the nonvolatile memory in association with the same identification code as the identification code is compared, and the element data whose contents are changed from the old data in the element data group constituting the write target data The electronic apparatus according to claim 1, wherein the electronic apparatus is specified.
前記要素データの夫々は、前記不揮発性メモリに書込可能な最小のデータ単位で前記書込対象データを区画化して表される各区画のデータであること
を特徴とする請求項1〜請求項4のいずれか一項記載の電子機器。
Each of the element data is data of each partition expressed by partitioning the write target data in a minimum data unit that can be written to the nonvolatile memory. 5. The electronic device according to any one of 4.
前記不揮発性メモリは、バイト単位でデータを書込可能なメモリであり、
前記要素データの夫々は、前記バイト単位で前記書込対象データを区画化して表される各区画のデータであること
を特徴とする請求項1〜請求項4のいずれか一項記載の電子機器。
The nonvolatile memory is a memory capable of writing data in units of bytes,
5. The electronic device according to claim 1, wherein each of the element data is data of each partition expressed by partitioning the write target data in the byte unit. .
前記不揮発性メモリは、フラッシュROMであることを特徴とする請求項1〜請求項6のいずれか一項記載の電子機器。   The electronic device according to claim 1, wherein the nonvolatile memory is a flash ROM.
JP2011120787A 2011-05-30 2011-05-30 Electronic equipment Pending JP2012248094A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011120787A JP2012248094A (en) 2011-05-30 2011-05-30 Electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011120787A JP2012248094A (en) 2011-05-30 2011-05-30 Electronic equipment

Publications (1)

Publication Number Publication Date
JP2012248094A true JP2012248094A (en) 2012-12-13

Family

ID=47468465

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011120787A Pending JP2012248094A (en) 2011-05-30 2011-05-30 Electronic equipment

Country Status (1)

Country Link
JP (1) JP2012248094A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014215628A (en) * 2013-04-22 2014-11-17 株式会社デンソー Data storage device
JP2016012213A (en) * 2014-06-27 2016-01-21 株式会社デンソー Electronic control unit

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0764868A (en) * 1993-08-24 1995-03-10 Melco:Kk Storage updating device
JP2010020586A (en) * 2008-07-11 2010-01-28 Nec Electronics Corp Data processing device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0764868A (en) * 1993-08-24 1995-03-10 Melco:Kk Storage updating device
JP2010020586A (en) * 2008-07-11 2010-01-28 Nec Electronics Corp Data processing device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014215628A (en) * 2013-04-22 2014-11-17 株式会社デンソー Data storage device
JP2016012213A (en) * 2014-06-27 2016-01-21 株式会社デンソー Electronic control unit

Similar Documents

Publication Publication Date Title
JP4418439B2 (en) Nonvolatile storage device and data writing method thereof
KR101110785B1 (en) Flash memory with programmable endurance
US7783851B2 (en) Methods of reusing log blocks in non-volatile memories and related non-volatile memory devices
JP4356686B2 (en) Memory device and memory control method
JP2010020586A (en) Data processing device
JP5570406B2 (en) Memory controller and data recording apparatus
US8271721B2 (en) Data writing method and data storage device
JP6123766B2 (en) Data reading apparatus, program, and data reading method
JP6028670B2 (en) Data storage
JP5695112B2 (en) Data storage device, data storage method, and in-vehicle control device
JP5569469B2 (en) Electronics
JP2012248094A (en) Electronic equipment
JP2009116465A (en) Storage device and memory control method
JP2017097576A (en) Rewrite system
US10073769B2 (en) Data storage device and data maintenance method thereof
JP4826232B2 (en) Information processing apparatus and boot program rewriting method
US20110082995A1 (en) Information processing apparatus
KR102315314B1 (en) Apparatus and method for controlling eeprom
JP6512091B2 (en) INFORMATION MANAGEMENT DEVICE, INFORMATION MANAGEMENT METHOD, AND INFORMATION MANAGEMENT PROGRAM
JP4410271B2 (en) Memory control device
JP2006164354A (en) Counter device and counting method
JP2010039509A (en) Storage device and data write control method
JP7317609B2 (en) electronic controller
JP2007219793A (en) Writing method of flash memory
CN107863126B (en) Method for managing data of non-volatile memory of sensing node

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20130731

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140212

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140225

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20140708