Nonvolatile storage device, firmware damage processing method, and upgrading method
By employing a partitioned non-volatile storage device in the charging pile, the problems of the charging pile being unable to perform incremental upgrades and the firmware area becoming unavailable due to unexpected power outages are solved, achieving stable incremental upgrades and automatic rollback functions, ensuring that the device operates normally under unexpected circumstances.
Patent Information
- Application Number
- CN202211430136.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-11-15
AI Technical Summary
Existing technologies cannot enable incremental upgrades of charging stations, and the firmware area may become unavailable during unexpected power outages or signal interruptions, leading to upgrade failures.
The device employs a partitioned design for non-volatile storage, including a BootLoader area, a read-only file firmware area, and a read-write file firmware area. Incremental upgrades are achieved through the read-write file firmware area, and the device automatically rolls back to the read-only file firmware area in case of an accident, ensuring normal operation of the device.
It achieves stability in incremental upgrades, ensuring normal startup even in unexpected situations, thus improving the stability and reliability of upgrades.
Smart Images

Figure CN115686919B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a non-volatile storage device, a firmware damage processing method and an upgrading method. BACKGROUND
[0002] The flash partition of the charging pile stores the entire starting kernel, and before starting, the CRC value of the kernel image and the pre-value in the environment variable are checked for consistency, and when they are the same, the current image is started.
[0003] However, when we upgrade the system, we need to completely erase the entire backup area and then rewrite the startup flag to complete the upgrade startup, which cannot realize incremental upgrade, and if an unexpected power failure, signal interruption or other unexpected situations cause the upgrade to fail, the firmware area will be unusable. SUMMARY
[0004] The present application provides a non-volatile storage device, a firmware damage processing method and an upgrading method, which has the advantages of realizing incremental upgrade and reducing firmware capacity.
[0005] In order to solve the above technical problems, the present application solves the problems through the following technical solutions:
[0006] A non-volatile storage device, comprising a BootLoader area, a read-only file firmware area, a readable and writable file firmware area and a flag area;
[0007] The BootLoader area is used to determine the partition to be started according to the flag of the flag area;
[0008] The read-only file firmware area is used to store system critical firmware, and the data writing mode of the read-only file firmware area is integral writing and covering;
[0009] The readable and writable file firmware area is used to realize backup rollback, and the data writing mode of the readable and writable file firmware area is separate writing and covering, wherein the backup rollback means that when incremental upgrade is performed, incremental package writing and image generation can be realized to cover the read-only file firmware area;
[0010] The flag area is used to store startup flags, startup checksums and upgrade flags.
[0011] Optionally, it further comprises a general file system area, which is used to store storage running data or user data logs of a general file system.
[0012] Optionally, the readable and writable file firmware area is an abnormal damage backup of the read-only file firmware area, and the read-only file firmware area is an incremental upgrade backup of the readable and writable file firmware area.
[0013] A firmware damage processing method of a non-volatile storage device, the firmware damage processing method is applied to the non-volatile storage device in any one of the above, comprising the following steps:
[0014] Judging whether the read-only file firmware area is normally started;
[0015] If it is normally started, the read-only file firmware area is not damaged, if it cannot be started, restarting the non-volatile storage device, starting the read-write file firmware area, and compressing all data of the read-write file firmware area to generate cover backup data;
[0016] Based on the cover backup data, covering all data of the read-only file firmware area, and resetting the start flag of the read-only file firmware area.
[0017] Optionally, judging whether the read-only file firmware area is normally started, comprising the following steps:
[0018] Reading the start flag of the read-only file area, judging whether the start flag is startable;
[0019] If the start flag is startable, performing a timing reset process, and modifying the start flag to be unstartable;
[0020] During the timing reset process, judging whether a reset occurs, if it occurs, the read-only file firmware area cannot be started, if it does not occur, the read-only file firmware area is normally started.
[0021] Optionally, further comprising the following steps:
[0022] When the read-only file firmware area cannot be started, judging whether the read-write file firmware area is normally started.
[0023] Optionally, the restarting of the non-volatile storage device is based on the result of the timing reset process being in a reset state.
[0024] An upgrading method of a non-volatile storage device, the upgrading method is applied to the non-volatile storage device in any one of the above, comprising the following steps:
[0025] Receiving a remote upgrading instruction and an upgrading package, based on the type of the upgrading package, updating the data package of the read-write file firmware area;
[0026] Verifying whether the read-write file firmware area is normally running;
[0027] If the normal operation, the data packet of the read-write file firmware area is compressed to generate an upgrade image packet, and after erasing the read-only file firmware area, the upgrade image packet is written, and after verifying the normal start of the read-only file firmware area, an upgrade success flag is returned;
[0028] If the normal operation fails, the read-only file firmware area is started, rollback processing is performed, the data packet after the rollback processing is overwritten on the read-write file firmware area, and an upgrade failure flag is returned.
[0029] Optionally, based on the type of the upgrade packet, the data packet of the read-write file firmware area is updated, including the following steps:
[0030] If the upgrade packet is an incremental upgrade packet, the read-write file firmware area is directly written;
[0031] If the upgrade packet is a whole packet upgrade packet, after receiving the whole packet upgrade packet in the general file system area, the whole packet upgrade packet is overwritten on the read-write file firmware area.
[0032] A charging device, the charging device includes the nonvolatile storage device as claimed in any one of the above.
[0033] Compared with the prior art, the technical scheme provided by the application has the following beneficial effects:
[0034] By setting the read-write file firmware area, incremental upgrade is realized, the firmware capacity is reduced, and at the same time, during upgrade, the read-write file firmware area is preferentially set to be used, so that even if power failure or signal interruption occurs, the start and operation of the read-only file firmware area are not affected, the stability of the upgrade is improved, and during start and operation, the read-only file firmware area has a higher priority, and the read-write file firmware area is started as a backup. Through the double backup mechanism of such start backup and upgrade backup, when any one of the read-only file firmware area and the read-write file firmware area in the storage device is damaged, automatic rollback self-recovery of the storage device can be realized, and normal operation and start can be realized. BRIEF DESCRIPTION OF DRAWINGS
[0035] In order to more clearly illustrate the technical scheme in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0036] Figure 1 A partition diagram of a nonvolatile storage device provided in the first embodiment. DETAILED DESCRIPTION
[0037] The application will be further described in detail in connection with the following examples. The following examples are used to explain the application, but the application is not limited to the following examples.
[0038] Example 1
[0039] The non-volatile storage device comprises a BootLoader area, a read-only file firmware area, a read-write file firmware area and a flag area. The BootLoader area is used to determine the partition to be started according to the flag of the flag area. The read-only file firmware area is used to store system key firmware, and the data writing mode of the read-only file firmware area is overall writing and covering. The read-write file firmware area is used to realize backup rollback, and the data writing mode of the read-write file firmware area is separate writing and covering. The backup rollback means that when incremental upgrade is performed, the writing of the incremental package is realized and the mirror covering read-only file firmware area is generated. The flag area is used to store the starting flag, the starting checksum and the upgrade flag.
[0040] Specifically, the BootLoader area is responsible for the boot program of the system starting after power-on, such as the linux system, the rtlinux system and the like. Then, according to the flag of the flag area, it is determined whether the partition to be started is the read-only file firmware area or the read-write file firmware area. The read-only file firmware area is a read-only file system using a high compression rate fast decompression algorithm, and can store system key firmware such as kernel, dtb, rootfs and the like, and can realize full upgrade. The read-write file firmware area stores the same data as the read-only file firmware area using an uncompressed storage mode, and is used to realize backup rollback and the like. The flag area is used to store the starting flag of each area, the CRC checksum code to be verified before starting each area, and the upgrade flag for upgrade.
[0041] Meanwhile, the read-write file firmware area is the backup of the abnormal damage of the read-only file firmware area, and the read-only file firmware area is the incremental upgrade backup of the read-write file firmware area. When the non-volatile storage device is running, the read-only file firmware area is started preferentially, so that when unexpected power-off, signal interruption and the like occur, only the upgrade package processing is performed in the read-write file firmware area. Even if unexpected situations occur, the read-only file firmware area will not be affected, thereby ensuring the normal operation of the non-volatile storage device and improving the stability of the upgrade.
[0042] On the other hand, the non-volatile storage device further comprises a general file system area. The general file system area is used to store the storage running data or user data log of the general file system. When the upgrade package is an integral package upgrade, the integral upgrade package is stored in the general file system area, and after processing, it is written into the read-write file firmware area.
[0043] Example 2
[0044] The application discloses a firmware damage processing method of a nonvolatile storage device, and belongs to the technical field of nonvolatile storage devices.
[0045] Specifically, first, it is necessary to indicate that whether the read-only file firmware area is normally started includes two steps, the first is whether the start flag is set to need to start, and the second is to confirm whether the read-only file firmware area is actually started after the judgment of the start flag is completed. Based on this, after power-on, the BootLoader area is first loaded, the boot program is started, the boot program first reads the start flag of the flag area, and then judges whether the start flag of the read-only file firmware area is startable. The code flag of startable is 0xAA. The method for judging the start flag of the read-only file firmware area is to compare whether the check code of the kernel in the read-only file firmware area is consistent with the check code in the flag area. If they are consistent, it means that the start flag of the read-only file firmware area is startable, otherwise it is not startable.
[0046] After judging that the start flag of the read-only file firmware area is startable, it is impossible to confirm whether the read-only file firmware can actually be started, so in order to detect whether the read-only file firmware area is damaged, it is necessary to first change the start flag to be unstartable, so as to separately detect whether the read-only file firmware area can actually be started. The program code of the unstartable start flag is 0x55.
[0047] Further, the timing reset processing is set. The timing mentioned in the embodiment can be artificially set according to the actual situation, which is not limited here, and the timing reset processing is the dog feeding processing. If the read-only file firmware area is not started for a long time, the dog feeding time reaches, the dog is starved, and the nonvolatile storage device is reset. Therefore, when judging whether the read-only file firmware area is actually normally started, the dog feeding method is used for judgment.
[0048] Further, if it is normally started, the read-only file firmware area is actually not damaged, if it cannot be started, the nonvolatile storage device is restarted, wherein the nonvolatile storage device is restarted based on the result of the timing reset processing, that is, the dog is starved, then the readable and writable file firmware area is started, and all data of the readable and writable file firmware area is compressed to generate the backup data.
[0049] Specifically, if the read-only file firmware area can be normally started and is not damaged within the set time of the timing reset process, the root file system is mounted after the read-only file firmware area is successfully started, and then the start flag of the read-only file firmware area in the flag area needs to be updated to startable, and the start flag is reset; if the read-only file firmware area cannot be started, it means that the read-only file firmware area is damaged and cannot mount the root file system. At this time, under the timing reset mechanism of the timing reset process, the non-volatile storage device is restarted, and after the reset, the program of the BootLoader area first reads the start flag of the read-only file firmware area in the flag area. At this time, since it is set to unstartable before the damage is detected, the setting of unstartable before the damage is detected is still retained in the case of detecting that the read-only file firmware area is actually damaged.
[0050] Further, when the read-only file firmware area cannot be started, it is judged whether the readable and writable file firmware area is normally started. Specifically, after obtaining the start flag of the read-only file firmware area as unstartable, since the readable and writable file firmware area is the backup of the damaged read-only file firmware area, the program of the BootLoader area will judge whether the start flag of the readable and writable file firmware area is startable,
[0051] When judging, similarly, it is necessary to compare whether the check code of the kernel in the readable and writable file firmware area is consistent with the check code in the flag area. If they are consistent, the timing reset process is performed, and the start flag of the readable and writable file firmware area is updated to unstartable. Then, within the timing time of the timing reset process, if the reset occurs, it means that the readable and writable file firmware area used for backup is also damaged, and the reporting process needs to be performed; if the reset does not occur, the readable and writable file firmware area is successfully started and the root file system is mounted, and then the start flag of the readable and writable file firmware area is updated to startable again, and then the read-only file firmware area is restored. At this time, after the readable and writable file firmware area is started and runs, the backup data is obtained in the form of data packaging and compression of the entire area, and then based on the backup data, all data of the read-only file firmware area is overwritten, the rollback function is completed, the stability of the non-volatile storage device is ensured, and then the start flag of the read-only file firmware area is reset. Finally, the damaged event log data is generated and reported to the upper computer, so as to inform the occurrence of the event, so as to avoid and summarize the event in the future.
[0052] Embodiment Three
[0053] The upgrading method of the non-volatile storage device is applied to the non-volatile storage device in Embodiment One, and includes the following steps: receiving a remote upgrading instruction and an upgrading package, updating the data package of the read-write file firmware area based on the type of the upgrading package; when the device using the non-volatile storage device needs to be upgraded, the read-only file firmware area starts the whole device, then receives the remote upgrading script and data package, i.e. the remote upgrading instruction and the upgrading package, and judges the type of the upgrading package; if the upgrading package is an incremental upgrading package, the read-write file firmware area is directly written; if the upgrading package is a whole package upgrading package, the whole package upgrading package is received in the general file system area, and then the whole package upgrading package is covered in the read-write file firmware area using tar.
[0054] Further, to verify whether the upgrading is successful, it is needed to check whether the read-write file firmware area is normally running; first, the priority of the startup flag in the flag area is modified to the startup of the read-write file firmware area, then restarted, after the restart, the upgrading flag of the read-write file firmware area is changed to non-upgradable in the program boot stage of the BootLoader area, at this time, it is checked whether the read-write file firmware area is normally running, the checking method is to reset by timing, i.e. dog feeding processing,
[0055] If it is normally running, i.e. no reset appears, the read-write file firmware area is normally running and the startup is successful, at this time, the data package of the read-write file firmware area is compressed to generate an upgrading image package, and after the read-only file firmware area is erased, the upgrading image package is written, after the read-only file firmware area is checked to be normally started, the upgrading success flag is returned
[0056] Specifically, the read-write file firmware area uses a high compression rate fast decompression algorithm to package all data to generate an upgrading image package, then erases the data in the read-only file firmware area, and writes the upgrading image package into the read-only file firmware area, thereby completing the writing of the upgrading package into the read-only file firmware area
[0057] Then the priority of the startup flag in the flag area is updated to the read-only file firmware area, then to verify whether the upgrading of the read-only file firmware area is successful, the non-volatile storage device needs to be restarted again, then the BootLoader area boot program changes the startup flag of the read-only file firmware area to non-startup, and then the reset by timing processing is performed to judge whether the reset condition appears, if not, it indicates that the read-only file firmware area is normally started and the upgrading is successful, and the upgrading success flag is reported.
[0058] If the read-write file firmware area cannot normally run, i.e. a reset occurs, the startup flag of the read-write file firmware area is set to "unstartable", the read-only file firmware area needs to be started, i.e. the version before upgrading is started from the read-only file firmware area, and after starting, rollback processing is performed, the data packet after rollback processing is overwritten on the read-write file firmware area, and an upgrade failure flag is returned.
[0059] Specifically, the rollback processing is that the high compression original packet of the read-only file firmware area is overwritten on the read-write file firmware area in a decompression manner, then the startup flag of the read-write file firmware area is modified to "startable", the upgrade flag is modified to "unstartable", and the remote terminal is sent the information of the upgrade packet error, i.e. the upgrade failure flag is returned.
[0060] A charging device, the charging device comprising the nonvolatile storage device according to any one of the embodiments, wherein the charging device can be a smart charging pile or the like for charging, which is not specifically limited in the embodiment.
[0061] The above is only a preferred embodiment of the present application, and is not a limitation on the form and essence of the present application. It should be noted that, for those skilled in the art, without departing from the method of the present application, some improvements and supplements can also be made, which should also be considered as the protection scope of the present application. For those skilled in the art, without departing from the spirit and scope of the present application, some changes, modifications and equivalent changes can be made by using the above disclosed technical content, which are equivalent embodiments of the present application; at the same time, any equivalent changes, modifications and evolution of the above embodiments according to the essential technology of the present application are still within the scope of the technical solutions of the present application.
Claims
1. A nonvolatile storage device, characterized by comprising: The BootLoader area, the read-only file firmware area, the read-write file firmware area and the flag area are included. The BootLoader area is used to determine the started partition according to the flag of the flag area. The read-only file firmware area is used to store system key firmware, and the data writing mode of the read-only file firmware area is overall writing and covering. The read-write file firmware area is used to realize backup rollback, and the data writing mode of the read-write file firmware area is separate writing and covering. The read-write file firmware area is the abnormal damage backup of the read-only file firmware area, and the read-only file firmware area is the incremental upgrade backup of the read-write file firmware area. The flag area is used to store starting flags, starting checksum and upgrade flags. A general file system area is further included, which is used to store storage running data or user data logs of a general file system.
2. A firmware damage processing method of a nonvolatile storage device, characterized by comprising: The firmware damage processing method is applied to the nonvolatile storage device of claim 1, and includes the following steps. Determine whether the read-only file firmware area is normally started. If the read-only file firmware area is normally started, it is not damaged, and if it cannot be started, restart the nonvolatile storage device, start the read-write file firmware area, compress all data of the read-write file firmware area, and generate backup data for covering. Based on the backup data for covering, cover all data of the read-only file firmware area, and reset the starting flag of the read-only file firmware area.
3. The firmware damage processing method of a nonvolatile storage device according to claim 2, wherein Determine whether the read-only file firmware area is normally started, including the following steps. Read the starting flag of the read-only file area, and determine whether the starting flag can be started. If the starting flag can be started, perform timing reset processing, and modify the starting flag to be unable to be started. During the timing reset processing, determine whether reset occurs, if yes, the read-only file firmware area cannot be started, and if no, the read-only file firmware area is normally started.
4. The firmware damage processing method of a nonvolatile storage device according to claim 2, wherein Further include the following steps. When the read-only file firmware area cannot be started, determine whether the read-write file firmware area is normally started.
5. The firmware damage processing method of a nonvolatile storage device according to claim 3, wherein The nonvolatile storage device is restarted based on the result of the timing reset processing being in the reset state.
6. An upgrading method of a nonvolatile storage device, characterized by comprising: The upgrade method is applied to the nonvolatile storage device of claim 1, and includes the following steps. Receive a remote upgrade instruction and an upgrade package, update the data package of the read-write file firmware area based on the type of the upgrade package. Determine whether the read-write file firmware area is normally running. If it is normally running, compress the data package of the read-write file firmware area, generate an upgrade image package, write the upgrade image package after erasing the read-only file firmware area, return an upgrade success flag after determining that the read-only file firmware area is normally started. If it cannot be normally running, start the read-only file firmware area, and perform rollback processing, cover the data package after the rollback processing to the read-write file firmware area, and return an upgrade failure flag.
7. The upgrading method of a nonvolatile memory device according to claim 6, wherein Update the data package of the read-write file firmware area based on the type of the upgrade package, including the following steps. If the upgrade package is an incremental upgrade package, the read-write file firmware area is directly written; If the upgrade package is a whole package upgrade package, after the whole package upgrade package is received in the general file system area, the whole package upgrade package covers the read-write file firmware area.
8. A charging device comprising the nonvolatile storage device according to claim 1.
Citation Information
Patent Citations
Control method and control device used for software version upgrade and based on dual file system
CN102622280A
Service-uninterrupted upgrading method, to-be-upgraded node and readable storage medium
CN107515776A