Control device and method for rewriting control program
A control unit is configured to determine success or failure of a rewrite process after end of the rewrite process, and write success or failure display data into a success or failure determination result storage area in accordance with the success or failure, and read the success or failure display data present in the success or failure determination result storage area after startup of an electronic device, and execute a control program, in lieu of carrying out the rewrite process, when it is determined that the success or failure display data indicate a success of the rewrite process.
1 . A control device, comprising:
a control unit configured to control an operation of an electronic device to be controlled by executing a control program;
a storage unit configured to store the control program and success or failure display data; and
a communication unit configured to receive an update program from outside the control device,
wherein the control unit is configured to:
in a first step, determine whether the control program is stored in the storage unit and whether instructions exist to rewrite the control program;
in a second step, write an update program received via the communication unit as the control program stored in the storage unit, overwriting a current control program if any exists, in response to:
determining that no control program is stored in the storage unit; or
determining that the instructions to rewrite the control program exist;
in a third step, upon determining that a control program is stored in the storage unit and that the instructions to rewrite the control program do not exist, determine whether the success or failure display data indicates a success or a failure;
in a fourth step, after writing the update program as the control program in the second step or determining that the success or failure display data does not indicate an acceptable control pattern in the third step, test validity of the control program and update the success or failure display data to reflect a positive or negative result of testing the validity of the control program;
in response to the success or failure display data reflecting a negative result:
iteratively repeat the second and fourth steps so long as the instructions to rewrite the control program remain and a branching condition remain unsatisfied, the branching condition constituting one of an elapse of time or a completion of an iteration count limit; and
generate a user notification of an abnormality in the event that the instructions to rewrite the control program do not exist; and
commence startup of the control unit using the control program after executing the fourth step, in response to the success or failure display data reflecting success.
2 . The control device according to claim 1 , wherein a combination of the success or failure display data is:
a combination that indicates a success in the case of a success and indicates a failure in the case of a failure;
a combination that indicates a success in the case of the success and is null in the case of the failure; or
a combination that is null in the case of the success and indicates a failure in the case of the failure.
3 . The control device according to claim 1 , wherein the control program is a program that controls charging and discharging of a secondary battery provided in the electronic device.
4 . A method for writing or rewriting a control program stored in a storage unit for controlling an operation of an electronic device, the method for writing or rewriting the control program comprising:
a first step of determining whether or not there is an instruction to execute rewriting of the control program;
a second step of overwriting the control program with an updated program in response to:
determining that there is an instruction to execute rewriting of the control program; or
determining that no control program is stored in the storage unit;
a third step, upon determining that the control program is stored in the storage unit and that instructions to execute rewriting of the control program do not exist, of determining whether success or failure data exist indicating a success of a failure;
a fourth step, after writing the update program as the control program in the second step or determining that the success or failure display data does not indicate an acceptable control pattern in the third step, of testing validity of the control program and updating the success or failure display data to reflect a positive or negative result of testing the validity of the control program; and
a fifth step of reading the success or failure display data present in the success or failure determination result storage area,
wherein, upon a subsequent iteration of the first step after startup of the electronic device, the fifth step is immediately carried out in response to a determination in the first step that there is no instruction to execute the rewrite process, and the control program is executed without passing through a subsequent iteration of the second to fourth steps.
5 . The method for rewriting a control program according to claim 4 , wherein a combination of the success or failure display data is:
a combination that indicates a success in the case of a success and indicates a failure in the case of a failure;
a combination that indicates a success in the case of the success and is null in the case of the failure; or
a combination that is null in the case of the success and indicates a failure in the case of the failure.
6 . The control device according to claim 2 , wherein the control program is a program that controls charging and discharging of a secondary battery provided in the electronic device.
7 . The control device according to claim 1 , wherein the control program is a program that controls charging and discharging of a secondary battery provided in the electronic device.