JP7317609B2 - electronic controller - Google Patents

electronic controller Download PDF

Info

Publication number
JP7317609B2
JP7317609B2 JP2019128948A JP2019128948A JP7317609B2 JP 7317609 B2 JP7317609 B2 JP 7317609B2 JP 2019128948 A JP2019128948 A JP 2019128948A JP 2019128948 A JP2019128948 A JP 2019128948A JP 7317609 B2 JP7317609 B2 JP 7317609B2
Authority
JP
Japan
Prior art keywords
address
storage area
data
unit
recorded
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.)
Active
Application number
JP2019128948A
Other languages
Japanese (ja)
Other versions
JP2021015388A (en
Inventor
憲太 森島
雄司 千葉
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.)
Hitachi Astemo Ltd
Original Assignee
Hitachi Astemo Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Astemo Ltd filed Critical Hitachi Astemo Ltd
Priority to JP2019128948A priority Critical patent/JP7317609B2/en
Publication of JP2021015388A publication Critical patent/JP2021015388A/en
Application granted granted Critical
Publication of JP7317609B2 publication Critical patent/JP7317609B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Memory System (AREA)

Description

本発明は、電子制御装置に関する。 The present invention relates to electronic control units.

近年では様々な機器がネットワークに接続され、機器に記録された情報を更新する仕組みが広く知られている。人が持ち歩く携帯端末や移動体に搭載する機器には、衝撃への耐性が強い不揮発性メモリが用いられることが多い。特許文献1には、車両の動作を制御する処理を実装した制御プログラムを格納する不揮発メモリ、前記制御プログラムを実行する演算部、を備え、前記不揮発メモリは、第1記憶領域と第2記憶領域を有し、前記不揮発メモリはさらに、前記第1記憶領域と前記第2記憶領域のうちいずれが現在実行すべき現行版制御プログラムを格納しているかを表す管理データを格納し、前記演算部は、前記現行版制御プログラムの更新版である更新版制御プログラムと前記現行版制御プログラムとの間の差分を表す差分データ、前記更新版制御プログラムを圧縮した圧縮データ、または前記更新版制御プログラムのうちいずれかを用いて前記更新版制御プログラムのイメージを復元し、前記演算部は、前記第1記憶領域と前記第2記憶領域のうち前記管理データが指定していない側である一方に対して前記更新版制御プログラムのイメージを書き込むとともに、前記更新版制御プログラムの書込みが正常に完了した場合は、前記管理データを前記第1記憶領域と前記第2記憶領域のうち前記管理データが指定していない側を表すデータに書き換え、前記更新版制御プログラムの書込みが正常でない場合は、前記管理データを書き換えないことを特徴とする車両制御装置が開示されている。 In recent years, various devices are connected to a network, and a mechanism for updating information recorded in the devices is widely known. Portable terminals carried by people and devices mounted on moving bodies often use non-volatile memories that are highly resistant to impact. Patent document 1 includes a nonvolatile memory that stores a control program that implements processing for controlling the operation of a vehicle, and a computing unit that executes the control program, and the nonvolatile memory includes a first storage area and a second storage area. and the non-volatile memory further stores management data indicating which of the first storage area and the second storage area stores the current version control program to be currently executed, and the computing unit , difference data representing the difference between the current version control program and the update version control program, which is an update version of the current version control program, compressed data obtained by compressing the update version control program, or the update version control program The image of the update version control program is restored using either one of them, and the calculation unit restores the image of the update version control program to one of the first storage area and the second storage area that is not specified by the management data. The image of the update version control program is written, and if the writing of the update version control program is normally completed, the management data is not specified in the first storage area or the second storage area. A vehicle control device is disclosed that rewrites the management data to data representing a side, and does not rewrite the management data if the writing of the updated control program is not normal.

特開2018-018186号公報JP 2018-018186 A

特許文献1に記載されている発明では、特定のアドレスの書き換え回数が多くなる傾向があり、製品寿命の観点から改善の余地がある。 In the invention described in Patent Document 1, there is a tendency that the number of times of rewriting a specific address increases, and there is room for improvement in terms of product life.

本発明の第1の態様による電子制御装置は、アドレスが付されデータセットが記録されるデータ記憶領域、および2以上の前記アドレスを格納可能なアドレス記憶領域を含む不揮発性の記憶領域である記憶部と、前記データセットが入力される入力部と、前記入力部に入力された前記データセットを前記データ記憶領域における未記録領域に記録し、前記未記録領域のアドレスに関する情報を前記アドレス記憶領域の未記録領域に記録する記録部と、前記アドレス記憶領域における最新の記録に基づいて前記データ記憶領域から前記データセットを読み出す読出部と、を備え、前記データセットは複数のデータから構成され、前記記録部は、前記複数のデータのそれぞれが記録されたアドレスを示すアドレステーブルを前記データセットとともに前記データ記憶領域に記録し、前記未記録領域のアドレスに関する情報とは前記アドレステーブルが記録されているアドレスであるAn electronic control device according to a first aspect of the present invention is a memory which is a non-volatile storage area including a data storage area in which addresses are assigned and data sets are recorded, and an address storage area capable of storing two or more of the addresses. an input unit to which the data set is input; the data set input to the input unit is recorded in an unrecorded area in the data storage area; and a reading unit for reading the data set from the data storage area based on the latest recording in the address storage area, wherein the data set is composed of a plurality of data, The recording unit records an address table indicating an address where each of the plurality of data is recorded in the data storage area together with the data set, and the information regarding the address of the unrecorded area is the address table recorded. address .

本発明によれば、特定の領域が集中して書き換えられることを防止し、製品の寿命を延ばすことができる。 According to the present invention, it is possible to prevent concentrated rewriting in a specific area and extend the life of the product.

電子制御装置のハードウエア構成図Hardware configuration diagram of electronic control unit 電子制御装置の機能構成図Functional configuration diagram of the electronic control unit 記憶部の初期状態を示す図Diagram showing the initial state of the storage unit データセットが4回記録された記憶部の状態を示す図A diagram showing the state of the storage unit in which the data set has been recorded four times. 記憶部の別の状態を示す図A diagram showing another state of the memory unit 第1の実施の形態における記録部の動作を示すフローチャートFlowchart showing the operation of the recording unit in the first embodiment 第1の実施の形態における読出部の動作を示すフローチャートFlowchart showing the operation of the reading unit in the first embodiment 第2の実施の形態における記録部の動作を示すフローチャートFlowchart showing the operation of the recording unit in the second embodiment 第2の実施の形態における読出部の動作を示すフローチャートFlowchart showing the operation of the reading unit in the second embodiment 第2の実施の形態における記憶部の状態例を示す図FIG. 11 is a diagram showing an example of the state of a storage unit according to the second embodiment; 第2の実施の形態の変形例2における記憶部の状態例を示す図FIG. 11 is a diagram showing an example of the state of a storage unit in modification 2 of the second embodiment; 第3の実施の形態におけるデータセットの例を示す図A diagram showing an example of a data set in the third embodiment 第3の実施の形態における記憶部の状態例を示す図FIG. 11 is a diagram showing an example of the state of a storage unit according to the third embodiment; 第3の実施の形態における記録部のS304の詳細を示すフローチャートFlowchart showing details of S304 of the recording unit in the third embodiment 第3の実施の形態における読出部のS325の詳細を示すフローチャートFlowchart showing details of S325 of the reading unit in the third embodiment

―第1の実施の形態―
以下、図1~図7を参照して、電子制御装置の第1の実施の形態を説明する。
-First Embodiment-
A first embodiment of an electronic control unit will be described below with reference to FIGS. 1 to 7. FIG.

図1は、本発明に係る電子制御装置9のハードウエア構成図である。電子制御装置9は、中央演算装置であるCPU1、読み出し専用の記憶装置であるROM2、および読み書き可能な記憶装置であるRAM3、不揮発性の記憶領域、たとえばフラッシュメモリである記憶部4、および通信部5を備える。CPU1は、ROM2に格納されるプログラムをRAM3に展開して実行することで後述する複数の機能を実現する。 FIG. 1 is a hardware configuration diagram of an electronic control unit 9 according to the present invention. The electronic control unit 9 includes a CPU 1 that is a central processing unit, a ROM 2 that is a read-only storage device, a RAM 3 that is a readable and writable storage device, a non-volatile storage area such as a storage unit 4 that is a flash memory, and a communication unit. 5. The CPU 1 develops the programs stored in the ROM 2 in the RAM 3 and executes them, thereby realizing a plurality of functions to be described later.

記憶部4は、書き換え可能でかつ、ハードウエアの仕様として書き込み回数に制限がある不揮発性の記憶装置、たとえばフラッシュメモリである。記憶部4への書き込みおよび記憶部4からの読み込みは任意のデータサイズで可能である。記憶部4に記録された情報の消去は、所定のブロック単位(以下、「消去単位ブロック」)でしか実行できない。なお消去単位ブロックは数キロバイト~数百キロバイトの製品が多いが、本実施の形態では説明の簡略のために消去単位ブロックを16バイトとする。通信部5は、電子制御装置9の外部から情報を受信する通信モジュールである。通信部5が実行する通信は、無線通信でもよいし有線通信でもよい。 The storage unit 4 is a rewritable non-volatile storage device, such as a flash memory, whose hardware specification limits the number of times of writing. Any data size can be written to and read from the storage unit 4 . Erasure of information recorded in the storage unit 4 can be executed only in units of predetermined blocks (hereinafter referred to as "erase unit blocks"). Although many products have an erase unit block of several kilobytes to several hundred kilobytes, in the present embodiment, the erase unit block is assumed to be 16 bytes for the sake of simplicity of explanation. The communication unit 5 is a communication module that receives information from the outside of the electronic control unit 9 . The communication performed by the communication unit 5 may be wireless communication or wired communication.

図2は、電子制御装置9の機能構成図である。ただし図2には、記憶部4の便宜的な領域構成も図示している。電子制御装置9は、その機能として、入力部11と、記録部12と、読出部13とを備える。記憶部4には、データ記憶領域41と、アドレス記憶領域42とが含まれる。入力部11は、電子制御装置9の外部から通信部5に入力された情報を取得する。入力部11は、通信部5に入力された全ての情報を取得してもよいし、特別な識別子が付された情報のみを取得してもよい。 FIG. 2 is a functional configuration diagram of the electronic control unit 9. As shown in FIG. However, FIG. 2 also shows a convenient area configuration of the storage unit 4 . The electronic control unit 9 includes an input unit 11, a recording unit 12, and a reading unit 13 as its functions. The storage unit 4 includes a data storage area 41 and an address storage area 42 . The input unit 11 acquires information input to the communication unit 5 from the outside of the electronic control unit 9 . The input unit 11 may acquire all information input to the communication unit 5, or may acquire only information with a special identifier.

以下では、入力部11が取得する情報を「データセット」と呼ぶ。データセットは、電子データであればよく、その実態は不問である。たとえばデータセットは、1つの実行可能ファイル、複数の実行可能ファイル、実行可能ファイルの一部、ソースコード、ソースコードの差分、演算に用いるデータなどである。念のために記載すると、データセットはアスキーデータでもよいしバイナリデータでもよい。 Information acquired by the input unit 11 is hereinafter referred to as a “data set”. The data set may be electronic data, and its actual state is irrelevant. For example, a data set may be an executable file, multiple executable files, a portion of an executable file, source code, source code differences, data used in calculations, and the like. Just to be sure, the data set may be ASCII data or binary data.

記録部12は、入力部11が取得した情報、すなわちデータセットをデータ記憶領域41に記録し、記録したアドレスの情報をアドレス記憶領域42に記録する。読出部13は、アドレス記憶領域42に記録されたアドレス情報に基づき、データ記憶領域41に記録された最新のデータセットを読み出す。読出部13は、読み出したデータセットをCPU1に提供してもよいし、通信部5を通じて外部に提供してもよい。なお読出部13は、最新以外のデータセットは読み出せる必要はなく、最新以外のデータセットは記憶部4に完全な状態で記録されていなくてもよい。記録部12および読出部13の動作は次に詳しく説明する。 The recording unit 12 records the information acquired by the input unit 11, that is, the data set in the data storage area 41, and records the information of the recorded address in the address storage area . The reading unit 13 reads the latest data set recorded in the data storage area 41 based on the address information recorded in the address storage area 42 . The reading unit 13 may provide the read data set to the CPU 1 or to the outside through the communication unit 5 . Note that the reading unit 13 does not need to be able to read data sets other than the latest, and the data sets other than the latest need not be recorded in the storage unit 4 in a complete state. The operations of the recording section 12 and reading section 13 will be described in detail below.

データ記憶領域41およびアドレス記憶領域42は、あらかじめ設定された記憶部4の領域である。詳しくは後述するが、データ記憶領域41およびアドレス記憶領域42はリングバッファのように使用される。記憶部4の全領域にあらかじめアドレスが設定されており、アドレスを指定することで記憶部4に記録された特定の情報にアクセスできる。アドレスは既知の固定長、たとえば32ビットであり具体的には、「0xFFFFFFFF」、「0x12345678」などである。なお例示した2つのアドレスの先頭に記載した「0x」は16進法の表記であることを示す符号であり、以下では記載を省略することもある。 The data storage area 41 and the address storage area 42 are preset areas of the storage unit 4 . Although the details will be described later, the data storage area 41 and the address storage area 42 are used like a ring buffer. Addresses are set in advance in all areas of the storage unit 4, and specific information recorded in the storage unit 4 can be accessed by designating the address. The address has a known fixed length, for example, 32 bits, specifically "0xFFFFFFFF", "0x12345678" and the like. Note that "0x" written at the beginning of the two addresses shown in the example is a code indicating hexadecimal notation, and the description may be omitted below.

本実施の形態では、アドレスの情報を格納可能な連続する32ビット、すなわち連続する4バイトを「アドレスブロック」とも呼ぶ。さらにこのアドレスブロックは、便宜的に先頭から通し番号を付してアドレスブロック(1)、アドレスブロック(2)、・・・と呼ぶこともある。 In this embodiment, continuous 32 bits capable of storing address information, that is, continuous 4 bytes are also called an "address block". Further, these address blocks may be referred to as address block (1), address block (2), .

入力部11、記録部12、および読出部13の動作を概略すると次のとおりである。たとえば、あるプログラムのバイナリデータを通信部5が受信するたびに入力部11がそのバイナリデータをデータセットとして取得する。そして記録部12は入力部11が取得したバイナリデータを記憶部4に記録する。詳しくは後述するが、記録部12は原則としてデータセットを上書きではなく追記する。読出部13は、所定のタイミング、たとえば電子制御装置9の起動時に記憶部4に記録された最新のバイナリデータを読み取る。 The operations of the input unit 11, the recording unit 12, and the reading unit 13 are summarized as follows. For example, every time the communication unit 5 receives binary data of a certain program, the input unit 11 acquires the binary data as a data set. Then, the recording unit 12 records the binary data acquired by the input unit 11 in the storage unit 4 . Although the details will be described later, in principle, the recording unit 12 adds data to the data set instead of overwriting it. The reading unit 13 reads the latest binary data recorded in the storage unit 4 at a predetermined timing, for example, when the electronic control unit 9 is activated.

(記憶部4の初期状態)
図3は、データセットが記録される前の記憶部4、すなわち記憶部4の初期状態を示す図である。図3は、左側のベースアドレス部47と、上部のオフセットアドレス部48と、右下の大きな領域であるデータ部49とから構成される。記憶部4に実際に格納されている情報はデータ部49に示すものであり、ベースアドレス部47およびオフセットアドレス部48は便宜的に記載している。
(Initial state of storage unit 4)
FIG. 3 is a diagram showing the storage unit 4 before the data set is recorded, that is, the initial state of the storage unit 4. As shown in FIG. FIG. 3 is composed of a base address section 47 on the left, an offset address section 48 on the top, and a data section 49 which is a large area on the lower right. Information actually stored in the storage section 4 is shown in the data section 49, and the base address section 47 and the offset address section 48 are described for convenience.

図3に示すデータ部49は8行から構成され、1行は16個の小さなブロックから構成される。1つの小さなブロックは、「0x00」~「0xFF」の情報、すなわち1バイトの情報が格納できる。すなわち、オフセットアドレス部48に示す「+0」や「+1」は、アドレスをベースアドレスから指定された数のバイト数だけ増加させることを意味する。本実施の形態では、アドレスは4バイトなので、1つのアドレスはたとえばオフセットアドレス部48の「+0」~「+3」の範囲に格納された情報で表される。 The data section 49 shown in FIG. 3 consists of 8 rows, each row consisting of 16 small blocks. One small block can store information from '0x00' to '0xFF', that is, 1-byte information. In other words, "+0" or "+1" shown in the offset address field 48 means that the address is increased from the base address by the specified number of bytes. In this embodiment, since the address is 4 bytes, one address is represented by information stored in the range of "+0" to "+3" of the offset address section 48, for example.

本実施の形態では、アドレス記憶領域42はアドレス「0x00000000」から「0x0000001F」まで、データ記憶領域41はアドレス「0x00000020」から「0x0000008F」までである。初期状態では、アドレス記憶領域42およびデータ記憶領域41は全ビットが「1」で初期化されている。ただしこれは例示に過ぎず、データ記憶領域41の領域の広さおよびアドレス記憶領域42の領域の広さは任意である。 In this embodiment, the address storage area 42 has addresses from "0x00000000" to "0x0000001F", and the data storage area 41 has addresses from "0x00000020" to "0x0000008F". In the initial state, all bits of the address storage area 42 and the data storage area 41 are initialized to "1". However, this is merely an example, and the size of the data storage area 41 and the size of the address storage area 42 are arbitrary.

アドレス記憶領域42の領域は、消去単位ブロックの少なくとも2倍の領域を有する。本実施の形態では消去単位ブロックが16バイト(0x10バイト)なので、アドレス記憶領域42は少なくとも32バイト(0x20バイト)の領域を有する。また、アドレス記憶領域42およびデータ記憶領域41の初期状態はあらかじめ定まっていればよく図3の状態に限定されない。具体的には、初期状態の全ビットが「0」でもよいし、データ記憶領域41とアドレス記憶領域42では初期状態のビット状態が同一でなくてもよい。 The area of the address storage area 42 has an area at least twice as large as the erase unit block. Since the erase unit block is 16 bytes (0x10 bytes) in this embodiment, the address storage area 42 has an area of at least 32 bytes (0x20 bytes). Moreover, the initial states of the address storage area 42 and the data storage area 41 need only be determined in advance, and are not limited to the states shown in FIG. Specifically, all bits in the initial state may be "0", and the initial bit states of the data storage area 41 and the address storage area 42 may not be the same.

(記憶部4の状態例)
図4は、データセットが4回記録された記憶部4の状態を示す図である。図4ではデータセットを記録された順番に「データ1-1」~「データ1-4」と記載している。データ1-1は、「0x00000020」~「0x0000002B」に記録されている。データ1-2は、「0x0000002C」~「0x0000003F」に記録されている。データ1-3は、「0x00000040」~「0x00000057」に記録されている。データ1-4は、「0x00000058」~「0x0000006F」に記録されている。
(Example of state of storage unit 4)
FIG. 4 is a diagram showing the state of the storage unit 4 in which data sets have been recorded four times. In FIG. 4, the data sets are described as "data 1-1" to "data 1-4" in the order in which they were recorded. Data 1-1 is recorded in "0x00000020" to "0x0000002B". Data 1-2 are recorded in "0x0000002C" to "0x0000003F". Data 1-3 are recorded at "0x00000040" to "0x00000057". Data 1-4 are recorded in "0x00000058" to "0x0000006F".

データ1-1~データ1-4が記録されたアドレスを示すように、アドレス記憶領域42にはアドレス情報が格納される。前述のように本実施の形態ではアドレスは4バイトで表記するので、符号901などで示すように4つの小さなブロックが1つのアドレスを示す。アドレスブロック901に格納されている値である「0x00000020」は、データ1-1が格納される先頭のアドレスである。アドレスブロック902に格納されている値である「0x0000002C」は、データ1-2が格納される先頭のアドレスである。アドレスブロック903に格納されている値である「0x00000040」は、データ1-3が格納される先頭のアドレスである。アドレスブロック904に格納されている値である「0x00000058」は、データ1-4が格納される先頭のアドレスである。 Address information is stored in the address storage area 42 so as to indicate the addresses where data 1-1 to data 1-4 are recorded. As described above, in this embodiment, addresses are represented by 4 bytes, so four small blocks, such as reference numeral 901, represent one address. The value "0x00000020" stored in the address block 901 is the top address where the data 1-1 is stored. The value "0x0000002C" stored in the address block 902 is the top address where the data 1-2 are stored. The value "0x00000040" stored in the address block 903 is the top address where the data 1-3 are stored. The value "0x00000058" stored in the address block 904 is the top address where the data 1-4 are stored.

なお本実施の形態では、説明の都合上、バイトオーダーにビッグインディアンを採用しているがリトルインディアンを採用してもよい。また、本実施の形態では消去単位ブロックが16バイトなので、図4における1行に相当する。 In this embodiment, for convenience of explanation, the Big Indian is used as the byte order, but the Little Indian may be used. Also, in this embodiment, since the erase unit block is 16 bytes, it corresponds to one row in FIG.

(記憶部4の別の状態例)
図5は、記憶部4の別の状態を示す図である。図5は、データ記憶領域41およびアドレス記憶領域42の全域を使いきり、それぞれの先頭領域を初期化した状態を示している。図5では「データ1-51」が「0x00000020」~「0x00000027」および「0x00000071」~「0x0000007F」に記録されている。符号911で示すアドレスは「0x00000032」であり、符号912で示すアドレスは「0x00000046」であり、符号913で示すアドレスは「0x0000005E」であり、符号914で示すアドレスは「0x00000071」である。
(Another example of the state of the storage unit 4)
FIG. 5 is a diagram showing another state of the storage unit 4. As shown in FIG. FIG. 5 shows a state in which the entire data storage area 41 and address storage area 42 are used up, and the head area of each is initialized. In FIG. 5, "data 1-51" is recorded at "0x00000020" to "0x00000027" and "0x00000071" to "0x0000007F". The address indicated by reference numeral 911 is "0x00000032", the address indicated by reference numeral 912 is "0x00000046", the address indicated by reference numeral 913 is "0x0000005E", and the address indicated by reference numeral 914 is "0x00000071".

データ記憶領域41では、データ1-51が2つに分かれて記載されているが、これは、データ記憶領域41の末尾と先頭を繋げて使用しているからである。換言すると、データ1-51における「0x0000007F」の次のデータは、「0x00000020」に記載されている。すなわちデータ1-51が記録されている先頭のアドレスは「0x00000071」であり、符号914で示す領域に記録されている。 In the data storage area 41, the data 1-51 are written in two parts because the tail and the head of the data storage area 41 are connected. In other words, the data following "0x0000007F" in data 1-51 is described at "0x00000020". That is, the head address where data 1-51 are recorded is "0x00000071" and is recorded in the area indicated by reference numeral 914. FIG.

(記録部12の動作概要)
記録部12の動作の概要を説明する。記録部12は、入力部11がデータセットを取得すると、データセットを書き込むデータ記憶領域41を特定する。この書き込み位置は、データ記憶領域41における書き込み済の領域の直後である。すなわち記録部12は、データセットを上書きではなく追記することでデータ記憶領域41に記録する。このように記録することで、データ記憶領域41の特定のアドレスへの書き込みが集中することを避けることができ、記憶部4の寿命を延ばすことができる。
(Overview of Operation of Recording Unit 12)
An outline of the operation of the recording unit 12 will be described. When the input unit 11 acquires the data set, the recording unit 12 specifies the data storage area 41 in which the data set is written. This write position is immediately after the written area in the data storage area 41 . That is, the recording unit 12 records the data set in the data storage area 41 by appending instead of overwriting. By recording in this manner, it is possible to avoid concentration of writing to a specific address in the data storage area 41, and to extend the life of the storage section 4. FIG.

ただし記録部12は、追記を繰り返したことでデータ記憶領域41にデータセットを記録しきれないと判断する場合は、消去可能なデータ記憶領域41を特定して消去する。そして記録部12は、残りの領域と消去した領域を用いてデータセットを記録する。この際にも記録部12は、書き込み回数が均一になるように書き込みを行う。たとえば図5に示したように、データ1-51の一部を「0x00000071」~「0x0000007F」に記録し、残りを消去した領域である「0x00000020」~「0x00000027」に記録する。 However, when the recording unit 12 determines that the data set cannot be recorded in the data storage area 41 due to repeated additional writing, the erasable data storage area 41 is specified and erased. Then, the recording unit 12 records the data set using the remaining area and the erased area. Also at this time, the recording unit 12 performs writing so that the number of times of writing is uniform. For example, as shown in FIG. 5, part of data 1-51 is recorded in "0x00000071" to "0x0000007F" and the rest is recorded in the erased area "0x00000020" to "0x00000027".

また記録部12は、アドレスを書き込むアドレス記憶領域42を特定し、データセットを記録した先頭のアドレスを記録する。さらに記録部12は、データ記憶領域41と同様にアドレス記憶領域42も必要に応じて消去単位ブロックごとの消去を行う。ただし記録部12は、初期化を行った際にも書き込み回数が均一になるように書き込みを行う。このように記録することで、アドレス記憶領域42の特定のアドレスへの書き込みが集中することを避けることができ、記憶部4の寿命を延ばすことができる。 The recording unit 12 also specifies the address storage area 42 in which the address is written, and records the top address in which the data set is recorded. Further, the recording unit 12 erases the address storage area 42 as well as the data storage area 41 for each erase unit block as necessary. However, the recording unit 12 performs writing so that the number of times of writing is uniform even after initialization. By recording in this way, it is possible to avoid the concentration of writing to a specific address in the address storage area 42 and extend the life of the storage section 4 .

(読出部13の動作概要)
読出部13の動作の概要を説明する。読出部13は、所定のイベントが発生した場合に、たとえば電子制御装置9に備えられる他のプログラムから指令を受けた場合や、電子制御装置9の外部から通信部5を介して指令を受けた場合に動作する。読出部13は、まずアドレス記憶領域42に記録されている最新のアドレス情報を特定する。本実施の形態では、アドレス情報はアドレス記憶領域42の先頭から順番に記録されるので、最新のアドレス情報は原則として、アドレス記憶領域42に記録されているアドレス情報のうち一番後ろのものである。すなわちアドレス記憶領域42の先頭からアドレスブロックの大きさである4バイト単位で読み込み、格納されている情報が「FFFFFFFF」ではない最後のアドレスブロックの値を最新のアドレス情報と判断する。
(Outline of operation of reading unit 13)
An outline of the operation of the reading unit 13 will be described. When a predetermined event occurs, the reading unit 13 receives a command from another program provided in the electronic control unit 9, or receives a command from the outside of the electronic control unit 9 via the communication unit 5. If it works. The reading unit 13 first identifies the latest address information recorded in the address storage area 42 . In this embodiment, since the address information is recorded in order from the top of the address storage area 42, the latest address information is, in principle, the last address information recorded in the address storage area 42. be. That is, the address block size of 4 bytes is read from the beginning of the address storage area 42, and the value of the last address block whose stored information is not "FFFFFFFF" is determined as the latest address information.

例外は、アドレス記憶領域42の先頭領域を含む消去単位ブロックが初期化された場合である。この場合は、アドレス記憶領域42の先頭領域に格納されるアドレス情報が「FF・・・」となる。この場合には読出部13は、アドレス記憶領域42における最終の消去単位ブロックの先頭から検索を開始する。読出部13は、アドレスを特定すると、そのアドレスからデータセットを読み出す。 An exception is when an erase unit block including the head area of the address storage area 42 is initialized. In this case, the address information stored in the top area of the address storage area 42 is "FF...". In this case, the reading unit 13 starts searching from the beginning of the final erase unit block in the address storage area 42 . After specifying the address, the reading unit 13 reads the data set from the address.

(記録部12の動作フローチャート)
図6は、記録部12の動作を示すフローチャートである。記録部12は、入力部11がデータセットを取得すると、図6に示す処理を開始する。まず記録部12は、データセットを書き込むデータ記憶領域41を特定する(S301)。この書き込み位置は、データ記憶領域41における書き込み済の領域の直後である。書き込み済の領域は、書き込まれている情報が初期化された値であるか否かにより判断してもよいし、書き込みを行った領域を別途管理することで実現してもよい。
(Operational flowchart of recording unit 12)
FIG. 6 is a flow chart showing the operation of the recording unit 12. As shown in FIG. When the input unit 11 acquires the data set, the recording unit 12 starts the processing shown in FIG. First, the recording unit 12 specifies the data storage area 41 in which the data set is written (S301). This write position is immediately after the written area in the data storage area 41 . A written area may be determined based on whether or not the written information is an initialized value, or may be realized by separately managing the written area.

続いて記録部12は、S301において特定したアドレスから書き込みを開始した場合に、書き込み領域が不足するか否かを判断する。たとえば受信したデータセットが23バイトあり、書き込み開始位置からデータ記憶領域41の末尾までが15バイトの場合には、記録部12は不足すると判断する。この場合(S302:YES)には記録部12は、消去可能なブロックを特定して消去する。たとえば記録部12は、全領域にデータセットが書き込まれている消去単位ブロックを消去可能なブロックとして特定する。たとえば図4に示す状態において取得したデータセットが20バイトの場合には、「0x00000020」~「0x0000006F」の4つの消去単位ブロックが消去される。 Subsequently, the recording unit 12 determines whether or not the write area is insufficient when writing is started from the address specified in S301. For example, if the received data set has 23 bytes and the length from the write start position to the end of the data storage area 41 is 15 bytes, the recording unit 12 determines that there is a shortage. In this case (S302: YES), the recording unit 12 identifies and erases erasable blocks. For example, the recording unit 12 identifies an erasure unit block in which the data set is written in the entire area as an erasable block. For example, when the data set obtained in the state shown in FIG. 4 is 20 bytes, four erase unit blocks of "0x00000020" to "0x0000006F" are erased.

S302において否定判断された場合、およびS303の次に実行されるS304では、記録部12はS301において特定した領域にデータセットを書き込む。次に記録部12は、アドレス記憶領域42におけるアドレスの記録位置を特定する。書き込み済の領域は、書き込まれている情報が初期化された値であるか否かにより判断してもよいし、書き込みを行った領域を別途管理することで実現してもよい。すなわち記録部12は、データセットを上書きではなく追記することでデータ記憶領域41に記録する。このように記録することで、特定のアドレスへの書き込みが集中することを避けることができ、記憶装置の寿命を延ばすことができる。 If a negative determination is made in S302, and in S304 executed after S303, the recording unit 12 writes the data set to the area specified in S301. Next, the recording unit 12 identifies the address recording position in the address storage area 42 . A written area may be determined based on whether or not the written information is an initialized value, or may be realized by separately managing the written area. That is, the recording unit 12 records the data set in the data storage area 41 by appending instead of overwriting. By recording in this way, it is possible to avoid concentration of writing to a specific address, thereby extending the life of the storage device.

次に記録部12は、追記を繰り返したことでデータ記憶領域41にデータセットを記録しきれないと判断する場合は、消去可能なデータ記憶領域41を特定して消去する。そして記録部12は、残りの領域と消去した領域を用いてデータセットを記録する。この際にも記録部12は、書き込み回数が均一になるように書き込みを行う。具体的には、データ記憶領域41の最後までデータセットを記録し、その続きをデータ記憶領域41の先頭から記録する。 Next, when the recording unit 12 determines that the data set cannot be recorded in the data storage area 41 due to repeated additional writing, the recording unit 12 specifies and erases the erasable data storage area 41 . Then, the recording unit 12 records the data set using the remaining area and the erased area. Also at this time, the recording unit 12 performs writing so that the number of times of writing is uniform. Specifically, the data set is recorded to the end of the data storage area 41, and the continuation is recorded from the beginning of the data storage area 41. FIG.

さらに記録部12は、アドレスを書き込むアドレス記憶領域42を特定し(S305)、データセットを記録した先頭のアドレスを記録する(S306)。なお以下では、S306において書き込むアドレスの値を「最新アドレス」とも呼ぶ。すなわち最新アドレスとは、データセットを記録した先頭のアドレスである。記録部12は、アドレス記憶領域42への書き込み位置は、アドレス記憶領域42における未記録領域、すなわち書き込み済の領域の直後である。書き込み済の領域は、書き込まれている情報が初期化された値であるか否かにより判断してもよいし、書き込みを行った領域を別途管理することで実現してもよい。 Further, the recording unit 12 identifies the address storage area 42 in which the address is written (S305), and records the top address in which the data set is recorded (S306). Note that the value of the address written in S306 is hereinafter also referred to as the "latest address". That is, the latest address is the top address where the data set is recorded. The writing position in the address storage area 42 of the recording unit 12 is immediately after the unrecorded area in the address storage area 42, that is, the written area. A written area may be determined based on whether or not the written information is an initialized value, or may be realized by separately managing the written area.

次に記録部12は、S306における書き込みが、アドレス記憶領域42における最終位置、たとえば図3~図5に示す例では「0x0000001C」~「0x0000001F」への書き込みであるか否かを判断する(S307)。記録部12は、書き込みがアドレス記憶領域42の最終位置であると判断する場合には(S307:YES)、アドレス記憶領域42における最終の消去単位ブロック以外を消去する。 Next, the recording unit 12 determines whether the writing in S306 is the writing to the final position in the address storage area 42, for example, "0x0000001C" to "0x0000001F" in the examples shown in FIGS. 3 to 5 (S307). ). When the recording unit 12 determines that the writing is at the final position of the address storage area 42 (S307: YES), the recording unit 12 erases blocks other than the final erase unit block in the address storage area 42. FIG.

S307において否定判断された場合に実行されるS309では記録部12は、S306における書き込みが、アドレス記憶領域42における先頭位置、たとえば図3~図5に示す例では「0x00000000」~「0x00000003」への書き込みであるか否かを判断する(S309)。記録部12は、書き込みがアドレス記憶領域42の先頭位置であると判断する場合には(S309:YES)、アドレス記憶領域42における最終の消去単位ブロックを消去する(S310)。記録部12は、S308またはS310を実行すると、もしくはS309を否定判断すると図6に示す処理を終了する。 In S309, which is executed when a negative determination is made in S307, the recording unit 12 determines that the writing in S306 is to the head position in the address storage area 42, for example, "0x00000000" to "0x00000003" in the examples shown in FIGS. It is determined whether or not it is writing (S309). When the recording unit 12 determines that the writing is at the top position of the address storage area 42 (S309: YES), the recording unit 12 erases the final erase unit block in the address storage area 42 (S310). When the recording unit 12 executes S308 or S310, or makes a negative determination in S309, the processing shown in FIG. 6 ends.

(読出部13の動作フローチャート)
図7は、読出部13の動作を示すフローチャートである。読出部13はまず、アドレス記憶領域42の先頭から初期化されたままの領域、具体的には4バイトにわたってビットがすべて「1」であるアドレスブロックを検索する(S321)。次に読出部13は、「FFFFFFFF」がアドレス記憶領域42の先頭に存在するか否かを判断し、先頭に存在すると判断する場合は(S322:YES)、アドレス記憶領域42における最終の消去単位ブロックの先頭から再度検索を行う(S323)。ただしアドレス記憶領域42の末尾の次はアドレス記憶領域42の先頭を検索する。
(Operational flowchart of reading unit 13)
FIG. 7 is a flow chart showing the operation of the reading unit 13. As shown in FIG. First, the reading unit 13 searches the initialized area from the top of the address storage area 42, specifically, an address block whose bits are all "1" over 4 bytes (S321). Next, reading unit 13 determines whether “FFFFFFFF” exists at the head of address storage area 42. If it is determined that it exists at the head (S322: YES), reading unit 13 reads the final erase unit in address storage area 42. Search is performed again from the top of the block (S323). However, after the tail of the address storage area 42, the head of the address storage area 42 is searched.

次に読出部13は、検出した最初の「FFFFFFFF」の直前のアドレスブロックに記載されているアドレスをターゲットに設定し(S324)、ターゲットのアドレスからデータセットを読み出す。なおアドレス記憶領域42にはデータセットが記録された終末位置のアドレスや、データセットのデータ長は記録されていないが、読出部13は何らかの手段でデータセットの終了位置を判断する。読出部13はたとえば、データセットそのものにデータ長の情報が格納されていればそれを利用してデータセットの終了位置を判断し、データセットの長さが固定長であれば、読み出し位置のアドレスにその固定長を加えたアドレスをデータセットの終了位置と判断する。 Next, the reading unit 13 sets the address described in the address block immediately before the detected first "FFFFFFFF" as the target (S324), and reads the data set from the target address. Although the address of the end position where the data set is recorded and the data length of the data set are not recorded in the address storage area 42, the reading unit 13 determines the end position of the data set by some means. For example, if data length information is stored in the data set itself, the reading unit 13 uses this information to determine the end position of the data set. plus the fixed length is determined as the end position of the data set.

S324の動作を具体的に説明する。たとえば図4に示す例では、アドレス記憶領域42の先頭から検索すると「0x00000010」~「0x00000013」が「FFFFFFFF」なので、その直前のアドレスブロックに記載された「0x000058」をターゲットに設定する。また図5に示す例では、アドレス記憶領域42の先頭に「FFFFFFFF」が存在するので、アドレス記憶領域42における最終の消去単位ブロックの先頭、すなわち「0x00000010」から再度検索を行う。そしてアドレス記憶領域42の末尾まで検索しても「FFFFFFFF」が見つからないのでアドレス記憶領域42の先頭に戻り、先頭で「FFFFFFFF」を発見する。そして先頭の直前のアドレスブロック、すなわちアドレス記憶領域42の末尾のアドレスブロックに記載された「0x00000071」をターゲットに設定する。 The operation of S324 will be specifically described. For example, in the example shown in FIG. 4, since "0x00000010" to "0x00000013" are "FFFFFFFF" when searching from the top of the address storage area 42, "0x000058" described in the address block immediately before that is set as the target. In the example shown in FIG. 5, since "FFFFFFFF" exists at the beginning of the address storage area 42, the search is performed again from the beginning of the final erase unit block in the address storage area 42, that is, "0x00000010". Since "FFFFFFFF" is not found even after searching to the end of the address storage area 42, it returns to the beginning of the address storage area 42 and finds "FFFFFFFF" at the beginning. Then, the address block immediately before the head, that is, "0x00000071" written in the last address block of the address storage area 42 is set as the target.

上述した第1の実施の形態によれば、次の作用効果が得られる。
(1)電子制御装置9は、アドレスが付されデータセットが記録されるデータ記憶領域41、および2以上のアドレスを格納可能なアドレス記憶領域42を含む不揮発性の記憶領域である記憶部4と、データセットが入力される入力部11と、入力部11に入力されたデータセットをデータ記憶領域41における未記録領域に記録し、未記録領域のアドレスに関する情報をアドレス記憶領域42の未記録領域に記録する記録部12と、アドレス記憶領域42における最新の記録に基づいてデータ記憶領域41からデータセットを読み出す読出部13と、を備える。すなわち記録部12は、データセットを未記録領域に記録するので、上書き処理ではなく追記処理を行う。そのため、書き換え回数に制限があるフラッシュメモリの特定の領域が集中して書き換えられることを防止し、記憶部4の寿命を延ばすことができる。
According to the first embodiment described above, the following effects are obtained.
(1) The electronic control unit 9 includes a storage unit 4, which is a non-volatile storage area including a data storage area 41 in which addresses are assigned and data sets are recorded, and an address storage area 42 capable of storing two or more addresses. , an input unit 11 to which a data set is input; a data set input to the input unit 11 is recorded in an unrecorded area in the data storage area 41; and a reading unit 13 for reading the data set from the data storage area 41 based on the latest record in the address storage area 42 . That is, since the recording unit 12 records the data set in an unrecorded area, the recording unit 12 performs additional recording processing instead of overwriting processing. Therefore, it is possible to prevent concentrated rewriting of a specific area of the flash memory, which has a limited number of rewrites, and extend the life of the storage unit 4 .

(2)記憶部4は、データセットを記録した未記録領域のアドレスをアドレス記憶領域42の未記録領域に最新アドレスとして記録し、読出部13は、アドレス記憶領域42に記録された最新の最新アドレスが示すデータ記憶領域からデータセットを読み出す。そのため電子制御装置9は、アドレス記憶領域42に記録された最新アドレスからデータセットを読み出すことができる。 (2) The storage unit 4 records the address of the unrecorded area where the data set is recorded in the unrecorded area of the address storage area 42 as the latest address, and the reading unit 13 reads the latest address recorded in the address storage area 42 . Reads a data set from the data storage area indicated by the address. The electronic control unit 9 can thus read the data set from the latest address recorded in the address storage area 42 .

(3)データ記憶領域41およびアドレス記憶領域42のそれぞれは、ハードウエア特性により定まるデータを消去可能な最小単位である消去単位ブロックを少なくとも2つ含む。そのため、追記を繰り返すことでデータ記憶領域41およびアドレス記憶領域42のそれぞれの容量が不足した場合に、各領域の一部のみを消去して使用を継続できる。 (3) Each of the data storage area 41 and the address storage area 42 includes at least two erase unit blocks, which are minimum units for erasing data determined by hardware characteristics. Therefore, when the capacity of each of the data storage area 41 and the address storage area 42 is insufficient due to repeated additional writing, only a part of each area can be erased and used continuously.

(4)記録部12は、アドレス記憶領域42において、先頭から後方に向かって順番に、かつ隙間をあけずに最新アドレスを書き込む。そのためアドレス記憶領域42を有効に使用し、かつ処理ロジックを簡潔にできる。 (4) The recording unit 12 writes the latest addresses in the address storage area 42 in order from the top to the bottom without gaps. Therefore, the address storage area 42 can be effectively used and the processing logic can be simplified.

(5)記録部12は、アドレス記憶領域42において、先頭から後方に向かって順番に最新アドレスを書き込む。読出部13は、アドレス記憶領域42における最後方に記録されたアドレスを最新アドレスと判断する。 (5) The recording unit 12 writes the latest addresses in order from the top to the bottom in the address storage area 42 . The reading unit 13 determines that the last address recorded in the address storage area 42 is the latest address.

(6)記録部12は、アドレス記憶領域42において、先頭から後方に向かって順番に最新アドレスを書き込む。読出部13は、アドレス記憶領域42に格納されている値を記憶部4に設定されたアドレス空間の大きさの区切りで、本実施の形態では4バイト区切りでアドレスブロックとして先頭から後方に向かって検索する。読出部13は図7のフローチャートに示すように、記憶部4を初期化した際の値である「FFFFFFFF」を有し、検索により最初に該当したアドレスブロックの直前のアドレスブロックに格納されている値を最新アドレスと判断する。 (6) The recording unit 12 writes the latest addresses in order from the top to the bottom in the address storage area 42 . The reading unit 13 reads the value stored in the address storage area 42 as an address block by dividing the size of the address space set in the storage unit 4, in this embodiment, by dividing it into 4-byte blocks from the beginning to the rear. search for. As shown in the flow chart of FIG. 7, the reading unit 13 has "FFFFFFFF" which is the value when the storage unit 4 is initialized, and is stored in the address block immediately before the address block first found by the search. Judge the value as the latest address.

(変形例1)
上述した第1の実施の形態では、データ記憶領域41およびアドレス記憶領域42には、先頭から後方に向かって順番に書き込みが行われた。しかし書き込む順番が規定されていればよく、たとえばデータ記憶領域41およびアドレス記憶領域42の末尾から先頭に向かって順番に書き込みが行われてもよい。またデータ記憶領域41とアドレス記憶領域42の書き込み方向が異なってもよい。
(Modification 1)
In the above-described first embodiment, the data storage area 41 and the address storage area 42 are written in order from the top to the bottom. However, as long as the order of writing is specified, the writing may be performed in order from the end to the beginning of the data storage area 41 and the address storage area 42, for example. Also, the writing directions of the data storage area 41 and the address storage area 42 may be different.

(変形例2)
記憶部4には、データ記憶領域41およびアドレス記憶領域42以外の領域(以下、「通常領域」と呼ぶ)が設けられてもよい。たとえば通常領域には、プログラムやデータが格納されてもよい。この際に、プログラムやデータに更新があった際に、同一のアドレス領域に新たな情報が書き込まれると、そのアドレス領域だけ書き込み回数が増大して記憶部4の寿命が短くなる可能性がある。そのため、通常領域に対しては既知の手法であるハードウエア実装型のウェアレベリングを適用してもよい。
(Modification 2)
The storage unit 4 may be provided with areas other than the data storage area 41 and the address storage area 42 (hereinafter referred to as "normal areas"). For example, the normal area may store programs and data. At this time, if new information is written to the same address area when the program or data is updated, the number of times of writing increases by that address area, which may shorten the life of the storage unit 4. . Therefore, hardware-implemented wear leveling, which is a known technique, may be applied to the normal area.

(変形例3)
上述した第1の実施の形態では、動作中の電源断に対して特に対策をしていない。しかし記録部12は、特別なフラグを用意して対策を行ってもよい。たとえば記憶部4に記録中フラグを初期値「0」で用意する。記録部12は、書き込み処理を行う直前、すなわち図6のS304の直前に記録中フラグを「1」に変更し、S306の処理が完了すると記録中フラグを「0」に戻す。この場合に読出部13は、S324の実行前に記録中フラグの値を読み込み、記録中フラグの値が「0」の場合はそのままS324を実行する。また、記録中フラグの値が「1」の場合は読出部13は、「FFFFFFFF」の2つ前のアドレスブロックをターゲットに決定する。
(Modification 3)
In the above-described first embodiment, no particular countermeasures are taken against power interruption during operation. However, the recording unit 12 may take countermeasures by preparing a special flag. For example, a recording in-progress flag is prepared in the storage unit 4 with an initial value of "0". The recording unit 12 changes the recording flag to "1" immediately before performing the writing process, that is, immediately before S304 in FIG. 6, and resets the recording flag to "0" when the process of S306 is completed. In this case, the reading unit 13 reads the value of the recording flag before executing S324, and when the value of the recording flag is "0", the reading unit 13 executes S324 as it is. Further, when the value of the recording flag is "1", the reading unit 13 determines the address block two blocks before "FFFFFFFF" as the target.

この変形例3によれば、記録部12による記録が中断されて不完全な記録が行われた場合に、読出部13は従前の記録を読み出すことで障害の発生を回避できる。 According to Modification 3, when recording by the recording unit 12 is interrupted and incomplete recording is performed, the reading unit 13 can avoid the occurrence of a failure by reading the previous recording.

(変形例4)
入力部11、記録部12、および読出部13は、記憶部4と一体に構成されてもよい。すなわち、入力部11、記録部12、および読出部13がフラッシュメモリのコントローラの機能の一部として記憶部4に搭載されてもよい。
(Modification 4)
Input unit 11 , recording unit 12 , and reading unit 13 may be configured integrally with storage unit 4 . That is, the input unit 11, the recording unit 12, and the reading unit 13 may be mounted in the storage unit 4 as part of the function of the controller of the flash memory.

(変形例5)
入力部11、記録部12、および読出部13は、CPU1、ROM2、およびRAM3の組み合わせの代わりに書き換え可能な論理回路であるFPGA(Field Programmable Gate Array)や特定用途向け集積回路であるASIC(Application Specific Integrated Circuit)により実現されてもよい。また入力部11、記録部12、および読出部13は、CPU1、ROM2、およびRAM3の組み合わせの代わりに、異なる構成の組み合わせ、たとえばCPU1、ROM2、RAM3とFPGAの組み合わせにより実現されてもよい。
(Modification 5)
The input unit 11, the recording unit 12, and the reading unit 13 are a rewritable logic circuit FPGA (Field Programmable Gate Array) instead of a combination of the CPU 1, ROM 2, and RAM 3, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit). Also, the input unit 11, the recording unit 12, and the reading unit 13 may be realized by a combination of different configurations, for example, a combination of the CPU1, the ROM2, the RAM3, and an FPGA instead of the combination of the CPU1, the ROM2, and the RAM3.

(変形例6)
入力部11は、電子制御装置9の動作終了時にRAM3に格納されている情報であって、データ記憶領域41に格納されている情報と異なる情報をデータセットとして扱ってもよい。たとえば空燃比マップやカメラの外部パラメータなど、時折更新されうる情報であって高頻度で使用される情報を記憶部4に記録する場合に本変形例が有効である。空燃比マップを例に具体的に説明する。
(Modification 6)
The input unit 11 may handle information stored in the RAM 3 at the end of the operation of the electronic control unit 9 and different from information stored in the data storage area 41 as a data set. For example, this modification is effective when frequently used information that can be updated from time to time, such as an air-fuel ratio map or an external parameter of a camera, is recorded in the storage unit 4 . A specific description will be given with an air-fuel ratio map as an example.

読出部13は、電子制御装置9の起動時に記憶部4に記録されている空燃比マップを読み出してRAM3にコピーする。空燃比マップは、電子制御装置9に搭載される他のプログラムから参照され、必要に応じて修正が加えられる。入力部11は、電子制御装置9の電源がオフにされる際に、RAM3に格納されている空燃比マップと、記憶部4に記録されている空燃比マップとの異同を確認する。そして入力部11は、両者が異なる場合にはRAM3に格納されている空燃比マップを入力部11に入力されるデータセットとして扱い、記録部12がこれを記憶部4に記録する。 The reading unit 13 reads the air-fuel ratio map recorded in the storage unit 4 and copies it to the RAM 3 when the electronic control unit 9 is activated. The air-fuel ratio map is referred to by other programs installed in the electronic control unit 9 and modified as necessary. The input unit 11 confirms whether the air-fuel ratio map stored in the RAM 3 and the air-fuel ratio map recorded in the storage unit 4 are different when the electronic control unit 9 is powered off. If the two are different, the input unit 11 treats the air-fuel ratio map stored in the RAM 3 as a data set to be input to the input unit 11 , and the recording unit 12 records this in the storage unit 4 .

この変形例6によれば、低頻度で更新される可能性があるデータを書き換え回数に制限がある記憶部4に効率よく記録できる。 According to Modification 6, data that may be updated infrequently can be efficiently recorded in the storage section 4 that has a limited number of rewrites.

―第2の実施の形態―
図8~図10を参照して、電子制御装置の第2の実施の形態を説明する。以下の説明では、第1の実施の形態と同じ構成要素には同じ符号を付して相違点を主に説明する。特に説明しない点については、第1の実施の形態と同じである。本実施の形態では、主に、アドレス記憶領域にアドレスが2つ連続で記録される点で、第1の実施の形態と異なる。
-Second Embodiment-
A second embodiment of the electronic control unit will be described with reference to FIGS. 8 to 10. FIG. In the following description, the same components as those in the first embodiment are given the same reference numerals, and differences are mainly described. Points that are not particularly described are the same as those in the first embodiment. The present embodiment differs from the first embodiment mainly in that two consecutive addresses are recorded in the address storage area.

第2の実施の形態における電子制御装置9のハードウエア構成は第1の実施の形態と同様なので説明を省略する。第2の実施の形態における電子制御装置9の機能構成は、第1の実施の形態に比べて記録部12および読出部13の動作が次のように異なる。記録部12は、アドレス記憶領域42にデータセットを記録したアドレスを2回書き込む。読出部13は、アドレス記憶領域に記録された2つの連続するアドレスであって、最も後ろに記録されているアドレスを最新アドレスと判断する。 The hardware configuration of the electronic control unit 9 in the second embodiment is the same as that in the first embodiment, so description thereof will be omitted. The functional configuration of the electronic control unit 9 according to the second embodiment differs from that according to the first embodiment in the operations of the recording section 12 and the reading section 13 as follows. The recording unit 12 writes the address where the data set is recorded in the address storage area 42 twice. The reading unit 13 determines that the latest address among the two consecutive addresses recorded in the address storage area is the latest address.

(記録部12の動作)
図8は、第2の実施の形態における記録部12の動作を示すフローチャートである。ただし図8では、図6や図7と同じ処理には同一のステップ番号を付して説明を省略する。さらに図8では、図示の都合により図6や図7の複数の処理をまとめて記載することもある。記録部12は、S313として図6に示すS301~S303の処理を行う。次に記録部12は、S314として図6に示すS304~S310の処理を行う。そして記録部12は、S315として図7に示すS321~S325の処理を行う。
(Operation of recording unit 12)
FIG. 8 is a flow chart showing the operation of the recording section 12 in the second embodiment. However, in FIG. 8, the same step numbers are assigned to the same processes as those in FIGS. 6 and 7, and the description thereof is omitted. Furthermore, in FIG. 8, for convenience of illustration, a plurality of processes in FIGS. 6 and 7 may be collectively described. The recording unit 12 performs the processing of S301 to S303 shown in FIG. 6 as S313. Next, the recording unit 12 performs the processing of S304 to S310 shown in FIG. 6 as S314. Then, the recording unit 12 performs the processing of S321 to S325 shown in FIG. 7 as S315.

次に記録部12は、S316において正常な書き込みが確認できたか否かを判断する。具体的には記録部12は、S325において読み出したデータと、S304において書き込んだデータが同一であればS316を肯定判断し、両者が異なればS316を否定判断する。記録部12は、S316を否定判断するとS314に戻って処理をやり直す。記録部12は、S316を肯定判断すると、S317に進んで2回目のアドレスの書き込みを行う。S317によるアドレス記憶領域42へのアドレスの書き込みは、S306において書き込んだ領域の直後である。以上が第2の実施の形態における記録部12の動作の説明である。 Next, the recording unit 12 determines in S316 whether normal writing has been confirmed. Specifically, the recording unit 12 makes an affirmative determination in S316 if the data read in S325 and the data written in S304 are the same, and makes a negative determination in S316 if they are different. If the recording unit 12 makes a negative determination in S316, it returns to S314 and redoes the process. When the recording unit 12 makes an affirmative determination in S316, the recording unit 12 proceeds to S317 and writes the address for the second time. The writing of the address to the address storage area 42 in S317 is immediately after the area written in S306. The above is the description of the operation of the recording unit 12 in the second embodiment.

(読出部13の動作)
図9は、第2の実施の形態における読出部13の動作を示すフローチャートである。ただし図9では、図7と同じ処理には同一のステップ番号を付して説明を省略する。読出部13は、S321~S323の処理を行う。次に読出部13は、S331において、アドレスブロック(k)を検出した最初の「FFFFFFFF」のアドレスブロックとする。続くS332では読出部13は、アドレスブロック(k-1)に格納されている値と、アドレスブロック(k-2)に格納されている値とが同一であるか否かを判断する。
(Operation of reading unit 13)
FIG. 9 is a flow chart showing the operation of reading unit 13 in the second embodiment. However, in FIG. 9, the same step numbers are assigned to the same processes as in FIG. 7, and the description thereof is omitted. The reading unit 13 performs the processing of S321 to S323. Next, in S331, the reading unit 13 detects the address block (k) as the first detected address block of "FFFFFFFF". In subsequent S332, the reading unit 13 determines whether or not the value stored in the address block (k-1) and the value stored in the address block (k-2) are the same.

読出部13は、両者が同一と判断する場合はS333に進み、両者が同一でないと判断する場合はS334に進む。S333では読出部13は、アドレスブロック(k-1)に格納されたアドレスからデータを読み出して図9に示す処理を終了する。S334では読出部13は、変数kをデクリメントして、すなわち変数kの値を「1」だけ減算してS332に戻る。すなわちS332とS334のループでは、格納されているアドレス値が同一になるまで、比較対象を後ろから前に移動させる。以上が第2の実施の形態における読出部13の動作の説明である。 The reading unit 13 proceeds to S333 when determining that both are the same, and proceeds to S334 when determining that they are not the same. In S333, the reading unit 13 reads data from the address stored in the address block (k-1), and ends the processing shown in FIG. In S334, the reading unit 13 decrements the variable k, that is, subtracts "1" from the value of the variable k, and returns to S332. That is, in the loop of S332 and S334, the object of comparison is moved from back to front until the stored address values become the same. The above is the description of the operation of the reading unit 13 in the second embodiment.

(動作例)
図10は、第2の実施の形態において記録部12による書き込みの途中で電源断された場合の、記憶部4の状態例を示す図である。図10ではデータセットを記録された順番に「データ1-21」~「データ1-23」と記載している。データ1-21は、「0x00000020」~「0x0000002B」に記録されている。データ1-22は、「0x0000002C」~「0x0000003F」に記録されている。データ1-23は、「0x00000040」~「0x0000004D」に記録されている。ただしデータ1-23は書き込みが完了しておらず途中までしか記録されていない。
(Operation example)
FIG. 10 is a diagram showing an example of the state of the storage unit 4 when the power is turned off during writing by the recording unit 12 in the second embodiment. In FIG. 10, the data sets are described as "data 1-21" to "data 1-23" in the order in which they were recorded. Data 1-21 are recorded in "0x00000020" to "0x0000002B". Data 1-22 are recorded in "0x0000002C" to "0x0000003F". Data 1-23 are recorded in "0x00000040" to "0x0000004D". However, data 1-23 has not been completely written and has been recorded only halfway.

アドレスブロック921およびアドレスブロック922には、「データ1-21」の先頭のアドレスが格納されている。アドレスブロック923およびアドレスブロック924には、「データ1-22」の先頭のアドレスが格納されている。アドレスブロック925には、「データ1-23」の先頭のアドレスが格納されている。アドレスブロック926にはアドレス記憶領域42の初期値である「0xFFFFFFFF」が格納されている。 Address block 921 and address block 922 store the top address of "data 1-21". Address block 923 and address block 924 store the top address of "data 1-22". The address block 925 stores the top address of "data 1-23". The address block 926 stores “0xFFFFFFFF” which is the initial value of the address storage area 42 .

便宜的にアドレスブロックに通し番号を付すと、アドレスブロック(1)がアドレスブロック921、アドレスブロック(2)がアドレスブロック922、アドレスブロック(3)がアドレスブロック923、アドレスブロック(4)がアドレスブロック924、アドレスブロック(5)がアドレスブロック925、アドレスブロック(6)がアドレスブロック926である。 Address block (1) is address block 921, address block (2) is address block 922, address block (3) is address block 923, and address block (4) is address block 924. , address block ( 5 ) is address block 925 and address block ( 6 ) is address block 926 .

読出部13の動作を図9のフローチャートと合わせて説明する。読出部13は、アドレス記憶領域42の先頭から「FFFFFFFF」を検索し、アドレスブロック926を発見する(S321)。アドレスブロック926はアドレス記憶領域42の先頭ではないので(S322:NO)、S331に進む。S331では読出部13は、アドレスブロック926をアドレスブロック(k)とする。前述のとおり、アドレスブロック926はアドレスブロック(6)とも表記されるので、S331では「k=6」に設定される。 The operation of the reading unit 13 will be described with reference to the flow chart of FIG. The reading unit 13 searches for "FFFFFFFF" from the beginning of the address storage area 42 and finds the address block 926 (S321). Since the address block 926 is not at the top of the address storage area 42 (S322: NO), the process proceeds to S331. In S331, the reading unit 13 sets the address block 926 as the address block (k). As described above, address block 926 is also written as address block (6), so in S331, "k=6" is set.

続くS332では読出部13は、アドレスブロック(k-1)とアドレスブロック(k-2)の値が同一か否か、すなわちアドレスブロック(5)であるアドレスブロック925と、アドレスブロック(4)であるアドレスブロック924の値が同一か否かを判断する。両者は「00000040」と「0000002C」で異なる値なので、読出部13は否定判断してS334に進み、変数「k」をデクリメントして「k=5」としてS332に戻る。 In subsequent S332, the reading unit 13 checks whether the values of the address block (k-1) and the address block (k-2) are the same, that is, the address block 925, which is the address block (5), and the address block (4). It is determined whether or not the values of certain address blocks 924 are the same. Since both are different values of "00000040" and "0000002C", the reading unit 13 makes a negative determination, proceeds to S334, decrements the variable "k", sets "k=5", and returns to S332.

再び実行されるS332では読出部13は、アドレスブロック(4)であるアドレスブロック924と、アドレスブロック(3)であるアドレスブロック923の値が同一か否かを判断する。両者は「0000002C」で同一なので、読出部13はS333に進んでアドレス「0x0000002C」からデータ1-22を読み出す。 In S332, which is executed again, the reading unit 13 determines whether or not the values of the address block 924, which is the address block (4), and the address block 923, which is the address block (3), are the same. Since both are "0000002C" and are the same, the reading unit 13 advances to S333 to read data 1-22 from the address "0x0000002C".

上述した第2の実施の形態によれば、次の作用効果が得られる。
(7)記録部12は、最新アドレスをアドレス記憶領域42の未記録領域の末尾に記録し、記録した最新アドレスからデータセットが読み出せるとアドレス記憶領域42の未記録領域の末尾にさらに最新アドレスを記録する。読出部13は、アドレス記憶領域42に記録された2つの連続するアドレスであって、最も後ろに記録されているアドレスを最新アドレスと判断する。そのため記録部12による記録の最中に電源の遮断などで動作が停止しても、読出部13は同じアドレスが続けて記録されていないことで異常の発生を検知し、問題が検出されていない従前の情報を読み出すことができる。すなわち本実施の形態による電子制御装置9は、異常時が発生する以前の状態にロールバックすることができる。
According to the second embodiment described above, the following effects are obtained.
(7) The recording unit 12 records the latest address at the end of the unrecorded area of the address storage area 42, and when the data set can be read from the recorded latest address, the recording unit 12 further adds the latest address to the end of the unrecorded area of the address storage area 42. record. Of the two consecutive addresses recorded in the address storage area 42, the reading unit 13 determines that the last recorded address is the latest address. Therefore, even if the operation of the recording unit 12 is stopped due to a power interruption or the like during recording, the reading unit 13 detects the occurrence of an abnormality because the same address is not continuously recorded, and the problem is not detected. Previous information can be read. That is, the electronic control unit 9 according to this embodiment can roll back to the state before the occurrence of the abnormality.

(第2の実施の形態の変形例1)
記録部12は、アドレスを3回以上連続で書き込んでもよい。この場合は、3回目以降のアドレスの書き込みは、2回目の書き込みと同時に行ってもよい。さらに記録部12は、N-1回目の書き込みが正常に行われていることを確認してからN回目の書き込みを行ってもよい。
(Modification 1 of the second embodiment)
The recording unit 12 may write the address three times or more consecutively. In this case, the third and subsequent address writes may be performed at the same time as the second write. Further, the recording unit 12 may perform the N-th writing after confirming that the N-1th writing is normally performed.

(第2の実施の形態の変形例2)
アドレス記憶領域42は、第1アドレス記憶領域421と、第2アドレス記憶領域422とから構成されてもよい。この場合に記録部12は、データセットを記録したアドレスを第1アドレス記憶領域421および第2アドレス記憶領域422に追記する。記録部12による追記する位置の決定方法は第1の実施の形態と同様である。記録部12はたとえば、1回目のアドレスの書き込みを第1アドレス記憶領域421に行い、2回目のアドレスの書き込みを第2アドレス記憶領域422に行う。ただし記録部12は、2回目のアドレスの書き込みは、第2の実施の形態と同様に1回目の書き込みが正常に行われていることを確認してから行う。
(Modification 2 of the second embodiment)
The address storage area 42 may be composed of a first address storage area 421 and a second address storage area 422 . In this case, the recording unit 12 additionally writes the address where the data set is recorded in the first address storage area 421 and the second address storage area 422 . The method of determining the position to be additionally written by the recording unit 12 is the same as in the first embodiment. For example, the recording unit 12 writes the address for the first time to the first address storage area 421 and writes the address for the second time to the second address storage area 422 . However, the recording unit 12 writes the address for the second time after confirming that the first write is performed normally, as in the second embodiment.

この場合に読出部13は、第1アドレス記憶領域421および第2アドレス記憶領域422の同じ位置に記録されたアドレスであって、最も後ろに記録されているアドレスからデータセットを読み出す。具体的には読出部13は、まず第1アドレス記憶領域421および第2アドレス記憶領域422の両方を対象として先頭から順番に、格納されている値が「FFFFFFFF」ではない最も後ろのアドレスブロックを検索する。そして第1アドレス記憶領域421および第2アドレス記憶領域422における先頭からの位置が同じであり、格納されている値が「FFFFFFFF」ではなく、同一の値が格納されているアドレスブロックを特定する。さらに読出部13は、その特定したアドレスブロックに格納されているアドレスからデータセットを読み出す。 In this case, the reading unit 13 reads out the data set from the last address recorded at the same position in the first address storage area 421 and the second address storage area 422 . Specifically, the reading unit 13 first reads the last address block in both the first address storage area 421 and the second address storage area 422 in order from the beginning, in which the stored value is not "FFFFFFFF". search for. Address blocks in which the positions from the beginning of the first address storage area 421 and the second address storage area 422 are the same and the stored value is not "FFFFFFFF" but the same value are specified. Further, the reading unit 13 reads the data set from the address stored in the specified address block.

図11は、第2の実施の形態の変形例2における記憶部4の状態例を示す図である。図11では、第2の実施の形態で示した図10と同様の状況、すなわち記録部12による書き込みの途中で電源断された場合を示している。本変形例では、記憶部4の最初の0x20バイトが第1アドレス記憶領域421、次の0x20バイトが第2アドレス記憶領域422、さらに次の0x60バイトがデータ記憶領域41である。データ1-21は、「0x00000040」~「0x0000004B」に記録されている。データ1-22は、「0x0000004C」~「0x0000005F」に記録されている。データ1-23は、「0x00000060」~「0x0000006D」に記録されている。ただしデータ1-23は書き込みが完了しておらず途中までしか記録されていない。 FIG. 11 is a diagram showing a state example of the storage unit 4 in Modification 2 of the second embodiment. FIG. 11 shows a situation similar to that of FIG. 10 shown in the second embodiment, that is, a case where the power is turned off during writing by the recording unit 12 . In this modification, the first 0x20 bytes of the storage unit 4 are the first address storage area 421 , the next 0x20 bytes are the second address storage area 422 , and the next 0x60 bytes are the data storage area 41 . Data 1-21 are recorded in "0x00000040" to "0x0000004B". Data 1-22 are recorded in "0x0000004C" to "0x0000005F". Data 1-23 are recorded in "0x00000060" to "0x0000006D". However, data 1-23 has not been completely written and has been recorded only halfway.

アドレスブロック931およびアドレスブロック934には、「データ1-21」の先頭のアドレスが格納されている。アドレスブロック932およびアドレスブロック935には、「データ1-22」の先頭のアドレスが格納されている。アドレスブロック933には、「データ1-23」の先頭のアドレスが格納されている。アドレスブロック936にはアドレス記憶領域42の初期値である「0xFFFFFFFF」が格納されている。 Address block 931 and address block 934 store the top address of "data 1-21". Address block 932 and address block 935 store the top address of "data 1-22". The address block 933 stores the top address of "data 1-23". The address block 936 stores “0xFFFFFFFF” which is the initial value of the address storage area 42 .

読出部13は、第1アドレス記憶領域421および第2アドレス記憶領域422の両方を対象として先頭から順番に、格納されている値が「FFFFFFFF」ではない最も後ろのアドレスブロックを検索する。これにより、第1アドレス記憶領域421ではアドレスブロック933が選択され、第2アドレス記憶領域422ではアドレスブロック935が検索される。しかしアドレスブロック933は第1アドレス記憶領域421の先頭から3番目であり、アドレスブロック935が第2アドレス記憶領域422の先頭から2番目で両者は同じ位置ではない。そのため読出部13は、第1アドレス記憶領域421の先頭から2番目のアドレスブロック932を選択し、アドレスブロック932とアドレスブロック935に格納されている値が同一なので、読出部13は「0x0000004C」からデータセットを読み出す。 Reading unit 13 searches both first address storage area 421 and second address storage area 422 for the last address block in which the stored value is not "FFFFFFFF" in order from the top. As a result, the address block 933 is selected in the first address storage area 421 and the address block 935 is searched in the second address storage area 422 . However, the address block 933 is the third from the top of the first address storage area 421, the address block 935 is the second from the top of the second address storage area 422, and they are not at the same position. Therefore, the reading unit 13 selects the second address block 932 from the top of the first address storage area 421, and since the values stored in the address blocks 932 and 935 are the same, the reading unit 13 reads from "0x0000004C". Read the dataset.

以上説明した変形例によれば次の作用効果が得られる。
(8)アドレス記憶領域42は、第1アドレス記憶領域421および第2アドレス記憶領域422から構成される。記録部12は、最新アドレスを第1アドレス記憶領域421の未記録領域の末尾に記録し、記録した最新アドレスからデータセットが読み出せると第2アドレス記憶領域422の未記録領域の末尾に最新アドレスを記録する。読出部13は、第1アドレス記憶領域421および第2アドレス記憶領域422の先頭から同じ位置に記録されたアドレスであって、最も後ろに記録されているアドレスを最新アドレスと判断する。そのため、第2の実施の形態と異なる実装形態で、電源の不意な切断に対応できる。
According to the modified example described above, the following effects can be obtained.
(8) The address storage area 42 is composed of a first address storage area 421 and a second address storage area 422 . The recording unit 12 records the latest address at the end of the unrecorded area of the first address storage area 421, and when the data set can be read from the recorded latest address, records the latest address at the end of the unrecorded area of the second address storage area 422. record. The reading unit 13 determines that the last address recorded at the same position from the beginning of the first address storage area 421 and the second address storage area 422 is the latest address. Therefore, a mounting form different from the second embodiment can cope with sudden power-off.

―第3の実施の形態―
図12~図15を参照して、電子制御装置の第3の実施の形態を説明する。以下の説明では、第1の実施の形態と同じ構成要素には同じ符号を付して相違点を主に説明する。特に説明しない点については、第1の実施の形態と同じである。本実施の形態では、主に、データ記憶領域に複数種類のデータが記録され、それぞれを示すアドレステーブルも併せて保存される点で、第1の実施の形態と異なる。本実施の形態では、入力部11に入力されるデータセットには1または複数のデータが含まれ、さらにデータセットには含まれるデータの種類を示す識別子が付されている。
-Third Embodiment-
A third embodiment of the electronic control unit will be described with reference to FIGS. 12 to 15. FIG. In the following description, the same components as those in the first embodiment are given the same reference numerals, and differences are mainly described. Points that are not particularly described are the same as those in the first embodiment. This embodiment differs from the first embodiment mainly in that a plurality of types of data are recorded in the data storage area, and an address table indicating each type is also stored together. In this embodiment, the data set input to the input unit 11 includes one or more pieces of data, and an identifier indicating the type of data included is attached to the data set.

(データセット)
図12は、第3の実施の形態におけるデータセットの例を示す図である。図12では符号1101~1103で示す3つのデータセットを図示しており、符号の順番で入力部11に入力される。データセット1101にはデータ1、データ2、およびデータ3が含まれる。図12では、データの種類を示す識別子として山括弧で数字を囲った記号、すなわち「<1>」などを記載している。ただし実際にはあらかじめ定めた符号を用いればよく、表記形式は任意である。
(data set)
FIG. 12 is a diagram showing an example of data sets in the third embodiment. FIG. 12 shows three data sets denoted by reference numerals 1101 to 1103, which are input to the input unit 11 in order of the reference numerals. Data set 1101 includes data1, data2, and data3. In FIG. 12, a symbol enclosing a number in angle brackets, such as "<1>", is described as an identifier indicating the type of data. However, in practice, a predetermined code may be used, and the notation format is arbitrary.

(記憶部4の状態例)
図13は、第3の実施の形態における記憶部4の状態例を示す図である。図13では、図12に示した3つのデータセットを記録した状態を示している。ただし各データのサイズは作図の都合により非常に小さく記載している。実際にはデータのサイズは数キロバイト以上あってもよい。
(Example of state of storage unit 4)
FIG. 13 is a diagram showing a state example of the storage section 4 in the third embodiment. FIG. 13 shows a state in which the three data sets shown in FIG. 12 are recorded. However, the size of each data is shown very small for convenience of drawing. In practice, the data size may be several kilobytes or more.

図13では、アドレス記憶領域42の最初のアドレスブロック941に「0x00000020」が格納され、2番目のアドレスブロック942に「0x00000040」が格納され、3番目のアドレスブロック943に「0x00000050」が格納されている。図13のデータ記憶領域41には、3つのアドレステーブルと、受信したそれぞれのデータが格納されている。記録部12は、入力部11がデータセットを受信するたびにアドレステーブルを作成して受信したデータセットに含まれるデータとともにデータ記憶領域41に格納する。 In FIG. 13, the first address block 941 of the address storage area 42 stores "0x00000020", the second address block 942 stores "0x00000040", and the third address block 943 stores "0x00000050". there is The data storage area 41 of FIG. 13 stores three address tables and their respective received data. The recording unit 12 creates an address table each time the input unit 11 receives a data set and stores it in the data storage area 41 together with the data included in the received data set.

アドレステーブルには、データ1~データ3が格納されているアドレスが格納される。図13に示す例ではデータセットに含まれるデータの種類は3つなので、データセットにはアドレスが3つ含まれる。そのためデータセットのサイズは、4バイトの3倍である12バイトである。各アドレステーブルの具体的な値は図13の下部に示している。アドレステーブル1には、データ1が格納されているアドレスを示す「0000002C」と、データ2が格納されているアドレスを示す「00000030」と、データ3が格納されているアドレスを示す「00000034」とから構成される。 The address table stores addresses where data 1 to data 3 are stored. In the example shown in FIG. 13, the data set contains three types of data, so the data set contains three addresses. So the size of the data set is 12 bytes which is 3 times 4 bytes. Specific values of each address table are shown at the bottom of FIG. The address table 1 contains "0000002C" indicating the address where data 1 is stored, "00000030" indicating the address where data 2 is stored, and "00000034" indicating the address where data 3 is stored. consists of

アドレステーブル2の値は、データ2を除いてアドレステーブル1と同じである。図12に示したようにデータセット1102にはデータ2しか含まれないからである。アドレステーブル2のデータ2の値は、「0000004C」である。アドレステーブル3の値は、データ3のみアドレステーブル2と同じである。データセット1103にはデータ1およびデータ2しか含まれないからである。アドレステーブル3のデータ1の値は「0000005C」、データ2の値は「00000060」である。 The values in address table 2 are the same as in address table 1 except for data 2 . This is because data set 1102 includes only data 2 as shown in FIG. The value of data 2 in address table 2 is "0000004C". The value of address table 3 is the same as that of address table 2 only for data 3 . This is because data set 1103 contains only data 1 and data 2 . The value of data 1 in the address table 3 is "0000005C", and the value of data 2 is "00000060".

(記録部12の動作フローチャート)
図14は、本実施の形態における記録部12のS304の詳細を示すフローチャートである。本実施の形態における記録部12の動作は第1の実施の形態とS304を除いて同一なので、ここでは図14を参照してS304の詳細のみを説明する。本実施の形態では、S304は以下に説明するようにS3041~S3045で構成される。S3041では記録部12は、データ記憶領域41に保存されている最新のアドレステーブルを読み込む。ただし記録部12は、RAM3に最新のアドレステーブルを記録し、S3041ではRAM3からアドレステーブルを読み込んでもよい。
(Operational flowchart of recording unit 12)
FIG. 14 is a flow chart showing details of S304 of the recording unit 12 in this embodiment. Since the operation of the recording unit 12 in this embodiment is the same as that in the first embodiment except for S304, only the details of S304 will be described here with reference to FIG. In this embodiment, S304 consists of S3041 to S3045 as described below. At S<b>3041 , the recording unit 12 reads the latest address table saved in the data storage area 41 . However, the recording unit 12 may record the latest address table in the RAM 3 and read the address table from the RAM 3 in S3041.

続くS3042では記録部12は、受信したデータセットに付された識別子に基づき、更新されたデータを特定する。続くS3043では記録部12は、新たに記録されるデータが記録されるデータ記憶領域41のアドレスを特定する。このアドレスはたとえば、S305において特定したアドレスにアドレステーブルのサイズを加えることで算出できる。また、新たに記録されるデータが複数存在する場合には、他のデータのデータサイズをあわせて利用することで、データの記録されるアドレスを算出できる。 In subsequent S3042, the recording unit 12 identifies the updated data based on the identifier attached to the received data set. In subsequent S3043, the recording unit 12 specifies the address of the data storage area 41 where the newly recorded data is recorded. This address can be calculated, for example, by adding the size of the address table to the address specified in S305. Also, when there are a plurality of data to be newly recorded, by using the data sizes of the other data as well, the address where the data is recorded can be calculated.

続くS3044では記録部12は、データ記憶領域41におけるS305において特定した位置に新たなアドレステーブルを記録する。このアドレステーブルは、全データについて記録されているアドレスを示すものである。最後のS3045では記録部12は、アドレステーブルを記録した領域の直後に新たなデータを書き込む。 In subsequent S3044, the recording unit 12 records a new address table in the position specified in S305 in the data storage area 41. FIG. This address table indicates addresses recorded for all data. In the final S3045, the recording unit 12 writes new data immediately after the area in which the address table is recorded.

(読出部13の動作フローチャート)
図15は、本実施の形態における読出部13のS325の詳細を示すフローチャートである。本実施の形態における読出部13の動作は第1の実施の形態とS325を除いて同一なので、ここでは図15を参照してS325の詳細のみを説明する。本実施の形態では、S325は以下に説明するようにS3251~S3252で構成される。S3251では読出部13は、ターゲットからアドレステーブルを読み込む。続くS3252では読出部13は、アドレステーブルに記載された各アドレスからデータを読み出す。
(Operational flowchart of reading unit 13)
FIG. 15 is a flow chart showing details of S325 of the reading unit 13 in this embodiment. Since the operation of the reading unit 13 in this embodiment is the same as that in the first embodiment except for S325, only the details of S325 will be described here with reference to FIG. In this embodiment, S325 consists of S3251 to S3252 as described below. In S3251, the reading unit 13 reads the address table from the target. In subsequent S3252, the reading unit 13 reads data from each address described in the address table.

上述した第3の実施の形態によれば、次の作用効果が得られる。
(9)データセットは複数のデータから構成される。記録部12は、複数のデータのそれぞれが記録されたアドレスを示すアドレステーブルをデータセットとともにデータ記憶領域に記録する。そのため複数のデータを記録する場合にも、第1の実施の形態と同様に記憶部4の寿命を延ばすことができる。
According to the third embodiment described above, the following effects are obtained.
(9) A data set consists of a plurality of data. The recording unit 12 records an address table indicating addresses where each of the plurality of data is recorded together with the data set in the data storage area. Therefore, even when recording a plurality of data, the life of the storage unit 4 can be extended as in the first embodiment.

(10)データセットを構成する複数のデータのそれぞれには識別子が対応付けられている。入力部11に入力されるデータセットには、当該データセットに含まれるデータに対応する識別子が付されている。記録部12は、入力部11にデータセットが入力されると、データセットに付された識別子に基づきアドレステーブルにおける書き換え対象を特定する(図14のS3042)。そして記録部12は、特定した書き換え対象を新たに記録したアドレスに書き換える(図14のS3044)。そのため、データセットを構成する一部のデータのみが更新された場合に、効率よく情報を記録することができる。 (10) An identifier is associated with each of a plurality of pieces of data forming a data set. A data set input to the input unit 11 is assigned an identifier corresponding to data included in the data set. When the data set is input to the input unit 11, the recording unit 12 specifies rewriting targets in the address table based on the identifier attached to the data set (S3042 in FIG. 14). Then, the recording unit 12 rewrites the specified rewrite target to the newly recorded address (S3044 in FIG. 14). Therefore, information can be efficiently recorded when only a part of the data constituting the data set is updated.

上述した各実施の形態および変形例において、機能ブロックの構成は一例に過ぎない。別々の機能ブロックとして示したいくつかの機能構成を一体に構成してもよいし、1つの機能ブロック図で表した構成を2以上の機能に分割してもよい。また各機能ブロックが有する機能の一部を他の機能ブロックが備える構成としてもよい。 In each of the embodiments and modifications described above, the configuration of the functional blocks is merely an example. Some functional configurations shown as separate functional blocks may be configured integrally, or a configuration represented by one functional block diagram may be divided into two or more functions. Further, a configuration may be adopted in which part of the functions of each functional block is provided in another functional block.

上述した各実施の形態および変形例において、プログラムは不図示のROMに格納されるとしたが、プログラムは記憶部4に格納されていてもよい。また、電子制御装置9が不図示の入出力インタフェースを備え、必要なときに入出力インタフェースと電子制御装置9が利用可能な媒体を介して、他の装置からプログラムが読み込まれてもよい。ここで媒体とは、例えば入出力インタフェースに着脱可能な記憶媒体、または通信媒体、すなわち有線、無線、光などのネットワーク、または当該ネットワークを伝搬する搬送波やディジタル信号、を指す。また、プログラムにより実現される機能の一部または全部がハードウエア回路やFPGAにより実現されてもよい。 Although the program is stored in the ROM (not shown) in each of the embodiments and modifications described above, the program may be stored in the storage unit 4 . Alternatively, the electronic control unit 9 may have an input/output interface (not shown), and a program may be read from another device via a medium that can be used by the input/output interface and the electronic control unit 9 when necessary. Here, the medium refers to, for example, a storage medium that can be attached to and detached from an input/output interface, or a communication medium, that is, a wired, wireless, or optical network, or a carrier wave or digital signal that propagates through the network. Also, part or all of the functions realized by the program may be realized by a hardware circuit or FPGA.

上述した各実施の形態および変形例は、それぞれ組み合わせてもよい。上記では、種々の実施の形態および変形例を説明したが、本発明はこれらの内容に限定されるものではない。本発明の技術的思想の範囲内で考えられるその他の態様も本発明の範囲内に含まれる。 Each of the embodiments and modifications described above may be combined. Although various embodiments and modifications have been described above, the present invention is not limited to these contents. Other aspects conceivable within the scope of the technical idea of the present invention are also included in the scope of the present invention.

4…記憶部
9…電子制御装置
11…入力部
12…記録部
13…読出部
41…データ記憶領域
42…アドレス記憶領域
421…第1アドレス記憶領域
422…第2アドレス記憶領域
4 storage unit 9 electronic control unit 11 input unit 12 recording unit 13 reading unit 41 data storage area 42 address storage area 421 first address storage area 422 second address storage area

Claims (5)

アドレスが付されデータセットが記録されるデータ記憶領域、および2以上の前記アドレスを格納可能なアドレス記憶領域を含む不揮発性の記憶領域である記憶部と、
前記データセットが入力される入力部と、
前記入力部に入力された前記データセットを前記データ記憶領域における未記録領域に記録し、前記未記録領域のアドレスに関する情報を前記アドレス記憶領域の未記録領域に記録する記録部と、
前記アドレス記憶領域における最新の記録に基づいて前記データ記憶領域から前記データセットを読み出す読出部と、を備え
前記データセットは複数のデータから構成され、
前記記録部は、前記複数のデータのそれぞれが記録されたアドレスを示すアドレステーブルを前記データセットとともに前記データ記憶領域に記録し、
前記未記録領域のアドレスに関する情報とは前記アドレステーブルが記録されているアドレスである、電子制御装置。
a storage unit, which is a non-volatile storage area including a data storage area in which addresses are assigned and data sets are recorded, and an address storage area capable of storing two or more of the addresses;
an input unit to which the data set is input;
a recording unit that records the data set input to the input unit in an unrecorded area in the data storage area, and records information about an address of the unrecorded area in an unrecorded area of the address storage area;
a reading unit that reads the data set from the data storage area based on the latest record in the address storage area ;
The data set is composed of a plurality of data,
The recording unit records an address table indicating an address where each of the plurality of data is recorded together with the data set in the data storage area;
The electronic control device , wherein the information about the address of the unrecorded area is the address where the address table is recorded .
請求項1に記載の電子制御装置において、
前記データセットを構成する前記複数のデータのそれぞれには識別子が対応付けられており、
前記入力部に入力されるデータセットには、当該データセットに含まれるデータに対応する前記識別子が付されており、
前記記録部は、前記入力部に前記データセットが入力されると、前記データセットに付された前記識別子に基づき前記アドレステーブルにおける書き換え対象を特定し、特定した前記書き換え対象を新たに記録したアドレスに書き換える電子制御装置。
In the electronic control device according to claim 1,
each of the plurality of data constituting the data set is associated with an identifier;
The data set input to the input unit is attached with the identifier corresponding to the data included in the data set,
When the data set is input to the input unit, the recording unit specifies a rewriting target in the address table based on the identifier attached to the data set, and an address where the specified rewriting target is newly recorded. Electronic control unit that rewrites to
請求項1に記載の電子制御装置において、
前記記録部は、前記アドレス記憶領域において、先頭から後方に向かって順番に、または末尾から先頭に向かって順番に、前記アドレステーブルが記録されているアドレスを書き込む電子制御装置。
In the electronic control device according to claim 1,
The recording unit is an electronic control unit that writes addresses in which the address table is recorded in order from the head to the rear or from the tail to the head in the address storage area.
請求項1に記載の電子制御装置において、
前記記録部は、前記アドレス記憶領域において、先頭から後方に向かって順番に前記アドレステーブルが記録されているアドレスである最新アドレスを書き込み、
前記読出部は、前記アドレス記憶領域における最後方に記録されたアドレスを前記最新アドレスと判断する電子制御装置。
In the electronic control device according to claim 1,
The recording unit writes the latest address, which is the address where the address table is recorded, in order from the beginning to the rear in the address storage area,
The electronic control unit, wherein the reading unit determines an address recorded last in the address storage area as the latest address.
請求項4に記載の電子制御装置において、
前記記録部は、前記アドレス記憶領域において、先頭から後方に向かって順番に前記最新アドレスを書き込み、
前記読出部は、前記アドレス記憶領域に格納されている値を前記記録部に設定されたアドレス空間の大きさの区切りでアドレスブロックとして先頭から後方に向かって検索し、前記記憶部を初期化した際の値を有し前記検索により最初に該当したアドレスブロックの直前のアドレスブロックに格納されている値を前記最新アドレスと判断する電子制御装置。
In the electronic control device according to claim 4,
The recording unit writes the latest addresses in order from the beginning to the end in the address storage area,
The readout unit retrieves the values stored in the address storage area from the beginning to the rear as address blocks at intervals of the size of the address space set in the recording unit, and initializes the storage unit. an electronic control unit for determining, as the latest address, a value stored in an address block immediately preceding an address block first found by the search and having an actual value.
JP2019128948A 2019-07-11 2019-07-11 electronic controller Active JP7317609B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2019128948A JP7317609B2 (en) 2019-07-11 2019-07-11 electronic controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2019128948A JP7317609B2 (en) 2019-07-11 2019-07-11 electronic controller

Publications (2)

Publication Number Publication Date
JP2021015388A JP2021015388A (en) 2021-02-12
JP7317609B2 true JP7317609B2 (en) 2023-07-31

Family

ID=74531440

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2019128948A Active JP7317609B2 (en) 2019-07-11 2019-07-11 electronic controller

Country Status (1)

Country Link
JP (1) JP7317609B2 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001318824A (en) 2000-05-10 2001-11-16 Nec Miyagi Ltd System for managing data of flash memory and recording medium with its program recorded
JP2006190036A (en) 2005-01-05 2006-07-20 Matsushita Electric Ind Co Ltd Memory controller, nonvolatile storage device, nonvolatile storage system, and memory control method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07182246A (en) * 1993-11-25 1995-07-21 Sanyo Electric Co Ltd Device and method for controlling non-volatile memory

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001318824A (en) 2000-05-10 2001-11-16 Nec Miyagi Ltd System for managing data of flash memory and recording medium with its program recorded
JP2006190036A (en) 2005-01-05 2006-07-20 Matsushita Electric Ind Co Ltd Memory controller, nonvolatile storage device, nonvolatile storage system, and memory control method

Also Published As

Publication number Publication date
JP2021015388A (en) 2021-02-12

Similar Documents

Publication Publication Date Title
KR100847506B1 (en) Storage device, memory management method and program
JP4418439B2 (en) Nonvolatile storage device and data writing method thereof
US10509570B2 (en) Method, device, and program for managing a flash memory for mass storage
JP4122972B2 (en) Data recording apparatus and data writing method for flash memory
KR100645540B1 (en) Apparatus and method for managing data on flash memory
JP2005242897A (en) Flash disk drive
JP2010020586A (en) Data processing device
JP4153324B2 (en) DIFFERENTIAL DATA GENERATION DEVICE AND METHOD, UPDATED DATA RESTORE DEVICE AND METHOD, AND PROGRAM
US20070136510A1 (en) Storage device, memory managing device, memory managing method, and program
JP6123766B2 (en) Data reading apparatus, program, and data reading method
JP2009205689A (en) Flash disk device
JP7317609B2 (en) electronic controller
JP6050794B2 (en) FLASH MEMORY MODULE, NONVOLATILE SEMICONDUCTOR MEMORY MODULE, AND STORAGE DEVICE
JP4826232B2 (en) Information processing apparatus and boot program rewriting method
JP2004078902A (en) Storage device, memory management method, and program thereof
JP3826115B2 (en) Storage device, memory management method, and program
US11609844B2 (en) Memory system with hierarchical tables
KR102315314B1 (en) Apparatus and method for controlling eeprom
US20110082995A1 (en) Information processing apparatus
KR20050011869A (en) Memory device using flash memory and error correction method the same
US11182286B2 (en) Data storage device and control method for non-volatile memory
WO2020039927A1 (en) Non-volatile storage device, host device, and data storage system
JP5521437B2 (en) Portable terminal device, software update method and program
JP2010182160A (en) Memory access device, nonvolatile storage device, nonvolatile storage system, memory access method, program and integrated circuit
JP2005321843A (en) Rewriting method for firmware

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20220602

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20230425

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20230523

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20230629

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: 20230711

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20230719

R150 Certificate of patent or registration of utility model

Ref document number: 7317609

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150