Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP5821788B2 - Electronic control unit - Google Patents
[go: Go Back, main page]

JP5821788B2 - Electronic control unit - Google Patents

Electronic control unit Download PDF

Info

Publication number
JP5821788B2
JP5821788B2 JP2012139908A JP2012139908A JP5821788B2 JP 5821788 B2 JP5821788 B2 JP 5821788B2 JP 2012139908 A JP2012139908 A JP 2012139908A JP 2012139908 A JP2012139908 A JP 2012139908A JP 5821788 B2 JP5821788 B2 JP 5821788B2
Authority
JP
Japan
Prior art keywords
control program
program
nonvolatile memory
termination
information
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
JP2012139908A
Other languages
Japanese (ja)
Other versions
JP2014006575A (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.)
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 JP2012139908A priority Critical patent/JP5821788B2/en
Publication of JP2014006575A publication Critical patent/JP2014006575A/en
Application granted granted Critical
Publication of JP5821788B2 publication Critical patent/JP5821788B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Description

本発明は、制御プログラムと埋め込みコードとが書き込まれた不揮発性メモリと、外部装置から送られてくる制御プログラムを保存する保存部と、書換プログラムにしたがって、不揮発性メモリに書き込まれた制御プログラムを、保存部に保存された制御プログラムに書き換えるCPUと、を備える電子制御装置に関するものである。   The present invention relates to a nonvolatile memory in which a control program and an embedded code are written, a storage unit for storing a control program sent from an external device, and a control program written in the nonvolatile memory in accordance with the rewriting program. The present invention relates to an electronic control device including a CPU that rewrites a control program stored in a storage unit.

従来、例えば特許文献1に示されるように、通常時には内蔵プログラム及び内蔵データに基づく制御処理を実行することにより所定の制御対象を制御し、外部装置からの書き換え指令があった場合には、内蔵プログラム又は内蔵データを外部装置から送信される新たなプログラム又はデータに書き換えるための書換処理を実行する電子制御装置が提案されている。   Conventionally, for example, as shown in Patent Document 1, a predetermined control target is controlled by executing a control process based on a built-in program and built-in data in a normal state, and when there is a rewrite command from an external device, There has been proposed an electronic control device that executes a rewriting process for rewriting a program or built-in data with a new program or data transmitted from an external device.

特開平9−128229号公報JP-A-9-128229

特許文献1に示される電子制御装置では、メモリ領域に、上記した内蔵プログラム及び内蔵データが書き込まれている。通常、メモリ領域のサイズは、上記した内蔵プログラムと内臓データそれぞれのサイズの和よりも大きく、その空き領域には、エラーを通知する埋め込みコードが書き込まれている。   In the electronic control device disclosed in Patent Document 1, the above-described built-in program and built-in data are written in the memory area. Usually, the size of the memory area is larger than the sum of the sizes of the built-in program and the built-in data, and an embedded code for notifying an error is written in the empty area.

これに対して、特許文献1に示される電子制御装置は、内蔵プログラムや内蔵データのサイズ、及び、新たに書き換えられるプログラムやデータのサイズそれぞれに関する情報を有していない。そのため、書換処理を実行する際、新たに書き込まれるプログラムやデータを確実にメモリ領域に書き込むために、メモリ領域に書き込まれた、内蔵プログラムや内蔵データだけではなく、埋め込みコードも全て消去しなくてはならなかった。   On the other hand, the electronic control device disclosed in Patent Document 1 does not have information on the size of the built-in program and the built-in data, and the size of the newly rewritten program and data. Therefore, when executing rewrite processing, not only the built-in program and built-in data written to the memory area but also all embedded codes must be erased in order to reliably write the newly written program and data to the memory area. I didn't.

埋め込みコードは、エラーを通知するためのコードであり、各アドレスに書き込まれる埋め込みコードは、全て同一である。このように、埋め込みコードは、書き込まれるアドレスには依存しない。したがって、書換処理の際には、新たに書き換えられるプログラムやデータのサイズを確保する分だけの埋め込みコードを消去すればよい。しかしながら、上記したように、特許文献1に示される電子制御装置は、新たに書き換えられるプログラムやデータのサイズそれぞれに関する情報を有していない。そのため、新たに書き込まれるプログラムやデータを確実にメモリ領域に書き込むためには、埋め込みコードの全てを消去しなくてはならず、余分に埋め込みコードが消去されることとなる。この結果、消去時間が余分にかかった。また、新たにプログラムやデータを書き込んだ際、余ったアドレスに埋め込みコードを書き込まなくてはならなくなるが、その書き込み時間が余分にかかった。このように、余分な埋め込みコードの消去と書き込みの分、書き換えに時間がかかる、という問題があった。   The embedded code is a code for notifying an error, and the embedded code written in each address is the same. Thus, the embedded code does not depend on the address to be written. Therefore, in the rewriting process, it is only necessary to delete the embedded code as much as the size of the newly rewritten program or data is secured. However, as described above, the electronic control device disclosed in Patent Document 1 does not have information regarding the size of a newly rewritten program or data. Therefore, in order to reliably write a newly written program or data to the memory area, all of the embedded code must be erased, and the embedded code is erased extra. As a result, it took extra time to erase. In addition, when a new program or data is written, it is necessary to write an embedded code at a surplus address, but the writing time is excessive. As described above, there is a problem that rewriting takes time for erasing and writing of an extra embedded code.

これに対して、内蔵プログラムや内蔵データのサイズ、及び、新たに書き換えられるプログラムやデータのサイズそれぞれに関する情報をスキャンした後、必要な分、埋め込みコードを増減する、という方法も考えられる。しかしながら、そのスキャンの時間分、書き換えに時間がかかる、という問題があった。   On the other hand, a method of increasing / decreasing the number of embedded codes as necessary after scanning information on the size of the built-in program or built-in data and the size of the newly rewritten program or data can be considered. However, there is a problem that rewriting takes time for the scanning time.

そこで、本発明は上記問題点に鑑み、書換時間の短縮された電子制御装置を提供することを目的とする。   In view of the above problems, an object of the present invention is to provide an electronic control device with a shortened rewrite time.

上記した目的を達成するために、本発明は、第1制御プログラム及び埋め込みコードが書き込まれた不揮発性メモリ(50)と、外部装置から送られてくる第2制御プログラムを保存する保存部(30)と、書換プログラムにしたがって、不揮発性メモリに書き込まれた第1制御プログラムを、保存部に保存された第2制御プログラムに書き換えるCPU(70)と、を有する電子制御装置であって、不揮発性メモリには、第1制御プログラムと埋め込みコードの他に、第1制御プログラムの終端アドレスを示す第1終端情報が書き込まれ、保存部には、第2制御プログラムの他に、第2制御プログラムの終端アドレスを示す第2終端情報が保存され、書換プログラムは、不揮発性メモリ若しくは保存部に記憶され、不揮発性メモリにおける、第1終端情報と第2終端情報それぞれが格納される情報アドレス、及び、第1制御プログラム及び第2制御プログラムそれぞれの先頭アドレスは固定されており、書換プログラムには、第1制御プログラム、及び、第1終端情報を消去する消去プログラムと、第1終端情報、及び、第2終端情報それぞれに基づいて、第2制御プログラムの終端アドレスが、第1制御プログラムの終端アドレスと同一か否かを判定する判定プログラムと、該判定プログラムにて、両者の終端アドレスが同一の場合、第2制御プログラムと第2終端情報とを不揮発性メモリに書き込みし、両者の終端アドレスが異なる場合、埋め込みコードを増減して、第2制御プログラムと第2終端情報とを不揮発性メモリに書き込む書き込みプログラムと、が含まれていることを特徴とする。   In order to achieve the above object, the present invention provides a nonvolatile memory (50) in which a first control program and an embedded code are written, and a storage unit (30) for storing a second control program sent from an external device. ) And a CPU (70) for rewriting the first control program written in the nonvolatile memory into the second control program stored in the storage unit according to the rewriting program, In addition to the first control program and the embedded code, first end information indicating the end address of the first control program is written in the memory, and in addition to the second control program, the second control program is stored in the storage unit. Second end information indicating the end address is stored, and the rewrite program is stored in the non-volatile memory or storage unit. The information address where each of the first termination information and the second termination information is stored, and the first address of each of the first control program and the second control program are fixed, and the rewrite program includes the first control program, and Based on the erase program for erasing the first termination information, the first termination information, and the second termination information, it is determined whether the termination address of the second control program is the same as the termination address of the first control program. If the end address of both is the same in the determination program and the determination program, the second control program and the second end information are written to the nonvolatile memory. If the end addresses are different, the embedded code is increased or decreased. And a writing program for writing the second control program and the second termination information into the nonvolatile memory. And wherein the door.

このように本発明によれば、第1終端情報と第2終端情報それぞれに基づいて、第2制御プログラムを書き込むのに必要な分だけ埋め込みコードを増減する。これによれば、書き換えの際に、埋め込みコードの全てを消去する構成、及び、書き換えるデータのサイズをスキャンする構成それぞれと比べて、書換時間が短縮される。   As described above, according to the present invention, the number of embedded codes is increased or decreased by an amount necessary for writing the second control program based on the first termination information and the second termination information. According to this, at the time of rewriting, the rewriting time is shortened compared to the configuration in which all of the embedded code is erased and the configuration in which the size of data to be rewritten is scanned.

なお、本発明では、埋め込みコードを増減する、と表現しているように、埋め込みコードの増大も記している。これは、第2制御プログラムを書き換えるのに余分な埋め込みコードを消去したために生じる操作ではなく、CPU(70)の処理に依るものである。複数のアドレスに記憶されたデータをブロックとすると、CPU(70)は、このブロックを1単位(以下、ブロック単位と示す)として、不揮発性メモリ(50)に書き込まれたデータを消去する。新たに書き込まれる制御プログラムのサイズがブロック単位だけでは表されない場合、ある一つのブロックに、制御プログラムの一部が書き込まれる。この場合、そのブロックにおける制御プログラムの書き込まれていないアドレスが空きとなるので、この空いたアドレスに埋め込みコードを書き込む必要が生じる。この空いたアドレスを埋めるために、埋め込みコードを増大する、という操作が必要となるのである。ちなみに、第1制御プログラムよりも第2制御プログラムの方がデータサイズが小さい場合においても、空いたアドレスが生じる。そのため、この場合においても、空いたアドレスに埋め込みコードを書き込まなくてはならず、埋め込みコードを増大する、という操作が必要となる。   In the present invention, an increase in the number of embedded codes is also described as expressing that the number of embedded codes is increased or decreased. This is not an operation caused by erasing an extra embedded code to rewrite the second control program, but depends on the processing of the CPU (70). If the data stored at a plurality of addresses is a block, the CPU (70) erases the data written in the nonvolatile memory (50) with this block as one unit (hereinafter referred to as a block unit). When the size of a newly written control program is not expressed in units of blocks, a part of the control program is written in one block. In this case, since an address in which the control program is not written in that block becomes empty, it becomes necessary to write an embedded code in this empty address. In order to fill this vacant address, an operation of increasing the embed code is necessary. Incidentally, an empty address is generated even when the data size of the second control program is smaller than that of the first control program. Therefore, even in this case, it is necessary to write an embedded code at a vacant address, and an operation of increasing the embedded code is required.

ちなみに、第1終端情報は、第1制御プログラムの終端アドレス、若しくは、第1制御プログラムのデータサイズであり、第2終端情報は、第2制御プログラムの終端アドレス、若しくは、第2制御プログラムのデータサイズである。   Incidentally, the first end information is the end address of the first control program or the data size of the first control program, and the second end information is the end address of the second control program or the data of the second control program. Size.

第1実施形態に係る電子制御装置の概略構成を示すブロック図である。It is a block diagram showing a schematic structure of an electronic control unit concerning a 1st embodiment. メモリに記憶されるデータを示す概念図である。It is a conceptual diagram which shows the data memorize | stored in memory. 書き換え処理を示すフローチャートである。It is a flowchart which shows a rewriting process. 書き換え処理を示すフローチャートである。It is a flowchart which shows a rewriting process. 書き換え処理開始前において、不揮発性メモリに記憶されたデータを示す概念図である。It is a conceptual diagram which shows the data memorize | stored in the non-volatile memory before the rewriting process start. 図5に示す不揮発性メモリから第1制御プログラムが消去された状態を示す概念図である。FIG. 6 is a conceptual diagram showing a state where a first control program is erased from the nonvolatile memory shown in FIG. 5. 図6に示す不揮発性メモリから埋め込みコードが消去された状態を示す概念図である。FIG. 7 is a conceptual diagram illustrating a state where an embedded code is erased from the nonvolatile memory illustrated in FIG. 6. 図7に示す不揮発性メモリに第2終端情報と第2制御プログラムとが書き込まれた状態を示す概念図である。FIG. 8 is a conceptual diagram illustrating a state in which second termination information and a second control program are written in the nonvolatile memory illustrated in FIG. 7. 図8に示す不揮発性メモリに埋め込みコードが書き込まれた状態を示す概念図である。FIG. 9 is a conceptual diagram illustrating a state in which an embedded code is written in the nonvolatile memory illustrated in FIG. 8. 図5に示す不揮発性メモリから第1制御プログラムが消去された状態の変形例を示す概念図である。FIG. 6 is a conceptual diagram showing a modified example in a state where the first control program is erased from the nonvolatile memory shown in FIG. 5. 図10に示す不揮発性メモリに第2終端情報と第2制御プログラムとが書き込まれた状態を示す概念図である。It is a conceptual diagram which shows the state by which the 2nd termination | terminus information and the 2nd control program were written in the non-volatile memory shown in FIG. 図11に示す不揮発性メモリに埋め込みコードが書き込まれた状態を示す概念図である。FIG. 12 is a conceptual diagram illustrating a state where an embedded code is written in the nonvolatile memory illustrated in FIG. 11. 書き換え処理の変形例を示すフローチャートである。It is a flowchart which shows the modification of a rewriting process.

以下、本発明の実施の形態を図に基づいて説明する。
(第1実施形態)
図1〜図9に基づいて、本実施形態に係る電子制御装置を説明する。図1に示すように、電子制御装置100は、要部として、送受信コントローラ10と、揮発性メモリ30と、不揮発性メモリ50と、CPU70と、を有する。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
(First embodiment)
The electronic control device according to the present embodiment will be described based on FIGS. As shown in FIG. 1, the electronic control device 100 includes a transmission / reception controller 10, a volatile memory 30, a nonvolatile memory 50, and a CPU 70 as main parts.

送受信コントローラ10は、外部装置90とのデータの送受信を行うものである。送受信コントローラ10を介して外部装置90から送られてきたデータは、CPU70にて受信されるとともに、揮発性メモリ30に一時的に記憶(保存)される。   The transmission / reception controller 10 performs data transmission / reception with the external device 90. Data transmitted from the external device 90 via the transmission / reception controller 10 is received by the CPU 70 and temporarily stored (saved) in the volatile memory 30.

揮発性メモリ30は、送受信コントローラ10を介して外部装置90から送られてくる制御プログラム、及び、終端情報を一時的に記憶するものである。具体的に言えば、揮発性メモリ30は、RAMであり、特許請求の範囲に記載の保存部に相当する。本実施形態では、外部装置90から送られてくる書換プログラムも、揮発性メモリ30に記憶される。   The volatile memory 30 temporarily stores a control program and termination information sent from the external device 90 via the transmission / reception controller 10. Specifically, the volatile memory 30 is a RAM and corresponds to a storage unit described in the claims. In the present embodiment, the rewriting program sent from the external device 90 is also stored in the volatile memory 30.

不揮発性メモリ50は、制御プログラム、埋め込みコード、及び、終端情報を記憶するものである。具体的に言えば、不揮発性メモリ50は、フラッシュメモリである。不揮発性メモリ50における、終端情報が格納される情報アドレス、及び、制御プログラムの先頭アドレスは固定されている。   The nonvolatile memory 50 stores a control program, an embedded code, and termination information. Specifically, the nonvolatile memory 50 is a flash memory. In the nonvolatile memory 50, the information address where the termination information is stored and the head address of the control program are fixed.

終端情報は、制御プログラムの終端アドレスを示すデータであり、制御プログラムの終端アドレス、若しくは、制御プログラムのデータサイズである。終端情報が、制御プログラムのデータサイズである場合、CPU70は終端情報を読み込むことで、制御プログラムのデータサイズを判定する。これとは異なり、終端情報が、制御プログラムの終端アドレスである場合、上記したように、制御プログラムの先頭アドレスは固定されているので、CPU70は先頭アドレスと終端アドレスとを読み込むことで、制御プログラムのデータサイズを判定する。なお、埋め込みコードは、そのコードをCPU70が読み込んだ際に、エラーを通知するものである。   The end information is data indicating the end address of the control program, and is the end address of the control program or the data size of the control program. When the termination information is the data size of the control program, the CPU 70 reads the termination information to determine the data size of the control program. On the other hand, when the end information is the end address of the control program, the start address of the control program is fixed as described above, so the CPU 70 reads the start address and the end address, thereby controlling the control program. Determine the data size. The embedded code notifies an error when the CPU 70 reads the code.

CPU70は、通常動作時において、不揮発性メモリ50に書き込まれた制御プログラムにしたがって動作し、書換動作時において、不揮発性メモリ50に書き込まれたデータ(制御プログラム、埋め込みコード、終端情報)を書き換えるものである。   The CPU 70 operates in accordance with the control program written in the nonvolatile memory 50 during normal operation, and rewrites data (control program, embedded code, termination information) written in the nonvolatile memory 50 during rewrite operation. It is.

外部装置90は、書換プログラム、制御プログラム、及び、終端情報を電子制御装置100に送信するものである。外部装置90は、先ず、書換プログラムを電子制御装置100に送信し、次に、終端情報を電子制御装置100に送信し、最後に、制御プログラムを電子制御装置100に送信する。したがって、揮発性メモリ50には、書換プログラム、終端情報、及び、制御プログラムが記憶される。   The external device 90 transmits a rewrite program, a control program, and termination information to the electronic control device 100. The external device 90 first transmits a rewrite program to the electronic control device 100, then transmits termination information to the electronic control device 100, and finally transmits a control program to the electronic control device 100. Therefore, the volatile memory 50 stores a rewrite program, termination information, and a control program.

次に、不揮発性メモリ50に書き込まれたデータの書換である書換処理について、図2〜図9に基づいて説明する。その説明を簡便とするために、以下においては、不揮発性メモリ50に記憶されていた制御プログラムを第1制御プログラム、書き換えのために、外部装置90から送られてくる制御プログラムを第2制御プログラムと示す。また、第1制御プログラムの終端情報を第1終端情報、第2制御プログラムの終端情報を第2終端情報と示す。なお、図6〜図8では、空き領域(何もデータが書き込まれていないアドレス)をドットハッチングで示している。   Next, a rewriting process that is a rewriting of data written in the nonvolatile memory 50 will be described with reference to FIGS. In order to simplify the description, in the following, the control program stored in the non-volatile memory 50 is the first control program, and the control program sent from the external device 90 for rewriting is the second control program. It shows. Further, the end information of the first control program is referred to as first end information, and the end information of the second control program is referred to as second end information. In FIGS. 6 to 8, empty areas (addresses where no data is written) are indicated by dot hatching.

図2及び図5に示すように、書換処理が行われる前の状態では、不揮発性メモリ50に、第1終端情報、第1制御プログラム、及び、埋め込みコードが書き込まれている。これに対して、揮発性メモリ30には、書換処理に関するデータは記憶されておらず、CPU70は、通常動作状態となっている。外部装置90から書換プログラムが送信され、書換プログラムが、揮発性メモリ30に記憶され、それがCPU70にて読み込まれると、CPU70は通常動作状態から書換動作状態へと移行する。   As shown in FIGS. 2 and 5, the first termination information, the first control program, and the embedded code are written in the nonvolatile memory 50 before the rewriting process is performed. On the other hand, the volatile memory 30 does not store data related to the rewrite process, and the CPU 70 is in a normal operation state. When the rewrite program is transmitted from the external device 90, the rewrite program is stored in the volatile memory 30, and is read by the CPU 70, the CPU 70 shifts from the normal operation state to the rewrite operation state.

書換プログラムには、消去プログラム、判定プログラム、及び、書き込みプログラムが含まれており、CPU70は、これらのプログラムに従って書換処理を行う。消去プログラムは、第1制御プログラム、及び、第1終端情報を消去する指令を含む。判定プログラムは、第1終端情報、及び、第2終端情報それぞれに基づいて、第2制御プログラムの終端アドレスが、第1制御プログラムの終端アドレスと同一か否かを判定する指令を含む。書き込みプログラムは、判定プログラムにて、両者の終端アドレスが同一の場合、第2制御プログラムと第2終端情報とを不揮発性メモリ50に書き込みし、両者の終端アドレスが異なる場合、埋め込みコードを増減して、第2制御プログラムと第2終端情報とを不揮発性メモリ50に書き込む指令を含む。なお、判定プログラムは、第2制御プログラムの不揮発性メモリ50への書き込み後、不揮発性メモリ50に空き領域があるか否かを判定する指令も含んでいる。   The rewrite program includes an erase program, a determination program, and a write program, and the CPU 70 performs a rewrite process according to these programs. The erasing program includes a first control program and a command for erasing the first termination information. The determination program includes a command for determining whether the end address of the second control program is the same as the end address of the first control program based on the first end information and the second end information. The write program writes the second control program and the second end information to the non-volatile memory 50 when both end addresses are the same in the determination program, and increases or decreases the embedded code when both end addresses are different. And a command to write the second control program and the second termination information into the nonvolatile memory 50. The determination program also includes a command for determining whether or not there is a free area in the nonvolatile memory 50 after the second control program is written to the nonvolatile memory 50.

ちなみに、揮発性メモリ30のメモリサイズは、書換処理時に必要となるデータのサイズよりも小さい。そのため、書換処理時に必要となるデータを、その利用時に、揮発性メモリ30に順次記憶させる必要がある。しかしながら、この点に関しては、第2終端情報が必要となるタイミング(後述する第1読み出し処理S20)において、書換プログラムと共に第2終端情報が揮発性メモリ30に記憶されていれば良く、本実施形態に係る電子制御装置100を説明する上において、特に問題となる点ではない。そのため、説明を簡便とするために、書換処理において、書換処理時に必要となるデータの全てが揮発性メモリ30に記憶されているとする(図2参照)。   Incidentally, the memory size of the volatile memory 30 is smaller than the size of data necessary for the rewriting process. Therefore, it is necessary to sequentially store data necessary for the rewriting process in the volatile memory 30 when the data is used. However, regarding this point, it is sufficient that the second termination information is stored in the volatile memory 30 together with the rewriting program at the timing when the second termination information is necessary (first read processing S20 described later). In describing the electronic control device 100 according to the present invention, there is no particular problem. Therefore, in order to simplify the description, it is assumed that all data necessary for the rewriting process is stored in the volatile memory 30 in the rewriting process (see FIG. 2).

CPU70は、書換処理において、図3及び図4に示す処理を行い、不揮発性メモリ50に記憶されるデータを、図5〜図9のように書き換える。   In the rewriting process, the CPU 70 performs the processes shown in FIGS. 3 and 4 and rewrites the data stored in the nonvolatile memory 50 as shown in FIGS.

CPU70は、図6に示すように、書換処理の始まりにおいて、先ず、第1制御プログラムを消去する。以上が、第1消去処理S10である。   As shown in FIG. 6, the CPU 70 first erases the first control program at the beginning of the rewriting process. The above is the first erasing process S10.

第1消去処理S10後、CPU70は、不揮発性メモリ50の情報アドレスに記憶された第1終端情報を読み出すと共に、揮発性メモリ30から第2終端情報を読み出す。以上が第1読み出し処理S20である。   After the first erasing process S <b> 10, the CPU 70 reads the first termination information stored in the information address of the nonvolatile memory 50 and reads the second termination information from the volatile memory 30. The above is the first reading process S20.

第1読み出し処理S20後、CPU70は、第1終端情報と第2終端情報それぞれに基づいて、第2制御プログラムの終端アドレスが、第1制御プログラムの終端アドレスと同一か否かを判定する。具体的に言えば、第2制御プログラムが、第1制御プログラムよりもデータサイズが大きいか否かを判定する。以上が第1判定処理S30である。   After the first read process S20, the CPU 70 determines whether or not the end address of the second control program is the same as the end address of the first control program based on the first end information and the second end information. Specifically, the second control program determines whether or not the data size is larger than that of the first control program. The above is the first determination process S30.

第1判定処理S30にて、第2制御プログラムが、第1制御プログラムよりもデータサイズが大きいと判定された場合、CPU70は、図7に示すように、埋め込みコードを、第2制御プログラムを書き込むのに必要な分、消去する。以上が第2消去処理S40である。第2消去処理S40後、CPU70は、図4に示す処理S50へと移行する。   When it is determined in the first determination process S30 that the second control program has a data size larger than that of the first control program, the CPU 70 writes the embedded control code as shown in FIG. Erase as much as necessary. The above is the second erasing process S40. After the second erasing process S40, the CPU 70 proceeds to the process S50 shown in FIG.

これとは反対に、第1判定処理S30にて、第2制御プログラムが、第1制御プログラムよりもデータサイズが小さいと判定された場合、CPU70は、第2消去処理S40を行わずに、図4に示す処理S50へと移行する。   On the contrary, if it is determined in the first determination process S30 that the second control program has a smaller data size than the first control program, the CPU 70 does not perform the second erasure process S40, The process proceeds to process S50 shown in FIG.

処理S30若しくは処理S40後、CPU70は、不揮発性メモリ50の情報アドレスに記憶された第1終端情報を消去する。以上が第3消去処理S50である。   After the process S30 or the process S40, the CPU 70 erases the first termination information stored in the information address of the nonvolatile memory 50. The above is the third erasing process S50.

第3消去処理S50後、CPU70は、揮発性メモリ30に記憶された第2終端情報を読み出して、情報アドレスに書き込む。以上が第1書き込み処理S60である。   After the third erasing process S50, the CPU 70 reads the second termination information stored in the volatile memory 30 and writes it to the information address. The above is the first writing process S60.

第1書き込み処理S60後、CPU70は、図8に示すように、揮発性メモリ30に記憶された第2制御プログラムを読み出して、不揮発性メモリ50に書き込む。以上が第2書き込み処理S70である。   After the first write process S60, the CPU 70 reads the second control program stored in the volatile memory 30 and writes it in the nonvolatile memory 50 as shown in FIG. The above is the second writing process S70.

第2書き込み処理S70後、CPU70は、不揮発性メモリ50に空き領域があるか否かを判定する。以上が第2判定処理S80である。   After the second write process S70, the CPU 70 determines whether or not there is a free area in the nonvolatile memory 50. The above is the second determination process S80.

第2判定処理S80にて、図8に示すように、不揮発性メモリ50に空き領域があると判定された場合、CPU70は、図9に示すように、空き領域に、埋め込みコードを書き込む。以上が第3書き込み処理S90である。第3書き込み処理S90後、CPU70は、書換処理を終了する。   In the second determination process S80, when it is determined that there is a free area in the nonvolatile memory 50 as shown in FIG. 8, the CPU 70 writes an embedded code in the free area as shown in FIG. The above is the third writing process S90. After the third write process S90, the CPU 70 ends the rewrite process.

これとは反対に、第2判定処理S80にて、不揮発性メモリ50に空き領域がないと判定された場合、CPU70は、第3書き込み処理S90を行わずに、書換処理を終了する。   On the other hand, if it is determined in the second determination process S80 that there is no free space in the nonvolatile memory 50, the CPU 70 ends the rewrite process without performing the third write process S90.

以上の処理を経ることで、不揮発性メモリ50の書換が終了となる。なお、処理S10,S50は、消去プログラムにしたがって行われ、処理S20,S30,S80は、判定プログラムにしたがって行われ、処理S40,S60,S70,S90は、書き込みプログラムにしたがって行われる。   Through the above processing, rewriting of the nonvolatile memory 50 is completed. The processes S10 and S50 are performed according to the erase program, the processes S20, S30, and S80 are performed according to the determination program, and the processes S40, S60, S70, and S90 are performed according to the write program.

次に、本実施形態に係る電子制御装置100の作用効果を説明する。上記したように、第1終端情報と第2終端情報それぞれに基づいて、第2制御プログラムを書き込むのに必要な分だけ埋め込みコードを増減する。これによれば、書き換えの際に、埋め込みコードの全てを消去する構成、及び、書き換えるデータのサイズをスキャンする構成それぞれと比べて、書換時間が短縮される。   Next, functions and effects of the electronic control apparatus 100 according to the present embodiment will be described. As described above, the number of embedded codes is increased or decreased by an amount necessary for writing the second control program based on the first termination information and the second termination information. According to this, at the time of rewriting, the rewriting time is shortened compared to the configuration in which all of the embedded code is erased and the configuration in which the size of data to be rewritten is scanned.

なお、本実施形態では、処理S80、S90にて、不揮発性メモリ50に空き領域があるか否かを判定し、ある場合、空き領域に、埋め込みコードを書き込んでいる。これは、第2消去処理S40にて、第2制御プログラムを書き換えるのに余分な埋め込みコードを消去したために生じる操作だけではなく、CPU70の処理に依るものである。複数のアドレスに記憶されたデータをブロックとすると、CPU70は、このブロックを1単位(以下、ブロック単位と示す)として、不揮発性メモリ50に書き込まれたデータを消去する。新たに書き込まれる第2制御プログラムのサイズがブロック単位だけでは表されない場合、ある一つのブロックに、第2制御プログラムの一部が書き込まれる。この場合、そのブロックにおける第2制御プログラムの書き込まれていないアドレスが空きとなるので、この空いたアドレスに埋め込みコードを書き込む必要が生じる。この空いたアドレスを埋めるために、処理S80、S90にて、不揮発性メモリ50に空き領域があるか否かを判定し、ある場合、空き領域に、埋め込みコードを書き込む、という操作が必要となるのである。ちなみに、第1制御プログラムよりも第2制御プログラムの方がデータサイズが小さい場合においても、空き領域が生じる。そのため、この場合においても、空き領域に埋め込みコードを書き込まなくてはならず、埋め込みコードを増大する、という操作が必要となる。   In the present embodiment, it is determined in steps S80 and S90 whether or not there is an empty area in the nonvolatile memory 50. If there is, an embedded code is written in the empty area. This depends on the processing of the CPU 70 as well as the operation that occurs because the extra embedded code is erased to rewrite the second control program in the second erasure processing S40. If the data stored at a plurality of addresses is a block, the CPU 70 erases the data written in the nonvolatile memory 50 with this block as one unit (hereinafter referred to as a block unit). When the size of the second control program to be newly written is not expressed in units of blocks, a part of the second control program is written in one block. In this case, since an address in which the second control program is not written in the block becomes empty, it is necessary to write an embedded code in the empty address. In order to fill in this vacant address, it is necessary to determine whether or not there is an empty area in the nonvolatile memory 50 in steps S80 and S90. If there is, an operation of writing an embedded code in the empty area is required. It is. Incidentally, even when the data size of the second control program is smaller than that of the first control program, an empty area is generated. Therefore, even in this case, the embedded code must be written in the empty area, and an operation of increasing the embedded code is required.

また、本実施形態では、図7に、第2消去処理S40を経ることで、当初不揮発性メモリ50に記憶された埋め込みコードの一部が消去された状態の不揮発性メモリ50の状態を示した。これに対して、図10に、第2消去処理S40を経ずに、当初不揮発性メモリ50に記憶された埋め込みコードが消去されず、そのまま残っている状態の不揮発性メモリ50を示す。第2制御プログラムが、第1制御プログラムよりもデータサイズが小さい場合、CPU70は、図11に示すように、第2終端情報と第2制御プログラムとを不揮発性メモリ50に書き込んだ後、不揮発性メモリ50に空き領域があるか否かを判定する。そして、CPU70は、不揮発性メモリ50に空き領域があると判定した場合、図12に示すように、空き領域に、埋め込みコードを書き込む。この空き領域は、第1制御プログラムと第2制御プログラムとのデータサイズの差によって生じたものであり、上記した、CPU70の処理に依るものではない。なお、説明の都合上、図6と図10とを区別して表記したが、図6と図10とは、実質的に同一の図面である。図6は、第1消去処理S10直後の不揮発性メモリ50に書き込まれたデータを示し、図10は、第2消去処理S40が行われずに、第3消去処理S50が行われる直前の不揮発性メモリ50に書き込まれたデータを示している。   Further, in the present embodiment, FIG. 7 shows the state of the nonvolatile memory 50 in a state in which a part of the embedded code originally stored in the nonvolatile memory 50 is erased through the second erasing process S40. . On the other hand, FIG. 10 shows the nonvolatile memory 50 in a state where the embedded code originally stored in the nonvolatile memory 50 is not erased without passing through the second erasing process S40. When the data size of the second control program is smaller than that of the first control program, the CPU 70 writes the second termination information and the second control program into the nonvolatile memory 50 as shown in FIG. It is determined whether or not there is a free area in the memory 50. If the CPU 70 determines that there is a free area in the nonvolatile memory 50, the CPU 70 writes an embedded code in the free area as shown in FIG. This free space is caused by the difference in data size between the first control program and the second control program, and is not dependent on the processing of the CPU 70 described above. For convenience of explanation, FIG. 6 and FIG. 10 are distinguished from each other, but FIG. 6 and FIG. 10 are substantially the same drawings. 6 shows data written in the nonvolatile memory 50 immediately after the first erasing process S10, and FIG. 10 shows a nonvolatile memory immediately before the third erasing process S50 is performed without performing the second erasing process S40. 50 shows the data written to 50.

以上、本発明の好ましい実施形態について説明したが、本発明は上記した実施形態になんら制限されることなく、本発明の主旨を逸脱しない範囲において、種々変形して実施することが可能である。   The preferred embodiments of the present invention have been described above. However, the present invention is not limited to the above-described embodiments, and various modifications can be made without departing from the spirit of the present invention.

本実施形態では、制御プログラムと終端情報とが独立している例を示した。しかしながら、制御プログラムの中に、終端情報が含まれる構成を採用することもできる。この場合、CPU70は、図13に示すように、処理S10を行う前に、第1終端情報を読み出す第2読み出し処理S100を行う。そして、処理S10後、CPU70は、処理S20の代わりに、処理S110,S120を行う。すなわち、CPU70は、揮発性メモリ30の第2制御プログラムに含まれる第2終端情報を読み出す第3読み出し処理S110を行い、その読み出している間、第2制御プログラムの一部を、不揮発性メモリ50に書き込む処理をする第4書き込み処理S120を行う。第2終端情報を取得すると、CPU70は、処理S30へと移行し、第1実施形態で示した処理S30〜S90を行うことで、不揮発性メモリ50への書換処理を行う。このように、第2終端情報を読み出している際に、第2制御プログラムの一部が不揮発性メモリ50へ書き込まれるので、第1実施形態で示した書換処理と同等の早さにて、不揮発性メモリ50の書換が行われる。なお、第2書き込み処理S70においては、第4書き込み処理S120にて書き込みきれなかった第2制御プログラムの残りが、不揮発性メモリ50に書き込まれる。また、不揮発性メモリ50の情報アドレスには、制御プログラムに含まれる終端情報が書き込まれる。   In the present embodiment, an example is shown in which the control program and the termination information are independent. However, a configuration in which termination information is included in the control program can also be adopted. In this case, as shown in FIG. 13, the CPU 70 performs a second reading process S100 for reading the first termination information before performing the process S10. And after process S10, CPU70 performs process S110, S120 instead of process S20. That is, the CPU 70 performs a third read process S110 for reading the second termination information included in the second control program of the volatile memory 30, and during the reading, a part of the second control program is transferred to the nonvolatile memory 50. A fourth writing process S120 is performed to perform the process of writing to the. When the second termination information is acquired, the CPU 70 proceeds to the process S30, and performs the rewriting process to the nonvolatile memory 50 by performing the processes S30 to S90 shown in the first embodiment. As described above, when reading the second termination information, a part of the second control program is written to the nonvolatile memory 50, so that the nonvolatile memory 50 is nonvolatile at the same speed as the rewrite processing shown in the first embodiment. Rewriting of the memory 50 is performed. In the second write process S70, the remainder of the second control program that could not be written in the fourth write process S120 is written to the nonvolatile memory 50. Further, termination information included in the control program is written in the information address of the nonvolatile memory 50.

本実施形態では、外部装置90から送られてくる書換プログラムが、揮発性メモリ30に記憶された例を示した。しかしながら、不揮発性メモリ50に記憶された書換プログラムが、揮発性メモリ30に記憶された構成を採用することもできる。   In the present embodiment, an example in which the rewriting program sent from the external device 90 is stored in the volatile memory 30 is shown. However, a configuration in which the rewriting program stored in the nonvolatile memory 50 is stored in the volatile memory 30 can be adopted.

30・・・揮発性メモリ
50・・・不揮発性メモリ
70・・・CPU
100・・・電子制御装置
30 ... Volatile memory 50 ... Nonvolatile memory 70 ... CPU
100 ... Electronic control device

Claims (2)

第1制御プログラム及び埋め込みコードが書き込まれた不揮発性メモリ(50)と、
外部装置から送られてくる第2制御プログラムを保存する保存部(30)と、
書換プログラムにしたがって、前記不揮発性メモリに書き込まれた第1制御プログラムを、前記保存部に保存された第2制御プログラムに書き換えるCPU(70)と、を有する電子制御装置であって、
前記不揮発性メモリには、前記第1制御プログラムと前記埋め込みコードの他に、前記第1制御プログラムの終端アドレスを示す第1終端情報が書き込まれ、
前記保存部には、前記第2制御プログラムの他に、前記第2制御プログラムの終端アドレスを示す第2終端情報が保存され、
前記書換プログラムは、前記不揮発性メモリ若しくは前記保存部に記憶され、
前記不揮発性メモリにおける、前記第1終端情報と前記第2終端情報それぞれが格納される情報アドレス、及び、前記第1制御プログラム及び前記第2制御プログラムそれぞれの先頭アドレスは固定されており、
前記書換プログラムには、
前記第1制御プログラム、及び、前記第1終端情報を消去する消去プログラムと、
前記第1終端情報、及び、前記第2終端情報それぞれに基づいて、前記第2制御プログラムの終端アドレスが、前記第1制御プログラムの終端アドレスと同一か否かを判定する判定プログラムと、
該判定プログラムにて、両者の終端アドレスが同一の場合、前記第2制御プログラムと前記第2終端情報とを前記不揮発性メモリに書き込みし、両者の終端アドレスが異なる場合、前記埋め込みコードを増減して、前記第2制御プログラムと前記第2終端情報とを前記不揮発性メモリに書き込む書き込みプログラムと、が含まれていることを特徴とする電子制御装置。
A non-volatile memory (50) in which the first control program and the embedded code are written;
A storage unit (30) for storing the second control program sent from the external device;
A CPU (70) for rewriting a first control program written in the nonvolatile memory according to a rewrite program into a second control program stored in the storage unit;
In the nonvolatile memory, in addition to the first control program and the embedded code, first termination information indicating a termination address of the first control program is written,
The storage unit stores second termination information indicating a termination address of the second control program in addition to the second control program,
The rewrite program is stored in the nonvolatile memory or the storage unit,
In the non-volatile memory, information addresses where the first termination information and the second termination information are stored, respectively, and the first addresses of the first control program and the second control program are fixed,
The rewriting program includes
An erasing program for erasing the first control program and the first termination information;
A determination program for determining whether a termination address of the second control program is the same as a termination address of the first control program based on each of the first termination information and the second termination information;
In the determination program, when both end addresses are the same, the second control program and the second end information are written to the nonvolatile memory, and when the end addresses are different, the embedded code is increased or decreased. And a writing program for writing the second control program and the second termination information into the nonvolatile memory.
前記第1終端情報は、前記第1制御プログラムの終端アドレス、若しくは、前記第1制御プログラムのデータサイズであり、
前記第2終端情報は、前記第2制御プログラムの終端アドレス、若しくは、前記第2制御プログラムのデータサイズであることを特徴とする請求項1に記載の電子制御装置。
The first termination information is a termination address of the first control program or a data size of the first control program.
The electronic control device according to claim 1, wherein the second termination information is a termination address of the second control program or a data size of the second control program.
JP2012139908A 2012-06-21 2012-06-21 Electronic control unit Active JP5821788B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012139908A JP5821788B2 (en) 2012-06-21 2012-06-21 Electronic control unit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012139908A JP5821788B2 (en) 2012-06-21 2012-06-21 Electronic control unit

Publications (2)

Publication Number Publication Date
JP2014006575A JP2014006575A (en) 2014-01-16
JP5821788B2 true JP5821788B2 (en) 2015-11-24

Family

ID=50104265

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012139908A Active JP5821788B2 (en) 2012-06-21 2012-06-21 Electronic control unit

Country Status (1)

Country Link
JP (1) JP5821788B2 (en)

Also Published As

Publication number Publication date
JP2014006575A (en) 2014-01-16

Similar Documents

Publication Publication Date Title
JP4031190B2 (en) MEMORY CARD, NONVOLATILE MEMORY, NONVOLATILE MEMORY DATA WRITE METHOD AND DATA WRITE DEVICE
TWI436369B (en) Methods for measuring usable lifespan and replacing an in-system programming code of a memory device, and data storage system using the same
JP2018013837A (en) Data rewriting device, data rewriting program
CN105009096B (en) Data storage device, data storage method, and vehicle-mounted control device
JPWO2007000862A1 (en) MEMORY CONTROLLER, NONVOLATILE MEMORY DEVICE, NONVOLATILE MEMORY SYSTEM, AND DATA WRITE METHOD
JP4158526B2 (en) Memory card and data writing method to memory
CN111052075A (en) Methods to improve the robustness of in-place firmware updates
JP4843222B2 (en) Semiconductor memory device control method, memory card, and host device
JP5821788B2 (en) Electronic control unit
JP6636930B2 (en) Microcomputer with built-in flash memory, method of writing data to flash memory built in microcontroller, and program for writing data to flash memory
JP4997798B2 (en) Nonvolatile semiconductor memory device and memory system
US20110082995A1 (en) Information processing apparatus
JP5521477B2 (en) Memory control device
JP4602387B2 (en) MEMORY CARD, NONVOLATILE MEMORY, NONVOLATILE MEMORY DATA WRITE METHOD AND DATA WRITE DEVICE
US8954621B2 (en) Peripheral, method of controlling peripheral, and firmware downloading system
JP2013235530A (en) Control device, storage device, and storage control method
JP2014002478A (en) Electronic controller
JP2009223435A (en) Data storage method and device, and program
JP6334776B1 (en) Electronic control unit
JP2014071535A (en) Memory management device, microcontroller and memory management method
JP5976729B2 (en) Electronics
JP2015049722A (en) Microcomputer and non-volatile memory block management method
JP5939120B2 (en) Flash memory data processing method and program for data processing
JP4935101B2 (en) Memory access method and apparatus
JP2005276288A (en) Lifetime management method of nonvolatile memory device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20141024

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150728

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150921

R151 Written notification of patent or utility model registration

Ref document number: 5821788

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250