This application is based on Japanese Patent Application 2004-358974 filed on Dec. 10, 2004. The descriptions of the Patent Application are therefore all incorporated herein by reference.
1. Field of the Invention
The present invention relates to techniques for rewriting application programs while they are being mounted on/in a circuit board installed in an electronic control unit (ECU); these application programs are executable by a computer of the ECU. The electronic control unit will be abbreviated as ECU hereinafter.
2. Description of the Related Art
ECUs, which are preferably installed in an automobile and operative to control a target, such as an engine installed therein, have been well known, one example of which is disclosed in Japanese Unexamined Patent Publication No. H10-105468. In the ECU disclosed in the Publication, an application program for controlling a target(s) has been stored in a nonvolatile rewritable memory, such as a flash ROM (Reed Only Memory), EEPROM (Electrical Erasable Programmable Rom), or the like. The nonvolatile rewritable memory has been mounted, as a component of a computer, on/in a circuit board of the ECU. The computer of the ECU is operative to rewrite the application program in the nonvolatile rewritable memory without removing it from the circuit board of the ECU.
In such an ECU, when rewriting an earlier application program in a rewritable memory, first, an external device, such as a computer device, is prepared to be communicably connected to the ECU through a communication line. Next, a write request is sent from the external device to a computer of the ECU through the communication line as a command; this write request allows the computer to shift its operation mode into a mode (application program rewritable mode) in which the computer can rewrite application programs stored in the rewritable memory. Note that the write request can be transmitted from the external device to the ECU through a signal line different from the communication line.
After transmission of the write request, a rewrite control program is sent from the external device to the computer of the ECU; the rewrite control program is designed to cause a computer to:
receive a new application program sent from the external device; and
update the earlier application program to the received new application program.
Specifically, after sending of the rewrite control program, the new application program is sent from the external device to the computer of the ECU.
On the other hand, when receiving the write request, the computer of the ECU runs a boot loader (boot program) previously stored in the nonvolatile rewritable memory thereof. The boot loader causes the computer to:
receive the rewrite control program to download it in a RAM (Random Access Memory) of the computer; and
launch the rewrite control program stored in the RAM.
Specifically, as the launching process, the boot loader causes the execution location of the computer to jump to the leading address of the rewrite control program in the RAM. After jump of the computer's execution location, the computer executes the rewrite control program in the RAM to receive the new application program transferred from the external device, thereby updating the earlier application program to the received new application program in the rewritable memory.
These application-program rewriting operations set forth above are disclosed in the aforementioned Unexamined Patent Publication.
Specifically, these application-program rewriting operations allow the earlier application program to be rewritten into the new application program in the rewritable memory. For example, an earlier version of the application program can be updated to a new version thereof in the rewritable memory.
When no application programs to be updated has been stored in the rewritable memory, the new application program sent from the external device is stored in the rewritable memory.
In the Unexamined Patent Publication, the rewrite control program and the new application program have been stored in the external device as different files. The boot loader to be executed by the computer of the ECU serves as download of the rewrite control program into the RAM, and jump of the execution location of the computer to the leading address of the rewrite control program.
Such external devices for rewriting application programs in, for example, automobile field use any one of typically three different application-program sending ways (programs, procedures) A to C. A, B, and C types of external devices employ the application-program sending ways A, B and C, respectively.
Specifically, the A type of external devices is configured to have stored therein a rewrite control program and a new application program in different files.
The B type of external devices is configured to have stored therein a rewrite control program and a new application program in the same single file.
The C type of external devices is configured to have stored therein a new application program without storing a rewrite control program. This is because the C type of external devices is designed on the understanding that the rewrite control program has been stored in a nonvolatile memory of a computer of the ECU.
In order to rewrite an earlier application program stored in the ECU, in an external device of the A type, the rewrite control program and the new application program are separately sent from the external device of the A type to the ECU.
In contrast, in an external device of the B type, the rewrite control program and the new application program have been stored in the same single file, so that, in order to rewrite an earlier application program stored in the ECU, they are sent from the external device of the B type to the ECU in file. For this reason, the boot loader being executed by the computer of the ECU does not cause the computer to identify the end address of the rewrite control program. This results in that download of the rewrite control program into the RAM may come to nothing, making it difficult to accurately update the earlier application program.
In addition, because no rewrite control program is sent from an external device of the C type to the ECU, the boot loader being executed by the computer of the ECU may cause the computer to erroneously download the new application program sent from the external device of the C type into the RAM as the rewrite control program. This may also make it difficult to accurately update the earlier application program.
It may be considered that boot loaders (boot programs) are designed exclusively for the types A, B, and C of external devices. This may cause the number of processes for developing the dedicated boot loaders for the types A to C of external devices to increase. In addition, it may be necessary to select one of the boot loaders to match any one of the types of an external device used, causing management of the dedicated boot loaders and the external devices of the types A to C to become complicated.
If one of the boot loaders, which does not match the type of an external device used, is installed in the computer of the ECU, earlier application programs, which have been already installed in the computer of the ECU, cannot be updated to new ones.
The present invention has been made on the background set forth above. Specifically, at least one preferable embodiment of the present invention provides a program rewriting system and an electronic control unit, which are capable of meeting any different application-program sending ways employed by external devices.
According to a first aspect of the present invention, there is provided a system communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The system includes a receiving unit configured to receive an identifier sent from the external device. The identifier decides a sending timing of the second application program from the external device. The system also includes an identification unit configured to identify that the write target data sent from the external device is at least a module of the second application program after the identifier is received by the receiving unit.
According to a second aspect of the present invention, there is provided a system communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The system includes a determining unit configured to determine whether to receive an identifier sent from the external device. The identifier decides a sending timing of the second application program from the external device. The system also includes a first identification unit configured to identify that the write target data sent from the external device is at least a module of the rewrite control program until it is determined that the identifier is received. The system further includes a second identification unit configured to identify that the write target data sent from the external device is at least a module of the second application program after it is determined that the identifier is received.
According to a third aspect of the present invention, there is provided a program product having a boot loader installed in a system. The system is communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The boot loader includes first means for instructing a computer to determine whether to receive an identifier sent from the external device. The identifier decides a sending timing of the second application program from the external device. The boot loader also includes second means for instructing a computer to identify that the write target data sent from the external device is at least a module of the rewrite control program until it is determined that no identifier is received. The boot loader further includes third means for instructing a computer to identify that the write target data sent from the external device is at least a module of the second application program after it is determined that the identifier is received.
According to a fourth aspect of the present invention, there is provided a signal bearing media bearing the boot loader according to the third aspect of the present invention.
According to a fifth aspect of the present invention, there is provided a vehicle control unit for controlling a target installed in a vehicle. The vehicle control unit includes a computer and the signal bearing media according to the third aspect of the present invention. The signal bearing media is readable by the computer.
According to a sixth aspect of the present invention, there is provided a system communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The system includes a receiving unit configured to receive destination information sent from the external device. The destination information indicates an address at which the write target data is written. The system also includes a determining unit configured to determine whether the destination information indicates an address in the first memory. The system further includes an identification unit configured to identify that the write target data sent from the external device is at least a module of the second application program after it is determined that the destination information indicates an address in the first memory.
According to a seventh aspect of the present invention, there is provided a system communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The system includes a receiving unit configured to receive destination information sent from the external device. The destination information indicates an address at which the write target data is written. The system also includes a determining unit configured to determine whether the destination information indicates an address in the first memory. The system further includes a first identification unit configured to identify that the write target data sent from the external device is at least a module of the rewrite control program until it is determined that the destination information indicates an address in the first memory. The system still further includes a second identification unit configured to identify that the write target data sent from the external device is at least a module of the second application program after the it is determined that the destination information indicates an address in the first memory.
According to an eighth aspect of the present invention, there is provided a program product having a boot loader installed in a system. the system is communicably coupled to an external device at least when rewriting, at least in a module, a first application program stored in a first memory of the system into a second application program stored in the external device. The external device is configured to send, to the system, the second application program based on first and second different ways. The first way is to send, to the system, a rewrite control program stored in the external device as write target data, and the second application program next to the rewrite control program as the write target data. The second way is to send, to the system, the second application program as the write target data without sending the rewrite control program. The rewrite control program allows the system to rewrite the first application program into the second application program. The boot loader includes first means for instructing a computer to determine whether the destination information indicates an address in the first memory. The boot loader also includes second means for instructing a computer to identify that the write target data sent from the external device is at least a module of the rewrite control program until it is determined that the destination information indicates an address in the first memory. The boot loader includes third means for instructing a computer to identify that the write target data sent from the external device is at least a module of the second application program after the it is determined that the destination information indicates an address in the first memory.
According to a ninth aspect of the present invention, there is provided a signal bearing media bearing the boot loader according to the eighth embodiment.
According to a tenth aspect of the present invention, there is provided a vehicle control unit for controlling a target installed in a vehicle. The vehicle control unit includes a computer and the signal bearing media according to the eighth aspect of the present invention; this signal bearing media is readable by the computer.
Other objects and aspects of the invention will become apparent from the following description of an embodiment with reference to the accompanying drawings in which:
Embodiments of the present invention will be described hereinafter with reference to the attached figures.
Referring to
The ECU 1 includes a microcomputer 7 and a communication driver 9 for allowing the microcomputer 7 to communicate with the external tool 5 through the communication line 3. The microcomputer 7 includes a CPU 11 operative to run programs, a flash ROM 13 as an example of nonvolatile rewritable memories, and a RAM 15 as an example of volatile memories, which serves as a main working memory of the microcomputer 7. For example, the elements of the microcomputer 7 are mounted on/in a circuit board of the ECU 1.
The flash ROM 13 has stored therein an earlier application program AP1 and a boot loader BL. The boot loader BL causes the CPU 11 to, when a write request is sent from the external tool 5 to the microcomputer 7, launch a rewrite control program RP, described hereinafter, stored in the RAM 15. The write request allows the CPU 11 to shift its operation mode into a mode in which the CPU 11 can rewrite application programs stored in the flash ROM 13. The rewrite control program causes the CPU 11 to update the earlier application program AP1 to a new application program. The boot loader BL can be stored in a ROM of the microcomputer 7. In addition, the write request is configured to be sent from the external tool 5 to the ECU 1 when a predetermined operation is executed in the external tool 5.
In the first embodiment, as the external tool 5, any one of three types A, B, and C of external tools 5a to 5c can be used. The three types A to C of external tools 5a to 5c employ application-program sending ways A to C, respectively.
Specifically, the A type external tool 5a is configured to have stored therein the rewrite control program RP and a new application program AP2 in different files F1 and F2 (see
The B type external tool 5b is configured to have stored therein the rewrite control program RP and the new application program AP2 in the same single file F3 (see
The C type external tool 5c is configured to have stored therein the new application program AP2 as a file F2 without storing the rewrite control program RP. This is because the C type external tool 5c is designed on the understanding that the rewrite control program RP has been stored in the microcomputer 7 of the ECU 1.
As illustrated in
Similarly, as illustrated in
Each of the external tools 5a to 5c is configured to sequentially send, to the ECU 1 through the communication line 3, data in a predetermined unit quantity of data, such as in 2 bytes.
Specifically, when the ECU 1 has a function capable of communicating with the C type of external tools, the ECU 1 has stored the rewrite control program RP in the flash ROM 13 at a predetermined first address area thereof. Note that the rewrite control program RP can have been stored in another nonvolatile memory, such as a ROM of the microcomputer 7.
Next, operations of each of the external tools 5a to 5c and of the ECU 1 will be described hereinafter when rewriting the earlier application program AP1.
Independently of which external tool is ready to communicate with the ECU 1, when the write request is sent from any one of the external tools 5a to 5c to the ECU 1, the CPU 11 of the microcomputer 7 shifts its execution location from the earlier application program AP1 in the flash ROM 13 to the leading address of the boot loader BL therein.
Next, as illustrated in
When the rewrite control program RP is sent from the A type external tool 5a, the CPU 11 of the microcomputer 7 runs the boot loader BL. The boot loader B1 causes the CPU 11 to receive the rewrite control program RP to sequentially download it in the RAM 15 from a predetermined address (leading address) thereof. After completion of the rewrite control program download, the boot loader BL causes the CPU 11 to shift its execution location to the leading address of the rewrite control program RP.
After completion of sending the rewrite control program RP, the external tool 5a sends, to the ECU 1, the new application program AP2 (the file F2).
On the other hand, after shift of the CPU's execution location to the leading address of the rewrite control program RP, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the rewrite control program RP causes the CPU 11 to execute rewrite (update) operations for updating the new application program AP2 sent from the external tool 5a in the flash ROM 13. The rewrite operations permit the earlier application program AP1 stored in the flash ROM 13 is rewritten into the new application program AP2. If no application programs to be updated has been stored in the flash ROM 13, the new application program AP2 sent from the external tool 5a is stored in the flash ROM 13 in a new entry.
As illustrated in
When the file F2 is sent from the B type external tool 5b, the CPU 11 of the microcomputer 7 runs the boot loader BL. The boot loader BL causes the CPU 11 to receive the file F3 (the rewrite control program RP and the new application program AP2) to sequentially download them in the RAM 15 from a predetermined address (leading address) thereof. After completion of the file F3 download, the boot loader BL causes the CPU 11 to shift its execution location to the leading address of the file P3 (rewrite control program RF1.
Subsequently, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the rewrite control program RP causes the CPU 11 to execute rewrite (update) operations for updating the new application program AP1 sent from the external tool 5a in the flash ROM 13.
On the other hand, as illustrated in
When the file F2 is sent from the C type external tool 5c, the CPU 11 of the microcomputer 7 runs the boot loader BL. The boot loader BL causes the CPU 11 to receive the new application program AF) to sequentially download it in the RAM 15 from a predetermined address (leading address) thereof. After completion of the new application program AP2 download, the boot loader BL causes the CPU 11 to copy the rewrite control program RP previously stored in the flash ROM 13 into the RAM 15 from a predetermined address (leading address) thereof. After completion of the rewrite-control program copy, the boot loader BL causes the CPU 11 to shift its execution location to the leading address of the rewrite control program RP.
Subsequently, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the rewrite control program RP causes the CPU 11 to execute rewrite (update) operations for updating the new application program AP1 sent from the external tool 5a in the flash ROM 13.
Next, the specific instructions (procedures) of the boot loader BL according to the first embodiment will be described hereinafter with reference to
Specifically as set forth above, the CPU 11 of the microcomputer 7 of the ECU 1 shifts its execution location from the earlier application program AP1 to the boot loader BL when the write request is sent from the external tool 5 to the ECU 1. For example, the earlier application program AP1 includes a predetermined procedure to detect that the communication driver 9 receives the write request sent from the external tool 5. As a result, when the CPU 11 executes the predetermined procedure while executing the earlier application program AP1, the CPU 11 executes the procedures of the boot loader BL illustrated in
When the CPU 11 launches the procedures of the boot loader BL, in step S110, the CPU 11 receives a unit quantity of the data sent from the external tool 5 and received by the communication driver 9. Next, in step S120, the CPU 11 analyzes the received unit quantity of data to determine whether the received unit quantity of data is the write request based on the analyzed result.
If it is determined that the write request has been received (the determination in step S120 is YES), the CPU 11 goes to step S130 to execute an operation required to send, to the external tool 5, a response to the write request, and thereafter returning to the step S110. The response to the write request is a response message indicating, to the external tool 5, that the write request is normally received.
When it is determined that the write request has not been received (the determination in step S120 is NO), the CPU 11 goes to step S140. In step S140, the CPU 11 analyzes the received unit quantity of data in step S110 to determine whether the received unit quantity of data is a data download request based on the analyzed result.
The data download request is a command to indicate, to the ECU 1, that the external tool 5 starts to send data to be written except for commands; this data to be rewritten specifically is the rewrite control program RP or the new application program AP2. The data download request also includes download-data size information indicating the total volume of the data to be written. The data to be written will be referred to as write target data or write data hereinafter.
When it is determined that the data download request has been received (the determination in step S140 is YES), the CPU 11 goes to step S150 to store the download-data size information in the RAM 15. Subsequently, in the next step S160, the CPU 11 executes an operation required to send, to the external tool 5, a response to the data download request, and thereafter returning to the step S110. The response to the data download request is a response message indicating, to the external tool 5, that the data download request is normally received.
When it is determined that the data download request has not been received (the determination in step S140 is NO), the CPU 11 goes to step S170. In step S170, the CPU 11 analyzes the received unit quantity of data in step S110 to determine whether the received unit quantity of data is a part of the write target data based on the analyzed result. Note that, in step S170, it is determined that the ROM identification code CD belongs to the write target data.
When it is determined that the write target data has not been received (the determination in step S170 is NO), the CPU 11 returns to step S110. When it is determined that the write target data has been received (the determination in step S170 is YES), the CPU 11 goes to step S180. In step S180, the CPU 111 executes a transfer determining program, such as a subroutine, illustrated in
When launching the transfer determining program, the CPU 11 analyzes the received data in step S110 to determine whether the received data is the ROM identification code CD based on the analyzed result in step S210 of
When it is determined that ROM identification code CD has not been received (the determination in step S210 is NO), the CPU 11 goes to step S220. In step S220, the CPU 11 sets a rewrite control program download flag DF in its register; this flag DF indicates that the download of the rewrite control program RP has been completed. Next, the CPU 11 writes the current received data, that is, the write target data, into the RAM 15 at a predetermined address thereof as data constituting the rewrite control program RP in step S230.
In the next step S240, the CPU 11 determines whether received data volume is equivalent to the total volume indicated by the download-data size information stored in the RAM 15 in step S150. In other words, the CPU 11 determines whether the download-data size of the write target data has been entirely written in the RAM 15 in step S240.
When it is determined that the download-data size of the write target data has not been entirely written in the RAM 15 (the determination in step S240 is NO), the CPU 11 exits from the transfer determining program, returning to step S110.
In step S240, when it is determined that the download-data size of the write target data has been entirely written in the RAM 15 (the determination in step S240 is YES), the CPU 11 goes to step S250. In step S250, the CPU 11 executes an operation required to send, to the external tool 5, a response to the write data transfer, and thereafter exits from the transfer determining program, returning to step S110. The response to the write data transfer is a response message indicating, to the external tool 5, that the download-data size of the write target data has been entirely written in the RAM 15.
On the other hand, in step S210, when it is determined that ROM identification code CD has been received (the determination in step S210 is YES), the CPU 11 goes to step S260. In step S260, the CPU 11 determines whether the rewrite control program download flag DF is set to its register.
When it is determined that the rewrite control program download flag DF is set to its register (the determination in step S260 is YES), the CPU 11 goes to step S270. In step S270, the CPU 11 shifts its execution location to the leading address of the rewrite control program RP in the RAM 15.
Thereafter, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the CPU 11 executes the rewrite operations to update the new application program AP2 sent from the external tool 5 in the flash ROM 13. After completion of the new application program update, the CPU 11 sends, to the external tool 5, the response to the write data transfer.
In step S260, when it is determined that the rewrite control program download flag DF is not set to its register (the determination in step S260 is NO), the CPU 11 determines that the rewrite control program RP sent from the external tool 5 has not been stored in the RAM 15, going to step S280. In step S280, the CPU 11 copies the rewrite control program RP previously stored in the flash ROM 13 at the first address area into the RAM 15 from the leading address thereof. After completion of the rewrite control program copy, the CPU 11 shifts to the step S270.
In this case, the CPU 11 executes the rewrite control program RP copied from the flash ROM 13 into the RAM 15 in step S280.
Thereafter, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the CPU 11 executes the rewrite operations to update the new application program AP2 sent from the external tool 5 in the flash ROM 13. After completion of the new application program update, the CPU 11 sends, to the external tool 5, the response to the write data transfer.
Next, individual operations of each of the external tools 5a to 5c-23 and of the ECU 1 will be described hereinafter with reference to FIGS. 6 to 8.
First,
As illustrated by the reference numeral (1) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S120, and the response to the write request is sent therefrom to the A type external tool 5a in step S130, which is illustrated by the reference numeral (2) in
When receiving the response to the write request, the A type external tool 5a sends, to the ECU 1, the data download request, as a preparation for sending the rewrite control program RP, which is illustrated by the reference numeral (3) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S140. Next, the download-data size information is stored in the RAM 15 by the CPU 11 in step S150, and the response to the data download request is sent therefrom to the A type external tool 5a in step S160, which is illustrated by the reference numeral (4) in
When receiving the response to the data download request, the A type external tool 5a sends (downloads), to the ECU 1, the rewrite control program RP stored as the file F1 as the write target data, which is illustrated by the reference numeral (5) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S170. Next, the transfer determining program is executed by the CPU 11 in step S180 illustrated in
In the transfer determining program, when the rewrite control program RP is sent from the A type external tool 5a, because the ROM identification code CD has not been sent therefrom, the negative determination is executed by the CPU 11 in step S210. Next, the rewrite control program download flag DF is set in the register by the CPU 11 in step S220, and a unit quantity of the rewrite control program RP is written in the RAM 15 by the CPU 11 in step S230.
In the boot loader BL, every time a unit quantity of the rewrite control program RP is sent from the A type control tool 5a, the affirmative determination is executed by the CPU 11 in step S220 and the operations in step S230 are executed thereby. As a result, when the total volume of the rewrite control program RP has been entirely written in the RAM 15, the affirmative determination is executed by the CPU 11 in step S240. Next, the response to the write data transfer is sent from the CPU 11 to the A type external tool 5a in step S250, which is illustrated by the reference numeral (6) in
When receiving the response to the response to the rewrite data, the A type external tool 5a sends, to the ECU 1, the data download request as a preparation for sending the rewrite control program RP, which is illustrated by the reference numeral (7) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S140. Next, the download-data size information is stored in the RAM 15 by the CPU 11 in step S150, and the response to the data download request is sent therefrom to the A type external tool 5a in step S160, which is illustrated by the reference numeral (8) in
When receiving the response to the data download request, the A type external tool 5a sends (downloads), to the ECU 1, a first unit quantity of the new application program AP2 stored in the file F2 and the write target data, which is illustrated by the reference numeral (9) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S170. Next, the transfer determining program is executed by the CPU 11 in step S180 (see
In the transfer determining program, because the ROM identification code CD has been received by the CPU 11, the affirmative determination is executed by the CPU 11 in step S210. In addition, because the rewrite control program download flag DF has been set in the register by the CPU 11 in step S220 so that the rewrite control program RP has been stored in the RAM 11, the affirmative determination is executed by the CPU 11 in step S260. As a result, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 by the CPU 11 in step S270.
Thereafter, a unit quantity of the new application program AP2 is sequentially sent from the A type external tool 5a to the ECU 1, which is illustrated by the reference numeral (10) in
The rewrite operations by the CPU 11 in accordance with the rewrite control program RP are carried out, for example, as follows. Specifically, a predetermined second address area of the flash ROM 13 in which the earlier application program AP1 is stored is cleared, and each sent unit of the program AP2 is sequentially stored in the second address area of the flash ROM 13.
After all units of the new application program AP2 has been stored in the storage area of the flash ROM 13, the response to the write data transfer is sent from the CPU 1 to the A type external tool 5a based on the rewrite control program RP, which is illustrated by the reference numeral (11) in
Secondly,
In
When receiving the response to the data download request, the B type external tool 5b sends (downloads), to the ECU 1, the data stored in the file F3 as the write target data, which is illustrated by the reference numeral (5) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S170. Next, the transfer determining program is executed by the CPU 11 in step S180 illustrated in
In the transfer determining program, when the rewrite control program RP is sent from the B type external tool 5b, because the ROM identification code CD has not been sent therefrom, the negative determination is executed by the CPU 11 in step S210. Next, the rewrite control program download flag DF is set in the register by the CPU 11 in step S220, and a unit quantity of the rewrite control program RP is written in the RAM 15 by the CPU 11 in step S230.
In the boot loader BL, every time a unit quantity of the rewrite control program RP is sent from the B type control tool 5b, the affirmative determination is executed by the CPU 11 and the operations in step S220 and S230 are executed thereby.
After completion of the send of the rewrite control program RP, the B type external tool 5b sends, to the ECU 1, the ROM identification code CD located at the boundary between the rewrite control program RP and the new application program AP2 as the rewrite target data, which is illustrated by the reference numeral (6) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S170. Next, the transfer determining program is executed by the CPU 111 in step S180 (see
In the transfer determining program, because the ROM identification code CD has been received by the CPU 11, the affirmative determination is executed by the CPU 11 in step S210. In addition, because the rewrite control program download flag DF has been set in the register by the CPU 11 in step S220 so that the rewrite control program RP has been stored in the RAM 11, the affirmative determination is executed by the CPU 11 in step S260. As a result, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 by the CPU 11 in step S270.
Thereafter, a unit quantity of the new application program AP2 is sequentially sent from the B type external tool 5b to the ECU 1, which is illustrated by the reference numeral (7) in
After all units of the new application program AP2 has been stored in the storage area of the flash ROM 13, the response to the write data transfer is sent from the CPU 1 to the B type external tool 5b based on the rewrite control program RP, which is illustrated by the reference numeral (8) in
Thirdly,
In
When receiving the response to the data download request, the C type external tool 5c sends (downloads), to the ECU 1, the data stored in the file F2 as the write target data, which is illustrated by the reference numeral (5) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S170. Next, the transfer determining program is executed by the CPU 11 in step S180 illustrated in
In the transfer determining program, because the ROM identification code CD has been sent from the C type external tool 5c, the affirmative determination is executed by the CPU 11 in step S210. Next, because no rewrite control program RP is downloaded from the C type external tool 5c and the rewrite control program download flag DF has not been set in the register by the CPU 11, the negative determination is executed by the CPU 11 in step S260.
As a result, the rewrite control program RP previously stored in the flash ROM 13 at the first address area is copied into the RAM 15 from the leading address thereof. Thereafter, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 by the CPU 11 in step S270.
After the procedure in step S270, a unit quantity of the new application program AP2 is sequentially sent from the C type external tool 5c to the ECU 1, which is illustrated by the reference numeral (6) in
After all units of the new application program AP2 has been stored in the storage area of the flash ROM 13, the response to the write data transfer is sent from the CPU 1 to the C type external tool 5c based on the rewrite control program RP, which is illustrated by the reference numeral (7) in
As described above, in the program rewriting system RS according to the first embodiment, any type of the external tool 5 is configured to send, to the ECU 1, the ROM identification code CD before sending the new application program AP2; this ROM identification code CD indicates that the following data from the identification code CD is the new application program AP2.
In the boot loader BL installed in the microcomputer 7 used for the ECU 1, when the rewrite control program RP is sent from the external tool 5, it is determined whether the ROM identification code CD has been sent therefrom in step S210. It is determined that the write target data sequentially sent from the external tool 5 is a part of (a module of) the rewrite control program RP until it is determined that the ROM identification code CD has been sent therefrom in step S210. As a result, the write target data is stored in the RAM 15 as part of the rewrite control program RP in step S230. When it is determined that the ROM identification code CD has been sent from the external tool 5 in step S210, it is determined that the write target data sent from the external tool 5 after the determination in step S210 is part of the new application program AP2. Thereafter, it is determined whether the rewrite control program download flag DF has been set in the register of the CPU 11 in order to judge whether the rewrite control program RP sent from the external tool 5 has been stored in the RAM 15.
In step S260, when it is determined that the rewrite control program RP sent from the external tool 5 has been stored in the RAM 15, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 so that the rewrite control program RP runs in step S270. In contrast, when it is determined that the rewrite control program RP has not been stored in the RAM 15 in step S260, the rewrite control program RP is copied to the RAM 15 from the first address area of the flash ROM 13 in step S280. Thereafter, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15, allowing the rewrite control program RP to run in step S270
When the external tool 5 is the A type external tool 5a or the B type external tool 5b, the rewrite control program RP sent from the A type external tool 5a or the B type external tool 5b is stored in the RAM 15. Thereafter, when the ROM identification code CD is sent from the A type external tool 5a or the B type external tool 5b, it is determined that the rewrite control program RP sent from the A type external tool 5a or the B type external tool 5b has been stored in the RAM 15 in step S260. This allows the rewrite control program RP to run. Execution of the rewrite control program RP permits the earlier application program AP1 stored in the flash ROM 13 to be updated to the new application program AP2 therein; this new application program AP2 is sent from the external tool 5a or 5b after the rewrite control program execution.
In contrast, when the external tool 5 is the C type external tool 5c, because no rewrite control program is sent therefrom, when the ROM identification code CD is sent from the C type external tool 5c, it is determined that the rewrite control program RP has not been stored in the RAM 15 in step S260. This allows the rewrite control program RP previously stored in the first address area of the flash ROM 13 is copied to the RAM 15 so that the rewrite control program RP is run on the RAM 15. Thereafter, execution of the rewrite control program RP permits the earlier application program AP1 stored in the flash ROM 13 to be updated to the new application program AP2 therein; this new application program AP2 is sent from the external tool 5c after the rewrite control program execution.
As set forth above, even if using the external tool 5 with any one of the A to C types, the boot loader BL according to the first embodiment allows the earlier application program AP1 to be accurately updated (rewritten) into the new application program AP2.
In addition, the boot loader BL according to the first embodiment eliminates the need to develop dedicated boot loaders for the types A to C of external tools, making it possible to reduce the number of processes for developing the ECU 1 and/or to simplify management of the ECU 1 and the boot loader 7.
Note that, in step S280 of
A program rewriting system according to a second embodiment of the present invention will be described hereinafter. Note that elements of the program rewriting system RS1 according to the second embodiment, which are substantially identical to those of the program rewriting system RS according to the first embodiment, are represented by the same reference characters as in FIGS. 1 to 3. Descriptions of the elements of the program rewriting system according to the second embodiment are therefore omitted or simplified.
As compared with the program rewriting system RS according to the first embodiment, the program rewriting system according to the second embodiment is operative to send a destination address, which for example corresponds to destination information, before sending the write target data, such as the rewrite control program RS or the new application program AP2.
Specifically, the destination address preferably indicates a leading address of a predetermined memory space at which the write target data to be sent should be stored in the target memory, such as the flash ROM 13 or the RAM 15. Any type of the external tool 5 is configured to send, to the ECU 1, the data download request including the destination address of the write target data and the download-data size information.
In addition, in the program rewriting system RS1 according to the second embodiment, no ROM identification codes have been stored in the files F1, F2, and F3 stored in at least one of the A type external tool 5a, B type external tool 5b, and the C type external tool 5c.
Next, the specific instructions (procedures) of the boot loader BL according to the second embodiment will be described hereinafter with reference to
Like the first embodiment, the CPU 11 of the microcomputer 7 of the ECU 1 shifts its execution location from the earlier application program AP1 to the boot loader BL when the write request is sent from the external tool 5 to the ECU 1. When the CPU 11 launches the procedures of the boot loader BL, in step S310, the CPU 11 receives a unit quantity of the data sent from the external tool 5 and received by the communication driver 9. Next, in step S320, the CPU 11 analyzes the received unit quantity of data to determine whether the received unit quantity of data is the write request based on the analyzed result.
If it is determined that the write request has been received (the determination in step S320 is YES), the CPU 11 goes to step S330 to execute an operation required to send, to the external tool 5, a response to the write request, and thereafter returning to the step S310. The response to the write request is a response message indicating, to the external tool 5, that the write request is normally received.
If it is not determined in step S320 (the determination in step S320 is NO), the CPU 11 goes to step S340. In step S340, the CPU 11 analyzes the received unit quantity of data in step S310 to determine whether the received unit quantity of data is the data download request based on the analyzed result.
The data download request is a command to indicate, to the ECU 1, that the external tool 5 starts to send the write target data; this write target data specifically is the rewrite control program RP or the new application program AP2. The data download request includes the download-data size information indicating the total volume of the write target data, and the destination address thereof.
If it is determined that the data download request has been received (the determination in step S340 is YES), the CPU 11 goes to step S350 to store the download-data size information in the RAM 15. Subsequently, in the next step S360, the CPU 11 executes a transfer determining program, such as a subroutine, according to the second embodiment, which is illustrated in
When launching the transfer determining program, the CPU 11 determines whether the destination address included in the data download request is an address in the flash ROM 13 in step S410 of
When it is determined that the destination address included in the data download request is not an address in the flash ROM 13 (the determination in step S410 is NO), the CPU 11 goes to step S420. In step S420, the CPU 11 sets the rewrite control program download flag DF in its register; this flag DF indicates that the download of the rewrite control program RP has been completed. Next, the CPU 11 executes an operation required to send, to the external tool 5, a response to the data download request, and thereafter exits from the transfer determining program, returning to step S110. The response to the data download request is a response message indicating, to the external tool 5, that the data download request is normally received. In this case, after sending the response to the data download request, the rewrite control program RP is sent from the external tool 5 to the ECU 1, and the rewrite control program RP is stored in the RAM 15 by the operation of the CPU 11 in step S380 described hereinafter.
When it is determined that the destination address included in the data download request is an address in the flash ROM 13 (the determination in step S410 is YES), the CPU 11 goes to step S440. In step S440, the CPU 11 determines whether the rewrite control program download flag DF is set to its register.
When it is determined that the rewrite control program download flag DF is set to its register (the determination in step S440 is YES), the CPU 11 determines that the rewrite control program RP sent from the external tool 5 has been stored in the RAM 15, going to step S450. In step S450, the CPU 11 causes its execution location to jump to the leading address of the rewrite control program RP in the RAM 15.
Thereafter, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the CPU 11 executes the rewrite operations to update the new application program AP2 sent from the external tool 5 in the flash ROM 13. After completion of the new application program update, the CPU 11 sends, to the external tool 5, the response to the write data transfer.
In step S440, when it is not determined (the determination in step S440 is NO), the CPU 11 determines that the rewrite control program RP sent from the external tool 5 has not been stored in the RAM 15, going to step S460. In step S460, the CPU 11 copies the rewrite control program RP previously stored in the flash ROM 13 at the first address area into the RAM 15 from the leading address thereof. After completion of the rewrite control program copy, the CPU 11 shifts to the step S450.
In this case, the CPU 11 executes the rewrite control program RP copied from the flash ROM 13 into the RAM 15 in step S460.
Thereafter, the CPU 11 runs the rewrite control program RP from the leading address thereof. Specifically, the CPU 11 executes the rewrite operations to update the new application program AP2 sent from the external tool 5 in the flash ROM 13. After completion of the new application program update, the CPU 11 sends, to the external tool 5, the response to the write data transfer.
On the other hand, in step S340 in
When it is determined that the write target data has not been received (the determination in step S370 is NO), the CPU 11 returns to step S110. When it is determined that the write target data has been received (the determination in step S370 is YES), the CPU 11 goes to step S380. In step S380, the CPU 11 writes the current received data, that is, the write target data, into the RAM 15 at a predetermined address thereof as data constituting the rewrite control program RP.
In the next step S390, the CPU 11 determines whether received data volume is equivalent to the total volume indicated by the download-data size information stored in the RAM 15 in step S350. In other words, the CPU 11 determines whether the download-data size of the write target data has been entirely written in the RAM 15 in step S390.
When it is determined that the download-data size of the write target data has not been entirely written in the RAM 15 (the determination in step S390 is NO), the CPU 11 returns to step S310.
In step S390, when it is determined that the download-data size of the write target data has been entirely written in the RAM 15 (the determination in step S390 is YES), the CPU 11 goes to step S395. In step S395, the CPU 11 executes an operation required to send, to the external tool 5, a response to the write data transfer, and thereafter exits from the transfer determining program, returning to step S310. The response to the write data transfer is a response message indicating, to the external tool 5, that the download-data size of the write target data has been entirely written in the RAM 15.
Next, individual operations of each of the external tools 5a to 5c and of the ECU 1 will be described hereinafter with reference to
First,
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S320, and the response to the write request is sent therefrom to the A type external tool 5a or B type external tool 5b in step S330, which is illustrated by the reference numeral (2) in
When receiving the response to the write request, the A type external tool 5a or B type external tool 5b sends, to the ECU 1, the data download request, as a preparation for sending the rewrite control program RP, which is illustrated by the reference numeral (3) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S340. Next, the download-data size information is stored in the RAM 15 by the CPU 11 in step S350, and the transfer determining program is executed by the CPU 11 in step S360 illustrated in
In the transfer determining program, because the destination address included in the data down load request sent from the external tool 5a or 5b, which is illustrated by the reference numeral (3) in
When receiving the response to the data download request, the A type external tool 5a or the B type external tool 5b sends (downloads), to the ECU 1, the rewrite control program RP as the write target data, which is illustrated by the reference numeral (S) in
In the boot loader BL, every time a unit quantity of the rewrite control program RP is sent from the A type control tool 5a, the affirmative determination is executed by the CPU 11 in S370 and the operations in step S380 are executed thereby. As a result, when the total volume of the rewrite control program RP has been entirely written in the RAM 15, the affirmative determination is executed by the CPU 11 in step S390. Next, the response to the write data transfer is sent from the CPU 11 to the A type external tool 5a or the B type external tool 5b in step S395, which is illustrated by the reference numeral (6) in
When receiving the response to the response to the rewrite data, the A type external tool 5a or the B type external tool 5b sends, to the ECU 1, the data download request as a preparation for sending the rewrite control program RP, which is illustrated by the reference numeral (7) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S340. Next, the download-data size information is stored in the RAM 15 by the CPU 11 in step S350, and the transfer determining program is executed by the CPU 11 in step S360 illustrated in
In the transfer determining program, because the destination address included in the data down load request sent from the external tool 5a or 5b, which is illustrated by the reference numeral (7) in
Thereafter, the rewrite control program RP sent form the external tool 5a or 5b and stored in the RAM 15 is executed by the CPU 11.
Specifically, the response to the data download request is sent therefrom to the A type external tool 5a or B type external tool 5b, which is illustrated by the reference numeral (8) in
As a result, in the microcomputer 7, the execution of the rewrite control program RP by the CPU 11 allows the earlier application program AP1 stored in the flash ROM 13 to be sequentially updated into the new application program AP2 sent from the external tool 5a or 5b every sent unit of the program AP2, which is illustrated by the reference numeral 150 in
After all units of the new application program AP2 has been stored in the storage area of the flash ROM 13, the response to the write data transfer is sent from the CPU 1 to the external tool 5a or 5b based on the rewrite control program RP, which is illustrated by the reference numeral (10) in
Secondary,
In
When receiving the response to the write request, the C type external tool 5c sends, to the ECU 1, the data download request, as a preparation for sending the rewrite control program RP, which is illustrated by the reference numeral (3) in
In the boot loader BL, the affirmative determination is executed by the CPU 11 in step S340. Next, the download-data size information is stored in the RAM 15 by the CPU 11 in step S350, and the transfer determining program is executed by the CPU 11 in step S360 illustrated in
In the transfer determining program, because the destination address included in the data down load request sent from the external tool 5c, which is illustrated by the reference numeral (3) in
Thereafter, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 by the CPU 11 in step S450.
As a result, in the microcomputer 7, the rewrite control program RP, which is copied from the flash ROM 13 to the RAM 15, is launched by the CPU 11. This allows the response to the data download request to be sent to the C type external tool 5c, which is illustrated by the reference numeral (8) in
When receiving the response to the data download request, the external tool 5c sequentially sends (downloads), to the ECU 1, a unit quantity of the new application program AP2, which is illustrated by the reference numeral (5) in
As a result, in the microcomputer 7, the execution of the rewrite control program RP by the CPU 11 allows the earlier application program AP1 stored in the flash ROM 13 to be sequentially updated into the new application program AP2 sent from the C type external tool 5c every sent unit of the program AP2. This operation is illustrated by the reference numeral 150 in
After all units of the new application program AP2 has been stored in the storage area of the flash ROM 13, the response to the write data transfer is sent from the CPU 1 to the external tool 5c based on the rewrite control program RP, which is illustrated by the reference numeral (6) in
As described above, in the program rewriting system according to the second embodiment, any type of the external tool 5 is configured to send, to the ECU 1, the destination address of the write target data before sending the new application program AP2.
In the boot loader BL installed in the microcomputer 7 used for the ECU 1, after the write request is sent from the external tool 5, when the data download request including the destination address is sent from the external tool 5, it is determined whether the destination address is an address in the flash ROM 13. It is determined that the write target data sequentially sent from the external tool 5 is part of the rewrite control program RP until it is determined that the destination address is an address in the flash ROM 13 in step S410. As a result, the write target data is stored in the RAM 15 as part of the rewrite control program RP in step S380. When it is determined that the destination address is an address in the flash ROM 13 in step S410, it is determined that the write target data sent from the external tool 5 after the determination in step S410 is part of the new application program AP2. Thereafter, it is determined whether the rewrite control program download flag DF has been set in the register of the CPU 11 in order to judge whether the rewrite control program RP sent from the external tool 5 has been stored in the RAM 15.
In step S440, when it is determined that the rewrite control program RP sent from the external tool 5 has been stored in the RAM 15, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15 so that the rewrite control program RP runs in step S450. In contrast, when it is determined that the rewrite control program PP has not been stored in the RAM 15 in step S440, the rewrite control program RP is copied to the RAM 15 from the first address area of the flash ROM 13 in step S460. Thereafter, the execution location of the CPU 11 jumps to the leading address of the rewrite control program RP in the RAM 15, allowing the rewrite control program RP to run in step S450.
When the external tool 5 is the A type external tool 5a or the B type external tool 5b, the rewrite control program RP sent from the A type external tool 5a or the B type external tool 5b is stored in the RAM 15. Thereafter, when the data download request including an address in the flash ROM 13 as the destination address is sent from the A type external tool 5a or the B type external tool 5b, it is determined that the rewrite control program RP sent from the A type external tool 5a or the B type external tool 5b has been stored in the RAM 15 in step S440. This allows the rewrite control program RP to run. Execution of the rewrite control program RP permits the earlier application program AP1 stored in the flash ROM 13 to be updated to the new application program AP2 therein; this new application program AP2 is sent from the external tool 5a or 5b after the rewrite control program execution.
In contrast, when the external tool 5 is the C type external tool 5c, because no rewrite control program is sent therefrom, when the ROM identification code CD is sent from the C type external tool 5c, it is determined that the rewrite control program RP has not been stored in the RAM 15 in step S260 This allows the rewrite control program RP previously stored in the first address area of the flash ROM 13 is copied to the RAM 15 so that the rewrite control program RP is run on the RAM 15. Thereafter, execution of the rewrite control program RP permits the earlier application program AP1 stored in the flash ROM 13 to be updated to the new application program AP2 therein; this new application program AP2 is sent from the external tool 5c after the rewrite control program execution.
As described above, in the second embodiment, even if using the external tool 5 with any one of the A to C types, the boot loader BL according to the second embodiment allows the earlier application program AP1 to be accurately updated (rewritten) into the new application program AP2.
In addition, the boot loader BL according to the second embodiment eliminates the need to develop dedicated boot loaders for the types A to C of external tools, making it possible to reduce the number of processes for developing the ECU 1 and/or to simplify management of the ECU 1 and the boot loader 7.
Note that, in step S440 of
In each of the first and second embodiments, the ECU 1 includes the flash ROM 13 as one example of rewritable nonvolatile memories, but can include at least one of other types rewritable nonvolatile memories, such as an EEPROM.
In each of the first and second embodiments, note that the write request can be transmitted from the external tool 5 to the ECU 1 through a signal line different from the communication line 3.
In each of the first and second embodiments, the program rewriting system includes an ECU installed in an automobile, but the program rewriting system can include a control unit installed in other types of machines. Moreover, in each of the first and second embodiments, the ECU 1 is operative to control an engine installed in an automobile as a target, but the ECU 1 can control, as a target, other components installed in an automobile, such as a brake, a transmission, and suspensions.
In each of the first and second embodiments, it is important to note that, while the present invention has been and will continue to be described in the context of each of fully functional computers, such as the ECU 1 and the external tool 5. In the present invention, however, the elements provided in each of the ECU 1 and the external tool 5 can be implemented as dedicated hardware devices, such as custom LSI (Large-Scale Integration) circuits.
Moreover, those skilled in the art will appreciate that the present invention is capable of being distributed as program products, for example, the boot loader BL in a variety of forms. It is also important to note that the present invention applies equally regardless of the particular type of signal bearing media used to actually carry out the distribution. Examples of suitable signal bearing media include recordable type media such as CD-ROMs and DVD-ROMs, and transmission type media such as digital and analog communications links.
While there has been described what is at present considered to be the embodiments and modifications of the present invention, it will be understood that various modifications which are not described yet may be made therein, and it is intended to cover in the appended claims all such modifications as fall within the true spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2004-358974 | Dec 2004 | JP | national |