WO2012077604A1 - Processing device, program update method, and program - Google Patents

Processing device, program update method, and program Download PDF

Info

Publication number
WO2012077604A1
WO2012077604A1 PCT/JP2011/077937 JP2011077937W WO2012077604A1 WO 2012077604 A1 WO2012077604 A1 WO 2012077604A1 JP 2011077937 W JP2011077937 W JP 2011077937W WO 2012077604 A1 WO2012077604 A1 WO 2012077604A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
boot loader
area
stored
rewriting
Prior art date
Application number
PCT/JP2011/077937
Other languages
French (fr)
Japanese (ja)
Inventor
正幸 吉長
飯田 崇
Original Assignee
三洋電機株式会社
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 三洋電機株式会社 filed Critical 三洋電機株式会社
Priority to JP2012547831A priority Critical patent/JPWO2012077604A1/en
Publication of WO2012077604A1 publication Critical patent/WO2012077604A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories

Definitions

  • the present invention relates to a processing device that performs processing based on a program, a program update method, and a program that causes a processing device to execute a program update operation.
  • Such a processing apparatus usually has a non-volatile memory (flash memory or the like) for storing a program in addition to the CPU [Central Processing Unit].
  • the CPU reads and executes the program stored in the non-volatile memory as appropriate, thereby performing various processes.
  • the nonvolatile memory may store a program (boot loader) for executing rewriting of the program in addition to the main program that is usually used.
  • a program for executing rewriting of the program in addition to the main program that is usually used.
  • the main program can be rewritten and updated using the boot loader.
  • Patent Document 1 discloses a device that saves the boot loader before update in the FROM in advance. When the boot loader rewrite fails due to power interruption or the like, the device rewrites the saved boot loader in the flash memory and rewrites the boot loader again.
  • Patent Document 2 discloses a device that does not require a memory for saving the boot loader and copes with the failure of rewriting the boot loader. This apparatus is superior to that disclosed in Patent Document 1 in that it can reduce the necessary memory.
  • the storage area of the boot loader and the storage area of the main program are moved.
  • the CPU reads a program and accesses a specific address corresponding to the program, when such a movement occurs, the read process cannot be performed correctly.
  • the program storage area cannot be moved due to the limitation of the memory capacity or the block configuration of the erase area.
  • the present invention does not require a memory or the like for saving the boot loader, and safely and without moving the storage area of the boot loader and the storage area of the main program. It is an object of the present invention to provide a processing apparatus that can be updated. It is another object of the present invention to provide a program update method and a program related to the processing apparatus.
  • a processing apparatus includes a non-volatile memory having a first area for storing a program and a second area for storing a first boot loader that executes rewriting of the program in the first area.
  • a processing device for performing processing based on a main program stored in the first area, a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second area
  • a program update operation is performed to update the current main program stored in the first area to the new main program and the current first boot loader stored in the second area to the new first boot loader.
  • the program update operation is performed based on the current first boot loader and the current main stored in the first area.
  • a memory or the like for saving the boot loader is not required, and the storage area of the boot loader and the storage area of the main program are not moved safely.
  • the main program and boot loader can be updated.
  • the operation is performed based on the program stored in the first area.
  • the flag determination operation is performed based on the program stored in the second area.
  • the first boot loader is stored in the first area.
  • the second boot loader stores the second program in the second area.
  • the second boot loader stores the second program in the second area. Rewrite the program that has been changed to a program that is compatible with itself, change the state of the flag, and then restart the program It may be configured as a program.
  • the first boot loader may include a rewriting unit that executes rewriting of a program in the first area and a determination unit that executes the flag determination operation. Good.
  • the first boot loader may include a rewriting unit that executes rewriting of a program in the first area, but may not include a program that executes the flag determination operation. .
  • a program update method includes a nonvolatile memory having a first area for storing a program and a second area for storing a first boot loader for executing rewriting of the program in the first area.
  • a processing apparatus for performing processing based on a main program stored in one area is a method for updating a program, wherein a new main program, a new first boot loader, and a program rewriting in a second area are executed. In a situation where two boot loaders are prepared, the current main program stored in the first area is updated to the new main program, and the current first boot loader stored in the second area is updated to the new first boot loader.
  • the current main program stored in the first area is transferred to the second boot loader.
  • a program according to the present invention is a program that causes a processing apparatus including a nonvolatile memory having a first area and a second area to update a program, and is in a first state and a second state at startup.
  • the program operates based on the program stored in the first area, and when the flag is in the second state, the program is stored in the second area.
  • the program for performing the flag determination operation and the program stored in the first area are rewritten to a prepared program corresponding to itself and the state of the flag is changed. Rewrite the program that performs the operation to execute the restart and the program stored in the second area to the prepared program corresponding to itself Rutotomoni, after allowed to change the state of the flag, the program for performing the operation for executing the restart, the program having to.
  • the processing device of the present invention by performing the program update operation, a memory for saving the boot loader is not required, and the storage area of the boot loader and the storage area of the main program can be safely stored.
  • the main program and the boot loader can be updated so that no movement occurs.
  • FIG. 1 is a schematic configuration diagram of a microcomputer according to a first embodiment of the present invention. It is explanatory drawing regarding the storage etc. of the program in 1st Embodiment. It is a flowchart regarding a program update operation. It is a flowchart regarding a program update operation. It is a flowchart regarding a program update operation. It is explanatory drawing regarding the storage condition of the program by flash memory. It is a schematic block diagram of the microcomputer which concerns on 2nd Embodiment of this invention. It is explanatory drawing regarding the storage etc. of the program in 2nd Embodiment.
  • FIG. 1 is a schematic configuration diagram of a microcomputer [microcomputer] according to the present embodiment.
  • the microcomputer 2 includes a communication I / F 3, a CPU 4, and a flash memory 5.
  • the microcomputer 2 is connected to a PC [Personal Computer] 1 and an EEPROM [Electrically Erasable Programmable ROM] 6.
  • the communication I / F 3 enables communication with the PC 1 or the like, and is formed by, for example, CAN [Controller Area Network] or LAN [Local Area Network].
  • the CPU 4 executes various processes based on the program.
  • the flash memory 5 is a non-volatile memory that stores programs and the like in a rewritable manner.
  • the program storage area of the flash memory 5 will be described as being “first block” and “second block”. The specific form of these blocks is not particularly limited.
  • the CPU 4 can read and execute a program stored in the flash memory 5. Further, the CPU 4 can perform bidirectional communication with the PC 1 via the communication I / F 3.
  • the EEPROM 6 holds a boot flag that is either “0” or “1” in an updatable manner.
  • the CPU 4 can appropriately access the EEPROM 6 to refer to or update the boot flag.
  • the “main program” is a program that causes the CPU 4 to perform normal operations (various operations to be performed in a normal state). That is, the microcomputer 2 operates in accordance with the main program when it is in a normal state through the start-up operation.
  • the main program causes the CPU 4 to execute an operation of setting a boot flag to “1” and starting restart (steps described later). (See S1).
  • the “first boot loader” is subdivided into two programs: a “determination unit” and a “rewriting unit”.
  • the “determination unit” (1) Operation for determining the state of the boot flag, (2) When the determination result is “1”, the rewriting unit of the first boot loader stored in the second block is read and executed. And (3) a program that causes the CPU 4 to execute an operation of starting execution by reading the program stored in the first block when the determination result is “0” (steps described later) (See S12-S14, S22-S23, and S32-S33).
  • the “rewrite unit” (1) deletes the program stored in the first block. (2) After the deletion, the PC 1 requests the PC 1 to transmit the second boot loader or the main program. An operation to write the transmitted program to the first block, (3) an operation to determine whether or not the write operation has been normally completed, and (4) to reset the boot flag to “0” upon successful completion Then, the operation based on the restarting operation and (5) the operation based on the determination unit (the one already read by the CPU 4 or the one stored in the second block) is performed again when the normal termination is not completed. This is a program for causing the CPU 4 to execute an operation (see steps S15 to S18 and S34 to S37 described later).
  • the “second boot loader” (1) deletes the program stored in the second block. (2) After the deletion, the first boot loader sends a request to the PC 1 to transmit the first boot loader. The operation of writing the first boot loader to the second block, (3) the operation of determining whether or not the write operation is normally completed, and (4) the boot flag is set to “1” when the operation is normally completed. Then, the operation based on the restarting operation and (5) the operation based on the determination unit (the one already read by the CPU 4 or the one stored in the second block) is performed again when the normal termination is not completed. This is a program for causing the CPU 4 to execute the operation (see steps S24 to S27 described later).
  • the program update operation may be stopped.
  • the program transmitted from the PC 1 is received little by little (for example, 64 bytes), and each time the first block is received. Or it is written to the second block. Thereby, even if the capacity of the memory (for example, the memory attached to the CPU 4) used for receiving the program from the PC 1 is small, the operation can be sufficiently performed.
  • the “initial program” is a program that is first executed by the CPU 4 when the microcomputer 2 is activated.
  • the initial program is a program that causes the CPU 4 to execute an operation of starting execution by reading the determination unit of the first boot loader stored in the second block (see steps S11, S21, and S31 described later).
  • the initial program is fixedly stored in the CPU 4 and can be executed by the CPU 4 without requiring reading from the flash memory 5 or the like.
  • the main program is stored in the first block of the flash memory 5 and the first boot loader is stored in the second block. Similarly, during normal times, the boot flag is set to “0”.
  • the PC 1 can obtain a new version of the main program, the first boot loader, and the second boot loader, for example, by downloading from the program developer.
  • the PC 1 receives a microcomputer upgrade execution instruction from the user, the PC 1 issues a program update instruction to the microcomputer 2. Further, when there is a program transmission request from the microcomputer 2, the PC 1 transmits the program to the microcomputer 2 in response to the request.
  • the user can realize the update by giving the microcomputer 1 a version upgrade execution instruction to the PC 1 and causing the microcomputer 2 to execute the program update operation.
  • This program update operation includes three rewrite operations from the first rewrite operation to the third rewrite operation, as shown in the flowcharts of FIGS. The flow of operations for upgrading the microcomputer 2 will be described below with reference to the flowcharts of FIGS.
  • the PC 1 issues a program update instruction to the microcomputer 2 when receiving an instruction to execute a version upgrade of the microcomputer.
  • the CPU 4 operates based on the main program. Specifically, the CPU 4 sets a boot flag to “1” and starts restarting (step S1).
  • the types of programs held by the PC 1 and the microcomputer 2 at this time are as shown in FIG. That is, the current main program is stored in the first block of the flash memory 5, and the current first boot loader is stored in the second block.
  • the PC 1 also has a new main program, a new first boot loader, and a second boot loader. That is, these programs are prepared in advance.
  • the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts execution by reading the determination unit of the current first boot loader stored in the second block (step S11).
  • the CPU 4 first determines whether the boot flag is “0” or “1” (step S12). If the program update operation is proceeding normally, the boot flag is “1” at the present time. When the determination result is “1” (Y in step S12), the CPU 4 starts execution by reading the rewriting unit of the current first boot loader stored in the second block (step S14). On the other hand, when the determination result is “0” (N in step S12), the CPU 4 reads and starts the execution of the current main program stored in the first block (step S13).
  • step S13 When the operation of step S13 is executed, the program update operation is terminated, and the CPU 4 thereafter performs a normal operation (operation based on the current main program). On the other hand, when the operation of step S14 is executed, the CPU 4 operates based on the rewriting unit of the current first boot loader.
  • the CPU 4 erases the current main program stored in the first block (step S15), and after the erasure, writes the second boot loader received from the PC 1 into the first block ( Step S16) and an operation (step S17) for determining whether or not the write operation has ended normally are performed.
  • the CPU 4 further resets the boot flag to “0” to start the restart (Step S18) when it is normally completed (Step S18), and when it is not normally ended (Step S17). N), the operation based on the determination unit (step S12) is performed again.
  • the first rewrite operation is completed by performing the operation of step S18, and the second rewrite operation is subsequently started.
  • the types of programs stored in the flash memory 5 at this time are as shown in FIG. That is, a second boot loader is stored in the first block of the flash memory 5, and the current first boot loader is stored in the second block.
  • step S18 the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts execution by reading the determination unit of the current first boot loader stored in the second block (step S21).
  • the CPU 4 first determines whether the boot flag is “0” or “1” (step S22). If the program update operation is proceeding normally, the boot flag is “0” at the present time. Then, when the determination result is “1” (Y in step S22), the CPU 4 starts execution by reading the rewriting unit of the current first boot loader stored in the second block. That is, at this time, the operation in step S14 described above is performed again. On the other hand, when the determination result is “0” (N in step S22), the CPU 4 reads the second boot loader stored in the first block and starts execution (step S23).
  • step S23 When the operation of step S23 is executed, the CPU 4 operates based on the second boot loader. Specifically, the CPU 4 erases the current first boot loader stored in the second block (step S24), and writes the new first boot loader received from the PC 1 to the second block after the erase.
  • step S25 The operation (step S25) and the operation (step S26) for determining whether or not the write operation has been completed normally are performed.
  • the CPU 4 sets the boot flag to “1” when the normal end is completed (Y in step S26) and starts the restart (step S27), and when the normal end is not completed (step S26). N), the operation based on the determination unit (step S22) is performed again.
  • the second rewrite operation is completed by performing the operation of step S27, and the third rewrite operation is started.
  • the types of programs stored in the flash memory 5 at this time are as shown in FIG. That is, a second boot loader is stored in the first block of the flash memory 5, and a new first boot loader is stored in the second block.
  • step S27 the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts the execution by reading the determination unit of the new first boot loader stored in the second block (step S31).
  • the CPU 4 first determines whether the state of the boot flag is “0” or “1” (step S32). If the program update operation is proceeding normally, the boot flag is “1” at the present time. When the determination result is “1” (Y in step S32), the CPU 4 starts execution by reading the rewriting unit of the new first boot loader stored in the second block (step S33). On the other hand, when the determination result is “0” (N in step S32), the CPU 4 reads the second boot loader stored in the first block and starts execution. That is, at this time, the operation in step S23 described above is performed again.
  • step S33 When the operation of step S33 is executed, the CPU 4 operates based on the rewrite unit of the new first boot loader. Specifically, the CPU 4 erases the second boot loader stored in the first block (step S34), and after the erase, writes the new main program received from the PC 1 to the first block ( Step S35) and an operation (step S36) for determining whether or not the operation of the write has ended normally are performed.
  • the CPU 4 further resets the boot flag to “0” to start restart (step S37) when it is normally terminated (step S37), and when it is not normally terminated (step S36). N), the operation based on the determination unit (step S32) is performed again.
  • the third rewrite operation is completed by performing the operation of step S37, and the program update operation is completed.
  • the types of programs stored in the flash memory 5 are as shown in FIG. That is, a new main program is stored in the first block of the flash memory 5, and a new first boot loader is stored in the second block.
  • the CPU 4 operates based on the initial program when it is restarted (step S37). At this time, since the state of the boot flag is “0”, the CPU 4 reads and starts executing the new main program stored in the first block. As a result, the normal operation based on the new main program is performed thereafter.
  • the microcomputer 2 can update both the main program and the first boot loader stored in the flash memory 5 to the new version by performing the program update operation.
  • any boot loader (first boot loader or second boot loader) is stored in any block (first block or second block) of the flash memory 5. This state is maintained during execution of the program update operation. Based on the stored boot loader, the other block is rewritten.
  • the CPU 4 reads the boot loader stored in the other block (thereby In other words, the situation where the boot loader cannot be read is avoided. As described above, the microcomputer 2 can safely update each program.
  • such a boot loader can be read without requiring a memory for saving the boot loader.
  • the microcomputer 2 can reduce the necessary memory as compared with the case where the memory for saving the boot loader is provided.
  • the storage area of the first boot loader and the storage area of the main program do not move. That is, the main program is stored in the first block, and the first boot loader is stored in the second block.
  • the main program developer need not consider the change of the main program storage area (design change in consideration of the execution of the program update operation, etc.), and can develop the main program efficiently. .
  • both the main program and the first boot loader can be updated. .
  • the determination unit of the first boot loader has a simple configuration because it only needs to execute a simple operation, and the used capacity of the flash memory 5 is very small. Therefore, since the rewriting of the determination unit can be performed in a very short time, it can be said that it is extremely rare to encounter power interruption or the like during the rewriting of the determination unit.
  • Second Embodiment As described above, since the determination unit of the first boot loader has a simple configuration, there may be a case where the need for version upgrade is scarce. Therefore, in order to cope with such a case, the update of the determination unit of the first boot loader may be omitted in the program update operation.
  • FIG. 7 is a schematic configuration diagram of the microcomputer 2 according to the second embodiment.
  • the microcomputer 2 of the present embodiment has basically the same configuration as the microcomputer 2 according to the first embodiment, except that the auxiliary flash memory 7 is provided.
  • the first boot loader has only a rewrite unit and does not have a determination unit. Instead, as shown in FIG. 8, a determination program having the same content as the determination unit is stored in advance in the auxiliary flash memory 7.
  • the “second boot loader” in the present embodiment is (1) an operation for erasing the program stored in the second block, and (2) a transmission request for the first boot loader (only the rewriting unit) to the PC 1 after the erasure.
  • To write the first boot loader transmitted in response to this request to the second block (3) an operation to determine whether or not the write operation has ended normally, and (4) The boot flag is set to “1” and the restart is started, and (5) the determination program (which is already read by the CPU 4 or stored in the auxiliary flash memory 7 when not normally completed) It is a program that causes the CPU 4 to execute an operation for performing the operation based on the above-described operation again.
  • the “initial program” of the present embodiment is a program that causes the CPU 4 to execute an operation of starting execution by reading the determination program stored in the auxiliary flash memory 7.
  • the rewrite unit is stored in the flash memory 5 as the first boot loader, and is updated to a new version each time the program update operation is executed.
  • the determination program stored in the auxiliary flash memory 7 is not rewritten even if the program update operation is executed.
  • the update of the determination program that is, the program corresponding to the determination unit in the first embodiment is omitted. Therefore, the processing load of the program update operation in the microcomputer 2 can be reduced.
  • the microcomputer 2 includes the first block (first area) for storing the program and the second block for storing the first boot loader for executing rewriting of the program in the first block. And a flash memory 5 (nonvolatile memory) having (second area), and performs processing based on the main program stored in the first block.
  • the microcomputer 2 is stored in the first block in a situation where a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second block are prepared (can be appropriately received from the PC 1).
  • a program update operation is performed to update the current main program stored in the new main program and the current first boot loader stored in the second block into the new first boot loader.
  • This program update operation is written to the first block, the first rewrite operation (first update operation) for rewriting the current main program stored in the first block to the second boot loader based on the current first boot loader.
  • the second rewrite operation (second update operation) for rewriting the current first boot loader stored in the second block to the new first boot loader, and the new first boot loader written in the second block 3 includes a third rewrite operation (third update operation) in which the second boot loader stored in the first block is rewritten to the new main program.
  • the microcomputer 2 does not require a memory for saving the boot loader by performing the program update operation, so that the storage area of the first boot loader and the storage area of the main program do not move safely.
  • the main program and the first boot loader can be updated.
  • the microcomputer 2 operates based on the program stored in the first block when the flag that is either “0” or “1” is “0”.
  • the operation is performed based on the program stored in the second block (referred to as “flag determination operation”).
  • the first boot loader rewrites the program stored in the first block with a prepared program (second boot loader or main program) corresponding to itself and changes the state of the flag. It is a program that executes a restart.
  • the second boot loader rewrites the program stored in the second block with a prepared program (first boot loader) corresponding to itself, changes the flag state, and restarts the program. It is a program to be executed.
  • the first boot loader in the first embodiment includes a rewriting unit that causes the microcomputer 2 (CPU 4) to rewrite a program in the first block, and a determination unit that executes a flag determination operation.
  • the first boot loader in the second embodiment has a rewriting unit that causes the microcomputer 2 (CPU 4) to rewrite the program in the first block, while it has a program that executes the flag determination operation.
  • the program for executing the flag determination operation is stored in the auxiliary flash memory 7 as a determination program and cannot be rewritten by the program update operation.
  • the present invention can be used for various devices that perform processing based on a program.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

A processing device with nonvolatile memory having a first region and a second region, and conducting program update actions to update the current main program of the first region with a new main program, and to update the current first boot loader of the second region with a new first boot loader. The program update actions of the processing device rewrite the current main program of the first region with a second boot loader on the basis of the current first boot loader, rewrite the current first boot loader of the second region with a new first boot loader on the basis of the second boot loader, and rewrite the second boot loader of the first region with a new main program on the basis of the new first boot loader.

Description

処理装置、プログラム更新方法、およびプログラムProcessing apparatus, program update method, and program
 本発明は、プログラムに基づいて処理を行う処理装置、プログラム更新方法、および処理装置にプログラム更新動作を実行させるプログラムに関する。 The present invention relates to a processing device that performs processing based on a program, a program update method, and a program that causes a processing device to execute a program update operation.
 従来、各種プログラムに基づいて処理を行う処理装置が、広く利用されている。このような処理装置は通常、CPU[Central Processing Unit]の他にプログラムを格納する不揮発性メモリ(フラッシュメモリ等)を有している。CPUは、不揮発性メモリに格納されているプログラムを適宜リードして実行するようになっており、これにより各種処理が遂行される。 Conventionally, processing devices that perform processing based on various programs have been widely used. Such a processing apparatus usually has a non-volatile memory (flash memory or the like) for storing a program in addition to the CPU [Central Processing Unit]. The CPU reads and executes the program stored in the non-volatile memory as appropriate, thereby performing various processes.
 ところで不揮発性メモリには、通常用いられるメインプログラムの他、プログラムの書換などを実行させるプログラム(ブートローダ)が格納されることがある。この場合、格納されているメインプログラムについて機能追加や不具合修正が必要となったときは、ブートローダを用いて、メインプログラムの書換更新を行うことが可能である。 Incidentally, the nonvolatile memory may store a program (boot loader) for executing rewriting of the program in addition to the main program that is usually used. In this case, when it is necessary to add a function or correct a defect in the stored main program, the main program can be rewritten and updated using the boot loader.
 また、格納されているブートローダ自体を更新する必要が生じた場合、このブートローダについても書換更新を行う必要がある。但し、ブートローダの書換の途中に電源の遮断などがなされると、不揮発性メモリにおけるブートローダの格納領域のデータが破壊され、ブートローダのリードが不可能となってしまう。 Also, when it becomes necessary to update the stored boot loader itself, it is necessary to rewrite and update this boot loader. However, if the power supply is cut off during the boot loader rewriting, the data in the boot loader storage area in the nonvolatile memory is destroyed and the boot loader cannot be read.
 このような問題を解決するため、特許文献1には、更新前のブートローダを予めFROMに退避させる装置が開示されている。当該装置は、電源遮断などによってブートローダの書換に失敗した場合には、退避させていたブートローダをフラッシュメモリに書き直して、再度ブートローダの書換えを行うようになっている。 In order to solve such a problem, Patent Document 1 discloses a device that saves the boot loader before update in the FROM in advance. When the boot loader rewrite fails due to power interruption or the like, the device rewrites the saved boot loader in the flash memory and rewrites the boot loader again.
 しかし当該手法を実現させるにあたっては、ブートローダを退避させるメモリ(ここではFROM)を設けておく必要があり、その分、より多くのメモリが必要となってしまう。また、ブートローダの書換えが失敗したときのために、わざわざメモリを用意しておくのは、冗長であるとも言える。 However, in order to realize the method, it is necessary to provide a memory (in this case, FROM) for saving the boot loader, which requires more memory. Also, it can be said that it is redundant to prepare the memory in case the boot loader rewrite fails.
 一方、特許文献2には、ブートローダを退避させるメモリを要せず、ブートローダの書換えの失敗に対応する装置が開示されている。当該装置は、特許文献1に開示されたものに比べ、必要なメモリを少なくすることが可能である点で優れている。 On the other hand, Patent Document 2 discloses a device that does not require a memory for saving the boot loader and copes with the failure of rewriting the boot loader. This apparatus is superior to that disclosed in Patent Document 1 in that it can reduce the necessary memory.
特開2005-78336号公報JP 2005-78336 A 特開2007-193596号公報JP 2007-193596 A
 ところで特許文献2に開示されたものによれば、ブートローダの格納領域とメインプログラムの格納領域の移動が発生する。しかし、CPUがプログラムをリードする際に、そのプログラムに対応した特定のアドレスへのアクセスがなされる場合には、このような移動が発生すると、リード処理が正しく行われなくなってしまう。またメモリ容量の制限や、消去領域のブロック構成などにより、プログラムの格納領域を移動させることが出来ない場合もある。 By the way, according to what is disclosed in Patent Document 2, the storage area of the boot loader and the storage area of the main program are moved. However, when the CPU reads a program and accesses a specific address corresponding to the program, when such a movement occurs, the read process cannot be performed correctly. In some cases, the program storage area cannot be moved due to the limitation of the memory capacity or the block configuration of the erase area.
 本発明は上述した問題に鑑み、ブートローダを退避させるためのメモリ等を要せず、安全に、かつ、ブートローダの格納領域とメインプログラムの格納領域の移動が発生しないように、メインプログラムとブートローダの更新を行うことが可能となる処理装置の提供を目的とする。また本発明は、当該処理装置に関するプログラム更新方法、およびプログラムの提供を目的とする。 In view of the above-described problems, the present invention does not require a memory or the like for saving the boot loader, and safely and without moving the storage area of the boot loader and the storage area of the main program. It is an object of the present invention to provide a processing apparatus that can be updated. It is another object of the present invention to provide a program update method and a program related to the processing apparatus.
 上記目的を達成するため本発明に係る処理装置は、プログラムを格納する第1領域と、第1領域でのプログラムの書換を実行させる第1ブートローダを格納する第2領域と、を有する不揮発性メモリを備え、第1領域に格納されているメインプログラムに基づいて処理を行う処理装置であって、新メインプログラム、新第1ブートローダ、および第2領域でのプログラムの書換を実行させる第2ブートローダが用意された状況において、第1領域に格納されている現メインプログラムを新メインプログラムに、第2領域に格納されている現第1ブートローダを新第1ブートローダに、それぞれ更新するプログラム更新動作を行うものであり、前記プログラム更新動作は、現第1ブートローダに基づいて、第1領域に格納されている現メインプログラムを第2ブートローダに書き換える第1更新動作、第1領域に書き込まれた第2ブートローダに基づいて、第2領域に格納されている現第1ブートローダを新第1ブートローダに書き換える第2更新動作、および、第2領域に書き込まれた新第1ブートローダに基づいて、第1領域に格納されている第2ブートローダを新メインプログラムに書き換える第3更新動作、を含む構成とする。 In order to achieve the above object, a processing apparatus according to the present invention includes a non-volatile memory having a first area for storing a program and a second area for storing a first boot loader that executes rewriting of the program in the first area. A processing device for performing processing based on a main program stored in the first area, a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second area In the prepared situation, a program update operation is performed to update the current main program stored in the first area to the new main program and the current first boot loader stored in the second area to the new first boot loader. The program update operation is performed based on the current first boot loader and the current main stored in the first area. A first update operation for rewriting the program to the second boot loader; a second update operation for rewriting the current first boot loader stored in the second area to the new first boot loader based on the second boot loader written in the first area; And a third update operation for rewriting the second boot loader stored in the first area with the new main program based on the new first boot loader written in the second area.
 本構成によれば、プログラム更新動作を行うことにより、ブートローダを退避させるためのメモリ等を要せず、安全に、かつ、ブートローダの格納領域とメインプログラムの格納領域の移動が発生しないように、メインプログラムとブートローダの更新を行うことが可能となる。 According to this configuration, by performing a program update operation, a memory or the like for saving the boot loader is not required, and the storage area of the boot loader and the storage area of the main program are not moved safely. The main program and boot loader can be updated.
 また上記構成としてより具体的には、起動時において、第1状態および第2状態の何れか一方となるフラグが第1状態であるときは、第1領域に格納されているプログラムに基づいて動作し、該フラグが第2状態であるときは、第2領域に格納されているプログラムに基づいて動作する、フラグ判定動作を行うものであり、前記第1ブートローダは、第1領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えさせるとともに、前記フラグの状態を変更させた上で、再起動を実行させるプログラムであり、前記第2ブートローダは、第2領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えさせるとともに、前記フラグの状態を変更させた上で、再起動を実行させるプログラムである構成としてもよい。 More specifically, in the above configuration, when the flag that is in either the first state or the second state is the first state at the time of start-up, the operation is performed based on the program stored in the first area. When the flag is in the second state, the flag determination operation is performed based on the program stored in the second area. The first boot loader is stored in the first area. The second boot loader stores the second program in the second area. The second boot loader stores the second program in the second area. Rewrite the program that has been changed to a program that is compatible with itself, change the state of the flag, and then restart the program It may be configured as a program.
 また上記構成としてより具体的には、前記第1ブートローダは、第1領域でのプログラムの書換を実行させる書換部と、前記フラグ判定動作を実行させる判定部と、を有している構成としてもよい。 More specifically, as the above configuration, the first boot loader may include a rewriting unit that executes rewriting of a program in the first area and a determination unit that executes the flag determination operation. Good.
 また上記構成としてより具体的には、前記第1ブートローダは、第1領域でのプログラムの書換を実行させる書換部を有する一方、前記フラグ判定動作を実行させるプログラムを有していない構成としてもよい。 More specifically, as the above configuration, the first boot loader may include a rewriting unit that executes rewriting of a program in the first area, but may not include a program that executes the flag determination operation. .
 また本発明に係るプログラム更新方法は、プログラムを格納する第1領域と、第1領域でのプログラムの書換を実行させる第1ブートローダを格納する第2領域と、を有する不揮発性メモリを備え、第1領域に格納されているメインプログラムに基づいて処理を行う処理装置が、プログラムを更新する方法であって、新メインプログラム、新第1ブートローダ、および第2領域でのプログラムの書換を実行させる第2ブートローダが用意された状況において、第1領域に格納されている現メインプログラムを新メインプログラムに、第2領域に格納されている現第1ブートローダを新第1ブートローダに、それぞれ更新する方法であり、現第1ブートローダに基づいて、第1領域に格納されている現メインプログラムを第2ブートローダに書き換える第1更新ステップ、第1領域に書き込まれた第2ブートローダに基づいて、第2領域に格納されている現第1ブートローダを新第1ブートローダに書き換える第2更新ステップ、および、第2領域に書き込まれた新第1ブートローダに基づいて、第1領域に格納されている第2ブートローダを新メインプログラムに書き換える第3更新ステップ、を含む方法とする。 In addition, a program update method according to the present invention includes a nonvolatile memory having a first area for storing a program and a second area for storing a first boot loader for executing rewriting of the program in the first area. A processing apparatus for performing processing based on a main program stored in one area is a method for updating a program, wherein a new main program, a new first boot loader, and a program rewriting in a second area are executed. In a situation where two boot loaders are prepared, the current main program stored in the first area is updated to the new main program, and the current first boot loader stored in the second area is updated to the new first boot loader. Yes, based on the current first boot loader, the current main program stored in the first area is transferred to the second boot loader. A first update step to replace, a second update step to rewrite the current first boot loader stored in the second area with a new first boot loader based on the second boot loader written in the first area, and a second area And a third update step of rewriting the second boot loader stored in the first area with the new main program based on the new first boot loader written in (1).
 また本発明に係るプログラムは、第1領域および第2領域を有する不揮発性メモリを備えた処理装置に、プログラムの更新を行わせるプログラムであって、起動時において、第1状態および第2状態の何れか一方となるフラグが第1状態であるときは、第1領域に格納されているプログラムに基づいて動作し、前記フラグが第2状態であるときは、第2領域に格納されているプログラムに基づいて動作する、フラグ判定動作を行わせるプログラムと、第1領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えるとともに、前記フラグの状態を変更させた上で、再起動を実行する動作を行わせるプログラムと、第2領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えるとともに、前記フラグの状態を変更させた上で、再起動を実行する動作を行わせるプログラムと、を有するプログラムとする。 A program according to the present invention is a program that causes a processing apparatus including a nonvolatile memory having a first area and a second area to update a program, and is in a first state and a second state at startup. When one of the flags is in the first state, the program operates based on the program stored in the first area, and when the flag is in the second state, the program is stored in the second area. The program for performing the flag determination operation and the program stored in the first area are rewritten to a prepared program corresponding to itself and the state of the flag is changed. Rewrite the program that performs the operation to execute the restart and the program stored in the second area to the prepared program corresponding to itself Rutotomoni, after allowed to change the state of the flag, the program for performing the operation for executing the restart, the program having to.
 上述した通り本発明に係る処理装置によれば、プログラム更新動作を行うことにより、ブートローダを退避させるためのメモリ等を要せず、安全に、かつ、ブートローダの格納領域とメインプログラムの格納領域の移動が発生しないように、メインプログラムとブートローダの更新を行うことが可能となる。 As described above, according to the processing device of the present invention, by performing the program update operation, a memory for saving the boot loader is not required, and the storage area of the boot loader and the storage area of the main program can be safely stored. The main program and the boot loader can be updated so that no movement occurs.
本発明の第1実施形態に係るマイコンの概略的な構成図である。1 is a schematic configuration diagram of a microcomputer according to a first embodiment of the present invention. 第1実施形態におけるプログラムの格納等に関する説明図である。It is explanatory drawing regarding the storage etc. of the program in 1st Embodiment. プログラム更新動作に関するフローチャートである。It is a flowchart regarding a program update operation. プログラム更新動作に関するフローチャートである。It is a flowchart regarding a program update operation. プログラム更新動作に関するフローチャートである。It is a flowchart regarding a program update operation. フラッシュメモリによるプログラムの格納状況に関する説明図である。It is explanatory drawing regarding the storage condition of the program by flash memory. 本発明の第2実施形態に係るマイコンの概略的な構成図である。It is a schematic block diagram of the microcomputer which concerns on 2nd Embodiment of this invention. 第2実施形態におけるプログラムの格納等に関する説明図である。It is explanatory drawing regarding the storage etc. of the program in 2nd Embodiment.
 本発明の実施形態について、第1実施形態および第2実施形態を例に挙げて、以下に説明する。 Embodiments of the present invention will be described below by taking the first embodiment and the second embodiment as examples.
1.第1実施形態
[マイコンの構成等について]
 図1は、本実施形態に係るマイコン[マイクロコンピュータ]の概略的な構成図である。本図に示すように当該マイコン2は、通信I/F3、CPU4、およびフラッシュメモリ5を備えている。なおマイコン2は、PC[Personal Computer]1やEEPROM[Electrically Erasable Programmable ROM]6に接続されている。
1. First Embodiment [Microcomputer Configuration, etc.]
FIG. 1 is a schematic configuration diagram of a microcomputer [microcomputer] according to the present embodiment. As shown in the figure, the microcomputer 2 includes a communication I / F 3, a CPU 4, and a flash memory 5. The microcomputer 2 is connected to a PC [Personal Computer] 1 and an EEPROM [Electrically Erasable Programmable ROM] 6.
 通信I/F3は、PC1等との通信を可能とするものであり、例えばCAN[Controller Area Network]やLAN[Local Area Network]によって形成されている。またCPU4は、プログラムに基づいて各種処理を実行するものである。 The communication I / F 3 enables communication with the PC 1 or the like, and is formed by, for example, CAN [Controller Area Network] or LAN [Local Area Network]. The CPU 4 executes various processes based on the program.
 フラッシュメモリ5は、プログラム等を書換可能に格納する不揮発性メモリである。なお以降、説明の簡略化のため、フラッシュメモリ5が有するプログラムの格納領域は、「第1ブロック」と「第2ブロック」の二つであるとして説明を行う。これらのブロックの具体的な形態については特に限定されない。 The flash memory 5 is a non-volatile memory that stores programs and the like in a rewritable manner. In the following description, for the sake of simplification, the program storage area of the flash memory 5 will be described as being “first block” and “second block”. The specific form of these blocks is not particularly limited.
 CPU4は、フラッシュメモリ5に格納されているプログラムをリードして、実行することが可能となっている。またCPU4は、通信I/F3を介してPC1との双方向通信を行うことが可能となっている。 The CPU 4 can read and execute a program stored in the flash memory 5. Further, the CPU 4 can perform bidirectional communication with the PC 1 via the communication I / F 3.
 EEPROM6は、「0」および「1」の何れか一方となるブートフラグを、更新可能に保持する。CPU4は、EEPROM6に適宜アクセスして、ブートフラグを参照したり、更新したりすることが可能となっている。 The EEPROM 6 holds a boot flag that is either “0” or “1” in an updatable manner. The CPU 4 can appropriately access the EEPROM 6 to refer to or update the boot flag.
[各種プログラムについて]
 次に、マイコン2の動作に関わる各種のプログラムについて説明する。マイコン2の動作に関わるプログラムとしては、「メインプログラム」、「第1ブートローダ」、「第2ブートローダ」、および「初期プログラム」などが存在する。
[About various programs]
Next, various programs related to the operation of the microcomputer 2 will be described. As programs related to the operation of the microcomputer 2, there are a "main program", a "first boot loader", a "second boot loader", an "initial program", and the like.
 「メインプログラム」は、CPU4に通常動作(通常状態で行われるべき各種動作)を実行させるプログラムである。すなわちマイコン2は、起動動作を経て通常状態となっているとき、メインプログラムに従って動作することになる。なおメインプログラムは、マイコン2がPC1からプログラム更新命令を受けたときに、ブートフラグを「1」にセットして再起動を開始する動作を、CPU4に実行させるようになっている(後述のステップS1を参照)。 The “main program” is a program that causes the CPU 4 to perform normal operations (various operations to be performed in a normal state). That is, the microcomputer 2 operates in accordance with the main program when it is in a normal state through the start-up operation. When the microcomputer 2 receives a program update command from the PC 1, the main program causes the CPU 4 to execute an operation of setting a boot flag to “1” and starting restart (steps described later). (See S1).
 「第1ブートローダ」は、「判定部」と「書換部」の二つのプログラムに小分けされている。 The “first boot loader” is subdivided into two programs: a “determination unit” and a “rewriting unit”.
 「判定部」は、(1)ブートフラグの状態を判定する動作、(2)判定結果が「1」のときに、第2ブロックに格納されている第1ブートローダの書換部をリードして実行を開始する動作、および(3)判定結果が「0」のときに、第1ブロックに格納されているプログラムをリードして実行を開始する動作を、CPU4に実行させるプログラムである(後述のステップS12~S14、S22~S23、およびS32~S33を参照)。 The “determination unit” (1) Operation for determining the state of the boot flag, (2) When the determination result is “1”, the rewriting unit of the first boot loader stored in the second block is read and executed. And (3) a program that causes the CPU 4 to execute an operation of starting execution by reading the program stored in the first block when the determination result is “0” (steps described later) (See S12-S14, S22-S23, and S32-S33).
 「書換部」は、(1)第1ブロックに格納されているプログラムを消去する動作、(2)当該消去の後、PC1に第2ブートローダまたはメインプログラムの送信要求を行い、この要求に応じて送信されてきたプログラムを、第1ブロックにライトする動作、(3)ライトの動作が正常終了したか否かを判定する動作、(4)正常終了したときは、ブートフラグを「0」にリセットして再起動を開始する動作、および(5)正常終了していないときは判定部(既にCPU4がリードしているもの、或いは、第2ブロックに格納されているもの)に基づく動作を再度行う動作を、CPU4に実行させるプログラムである(後述のステップS15~S18、およびS34~S37を参照)。 The “rewrite unit” (1) deletes the program stored in the first block. (2) After the deletion, the PC 1 requests the PC 1 to transmit the second boot loader or the main program. An operation to write the transmitted program to the first block, (3) an operation to determine whether or not the write operation has been normally completed, and (4) to reset the boot flag to “0” upon successful completion Then, the operation based on the restarting operation and (5) the operation based on the determination unit (the one already read by the CPU 4 or the one stored in the second block) is performed again when the normal termination is not completed. This is a program for causing the CPU 4 to execute an operation (see steps S15 to S18 and S34 to S37 described later).
 また書換部に基づく上記(2)の動作がなされるにあたっては、第2ブートローダが未だライトされていないとき(後述する1回目書換動作の実行時)には、第2ブートローダの送信要求がなされ、第2ブートローダが既にライトされているとき(後述する3回目書換動作の実行時)には、メインプログラムの送信要求がなされるようになっている。 In addition, when the operation (2) based on the rewriting unit is performed, when the second boot loader is not yet written (when the first rewriting operation described later is executed), a transmission request for the second boot loader is made. When the second boot loader has already been written (when a third rewriting operation described later is executed), a transmission request for the main program is made.
 このことについては、例えばマイコン2に、第2ブートローダがライトされたか否かを記録しておく手段を設けること等により、実現可能である。またPC1が、当該送信要求を受ける度に第2ブートローダを既に送信したか否かを判別し、未だ送信していない場合には第2ブートローダを送信し、既に送信している場合にはメインプログラムを送信するようになっていてもよい。この場合、書換部に基づく上記(2)の動作における送信要求は、第2ブートローダとメインプログラムの何れの送信を要求すべきかに関わらず、同じものとすることが可能である。 This can be realized, for example, by providing the microcomputer 2 with means for recording whether or not the second boot loader has been written. Each time the PC 1 receives the transmission request, the PC 1 determines whether or not the second boot loader has already been transmitted. If the PC 1 has not transmitted yet, the second boot loader is transmitted. If it has already transmitted, the main program is transmitted. May be sent. In this case, the transmission request in the operation (2) based on the rewriting unit can be the same regardless of which transmission of the second boot loader and the main program should be requested.
 「第2ブートローダ」は、(1)第2ブロックに格納されているプログラムを消去する動作、(2)当該消去の後、PC1に第1ブートローダの送信要求を行い、この要求に応じて送信されてきた第1ブートローダを、第2ブロックにライトする動作、(3)ライトの動作が正常終了したか否かを判定する動作、(4)正常終了したときは、ブートフラグを「1」にセットして再起動を開始する動作、および(5)正常終了していないときは判定部(既にCPU4がリードしているもの、或いは、第2ブロックに格納されているもの)に基づく動作を再度行う動作を、CPU4に実行させるプログラムである(後述のステップS24~S27を参照)。 The “second boot loader” (1) deletes the program stored in the second block. (2) After the deletion, the first boot loader sends a request to the PC 1 to transmit the first boot loader. The operation of writing the first boot loader to the second block, (3) the operation of determining whether or not the write operation is normally completed, and (4) the boot flag is set to “1” when the operation is normally completed. Then, the operation based on the restarting operation and (5) the operation based on the determination unit (the one already read by the CPU 4 or the one stored in the second block) is performed again when the normal termination is not completed. This is a program for causing the CPU 4 to execute the operation (see steps S24 to S27 described later).
 なお書換部による上記(5)の動作、もしくは第2ブートローダによる上記(5)の動作について、正常終了していないという判定が予め指定された回数だけ続いた場合には、重大な異常が発生したとみなして、プログラム更新動作が中止されるようにしても構わない。また書換部による上記(2)の動作および第2ブートローダによる上記(2)の動作においては、PC1から送信されてくるプログラムは少しずつ(例えば、64バイトずつ)受取られ、その度に第1ブロックまたは第2ブロックにライトされる。これにより、PC1からのプログラムの受取りに用いられるメモリ(例えばCPU4に付属するメモリ)の容量が小さくても、当該動作を十分に実行することが可能となっている。 If the rewrite unit (5) or the second boot loader (5) is not completed normally for a predetermined number of times, a serious abnormality has occurred. As a result, the program update operation may be stopped. In the operation (2) by the rewriting unit and the operation (2) by the second boot loader, the program transmitted from the PC 1 is received little by little (for example, 64 bytes), and each time the first block is received. Or it is written to the second block. Thereby, even if the capacity of the memory (for example, the memory attached to the CPU 4) used for receiving the program from the PC 1 is small, the operation can be sufficiently performed.
 「初期プログラム」は、マイコン2の起動時において、CPU4によって最初に実行されるプログラムである。初期プログラムは、第2ブロックに格納されている第1ブートローダの判定部をリードして実行を開始する動作を、CPU4に実行させるプログラムである(後述のステップS11、S21、およびS31を参照)。初期プログラムはCPU4に固定的に格納されており、フラッシュメモリ5等からのリードを要することなく、CPU4によって実行可能となっている。 The “initial program” is a program that is first executed by the CPU 4 when the microcomputer 2 is activated. The initial program is a program that causes the CPU 4 to execute an operation of starting execution by reading the determination unit of the first boot loader stored in the second block (see steps S11, S21, and S31 described later). The initial program is fixedly stored in the CPU 4 and can be executed by the CPU 4 without requiring reading from the flash memory 5 or the like.
 そして通常時、図2に示すように、フラッシュメモリ5の第1ブロックにはメインプログラムが、第2ブロックには第1ブートローダが、それぞれ格納された状態となっている。また同じく通常時、ブートフラグは「0」にセットされている。 In the normal state, as shown in FIG. 2, the main program is stored in the first block of the flash memory 5 and the first boot loader is stored in the second block. Similarly, during normal times, the boot flag is set to “0”.
 またPC1は、例えばプログラムの開発元からのダウンロード等によって、新たなバージョンのメインプログラムおよび第1ブートローダ、ならびに第2ブートローダを、取得することが可能となっている。そしてPC1は、ユーザからマイコンのバージョンアップ実行指示を受けると、マイコン2にプログラム更新命令を出す。またPC1は、マイコン2からのプログラムの送信要求があると、これに応じて、マイコン2にプログラムを送信するようになっている。 Also, the PC 1 can obtain a new version of the main program, the first boot loader, and the second boot loader, for example, by downloading from the program developer. When the PC 1 receives a microcomputer upgrade execution instruction from the user, the PC 1 issues a program update instruction to the microcomputer 2. Further, when there is a program transmission request from the microcomputer 2, the PC 1 transmits the program to the microcomputer 2 in response to the request.
[マイコンのバージョンアップについて]
 ところで機能追加や不具合修正などのため、フラッシュメモリ5に現在格納されているメインプログラムおよび第1ブートローダ(現メインプログラム、および現第1ブートローダ)の各々を、新たなバージョンのもの(新メインプログラム、および新第1ブートローダ)に更新しようとする場合、すなわちマイコン2のバージョンアップを行おうとする場合がある。
[About MCU version upgrade]
By the way, in order to add functions or correct defects, the main program and the first boot loader (current main program and current first boot loader) currently stored in the flash memory 5 are replaced with new versions (new main program, And the new first boot loader), that is, the microcomputer 2 may be upgraded.
 このような場合、ユーザは、PC1にマイコンのバージョンアップ実行指示を与え、マイコン2にプログラム更新動作を実行させることにより、当該更新を実現することが可能である。なおこのプログラム更新動作は、図3~図5の各フローチャートに示すように、1回目書換動作から3回目書換動作までの3回の書換動作から成る。マイコン2をバージョンアップさせるための動作の流れについて、図3~図5の各フローチャートを参照しながら、以下に説明する。 In such a case, the user can realize the update by giving the microcomputer 1 a version upgrade execution instruction to the PC 1 and causing the microcomputer 2 to execute the program update operation. This program update operation includes three rewrite operations from the first rewrite operation to the third rewrite operation, as shown in the flowcharts of FIGS. The flow of operations for upgrading the microcomputer 2 will be described below with reference to the flowcharts of FIGS.
 先述したようにPC1は、マイコンのバージョンアップ実行指示を受けると、マイコン2にプログラム更新命令を出す。このときマイコン2側では、CPU4は、メインプログラムに基づいて動作するようになっている。具体的には、CPU4は、ブートフラグを「1」にセットして、再起動を開始する(ステップS1)。 As described above, the PC 1 issues a program update instruction to the microcomputer 2 when receiving an instruction to execute a version upgrade of the microcomputer. At this time, on the microcomputer 2 side, the CPU 4 operates based on the main program. Specifically, the CPU 4 sets a boot flag to “1” and starts restarting (step S1).
 なおこの時点でPC1およびマイコン2が保有しているプログラムの種類は、図2に示す通りである。すなわち、フラッシュメモリ5の第1ブロックには現メインプログラムが、第2ブロックには現第1ブートローダが、それぞれ格納されている。またPC1は、新メインプログラム、新第1ブートローダ、および第2ブートローダを保有している。つまりこれらのプログラムが、予め用意されている。 Note that the types of programs held by the PC 1 and the microcomputer 2 at this time are as shown in FIG. That is, the current main program is stored in the first block of the flash memory 5, and the current first boot loader is stored in the second block. The PC 1 also has a new main program, a new first boot loader, and a second boot loader. That is, these programs are prepared in advance.
 そして再起動がなされたことにより、CPU4は先ず、初期プログラムに基づいて動作する。具体的には、CPU4は、第2ブロックに格納されている、現第1ブートローダの判定部をリードして実行を開始する(ステップS11)。 Then, due to the restart, the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts execution by reading the determination unit of the current first boot loader stored in the second block (step S11).
 すなわちCPU4は、先ずブートフラグの状態が「0」と「1」の何れであるかを判定する(ステップS12)。なお、通常通りプログラム更新動作が進んでいる場合、ブートフラグは現時点で「1」となっている。そしてCPU4は、判定結果が「1」のとき(ステップS12のY)、第2ブロックに格納されている、現第1ブートローダの書換部をリードして実行を開始する(ステップS14)。一方、判定結果が「0」のとき(ステップS12のN)、CPU4は、第1ブロックに格納されている、現メインプログラムをリードして実行を開始する(ステップS13)。 That is, the CPU 4 first determines whether the boot flag is “0” or “1” (step S12). If the program update operation is proceeding normally, the boot flag is “1” at the present time. When the determination result is “1” (Y in step S12), the CPU 4 starts execution by reading the rewriting unit of the current first boot loader stored in the second block (step S14). On the other hand, when the determination result is “0” (N in step S12), the CPU 4 reads and starts the execution of the current main program stored in the first block (step S13).
 ステップS13の動作が実行された場合は、プログラム更新動作は終了し、CPU4は以降、通常動作(現メインプログラムに基づく動作)を行うことになる。一方、ステップS14の動作が実行された場合は、CPU4は、現第1ブートローダの書換部に基づいて動作する。 When the operation of step S13 is executed, the program update operation is terminated, and the CPU 4 thereafter performs a normal operation (operation based on the current main program). On the other hand, when the operation of step S14 is executed, the CPU 4 operates based on the rewriting unit of the current first boot loader.
 具体的には、CPU4は、第1ブロックに格納されている現メインプログラムを消去する動作(ステップS15)、当該消去の後、PC1から受取った第2ブートローダを、第1ブロックにライトする動作(ステップS16)、および、当該ライトの動作が正常終了したか否かを判定する動作(ステップS17)を行う。 Specifically, the CPU 4 erases the current main program stored in the first block (step S15), and after the erasure, writes the second boot loader received from the PC 1 into the first block ( Step S16) and an operation (step S17) for determining whether or not the write operation has ended normally are performed.
 そして更にCPU4は、正常終了したときは(ステップS17のY)、ブートフラグを「0」にリセットして再起動を開始する動作(ステップS18)、および、正常終了していないときは(ステップS17のN)、判定部に基づく動作(ステップS12)を再度行う動作を行う。 Further, the CPU 4 further resets the boot flag to “0” to start the restart (Step S18) when it is normally completed (Step S18), and when it is not normally ended (Step S17). N), the operation based on the determination unit (step S12) is performed again.
 ステップS18の動作がなされることで1回目書換動作は完了し、引き続き、2回目書換動作が開始される。なおこの時点でフラッシュメモリ5に格納されているプログラムの種類は、図6の(A)に示す通りである。すなわち、フラッシュメモリ5の第1ブロックには第2ブートローダが、第2ブロックには現第1ブートローダが、それぞれ格納されている。 The first rewrite operation is completed by performing the operation of step S18, and the second rewrite operation is subsequently started. Note that the types of programs stored in the flash memory 5 at this time are as shown in FIG. That is, a second boot loader is stored in the first block of the flash memory 5, and the current first boot loader is stored in the second block.
 次に、2回目書換動作について説明する。再起動がなされたことにより(ステップS18)、CPU4は、先ず初期プログラムに基づいて動作する。具体的には、CPU4は、第2ブロックに格納されている、現第1ブートローダの判定部をリードして実行を開始する(ステップS21)。 Next, the second rewriting operation will be described. When the restart is performed (step S18), the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts execution by reading the determination unit of the current first boot loader stored in the second block (step S21).
 すなわちCPU4は、先ずブートフラグの状態が「0」と「1」の何れであるかを判定する(ステップS22)。なお、通常通りプログラム更新動作が進んでいる場合、ブートフラグは現時点で「0」となっている。そしてCPU4は、判定結果が「1」のとき(ステップS22のY)、第2ブロックに格納されている、現第1ブートローダの書換部をリードして実行を開始する。すなわちこのときは、先述したステップS14の動作のやり直しが行われる。一方、判定結果が「0」のとき(ステップS22のN)、CPU4は、第1ブロックに格納されている、第2ブートローダをリードして実行を開始する(ステップS23)。 That is, the CPU 4 first determines whether the boot flag is “0” or “1” (step S22). If the program update operation is proceeding normally, the boot flag is “0” at the present time. Then, when the determination result is “1” (Y in step S22), the CPU 4 starts execution by reading the rewriting unit of the current first boot loader stored in the second block. That is, at this time, the operation in step S14 described above is performed again. On the other hand, when the determination result is “0” (N in step S22), the CPU 4 reads the second boot loader stored in the first block and starts execution (step S23).
 ステップS23の動作が実行された場合は、CPU4は、第2ブートローダに基づいて動作する。具体的には、CPU4は、第2ブロックに格納されている現第1ブートローダを消去する動作(ステップS24)、当該消去の後、PC1から受取った新第1ブートローダを、第2ブロックにライトする動作(ステップS25)、および、当該ライトの動作が正常終了したか否かを判定する動作(ステップS26)を行う。 When the operation of step S23 is executed, the CPU 4 operates based on the second boot loader. Specifically, the CPU 4 erases the current first boot loader stored in the second block (step S24), and writes the new first boot loader received from the PC 1 to the second block after the erase. The operation (step S25) and the operation (step S26) for determining whether or not the write operation has been completed normally are performed.
 そして更にCPU4は、正常終了したときは(ステップS26のY)、ブートフラグを「1」にセットして再起動を開始する動作(ステップS27)、および、正常終了していないときは(ステップS26のN)、判定部に基づく動作(ステップS22)を再度行う動作を行う。 Further, the CPU 4 sets the boot flag to “1” when the normal end is completed (Y in step S26) and starts the restart (step S27), and when the normal end is not completed (step S26). N), the operation based on the determination unit (step S22) is performed again.
 ステップS27の動作がなされることで2回目書換動作は完了し、引き続き、3回目書換動作が開始される。なおこの時点でフラッシュメモリ5に格納されているプログラムの種類は、図6の(B)に示す通りである。すなわち、フラッシュメモリ5の第1ブロックには第2ブートローダが、第2ブロックには新第1ブートローダが、それぞれ格納されている。 The second rewrite operation is completed by performing the operation of step S27, and the third rewrite operation is started. Note that the types of programs stored in the flash memory 5 at this time are as shown in FIG. That is, a second boot loader is stored in the first block of the flash memory 5, and a new first boot loader is stored in the second block.
 次に、3回目書換動作について説明する。再起動がなされたことにより(ステップS27)、CPU4は、先ず初期プログラムに基づいて動作する。具体的には、CPU4は、第2ブロックに格納されている、新第1ブートローダの判定部をリードして実行を開始する(ステップS31)。 Next, the third rewrite operation will be described. When the restart is performed (step S27), the CPU 4 first operates based on the initial program. Specifically, the CPU 4 starts the execution by reading the determination unit of the new first boot loader stored in the second block (step S31).
 すなわちCPU4は、先ずブートフラグの状態が「0」と「1」の何れであるかを判定する(ステップS32)。なお、通常通りプログラム更新動作が進んでいる場合、ブートフラグは現時点で「1」となっている。そしてCPU4は、判定結果が「1」のとき(ステップS32のY)、第2ブロックに格納されている、新第1ブートローダの書換部をリードして実行を開始する(ステップS33)。一方、判定結果が「0」のとき(ステップS32のN)、CPU4は、第1ブロックに格納されている、第2ブートローダをリードして実行を開始する。すなわちこのときは、先述したステップS23の動作のやり直しが行われる。 That is, the CPU 4 first determines whether the state of the boot flag is “0” or “1” (step S32). If the program update operation is proceeding normally, the boot flag is “1” at the present time. When the determination result is “1” (Y in step S32), the CPU 4 starts execution by reading the rewriting unit of the new first boot loader stored in the second block (step S33). On the other hand, when the determination result is “0” (N in step S32), the CPU 4 reads the second boot loader stored in the first block and starts execution. That is, at this time, the operation in step S23 described above is performed again.
 ステップS33の動作が実行された場合は、CPU4は、新第1ブートローダの書換部に基づいて動作する。具体的には、CPU4は、第1ブロックに格納されている第2ブートローダを消去する動作(ステップS34)、当該消去の後、PC1から受取った新メインプログラムを、第1ブロックにライトする動作(ステップS35)、および、当該ライトの動作が正常終了したか否かを判定する動作(ステップS36)を行う。 When the operation of step S33 is executed, the CPU 4 operates based on the rewrite unit of the new first boot loader. Specifically, the CPU 4 erases the second boot loader stored in the first block (step S34), and after the erase, writes the new main program received from the PC 1 to the first block ( Step S35) and an operation (step S36) for determining whether or not the operation of the write has ended normally are performed.
 そして更にCPU4は、正常終了したときは(ステップS36のY)、ブートフラグを「0」にリセットして再起動を開始する動作(ステップS37)、および、正常終了していないときは(ステップS36のN)、判定部に基づく動作(ステップS32)を再度行う動作を行う。 Further, the CPU 4 further resets the boot flag to “0” to start restart (step S37) when it is normally terminated (step S37), and when it is not normally terminated (step S36). N), the operation based on the determination unit (step S32) is performed again.
 ステップS37の動作がなされることで3回目書換動作は完了し、プログラム更新動作は完了する。この時点でフラッシュメモリ5に格納されているプログラムの種類は、図6の(C)に示す通りである。すなわち、フラッシュメモリ5の第1ブロックには新メインプログラムが、第2ブロックには新第1ブートローダが、それぞれ格納されている。 The third rewrite operation is completed by performing the operation of step S37, and the program update operation is completed. At this time, the types of programs stored in the flash memory 5 are as shown in FIG. That is, a new main program is stored in the first block of the flash memory 5, and a new first boot loader is stored in the second block.
 なおその後、CPU4は、再起動がなされたことにより(ステップS37)、初期プログラムに基づいて動作する。このときブートフラグの状態は「0」であるため、CPU4は、第1ブロックに格納されている、新メインプログラムをリードして実行を開始する。その結果、以降は、新メインプログラムに基づいた通常動作が行われることになる。 After that, the CPU 4 operates based on the initial program when it is restarted (step S37). At this time, since the state of the boot flag is “0”, the CPU 4 reads and starts executing the new main program stored in the first block. As a result, the normal operation based on the new main program is performed thereafter.
[プログラム更新動作の特長等について]
 上述した通りマイコン2は、プログラム更新動作を行うことにより、フラッシュメモリ5に格納されているメインプログラムおよび第1ブートローダの両方を、新たなバージョンのものに更新することが可能となっている。
[Features of program update operation]
As described above, the microcomputer 2 can update both the main program and the first boot loader stored in the flash memory 5 to the new version by performing the program update operation.
 また上述した説明から明らかな通り、プログラム更新動作によれば、何れかのブートローダ(第1ブートローダまたは第2ブートローダ)をフラッシュメモリ5の何れかのブロック(第1ブロックまたは第2ブロック)に格納させた状態が、プログラム更新動作の実行中において維持される。そしてこの格納されているブートローダに基づいて、他方のブロックに対する書換が行われる。 As is clear from the above description, according to the program update operation, any boot loader (first boot loader or second boot loader) is stored in any block (first block or second block) of the flash memory 5. This state is maintained during execution of the program update operation. Based on the stored boot loader, the other block is rewritten.
 そのため、仮にブートローダの書換の途中に電源の遮断などがなされ、当該書換がなされていたブロックのデータが破壊されても、CPU4はその後、他方のブロックに格納されているブートローダをリードする(これにより、書換のやり直し等を行う)ことが可能であり、ブートローダのリードが不可能となってしまう事態は回避される。このようにマイコン2は、各プログラムの更新を安全に行うことが可能となっている。 For this reason, even if the power is shut off during the boot loader rewriting, and the data in the rewritten block is destroyed, the CPU 4 then reads the boot loader stored in the other block (thereby In other words, the situation where the boot loader cannot be read is avoided. As described above, the microcomputer 2 can safely update each program.
 なおプログラム更新動作によれば、ブートローダを退避させるメモリを要することなく、このようなブートローダのリードが可能となっている。このようにマイコン2は、ブートローダを退避させるメモリを設けた場合に比べ、必要なメモリを少なくすることが可能となっている。 It should be noted that according to the program update operation, such a boot loader can be read without requiring a memory for saving the boot loader. As described above, the microcomputer 2 can reduce the necessary memory as compared with the case where the memory for saving the boot loader is provided.
 またプログラム更新動作によれば、第1ブートローダの格納領域とメインプログラムの格納領域の移動は発生しない。すなわち第1ブロックにはメインプログラムが、第2ブロックには第1ブートローダが、それぞれ格納された状態が維持される。 Also, according to the program update operation, the storage area of the first boot loader and the storage area of the main program do not move. That is, the main program is stored in the first block, and the first boot loader is stored in the second block.
 そのため、CPU4がプログラムをリードする際に、そのプログラムに対応した特定のアドレスへのアクセスを行う場合であっても、プログラム更新動作の実行によってリード処理に支障が生じることは回避される。また、メインプログラムの開発者は、メインプログラムの格納領域の変更を考慮すること(プログラム更新動作の実行を考慮した設計変更など)は必要無く、メインプログラムの開発を効率よく行うことが可能である。 Therefore, even when the CPU 4 accesses a specific address corresponding to the program when reading the program, it is avoided that the read processing is hindered by executing the program update operation. In addition, the main program developer need not consider the change of the main program storage area (design change in consideration of the execution of the program update operation, etc.), and can develop the main program efficiently. .
 またメモリ容量の制限や、消去領域のブロック構成などにより、フラッシュメモリ5においてプログラムの格納領域を移動させることが出来ない場合であっても、メインプログラムと第1ブートローダの双方の更新が可能である。 Even if the storage area of the program cannot be moved in the flash memory 5 due to the memory capacity limitation or the block configuration of the erase area, both the main program and the first boot loader can be updated. .
 なお第1ブートローダの判定部は、簡単な動作を実行させるだけで良いため簡単な構成となっており、フラッシュメモリ5の使用容量もごく僅かである。従って、判定部の書換は非常に短時間で実施可能であるため、判定部の書換の途中で電源遮断などに遭遇することは極めて少ないといえる。 Note that the determination unit of the first boot loader has a simple configuration because it only needs to execute a simple operation, and the used capacity of the flash memory 5 is very small. Therefore, since the rewriting of the determination unit can be performed in a very short time, it can be said that it is extremely rare to encounter power interruption or the like during the rewriting of the determination unit.
2.第2実施形態
 ところで先述したように、第1ブートローダの判定部は簡単な構成であるため、バージョンアップの必要性が乏しいケースも考えられる。そこでこのようなケースに対応するため、プログラム更新動作においては、第1ブートローダの判定部の更新が省略されるようにしても構わない。
2. Second Embodiment As described above, since the determination unit of the first boot loader has a simple configuration, there may be a case where the need for version upgrade is scarce. Therefore, in order to cope with such a case, the update of the determination unit of the first boot loader may be omitted in the program update operation.
 このようにする場合の実施形態を、第2実施形態として以下に説明する。なお本実施形態の説明は、第1実施形態と異なる点に重点を置き、共通する点については説明を省略することがある。 An embodiment in this case will be described below as a second embodiment. Note that the description of the present embodiment focuses on differences from the first embodiment, and the description of common points may be omitted.
 図7は、第2実施形態に係るマイコン2の概略的な構成図である。なお本実施形態のマイコン2は、補助フラッシュメモリ7が設けられた点を除き、第1実施形態に係るマイコン2と基本的に同等の構成である。但し本実施形態では、第1ブートローダは書換部のみを有し、判定部を有していない。その代わりに図8に示すように、この判定部と同等の内容である判定プログラムが、補助フラッシュメモリ7に予め格納されている。 FIG. 7 is a schematic configuration diagram of the microcomputer 2 according to the second embodiment. Note that the microcomputer 2 of the present embodiment has basically the same configuration as the microcomputer 2 according to the first embodiment, except that the auxiliary flash memory 7 is provided. However, in the present embodiment, the first boot loader has only a rewrite unit and does not have a determination unit. Instead, as shown in FIG. 8, a determination program having the same content as the determination unit is stored in advance in the auxiliary flash memory 7.
 そして本実施形態の「第2ブートローダ」は、(1)第2ブロックに格納されているプログラムを消去する動作、(2)当該消去の後、PC1に第1ブートローダ(書換部のみ)の送信要求を行い、この要求に応じて送信されてきた第1ブートローダを第2ブロックにライトする動作、(3)ライトの動作が正常終了したか否かを判定する動作、(4)正常終了したときは、ブートフラグを「1」にセットして再起動を開始する動作、および(5)正常終了していないときは判定プログラム(既にCPU4がリードしているもの、或いは、補助フラッシュメモリ7に格納されているもの)に基づく動作を再度行う動作を、CPU4に実行させるプログラムとなっている。 The “second boot loader” in the present embodiment is (1) an operation for erasing the program stored in the second block, and (2) a transmission request for the first boot loader (only the rewriting unit) to the PC 1 after the erasure. To write the first boot loader transmitted in response to this request to the second block, (3) an operation to determine whether or not the write operation has ended normally, and (4) The boot flag is set to “1” and the restart is started, and (5) the determination program (which is already read by the CPU 4 or stored in the auxiliary flash memory 7 when not normally completed) It is a program that causes the CPU 4 to execute an operation for performing the operation based on the above-described operation again.
 また本実施形態の「初期プログラム」は、補助フラッシュメモリ7に格納されている判定プログラムをリードして実行を開始する動作を、CPU4に実行させるプログラムとなっている。 In addition, the “initial program” of the present embodiment is a program that causes the CPU 4 to execute an operation of starting execution by reading the determination program stored in the auxiliary flash memory 7.
 そのためフラッシュメモリ5には、第1ブートローダとしては書換部だけが格納され、プログラム更新動作が実行される度に、新たなバージョンのものに更新される。一方で、補助フラッシュメモリ7に格納されている判定プログラムは、プログラム更新動作が実行されても書き換えられない。 Therefore, only the rewrite unit is stored in the flash memory 5 as the first boot loader, and is updated to a new version each time the program update operation is executed. On the other hand, the determination program stored in the auxiliary flash memory 7 is not rewritten even if the program update operation is executed.
 このように本実施形態に係るプログラム更新動作によれば、判定プログラム、すなわち第1実施形態における判定部に相当するプログラムについては、更新が省略されるようになっている。そのため、マイコン2におけるプログラム更新動作の処理負担を、軽減させることが可能となっている。 As described above, according to the program update operation according to the present embodiment, the update of the determination program, that is, the program corresponding to the determination unit in the first embodiment is omitted. Therefore, the processing load of the program update operation in the microcomputer 2 can be reduced.
3.その他
 以上までに説明した通り、マイコン2(処理装置)は、プログラムを格納する第1ブロック(第1領域)と、第1ブロックでのプログラムの書換を実行させる第1ブートローダを格納する第2ブロック(第2領域)と、を有するフラッシュメモリ5(不揮発性メモリ)を備え、第1ブロックに格納されているメインプログラムに基づいて処理を行う。
3. Others As described above, the microcomputer 2 (processing device) includes the first block (first area) for storing the program and the second block for storing the first boot loader for executing rewriting of the program in the first block. And a flash memory 5 (nonvolatile memory) having (second area), and performs processing based on the main program stored in the first block.
 またマイコン2は、新メインプログラム、新第1ブートローダ、および第2ブロックでのプログラムの書換を実行させる第2ブートローダが用意された(PC1から適宜受取ることができる)状況において、第1ブロックに格納されている現メインプログラムを新メインプログラムに、第2ブロックに格納されている現第1ブートローダを新第1ブートローダに、それぞれ更新するプログラム更新動作を行う。 The microcomputer 2 is stored in the first block in a situation where a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second block are prepared (can be appropriately received from the PC 1). A program update operation is performed to update the current main program stored in the new main program and the current first boot loader stored in the second block into the new first boot loader.
 そしてこのプログラム更新動作は、現第1ブートローダに基づいて、第1ブロックに格納されている現メインプログラムを第2ブートローダに書き換える1回目書換動作(第1更新動作)、第1ブロックに書き込まれた第2ブートローダに基づいて、第2ブロックに格納されている現第1ブートローダを新第1ブートローダに書き換える2回目書換動作(第2更新動作)、および、第2ブロックに書き込まれた新第1ブートローダに基づいて、第1ブロックに格納されている第2ブートローダを新メインプログラムに書き換える3回目書換動作(第3更新動作)を含んでいる。 This program update operation is written to the first block, the first rewrite operation (first update operation) for rewriting the current main program stored in the first block to the second boot loader based on the current first boot loader. Based on the second boot loader, the second rewrite operation (second update operation) for rewriting the current first boot loader stored in the second block to the new first boot loader, and the new first boot loader written in the second block 3 includes a third rewrite operation (third update operation) in which the second boot loader stored in the first block is rewritten to the new main program.
 そのためマイコン2は、プログラム更新動作を行うことにより、ブートローダを退避させるためのメモリを要せず、安全に、かつ、第1ブートローダの格納領域とメインプログラムの格納領域の移動が発生しないように、メインプログラムと第1ブートローダの更新を行うことが可能となっている。 Therefore, the microcomputer 2 does not require a memory for saving the boot loader by performing the program update operation, so that the storage area of the first boot loader and the storage area of the main program do not move safely. The main program and the first boot loader can be updated.
 またマイコン2は、より具体的には、「0」および「1」の何れか一方となるフラグが「0」であるときは、第1ブロックに格納されているプログラムに基づいて動作し、該フラグが「1」であるときは、第2ブロックに格納されているプログラムに基づいて動作すること(「フラグ判定動作」とする)を行う。 More specifically, the microcomputer 2 operates based on the program stored in the first block when the flag that is either “0” or “1” is “0”. When the flag is “1”, the operation is performed based on the program stored in the second block (referred to as “flag determination operation”).
 そして第1ブートローダは、第1ブロックに格納されているプログラムを、自身に対応している用意されたプログラム(第2ブートローダまたはメインプログラム)に書き換えさせるとともに、フラグの状態を変更させた上で、再起動を実行させるプログラムである。また第2ブートローダは、第2ブロックに格納されているプログラムを、自身に対応している用意されたプログラム(第1ブートローダ)に書き換えさせるとともに、フラグの状態を変更させた上で、再起動を実行させるプログラムである。 Then, the first boot loader rewrites the program stored in the first block with a prepared program (second boot loader or main program) corresponding to itself and changes the state of the flag. It is a program that executes a restart. The second boot loader rewrites the program stored in the second block with a prepared program (first boot loader) corresponding to itself, changes the flag state, and restarts the program. It is a program to be executed.
 また第1実施形態における第1ブートローダは、マイコン2(CPU4)に対して、第1ブロックでのプログラムの書換を実行させる書換部と、フラグ判定動作を実行させる判定部と、を有している。また第2実施形態における第1ブートローダは、マイコン2(CPU4)に対して、第1ブロックでのプログラムの書換を実行させる書換部を有している一方、フラグ判定動作を実行させるプログラムは有していない。第2実施形態では、フラグ判定動作を実行させるプログラムは判定プログラムとして、補助フラッシュメモリ7に格納され、プログラム更新動作によっては書き換えられないようになっている。 The first boot loader in the first embodiment includes a rewriting unit that causes the microcomputer 2 (CPU 4) to rewrite a program in the first block, and a determination unit that executes a flag determination operation. . In addition, the first boot loader in the second embodiment has a rewriting unit that causes the microcomputer 2 (CPU 4) to rewrite the program in the first block, while it has a program that executes the flag determination operation. Not. In the second embodiment, the program for executing the flag determination operation is stored in the auxiliary flash memory 7 as a determination program and cannot be rewritten by the program update operation.
 以上、本発明の実施形態について説明したが、本発明はこの内容に限定されるものではない。また本発明の実施形態は、本発明の主旨を逸脱しない限り、種々の改変を加えることが可能である。 As mentioned above, although embodiment of this invention was described, this invention is not limited to this content. The embodiments of the present invention can be variously modified without departing from the gist of the present invention.
 本発明は、プログラムに基づいて処理を行う各種装置に利用することができる。 The present invention can be used for various devices that perform processing based on a program.
   1  PC
   2  マイコン(処理装置)
   3  通信I/F
   4  CPU
   5  フラッシュメモリ(不揮発性メモリ)
   6  EEPROM
   7  補助フラッシュメモリ
1 PC
2 Microcomputer (processing equipment)
3 Communication I / F
4 CPU
5 Flash memory (nonvolatile memory)
6 EEPROM
7 Auxiliary flash memory

Claims (6)

  1.  プログラムを格納する第1領域と、第1領域でのプログラムの書換を実行させる第1ブートローダを格納する第2領域と、を有する不揮発性メモリを備え、
     第1領域に格納されているメインプログラムに基づいて処理を行う処理装置であって、
     新メインプログラム、新第1ブートローダ、および第2領域でのプログラムの書換を実行させる第2ブートローダが用意された状況において、第1領域に格納されている現メインプログラムを新メインプログラムに、第2領域に格納されている現第1ブートローダを新第1ブートローダに、それぞれ更新するプログラム更新動作を行うものであり、
     前記プログラム更新動作は、
     現第1ブートローダに基づいて、第1領域に格納されている現メインプログラムを第2ブートローダに書き換える第1更新動作、
     第1領域に書き込まれた第2ブートローダに基づいて、第2領域に格納されている現第1ブートローダを新第1ブートローダに書き換える第2更新動作、および、
     第2領域に書き込まれた新第1ブートローダに基づいて、第1領域に格納されている第2ブートローダを新メインプログラムに書き換える第3更新動作、
     を含むことを特徴とする処理装置。
    A non-volatile memory having a first area for storing a program and a second area for storing a first boot loader that executes rewriting of the program in the first area;
    A processing device that performs processing based on a main program stored in a first area,
    In a situation where a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second area are prepared, the current main program stored in the first area is changed to the second main program. A program update operation for updating the current first boot loader stored in the area to the new first boot loader,
    The program update operation is:
    A first update operation for rewriting the current main program stored in the first area to the second boot loader based on the current first boot loader;
    A second update operation for rewriting the current first boot loader stored in the second area with the new first boot loader based on the second boot loader written in the first area; and
    A third update operation for rewriting the second boot loader stored in the first area with the new main program based on the new first boot loader written in the second area;
    The processing apparatus characterized by including.
  2.  起動時において、第1状態および第2状態の何れか一方となるフラグが第1状態であるときは、第1領域に格納されているプログラムに基づいて動作し、該フラグが第2状態であるときは、第2領域に格納されているプログラムに基づいて動作する、フラグ判定動作を行う請求項1に記載の処理装置であって、
     前記第1ブートローダは、
     第1領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えさせるとともに、前記フラグの状態を変更させた上で、再起動を実行させるプログラムであり、
     前記第2ブートローダは、
     第2領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えさせるとともに、前記フラグの状態を変更させた上で、再起動を実行させるプログラムであることを特徴とする処理装置。
    At startup, when the flag that is in either the first state or the second state is in the first state, it operates based on the program stored in the first area, and the flag is in the second state The processing apparatus according to claim 1, wherein the processing unit performs a flag determination operation that operates based on a program stored in the second area.
    The first boot loader is
    The program stored in the first area is rewritten with a prepared program corresponding to itself, and the state of the flag is changed, and then the program is restarted.
    The second boot loader is
    The program stored in the second area is rewritten with a prepared program corresponding to itself, and the program is restarted after changing the state of the flag. Processing equipment.
  3.  前記第1ブートローダは、
     第1領域でのプログラムの書換を実行させる書換部と、
     前記フラグ判定動作を実行させる判定部と、
     を有していることを特徴とする請求項2に記載の処理装置。
    The first boot loader is
    A rewriting unit for executing rewriting of the program in the first area;
    A determination unit for executing the flag determination operation;
    The processing apparatus according to claim 2, further comprising:
  4.  前記第1ブートローダは、
     第1領域でのプログラムの書換を実行させる書換部を有する一方、
     前記フラグ判定動作を実行させるプログラムを有していないことを特徴とする請求項2に記載の処理装置。
    The first boot loader is
    While having a rewriting unit for executing rewriting of the program in the first area,
    The processing apparatus according to claim 2, wherein the processing apparatus does not have a program for executing the flag determination operation.
  5.  プログラムを格納する第1領域と、第1領域でのプログラムの書換を実行させる第1ブートローダを格納する第2領域と、を有する不揮発性メモリを備え、第1領域に格納されているメインプログラムに基づいて処理を行う処理装置が、プログラムを更新する方法であって、
     新メインプログラム、新第1ブートローダ、および第2領域でのプログラムの書換を実行させる第2ブートローダが用意された状況において、第1領域に格納されている現メインプログラムを新メインプログラムに、第2領域に格納されている現第1ブートローダを新第1ブートローダに、それぞれ更新する方法であり、
     現第1ブートローダに基づいて、第1領域に格納されている現メインプログラムを第2ブートローダに書き換える第1更新ステップ、
     第1領域に書き込まれた第2ブートローダに基づいて、第2領域に格納されている現第1ブートローダを新第1ブートローダに書き換える第2更新ステップ、および、
     第2領域に書き込まれた新第1ブートローダに基づいて、第1領域に格納されている第2ブートローダを新メインプログラムに書き換える第3更新ステップ、
     を含むことを特徴とするプログラム更新方法。
    The main program stored in the first area includes a non-volatile memory having a first area for storing a program and a second area for storing a first boot loader that executes rewriting of the program in the first area. A processing device that performs processing based on a method for updating a program,
    In a situation where a new main program, a new first boot loader, and a second boot loader for executing program rewriting in the second area are prepared, the current main program stored in the first area is changed to the second main program. Updating the current first boot loader stored in the area to a new first boot loader,
    A first updating step of rewriting the current main program stored in the first area to the second boot loader based on the current first boot loader;
    A second updating step of rewriting the current first boot loader stored in the second area with the new first boot loader based on the second boot loader written in the first area; and
    A third update step of rewriting the second boot loader stored in the first area with the new main program based on the new first boot loader written in the second area;
    A program update method comprising:
  6.  第1領域および第2領域を有する不揮発性メモリを備えた処理装置に、プログラムの更新を行わせるプログラムであって、
     起動時において、第1状態および第2状態の何れか一方となるフラグが第1状態であるときは、第1領域に格納されているプログラムに基づいて動作し、前記フラグが第2状態であるときは、第2領域に格納されているプログラムに基づいて動作する、フラグ判定動作を行わせるプログラムと、
     第1領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えるとともに、前記フラグの状態を変更させた上で、再起動を実行する動作を行わせるプログラムと、
     第2領域に格納されているプログラムを、自身に対応している用意されたプログラムに書き換えるとともに、前記フラグの状態を変更させた上で、再起動を実行する動作を行わせるプログラムと、
     を有することを特徴とするプログラム。
    A program for causing a processing device including a nonvolatile memory having a first area and a second area to update a program,
    At startup, when the flag that is in either the first state or the second state is in the first state, the flag operates in the first area and the flag is in the second state A program that operates based on a program stored in the second area and that performs a flag determination operation;
    Rewriting the program stored in the first area to a prepared program corresponding to itself, changing the state of the flag, and performing an operation of executing a restart; and
    Rewriting the program stored in the second area to a prepared program corresponding to itself, changing the state of the flag, and performing an operation of executing a restart; and
    The program characterized by having.
PCT/JP2011/077937 2010-12-08 2011-12-02 Processing device, program update method, and program WO2012077604A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012547831A JPWO2012077604A1 (en) 2010-12-08 2011-12-02 Processing apparatus, program update method, and program

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2010-273187 2010-12-08
JP2010273187 2010-12-08

Publications (1)

Publication Number Publication Date
WO2012077604A1 true WO2012077604A1 (en) 2012-06-14

Family

ID=46207092

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2011/077937 WO2012077604A1 (en) 2010-12-08 2011-12-02 Processing device, program update method, and program

Country Status (2)

Country Link
JP (1) JPWO2012077604A1 (en)
WO (1) WO2012077604A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2017151510A (en) * 2016-02-22 2017-08-31 Kyb株式会社 controller
CN111488168A (en) * 2019-12-25 2020-08-04 湖北航天飞行器研究所 Weapon system control software safety upgrading method based on boot secondary loading
CN111580842A (en) * 2020-04-16 2020-08-25 北京遥感设备研究所 On-line upgrading method and system for vehicle-mounted millimeter wave radar application program

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004318350A (en) * 2003-04-15 2004-11-11 Matsushita Electric Ind Co Ltd Updating method of control program
JP2007193596A (en) * 2006-01-19 2007-08-02 Nec Corp Firmware updating circuit and firmware updating method
JP2007316800A (en) * 2006-05-24 2007-12-06 Mitsubishi Electric Corp Onboard program rewriting controller

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004318350A (en) * 2003-04-15 2004-11-11 Matsushita Electric Ind Co Ltd Updating method of control program
JP2007193596A (en) * 2006-01-19 2007-08-02 Nec Corp Firmware updating circuit and firmware updating method
JP2007316800A (en) * 2006-05-24 2007-12-06 Mitsubishi Electric Corp Onboard program rewriting controller

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2017151510A (en) * 2016-02-22 2017-08-31 Kyb株式会社 controller
CN111488168A (en) * 2019-12-25 2020-08-04 湖北航天飞行器研究所 Weapon system control software safety upgrading method based on boot secondary loading
CN111488168B (en) * 2019-12-25 2023-09-12 湖北航天飞行器研究所 Weapon system control software safety upgrading method based on boot secondary loading
CN111580842A (en) * 2020-04-16 2020-08-25 北京遥感设备研究所 On-line upgrading method and system for vehicle-mounted millimeter wave radar application program

Also Published As

Publication number Publication date
JPWO2012077604A1 (en) 2014-05-19

Similar Documents

Publication Publication Date Title
US7664923B2 (en) Method and system for updating software
CN102023908B (en) Method and device for backing up boot program
WO2022007656A1 (en) Bootloader software updating method and apparatus, embedded controller, and storage medium
WO2010035596A1 (en) Firmware update device and method
US8136108B2 (en) Updating firmware with multiple processors
JP6070360B2 (en) Information processing apparatus and processing method thereof
TWI722269B (en) Firmware updating method and electronic device using the same
WO2012079400A1 (en) Method and apparatus for upgrading embedded system bootrom
JP2010170197A (en) Firmware management program, storage device, and firmware management method
WO2012077604A1 (en) Processing device, program update method, and program
JP6074064B2 (en) Electronics
CN111026417A (en) Embedded equipment upgrading method and embedded equipment
CN110688141A (en) Firmware updating method
JP6575157B2 (en) Firmware download method and firmware embedded device
JP2012174061A (en) Information processing device, information processing method, scanner device, and control method of scanner device
JP6192089B2 (en) Information processing apparatus, control method and control program for information processing apparatus
JP2002189609A (en) System and method for updating software adapted to accident
JPH1063497A (en) Program updating method
JP2002175193A (en) Device and method for rewriting program
JP5158883B2 (en) Firmware update method and firmware update apparatus
JP5418348B2 (en) Information processing apparatus and karaoke apparatus
KR20080042502A (en) Electronic control unit for vehicle and method of control program setup thereof
JPH06222986A (en) Memory controller
JP7491765B2 (en) Firmware update system and firmware update method
CN113126883B (en) Data processing method, system and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11846585

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2012547831

Country of ref document: JP

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11846585

Country of ref document: EP

Kind code of ref document: A1