Power-down processing method and device for energy storage equipment and computer equipment
By reading and updating the status signs of the upgrade sign area when the energy storage equipment is powered down and re-energized and restored to the working stage, the problem of equipment failure caused by accidental power failure during the upgrade of the energy storage equipment is solved, and the stable recovery and normal operation of the equipment is achieved.
Patent Information
- Application Number
- CN202510333814.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-04
AI Technical Summary
Unexpected power failure during the upgrade of energy storage equipment caused the software update process to be interrupted, resulting in corruption of software system files and loss of critical configurations, the device cannot start normally, and it is difficult for the existing technology to restore normal functions.
When the energy storage device is powered on again after power is lost, the status flag of the upgrade sign area is read, the corresponding operations are performed according to the working stage of different types of status flags, and the status flag of the upgrade sign area is updated until the normal state is restored.
By promptly identifying and restoring the working stage of energy storage equipment, equipment chaos caused by power failure is avoided, energy storage equipment resumes operation in an orderly manner, reduces adverse effects of functions and performance, and ensures the stable work of the equipment in complex environments.
Smart Images

Figure CN120256197A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of energy storage devices, and particularly to a method and device for handling power-off of an energy storage device and a computer device. Background Art
[0002] In today's digital age, the Over The Air (OTA) technology is widely used in fields such as smart phones, automobiles, and Internet of Things devices. Through the OTA technology, remote management and upgrade of the software system of the device can be realized.
[0003] Taking an energy storage device as an example, in the related art, during the upgrade process using the OTA technology, the software system of the energy storage device is in a state of being updated and replaced. If a sudden unexpected power-off occurs at this time, the software update process will be forced to interrupt, which may cause damage to the software system files and loss of key configurations, resulting in the device being unable to start normally and falling into an unusable "bricked" state. Once this situation occurs, it is often impossible to roll back to the previous version of the software under the current technical conditions, which makes it difficult for the device to quickly resume normal functions after a failure.
[0004] Therefore, how to recover from an unexpected power-off during the upgrade process has become an urgent problem to be solved. Summary of the Invention
[0005] Based on this, in view of the above technical problems, it is necessary to provide a method and device for handling power-off of an energy storage device and a computer device, which can recover from an unexpected power-off during the upgrade process.
[0006] In a first aspect, this application provides a method for handling power-off of an energy storage device, including:
[0007] When detecting a re-power-on in the case of a power-off of the energy storage device, read the status flag of the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the power-off of the energy storage device occurs;
[0008] According to the reading result of the status flag of the upgrade flag area, start executing the operations corresponding to the working stage represented by the reading result of the status flag, and update the status flag of the upgrade flag area according to the operation content during the execution until the status flag of the upgrade flag area is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device resumes normal;
[0009] Execute the operations of the working stage represented by the preset type of status flag.
[0010] In one embodiment, the status flag includes a marked write status flag and an unmarked write status flag;
[0011] According to the result of reading the status flag in the upgrade flag area, start executing the operations corresponding to the working stage characterized by the result of reading the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to the status flag of the preset type, including:
[0012] When the result of reading the status flag in the upgrade flag area is the marked write status flag, restore the status flag in the upgrade flag area to the default status flag, and execute the operations corresponding to the working stage characterized by the default status flag;
[0013] When the result of reading the status flag in the upgrade flag area is a non-marked write status flag, start executing the operations corresponding to the working stage characterized by the result of reading the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to the status flag of the preset type.
[0014] In one embodiment, the non-marked write status flag includes the default status flag, and the preset type of status flag includes the erase status flag;
[0015] Start executing the operations corresponding to the working stage characterized by the result of reading the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution, including:
[0016] Perform a legality check on the program files in the program running area of the energy storage device;
[0017] If the legality check passes, run the program files in the program running area;
[0018] If the legality check fails, update the default status flag to the erase status flag, and execute the operations corresponding to the working stage characterized by the erase status flag.
[0019] In one embodiment, the non-marked write status flag further includes the erase status flag;
[0020] Start executing the operations corresponding to the working stage characterized by the result of reading the status flag, including:
[0021] Erase the program files in the program running area and the temporary storage area, and wait for the firmware supply server to send an upgrade request to the processor of the energy storage device.
[0022] In one embodiment, the non-marked write status flag further includes the copy status flag;
[0023] Start executing the operations corresponding to the working stage characterized by the result of reading the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution, including:
[0024] Copy multiple upgraded firmware data in the temporary storage area to the program running area;
[0025] If the copy is successful, update the copy status flag to the default status flag and perform the operations corresponding to the working stage represented by the default status flag;
[0026] If the copy fails, update the copy status flag to the erase status flag and perform the operations corresponding to the working stage represented by the erase status flag.
[0027] In one embodiment, the non-marked write status flag further includes a waiting status flag;
[0028] Start executing the operations corresponding to the working stage represented by the status flag read result, and update the status flag in the upgrade flag area according to the operation content during the execution process, including:
[0029] Update the waiting status flag to the default status flag;
[0030] Judge whether upgraded firmware data is received within a preset duration to obtain a first judgment result; and judge whether there is a temporary storage area in the energy storage device to obtain a second judgment result;
[0031] Update the status flag in the upgrade flag area based on the first judgment result and the second judgment result.
[0032] In one embodiment, updating the status flag in the upgrade flag area based on the first judgment result and the second judgment result includes:
[0033] When the first judgment result is that the upgraded firmware data is not received, run the program file in the program running area;
[0034] When the first judgment result is that the upgraded firmware data is received, update the default status flag to the waiting status flag, perform corresponding operations according to the second judgment result, and update the status flag in the upgrade flag area according to the operation content during the execution process.
[0035] In one embodiment, performing corresponding operations according to the second judgment result and updating the status flag in the upgrade flag area according to the operation content during the execution process includes:
[0036] When the second judgment result is that there is a temporary storage area, store the received upgraded firmware data in the temporary storage area, and after the storage is completed, update the waiting status flag to the copy status flag and perform the operations corresponding to the working stage represented by the copy status flag;
[0037] When the second judgment result indicates that there is no temporary storage area, update the waiting status flag to the erasure status flag, directly store the received upgraded firmware data into the program running area, and after the storage is completed, update the erasure status flag to the default status flag, and execute the operations corresponding to the working stage represented by the erasure status flag.
[0038] In a second aspect, the present application further provides a power failure processing device for an energy storage device, including:
[0039] A reading module, configured to detect a power-on again when the energy storage device loses power, and read the status flag of the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device loses power;
[0040] A first execution module, configured to start executing from the operations corresponding to the working stage represented by the status flag reading result according to the status flag reading result of the upgrade flag area, and update the status flag of the upgrade flag area according to the operation content during the execution until the status flag of the upgrade flag area is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device returns to normal;
[0041] A second execution module, configured to execute the operations of the working stage represented by the preset type of status flag.
[0042] In a third aspect, the present application further provides a computer device, including a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the content of any one of the embodiments of the power failure processing method for an energy storage device in the first aspect above.
[0043] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the content of any one of the embodiments of the power failure processing method for an energy storage device in the first aspect above.
[0044] In a fifth aspect, the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the content of any one of the embodiments of the power failure processing method for an energy storage device in the first aspect above.
[0045] The above power-off processing method, device and computer device for energy storage devices detect power-on again when the energy storage device loses power, and read the status flag in the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device loses power; according to the read result of the status flag in the upgrade flag area, start executing the operations corresponding to the working stage represented by the read result of the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to the status flag of a preset type; the status flag of the preset type represents the status flag when the energy storage device returns to normal; execute the operations of the working stage represented by the status flag of the preset type. When the energy storage device is powered on again after losing power, this method can timely read the status flag in the upgrade flag area, resume the execution of operations according to the working stage when losing power, and update the status flag in the upgrade flag area, which can avoid the chaos of the energy storage device caused by power-off interruption and the situation of brickification, enable the energy storage device to resume operation orderly, ensure its stable operation in a complex power consumption environment, and reduce the adverse effects of accidental power-off on the functions and performance of the energy storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0047] Figure 1 It is an application environment diagram of the power-off processing method for an energy storage device in an embodiment;
[0048] Figure 2 It is a flowchart of the power-off processing method for an energy storage device in an embodiment;
[0049] Figure 3 It is a schematic diagram of an energy storage device in the upgrade stage in an embodiment;
[0050] Figure 4 It is a flowchart of the power-off processing method for an energy storage device in an embodiment;
[0051] Figure 5 It is a schematic diagram of the operation process of marking and writing the status flag in an embodiment;
[0052] Figure 6 It is a flowchart of the power-off processing method for an energy storage device in an embodiment;
[0053] Figure 7 It is a schematic diagram of the operation process of the default status flag in an embodiment;
[0054] Figure 8 Schematic diagram of the operation process of the erasure status flag in an embodiment;
[0055] Figure 9 Schematic flow chart of the power-off processing method for an energy storage device in an embodiment;
[0056] Figure 10 Schematic diagram of the operation process of the copy status flag in an embodiment;
[0057] Figure 11 Schematic flow chart of the power-off processing method for an energy storage device in an embodiment;
[0058] Figure 12 Schematic flow chart of the power-off processing method for an energy storage device in an embodiment;
[0059] Figure 13 Schematic flow chart of the power-off processing method for an energy storage device in an embodiment;
[0060] Figure 14 Schematic diagram of the operation process of the waiting status flag in an embodiment;
[0061] Figure 15 Schematic block diagram of the power-off processing device for an energy storage device in an embodiment;
[0062] Figure 16 Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0063] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0064] The power-off processing method for an energy storage device provided by the embodiments of the present application can be applied to, for example Figure 1In the application environment shown. The application environment includes a computer device 101 and an energy storage device 102. The computer device 101 can be integrated inside the energy storage device 102 or can be separately and independently set from the energy storage device 102. The computer device 101 can detect the power-off and power-on conditions of the energy storage device 102. And when the energy storage device is detected to be powered on again after a power-off, the status flag in the upgrade flag area of the energy storage device 102 is read; according to the read result of the status flag in the upgrade flag area, the operation corresponding to the working stage represented by the read result of the status flag is started to be executed, and the status flag in the upgrade flag area is updated according to the operation content during the execution until the status flag in the upgrade flag area is updated to a status flag of a preset type; the operation of the working stage represented by the status flag of the preset type is executed.
[0065] In an exemplary embodiment, as Figure 2 shown, a method for processing power-off of an energy storage device is provided. Taking the computer device in Figure 1 as an example, the method includes the following steps 101 to 103. Wherein:
[0066] S101, when it is detected that the energy storage device is powered on again after a power-off, read the status flag in the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device has a power-off.
[0067] The power-off of the energy storage device may occur during the operation stage of the energy storage device or during the upgrade stage of the energy storage device. For the operation stage, it is mainly to run the program files in the program operation area of the energy storage device. For the upgrade stage, it is mainly to provide upgrade firmware data to the energy storage device through a firmware supply server. Figure 3 is a schematic diagram of the energy storage device during the upgrade stage. The figure mainly involves the interaction process between the firmware supply server and the processor of the energy storage device. The firmware supply server sends a handshake command to the processor. After the processor feedbacks that the handshake is successful, the multiple split upgrade firmware data can be sequentially sent to the processor. It should be noted that after each sending of the upgrade firmware data to the processor, the processor needs to verify the upgrade firmware data, and after the verification passes, receive the next upgrade firmware data provided by the firmware supply server. When the processor receives all the upgrade firmware data, the upgrade firmware data can be sequentially copied from the temporary storage area to the program operation area to complete the program upgrade process.
[0068] Taking the Flash of a microcontroller chip in an energy storage system as an example, the Flash of the microcontroller chip includes five regions, namely the Boot region, the upgrade flag region, the program running region, the temporary storage region, and the emergency region. Among them, the upgrade flag region is used to store the status flags of the energy storage device during the upgrade. For example, the upgrade status flags can include no flag, default status flag, waiting status flag, erasing status flag, copying status flag, and so on. Different types of status flags represent different working stages when the energy storage device experiences a power failure. No flag or no legal flag means that the processor loses power during the process of writing the flag. The default status flag means that the energy storage device loses power during the program running process. The waiting status flag, erasing status flag, and copying status flag all mean that the energy storage device loses power during the upgrade process.
[0069] Whether in the running stage or the upgrade stage, the computer device can detect the status of the energy storage device in real time to determine whether the energy storage device has lost power. When it is determined that the energy storage device has lost power and then powers on again, the computer device can send a status flag reading instruction to the processor of the energy storage device. After receiving the status flag reading instruction, the processor forwards the status flag in the upgrade flag region to the computer device. Or, the processor can also send the status flag in the upgrade flag region to the computer device at a preset time interval. Then, when the computer device determines that the energy storage device has lost power and then powers on again, the first received status flag is used as the status flag of the upgrade flag region of the energy storage device.
[0070] S102, according to the status flag reading result of the upgrade flag region, start executing from the operation corresponding to the working stage represented by the status flag reading result, and update the status flag of the upgrade flag region according to the operation content during the execution until the status flag of the upgrade flag region is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device returns to normal.
[0071] In the embodiments of the present application, for the situation of powering on again after a power failure, it is necessary to determine the working stage of the energy storage device before the power failure and continue to execute the operations of that working stage. Since different types of status flags represent different working stages when the energy storage device experiences a power failure, the computer device can determine the working stage corresponding to the read status flag based on the correspondence between the status flag and the working stage. Then execute the operations corresponding to that working stage, and update the status flag of the upgrade flag region according to the operation content during the execution.
[0072] It should be noted that the operations and updated status flags corresponding to different working stages are different. That is to say, the computer device can perform different operations and update the status flags based on the status flags read from the upgrade flag area until the status flags in the upgrade flag area are updated to the status flags of a preset type. That is to say, the process of performing operations and updating flags includes at least one step and may also be multiple steps. Assuming that the status flags read from the upgrade flag area are already the status flags of a preset type, the operations corresponding to the working stage of the status flags can be directly executed.
[0073] S103, perform the operations of the working stage represented by the status flags of the preset type.
[0074] In the embodiments of the present application, the status flags of the preset type can be one status flag or multiple status flags. Taking the status flags of the preset type being the default status flag or the erase status flag as an example, if it is the default status flag, the computer device needs to verify the program files in the program running area of the energy storage device and continue to perform the corresponding operations based on the verification results. If it is the erase status flag, the program files in the program running area and the temporary storage area of the energy storage device are erased, and it stays in the BOOT area waiting for the firmware supply server to send a new handshake command.
[0075] In the above method for processing power-off of the energy storage device, when power-on is detected after the energy storage device is powered off, the status flags of the upgrade flag area of the energy storage device are read; different types of status flags in the upgrade flag area represent different working stages when the energy storage device loses power; according to the read result of the status flags in the upgrade flag area, start executing from the operations corresponding to the working stage represented by the read result of the status flags, and update the status flags in the upgrade flag area according to the operation content during the execution until the status flags in the upgrade flag area are updated to the status flags of a preset type; the status flags of the preset type represent the status flags when the energy storage device returns to normal; perform the operations of the working stage represented by the status flags of the preset type. This method can timely read the status flags of the upgrade flag area when the energy storage device is powered on again after a power-off, resume the execution of operations according to the working stage when the power-off occurred, and update the status flags in the upgrade flag area, which can avoid the chaos of the energy storage device's work caused by power-off interruption and the situation of brickification, enable the energy storage device to resume operation orderly, ensure its stable work in a complex power consumption environment, and reduce the adverse effects of accidental power-off on the functions and performance of the energy storage device.
[0076] Assuming that the status flags include the marked write status flag and the unmarked write status flag, then, in one embodiment, as Figure 4As shown in the figure, the specific content of starting to execute the operations corresponding to the working stage characterized by the status flag reading result according to the status flag in the upgrade flag area and updating the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to the status flag of the preset type will be introduced. The specific content includes:
[0077] S201, when the status flag reading result in the upgrade flag area is the mark writing status flag, restore the status flag in the upgrade flag area to the default status flag, and execute the operations corresponding to the working stage characterized by the default status flag.
[0078] Among them, the mark writing status flag indicates that the processor of the energy storage device loses power during the mark writing process. The power loss is divided into two cases. In one case, the power loss occurs during the erasing process, and in the other case, the power loss occurs during the writing process. For this situation, when powering on again, the upgrade flag area may be without a mark or without a valid mark.
[0079] In the embodiment of the present application, when it is determined that the read status flag is the mark writing status flag, it can be determined that the processor of the energy storage device loses power during the mark writing process. Then, the computer device needs to restore the status flag in the upgrade flag area to the default status flag and then execute the operations corresponding to the working stage characterized by the default status flag. This operation is specifically to verify the program files in the program running area of the energy storage device, and based on the verification result, continue to execute the subsequent corresponding operations. Among them, the default status flag can be expressed as BOOT_COMPLETED.
[0080] Figure 5 As shown in the schematic diagram of the operation process for the mark writing status flag, it can be seen from the figure that if the status flag is not read out, it means that the status flag reading result in the upgrade flag area is the mark writing status flag, that is, the status flag loses power during the writing process. Then, the status flag can be restored to the default status flag, and the operations of the working stage characterized by the default status flag can be executed.
[0081] S202, when the status flag reading result in the upgrade flag area is a non-mark writing status flag, start to execute the operations corresponding to the working stage characterized by the status flag reading result, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to the status flag of the preset type.
[0082] Among them, the non-mark writing status flag indicates that the power loss does not occur during the mark writing process. Then, this process may include power loss during the operation of the energy storage device, power loss during the upgrade firmware transmission process, power loss during the copy process, and so on.
[0083] In an embodiment of the present application, when it is determined that the status flag reading result in the upgrade flag area is not the marked write status flag, then the status flag reading result is the non-marked write status flag. In this case, the computer device can determine the working stage corresponding to the read status flag based on the correspondence between the status flag and the working stage. Then, perform the operations corresponding to the working stage, and update the status flag in the upgrade flag area according to the operation content during the execution process.
[0084] In the above power-off processing method for the energy storage device, when the status flag reading result in the upgrade flag area is the marked write status flag, restore the status flag in the upgrade flag area to the default status flag, and perform the operations corresponding to the working stage represented by the default status flag; when the status flag reading result in the upgrade flag area is the non-marked write status flag, start executing the operations corresponding to the working stage represented by the status flag reading result, and update the status flag in the upgrade flag area according to the operation content during the execution process until the status flag in the upgrade flag area is updated to the status flag of the preset type. This method has corresponding processing mechanisms for different status flag situations, enabling the energy storage device to perform the operations corresponding to the working stage of the status flag in the face of different types of flag statuses. In this way, the stability of the operation of the energy storage device can be greatly enhanced, avoiding serious problems such as the energy storage device crashing and data corruption, and ensuring the long-term stable operation of the energy storage device.
[0085] Assume that the read non-marked write status flag is the default status flag, or when switching from other status flags to the default status flag. In one embodiment, as Figure 6 shown, the specific content of starting to execute the operations corresponding to the working stage represented by the status flag reading result and updating the status flag in the upgrade flag area according to the operation content during the execution process will be introduced. The specific content includes:
[0086] S301, perform a legality check on the program files in the program operation area of the energy storage device.
[0087] When the energy storage device is powered off and then powered on again, and the read status flag is the default status flag, it is determined that the energy storage device was in a normal operating state before the power-off. Based on this, the computer device can perform the operations corresponding to the normal operating state, that is, obtain the program files in the program operation area of the energy storage device, and perform a legality check on the program files to determine whether the program files can operate normally. Specifically, the computer device can compare the program files after power-on with the program files before power-off. If the two program files are the same, it is determined that the legality check passes; if the two program files are different, it is determined that the legality check fails.
[0088] S302, if the legality check passes, then run the program file in the program running area.
[0089] In the embodiment of the present application, when it is determined that the legality check of the program file passes, the computer device may send a running instruction to the processor of the energy storage device. After receiving the running instruction, the processor jumps to the program running area to run the program file in the program running area, so that the energy storage device can be in a normal working state.
[0090] S303, if the legality check fails, then update the default status flag to the erase status flag, and execute the operations corresponding to the working stage represented by the erase status flag.
[0091] In the embodiment of the present application, when it is determined that the legality check of the program file fails, it indicates that there is an abnormality in the data in the program running area of the energy storage device. At this time, the energy storage device cannot work normally. In this case, the computer device needs to update the default status flag to the erase status flag, and then execute the operations of the working stage represented by the erase status flag. The erase status flag can be expressed as BOOT_EREASE_FLASH.
[0092] Figure 7 FIG. is a schematic diagram of the operation process of the default status flag. It can be seen from the figure that after power-off and power-on again, when the status flag of the energy storage device is the default status flag, it is necessary to perform a legality check on the program file in the program running area. If the check passes, then run the program file in the program running area. If the check fails, switch the default status flag to the erase status flag, and then execute the operations of the working stage represented by the erase status flag.
[0093] In the above method for processing power-off of the energy storage device, a legality check is performed on the program file in the program running area of the energy storage device; if the legality check passes, then run the program file in the program running area; if the legality check fails, then update the default status flag to the erase status flag, and execute the operations corresponding to the working stage represented by the erase status flag. This method performs a legality check on the program file in the program running area of the energy storage device, and can effectively identify illegal or tampered program files. Only when the check passes can the program file in the program running area be run; once the legality check fails, the default status flag can be updated to the erase status flag in time and the corresponding operations can be executed, which can prevent the wrong program file from continuously affecting the system and ensure the stable operation of the energy storage device in a safe program environment.
[0094] The non-mark writing status flag also includes an erase status flag. Then, in the case where the read status flag is the erase status flag, or when switching from other status flags to the erase status flag, a specific content of starting to execute the operations corresponding to the working stage represented by the read result of the status flag is introduced through an embodiment. The specific content includes:
[0095] Erase the program files in the program running area and the temporary storage area, and wait for the firmware supply server to initiate an upgrade request to the processor of the energy storage device.
[0096] In the embodiment of the present application, when the status flag in the upgrade flag area is the erase status flag, the computer device will control to empty the program files in the program running area and the temporary storage area, that is, erase the program files in the program running area and the temporary storage area. At this time, both the program running area and the temporary storage area are in an idle state, waiting for the firmware supply server to initiate an upgrade request to the processor of the energy storage device. After receiving the upgrade request, a new upgrade process is performed.
[0097] Figure 8 It is a schematic diagram of the operation process for the erase status flag. It can be seen from the figure that when the read status flag is the erase status flag, or when switching from other status flags to the erase status flag, stay in the BOOT area and wait for the firmware supply server to initiate an upgrade again.
[0098] In the above method for processing power failure of the energy storage device, erase the program files in the program running area and the temporary storage area, and wait for the firmware supply server to initiate an upgrade request to the processor of the energy storage device. When it is determined that the status flag in the upgrade flag area is the erase status flag, it indicates that there are errors or unstable factors in the program files in the program running area and the temporary storage area. Then, by erasing these files, it is possible to avoid crashing or abnormal behaviors due to the continuous operation of the error program. At the same time, waiting for the firmware supply server to initiate an upgrade request can ensure that the energy storage device receives a new upgrade request in a stable state and avoid the influence of error files on the upgrade process.
[0099] The non-marked write status flag further includes a copy status flag. Then, when the read status flag is the copy status flag, or when switching from other status flags to the copy status flag, a description is given of starting to execute the operations corresponding to the working stage characterized by the read result of the status flag and updating the specific content of the status flag in the upgrade flag area during the execution process, as Figure 9 shown, including:
[0100] S401, copy multiple upgrade firmware data in the temporary storage area to the program running area.
[0101] In the embodiment of the present application, when the status flag in the upgrade flag area is the copy status flag, the computer device can send a data copy instruction to the processor of the energy storage device. After receiving the copy instruction, the processor can copy multiple upgrade firmware data in the temporary storage area to the program running area. Among them, the copy status flag can be BOOT_COPY_FLASH.
[0102] S402. If the copy is successful, update the copy status flag to the default status flag and perform the operations corresponding to the working stage represented by the default status flag.
[0103] In the embodiment of the present application, for the copy process, after each complete copy, the upgraded firmware data copied in the program running area can be verified, and after all the upgraded firmware data is copied, an overall verification is performed. If the verification of both the individual copy process and the overall verification process passes, it is determined that the copy process of the multiple upgraded firmware data is completed, and at this time, the upgrade process is also completed. Then, in this case, the copy status flag in the upgrade flag area can be updated to the default status flag, and then the content in steps S301 - S303 is executed.
[0104] S403. If the copy fails, update the copy status flag to the erase status flag and perform the operations corresponding to the working stage represented by the erase status flag.
[0105] In the embodiment of the present application, if the verification of any one of the individual copy process and the overall verification process fails, it indicates that the copy process fails. At this time, the copy status flag can be updated to the erase status flag, and then the operations corresponding to the working stage represented by the above default status flag are performed.
[0106] Figure 10 It is a schematic diagram of the operation process of the copy status flag. As can be seen from the figure, when the read status flag is the copy status flag, or when switching from other status flags to the copy status flag, copy processing is performed on multiple upgraded firmware data in the temporary storage area. If it is determined that the copy is successful, update the copy status flag to the default status flag and execute the content in steps S301 - S303. If the copy is not successful, update the copy status flag to the erase status flag and execute the Figure 8 content in.
[0107] In the above power-off processing method for the energy storage device, multiple upgraded firmware data in the temporary storage area are copied to the program running area; if the copy is successful, the copy status flag is updated to the default status flag, and the operations corresponding to the working stage represented by the default status flag are executed; if the copy fails, the copy status flag is updated to the erase status flag, and the operations corresponding to the working stage represented by the erase status flag are executed. This method copies multiple upgraded firmware data in the temporary storage area to the program running area, providing a necessary condition for device upgrade. If the copy is successful, updating to the default status flag and executing the corresponding operations can enable the device to smoothly transition to the normal operating state after upgrade, ensuring the continuous and stable operation of the device. If the copy fails, promptly updating the copy status flag to the erase status flag and executing the corresponding operations can quickly clear the possibly incorrect upgraded firmware data, avoiding the impact of incorrect data on the device.
[0108] The non-mark write status flag further includes a wait status flag. Then, in the case where the read status flag is the wait status flag. In one embodiment, as Figure 11 shown, a specific description is given of starting to execute the operations corresponding to the working stage represented by the read result of the status flag and updating the status flag in the upgrade flag area according to the operation content during the execution process, including:
[0109] S501, update the wait status flag to the default status flag.
[0110] In the embodiment of the present application, when the computer device determines that the status flag in the upgraded status flag area read is the wait status flag, it indicates that the energy storage device was in the process of transmitting upgraded firmware data before power-off. At this time, the computer device can control the wait status flag in the upgrade flag area to be converted to the default status flag. Among them, the wait status flag can be BOOT_WAIT.
[0111] S502, determine whether upgraded firmware data is received within a preset duration to obtain a first determination result; and, determine whether the energy storage device has a temporary storage area to obtain a second determination result.
[0112] Among them, the preset duration can be based on historical experience. For example, the preset duration can be 20 seconds, 25 seconds, 30 seconds, etc.
[0113] In the embodiment of the present application, the computer device can determine whether the processor of the energy storage device receives upgraded firmware data within the preset duration. If received, it indicates that the upgraded firmware transmission process before power-off continues after power-on; if not received, it indicates that the upgraded firmware transmission process before power-off is aborted after power-on.
[0114] In addition, the computer device can obtain the free memory in the temporary storage area of the energy storage device. If the free memory is zero, it is determined that the energy storage device does not have a temporary storage area; if the free memory is not zero, it is determined that the energy storage device has a temporary storage area.
[0115] S503. Based on the first judgment result and the second judgment result, update the status flag in the upgrade flag area.
[0116] In an embodiment of the present application, after obtaining the first judgment result and the second judgment result, the computer device can combine the two judgment results to determine the working stage corresponding to the combination result and the status flag of the upgrade flag area that needs to be changed.
[0117] In the above energy storage device power-off processing method, the waiting status flag is updated to the default status flag; it is judged whether upgrade firmware data is received within a preset duration to obtain the first judgment result; and, it is judged whether the energy storage device has a temporary storage area to obtain the second judgment result; based on the first judgment result and the second judgment result, the status flag in the upgrade flag area is updated. This method can effectively manage the program upgrade time of the energy storage device by using the preset duration to judge whether upgrade firmware data is received within the preset duration. If data is received within the specified time, the upgrade process can be quickly promoted; if not, the strategy can be adjusted in time to avoid the device waiting for a long time and improve the upgrade efficiency. At the same time, judging whether the energy storage device has a temporary storage area provides a basis for data storage and processing, and determines the area where the currently received upgrade firmware data needs to be stored according to different results (for example, the area that needs to be stored can be the temporary storage area or the program running area), and correspondingly updates the status flag in the upgrade flag area, making the entire upgrade process more standardized and orderly, so as to be able to match energy storage devices with different hardware configurations.
[0118] Next, a specific process of updating the status flag in the upgrade flag area based on the first judgment result and the second judgment result will be described through an embodiment, as Figure 12 shown, the specific content includes:
[0119] S601. When the first judgment result is that the upgrade firmware data has not been received, run the program file in the program running area.
[0120] In an embodiment of the present application, when the first judgment result is that the upgrade firmware data has not been received, it means that the upgrade firmware transmission before power-off has been completed after the device is powered on again. At this time, the computer device can send a running instruction to the processor of the energy storage device. After receiving the running instruction, the processor jumps to the program running area to run the program file in the program running area, so that the energy storage device can be in a normal working state.
[0121] S602. When the first judgment result is that the upgraded firmware data is received, update the default status flag to the waiting status flag, and perform corresponding operations according to the second judgment result. During the execution, update the status flag in the upgrade flag area according to the operation content.
[0122] In the embodiment of the present application, when the first judgment result is that the upgraded firmware data is received, it indicates that the transmission process of the upgraded firmware before power-off after restart is aborted. At this time, the computer device needs to update the default status flag to the waiting status flag and then wait for the transmission of the upgraded firmware data. Then, according to the second judgment result, determine the next operation process.
[0123] Specifically, in one embodiment, as Figure 13 shown, perform corresponding operations according to the second judgment result, and update the status flag in the upgrade flag area according to the operation content during the execution, including:
[0124] S701. When the second judgment result is that there is a temporary storage area, store the received upgraded firmware data in the temporary storage area. After the storage is completed, update the waiting status flag to the copy status flag, and perform the operations corresponding to the working stage represented by the copy status flag.
[0125] In the embodiment of the present application, if it is determined that the energy storage device has a temporary storage area, after successfully verifying a plurality of sequentially received upgraded firmware data, store the upgraded firmware data in the temporary storage area. After the data transmission is completed, enter the data copy stage. The computer device can first update the waiting status flag to the copy status flag, and then execute the content of steps S401 - S403.
[0126] S702. When the second judgment result is that there is no temporary storage area, update the waiting status flag to the erase status flag, directly store the received upgraded firmware data in the program running area, and after the storage is completed, update the erase status flag to the default status flag, and perform the operations corresponding to the working stage represented by the erase status flag.
[0127] In the embodiment of the present application, if it is determined that the energy storage device does not have a temporary storage area, the computer device needs to update the waiting status flag to the erase status flag. In this case, the program file in the program running area can be erased. After the erasure, store the received upgraded firmware data in the program running area, and then update the erase status flag to the default status flag, and execute the content of steps S301 - S303.
[0128] Figure 14Schematic diagram of the operation process of the waiting status flag. As can be seen from the figure, when the read status flag is the waiting status flag, it indicates that the energy storage device loses power and then powers on again during the data transmission process, and the waiting status flag is changed to the default status flag. Then, it is judged whether the upgraded firmware data is received within the preset time period. If received, the program file in the program running area is run; if not received, the default status flag is changed to the waiting status flag. Then, it is further judged whether there is a temporary storage area in the energy storage device. If there is, the flag needs to be changed. After the transmission is completed, the waiting status flag is changed to the copy status flag, and the operations in the corresponding working stage are executed. If not, the default status flag is changed to the erase status flag. After the data transmission is completed, the erase status flag is changed to the default status flag, and the operations in the corresponding working stage are executed.
[0129] In the above method for handling power failure of the energy storage device, when the first judgment result is that the upgraded firmware data is not received, the program file in the program running area is run; when the first judgment result is that the upgraded firmware data is received, the default status flag is updated to the waiting status flag; when the second judgment result is that there is a temporary storage area, the received upgraded firmware data is stored in the temporary storage area, and after the storage is completed, the waiting status flag is updated to the copy status flag, and the operations corresponding to the working stage represented by the copy status flag are executed; when the second judgment result is that there is no temporary storage area, the waiting status flag is updated to the erase status flag, and after the storage is completed, the erase status flag is updated to the default status flag, and the operations corresponding to the working stage represented by the erase status flag are executed. This method has corresponding processing strategies for energy storage devices with different hardware configurations, that is, in the case of the existence or non-existence of a temporary storage area. This enables the energy storage device to smoothly perform upgrade-related operations in different hardware environments, enhances the compatibility of the energy storage device with different hardware, and expands the applicable range of the energy storage device.
[0130] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence according to the arrows, these steps do not necessarily need to be executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily need to be executed at the same time, but can be executed at different times. The execution order of these steps or stages does not necessarily need to be sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0131] Based on the same inventive concept, an embodiment of the present application further provides an energy storage device power-off processing apparatus for implementing the energy storage device power-off processing method involved above. The solution provided by this apparatus for solving problems is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the energy storage device power-off processing apparatus provided below can refer to the limitations on the energy storage device power-off processing method in the above text, and will not be repeated here.
[0132] In an exemplary embodiment, as Figure 15 shown, an energy storage device power-off processing apparatus is provided, including: a reading module 11, a first execution module 12, and a second execution module 13, where:
[0133] The reading module 11 is configured to detect a power-on again when the energy storage device is powered off, and read the status flag of the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device experiences a power-off.
[0134] The first execution module 12 is configured to start executing from the operation corresponding to the working stage represented by the status flag reading result of the upgrade flag area according to the status flag reading result of the upgrade flag area, and update the status flag of the upgrade flag area according to the operation content during the execution until the status flag of the upgrade flag area is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device returns to normal.
[0135] The second execution module 13 is configured to execute the operation of the working stage represented by the preset type of status flag.
[0136] In an exemplary embodiment, the above first execution module includes a first execution unit and a second execution unit, where:
[0137] The first execution unit is configured to, when the status flag reading result of the upgrade flag area is the marked write status flag, restore the status flag of the upgrade flag area to the default status flag, and execute the operation corresponding to the working stage represented by the default status flag.
[0138] The second execution unit is configured to, when the status flag reading result of the upgrade flag area is a non-marked write status flag, start executing from the operation corresponding to the working stage represented by the status flag reading result, and update the status flag of the upgrade flag area according to the operation content during the execution until the status flag of the upgrade flag area is updated to a preset type of status flag.
[0139] In an exemplary embodiment, the second execution unit is further configured to perform a legality check on the program files in the program running area of the energy storage device; if the legality check passes, run the program files in the program running area; if the legality check fails, update the default status flag to an erase status flag, and perform the operations corresponding to the working stage represented by the erase status flag.
[0140] In an exemplary embodiment, the second execution unit is further configured to erase the program files in the program running area and the temporary storage area, and wait for the firmware supply server to send an upgrade request to the processor of the energy storage device.
[0141] In an exemplary embodiment, the second execution unit is further configured to copy multiple upgrade firmware data in the temporary storage area to the program running area; if the copy is successful, update the copy status flag to the default status flag, and perform the operations corresponding to the working stage represented by the default status flag; if the copy fails, update the copy status flag to the erase status flag, and perform the operations corresponding to the working stage represented by the erase status flag.
[0142] In an exemplary embodiment, the second execution unit is further configured to update the wait status flag to the default status flag; determine whether upgrade firmware data is received within a preset duration to obtain a first determination result; and determine whether the energy storage device has a temporary storage area to obtain a second determination result; based on the first determination result and the second determination result, update the status flag in the upgrade flag area.
[0143] In an exemplary embodiment, the second execution unit is further configured to run the program files in the program running area when the first determination result is that the upgrade firmware data is not received; when the first determination result is that the upgrade firmware data is received, update the default status flag to the wait status flag, and perform corresponding operations according to the second determination result, and update the status flag in the upgrade flag area according to the operation content during the execution process.
[0144] In an exemplary embodiment, the second execution unit is further configured to store the received upgrade firmware data in the temporary storage area when the second determination result is that there is a temporary storage area, and after the storage is completed, update the wait status flag to the copy status flag and perform the operations corresponding to the working stage represented by the copy status flag; when the second determination result is that there is no temporary storage area, update the wait status flag to the erase status flag, directly store the received upgrade firmware data in the program running area, and after the storage is completed, update the erase status flag to the default status flag and perform the operations corresponding to the working stage represented by the erase status flag.
[0145] Each module in the above power-off processing device of the energy storage device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0146] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 16 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store power-off processing data of the energy storage device. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a power-off processing method for an energy storage device.
[0147] Those skilled in the art can understand that Figure 16 the structure shown in
[0148] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0149] In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the content of any one of the above embodiments of the power-off processing method for an energy storage device.
[0150] In an embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, it implements the content of any one of the above embodiments of the power-off processing method for an energy storage device.
[0151] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0152] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., and are not limited thereto.
[0153] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this application.
[0154] The above embodiments only express several implementation manners of this application, and the description is relatively specific and detailed. However, it should not be construed as a limitation on the patent scope of this application. It should be noted that for those of ordinary skill in the art, without departing from the concept of this application, several deformations and improvements can still be made, and these all belong to the protection scope of this application. Therefore, the protection scope of this application should be subject to the appended claims.
Claims
1. A method for handling power failure of an energy storage device, characterized in that, The method includes: When detecting a power-on again after the energy storage device loses power, reading the status flag in the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device loses power. According to the read result of the status flag in the upgrade flag area, start executing the operation corresponding to the working stage represented by the read result of the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device resumes normal. Execute the operation of the working stage represented by the preset type of status flag.
2. The method according to claim 1, characterized in that, The status flag includes a marked write status flag and an unmarked write status flag. The step of starting to execute the operation corresponding to the working stage represented by the read result of the status flag in the upgrade flag area and updating the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to a preset type of status flag includes: When the read result of the status flag in the upgrade flag area is the marked write status flag, restore the status flag in the upgrade flag area to the default status flag, and execute the operation corresponding to the working stage represented by the default status flag. When the read result of the status flag in the upgrade flag area is the unmarked write status flag, start executing the operation corresponding to the working stage represented by the read result of the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to a preset type of status flag.
3. The method according to claim 2, wherein The unmarked write status flag includes a default status flag, and the preset type of status flag includes an erase status flag. The step of starting to execute the operation corresponding to the working stage represented by the read result of the status flag and updating the status flag in the upgrade flag area according to the operation content during the execution includes: Perform a legality check on the program files in the program running area of the energy storage device. If the legality check passes, run the program files in the program running area. If the legality check fails, update the default status flag to the erase status flag, and execute the operation corresponding to the working stage represented by the erase status flag.
4. The method according to claim 2, wherein The unmarked write status flag also includes an erase status flag. The step of starting to execute the operation corresponding to the working stage represented by the read result of the status flag includes: Erase the program files in the program running area and the temporary storage area, and wait for the firmware supply server to send an upgrade request to the processor of the energy storage device.
5. The method according to claim 2, wherein The unmarked write status flag also includes a copy status flag. The step of starting to execute the operation corresponding to the working stage represented by the read result of the status flag and updating the status flag in the upgrade flag area according to the operation content during the execution includes: Copy multiple upgrade firmware data in the temporary storage area to the program running area. If the copy is successful, update the copy status flag to the default status flag and perform the operations corresponding to the working stage represented by the default status flag; If the copy is not successful, update the copy status flag to the erase status flag and perform the operations corresponding to the working stage represented by the erase status flag.
6. The method according to claim 2, characterized in that The non-marked write status flag further includes a wait status flag; Start executing the operations corresponding to the working stage represented by the result read from the status flag, and update the status flag in the upgrade flag area according to the operation content during the execution, including: Update the wait status flag to the default status flag; Judge whether upgrade firmware data is received within a preset duration to obtain a first judgment result; and judge whether there is a temporary storage area in the energy storage device to obtain a second judgment result; Update the status flag in the upgrade flag area based on the first judgment result and the second judgment result.
7. The method according to claim 6, wherein The updating the status flag in the upgrade flag area based on the first judgment result and the second judgment result includes: When the first judgment result is that the upgrade firmware data is not received, run the program file in the program running area; When the first judgment result is that the upgrade firmware data is received, update the default status flag to the wait status flag, perform corresponding operations according to the second judgment result, and update the status flag in the upgrade flag area according to the operation content during the execution.
8. The method according to claim 7, characterized in that, The performing corresponding operations according to the second judgment result and updating the status flag in the upgrade flag area according to the operation content during the execution includes: When the second judgment result is that there is a temporary storage area, store the received upgrade firmware data in the temporary storage area, and after the storage is completed, update the wait status flag to the copy status flag and perform the operations corresponding to the working stage represented by the copy status flag; When the second judgment result is that there is no temporary storage area, update the wait status flag to the erase status flag, directly store the received upgrade firmware data in the program running area, and after the storage is completed, update the erase status flag to the default status flag and perform the operations corresponding to the working stage represented by the erase status flag.
9. A power-off processing device for an energy storage device, characterized in that, The device includes: A reading module, configured to detect power-on again when the energy storage device loses power and read the status flag in the upgrade flag area of the energy storage device; different types of status flags in the upgrade flag area represent different working stages when the energy storage device loses power; A first execution module, configured to start executing the operations corresponding to the working stage represented by the result of reading the status flag in the upgrade flag area, and update the status flag in the upgrade flag area according to the operation content during the execution until the status flag in the upgrade flag area is updated to a preset type of status flag; the preset type of status flag represents the status flag when the energy storage device returns to normal; A second execution module, configured to execute the operations of the working stage represented by the preset type of status flag.
10. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.