Updating method and device after router crash, electronic equipment and storage medium

By reading environmental variables and calculating count values ​​in the bootloader stage, it automatically triggers firmware upgrades and backs up user configurations, solving the problems of complicated operations and data loss after a router system crash, implementing a low-cost, automated router recovery process, and preventing frequent restarts and storage aging.

CN120692156APending Publication Date: 2025-09-23HUIZHOU GAOSHENGDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510622641.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

In the prior art, the method for restoring the system after a router system crash is complicated and costly, user configuration data is easily lost, frequent restarts lead to aging of storage particles, and there is no automatic backup and recovery mechanism.

Method used

By reading environment variables in the bootloader stage, calculating the count value and triggering the upgrade mode, automatically backing up the user configuration and encrypting it with AES-256, creating a fallback partition to prevent frequent restarts, and using the real-time count value and preset extreme value to determine whether to upgrade the firmware.

Benefits of technology

It enables simple and convenient firmware upgrades at the bootloader stage without additional hardware costs, automatically backs up and restores user configurations, prevents data loss and frequent restarts, and extends storage life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120692156A_ABST
    Figure CN120692156A_ABST
Patent Text Reader

Abstract

The invention relates to an updating method and device after router crash, electronic equipment and a storage medium. The method for updating the crashed router comprises the following steps: reading an environment variable, carrying out calculation processing on the environment variable, and outputting a count value; guiding the router module to perform initialization processing, if the router module is started abnormally, performing superposition processing on the count value, and outputting a real-time count value; and triggering an upgrade mode according to the fact that the real-time count value is greater than a preset extreme value, so that the router module obtains firmware upgrade. According to the scheme provided by the invention, the method for upgrading the router in the bootloader stage, which is simple, convenient and low in cost, can be provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of routers, and in particular to a method, device, electronic device and storage medium for updating a router after it crashes. Background Art

[0002] The bootloader is a special boot program that runs first when the router starts up. It has the important tasks of initializing the hardware and guiding the router's operating firmware.

[0003] In the related art, the method for restoring the system after a router system crash is to manually add a button or bring out the router serial port to enter the upgrade mode through the bootloader menu during the bootloader stage. This is not only complicated but also costly. Summary of the Invention

[0004] The purpose of the present invention is to overcome the deficiencies in the prior art and provide a method, device, electronic device and storage medium for updating a router after a crash, which can provide a simple, convenient and low-cost method for upgrading a router at the bootloader stage.

[0005] The object of the present invention is achieved through the following technical solutions:

[0006] In a first aspect, the present application provides a method for updating a router after a crash, comprising reading environment variables, calculating and processing the environment variables, and outputting a count value; guiding a router module to initialize, and if the router module starts abnormally, superimposing the count value and outputting a real-time count value; and triggering an upgrade mode based on the real-time count value being greater than a preset extreme value, so that the router module obtains a firmware upgrade.

[0007] The method further includes: if the router module starts normally, clearing the count value and outputting a zero value.

[0008] The method further includes: creating the environment variable, performing calculation processing on the environment variable, and outputting a preprocessing count value.

[0009] The method further includes exiting the upgrade mode if the router module fails to obtain the firmware within a preset time threshold.

[0010] A second aspect of the present application provides an update device after a router crashes, comprising: a reading module for reading environmental variables, performing calculation processing on the environmental variables, and outputting a count value; an initialization module for guiding the initialization processing of the router module, and if the router module starts abnormally, superimposing the count value and outputting a real-time count value; an update module for triggering an upgrade mode based on the real-time count value being greater than a preset extreme value, so that the router module obtains a firmware upgrade.

[0011] The initialization module is further configured to clear the count value and output a zero value if the router module starts normally.

[0012] It also includes a writing module, which is used to create the environment variables, perform calculation processing on the environment variables, and output a preprocessing count value.

[0013] It also includes a switching module, which is used to exit the upgrade mode if the router module fails to obtain the firmware within a preset time threshold.

[0014] A third aspect of the present application provides an electronic device, including:

[0015] processor; and

[0016] The memory stores executable codes thereon, and when the executable codes are executed by the processor, the processor is caused to execute the method described above.

[0017] A fourth aspect of the present application provides a computer-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor is caused to execute the method described above.

[0018] Compared with the prior art, the present invention has at least the following advantages:

[0019] This application determines the relationship between the real-time count value and the preset extreme value to determine whether the bootloader triggers the upgrade mode. The entire process is implemented at the software level, without adding additional hardware costs or leading to the serial port to enter the upgrade mode, thus simplifying the operation process. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments.

[0021] Figure 1 A flowchart of a method for updating a router after a crash according to an embodiment of the present invention;

[0022] Figure 2A flowchart of another implementation of a method for updating a router after a crash in one embodiment of the present invention;

[0023] Figure 3 A flowchart of another implementation of a method for updating a router after a crash in one embodiment of the present invention;

[0024] Figure 4 A functional module diagram of a post-router crash update device according to an embodiment of the present invention;

[0025] Figure 5 FIG. 4 is a schematic structural diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following describes embodiments of the present application in more detail with reference to the accompanying drawings. Although the accompanying drawings illustrate embodiments of the present application, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. Rather, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.

[0027] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0028] Unless otherwise expressly specified or limited, the terms "mounted," "connected," "connect," "fixed," and the like should be interpreted broadly. For example, they may refer to fixed connection, detachable connection, or integration; mechanical connection or electrical connection; direct connection or indirect connection through an intermediate medium; and internal communication between two components or interaction between two components. Those skilled in the art will understand the specific meanings of the above terms in this application based on the specific circumstances.

[0029] The method of restoring the router system after a crash is to manually add a button or bring out the router serial port to enter the upgrade mode through the bootloader menu during the bootloader stage. This operation is not only complicated but also costly.

[0030] To address the above issues, embodiments of the present application provide a method, device, electronic device, and storage medium for updating a router after it crashes, which can provide a simple, convenient, and low-cost method for upgrading a router at the bootloader stage.

[0031] The technical solutions of the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0032] Figure 1 This is a flow chart of a method for updating a router after a crash, as shown in an embodiment of the present application.

[0033] See also Figure 1 , a method for updating a router after a crash, comprising:

[0034] Step S101: read the environment variables, perform calculations on the environment variables, and output a count value.

[0035] It should be noted that after the router is powered on, the bootloader reads the environment variables. The initial value of the environment variable is 0. After the bootloader obtains the value, the value is incremented and saved. In addition, if the bootloader cannot read the environment variables, it creates the environment variables, calculates the environment variables, and outputs a preprocessing count value. The preprocessing count value and the count value are both the same, 1.

[0036] Step S102: boot the router module to initialize. If the router module is abnormally started, the count value is superimposed and the real-time count value is output.

[0037] It should be noted that the bootloader will guide the router module to initialize and start up. If the router module starts abnormally, the count value will be added to a value, and the output real-time count value will be 2. Specifically, if the router module starts abnormally, the count value will not be reset to zero. Each time the router module is powered on again, and each time the router module starts abnormally, the real-time count value will be the previous real-time count value plus 1. If the router module starts normally, the count value will be reset to zero, indicating that the router module starts normally, and the count value will be reset to 0.

[0038] Step S103: triggering an upgrade mode based on the real-time count value being greater than a preset limit value, so that the router module obtains a firmware upgrade.

[0039] It should be noted that the preset extreme value is greater than or equal to 5. This is to prevent the router module from starting abnormally due to accidental touch or unstable external power supply. Furthermore, when the real-time count value is greater than the preset extreme value, the bootloader will trigger the upgrade mode, and the router module will actively request the firmware file named GsdFW.bin from the tftp server. If the request is successful, the upgrade will be performed through the file. At this time, you only need to connect the router to the PC via a network cable, and configure the default static IP address of the router network card to 192.168.1.2. Then, open the tftp server on the PC and select the server's working directory to the GsdOta.bin directory. The tftp server is a server software that implements the simple file transfer protocol, which is used for lightweight file transfers between the client and the server.

[0040] Furthermore, in one embodiment, if the router module fails to obtain the firmware within a preset time threshold, the upgrade mode is exited.

[0041] It can be understood that the preset time threshold can be 3 seconds. If the router module fails to obtain the firmware within the preset time threshold, the bootloader exits the upgrade mode and automatically switches to the normal use mode. This is to avoid the situation where the external power supply is unstable for many consecutive times and the router module is repeatedly restarted incompletely in a small probability, causing the real-time count value to exceed the preset extreme value, and then mistakenly believe that the router module has crashed and automatically enters the upgrade mode. At this time, as long as the PC does not open the tftp server, the router module can start normally after waiting for the time threshold to exceed.

[0042] Furthermore, in another embodiment, when existing routers enter upgrade mode to update firmware after a crash, there is a common problem of user configuration data loss. Traditional methods require users to manually back up configurations such as WiFi passwords and port mappings. However, if the user does not back up or makes an error in the operation, reconfiguration is required after the update, which is time-consuming and laborious. Although some routers support configuration export and import functions, they rely on user active operation, and backup files are prone to recovery failure due to storage medium failure or format incompatibility. Therefore, a method for updating a router after a crash also includes:

[0043] Step S201: partition processing is performed in the router module to output the firmware storage area, user configuration area and independent backup area.

[0044] It should be noted that the firmware storage area is used to store the current firmware and the firmware to be updated, the user configuration area is used to store the real-time configuration data, and the independent backup area is used to store encrypted backup files. These three partitions are independent of each other.

[0045] Step S202: If the firmware verification fails, read the plaintext data in the user configuration area, encrypt the plaintext data, and output the backup hash value and encrypted data.

[0046] It should be noted that if the firmware verification fails, the Bootloader will send a data backup instruction to the control unit of the router module. The control unit reads the plaintext data from the user configuration area, where the plaintext data includes but is not limited to the basic network configuration, WIFI parameters and advanced function configuration. Then the plaintext data is encrypted with AES-256 and a SHA-256 hash value is generated.

[0047] Step S203: Write the backup hash value and encrypted data into an independent backup partition.

[0048] It should be noted that the backup hash value and encrypted data will be written to a separate backup partition, overwriting the old backup.

[0049] Step S204: Load the real-time firmware from the firmware storage area, perform verification processing, erase the firmware, and write the real-time firmware to the firmware storage area.

[0050] It should be noted that the Bootloader loads the new firmware from the firmware storage area, performs CRC32 checksum and digital signature verification, and after passing, erases the old firmware partition and writes the new firmware.

[0051] Step S205: Read the encrypted data of the independent backup partition, decrypt the encrypted data, and output a real-time hash value.

[0052] Step S206: Determine whether the real-time hash value is the same as the backup hash value. If so, output the configuration data, erase the plaintext data, and write the configuration data to the user configuration area. If not, load the factory default configuration of the router module.

[0053] It should be noted that after the firmware update is completed, the control unit will first read the latest backup from the independent backup partition, then perform AES-256 decryption on the encrypted data, generate a real-time hash value and compare it with the backup hash value; if the verification passes, the configuration data will be written to the user configuration area and overwrite the default configuration; if the verification fails, the router's factory default configuration will be loaded.

[0054] This approach eliminates the need for manual user intervention, automatically triggering backups after a crash and automatically restoring the device after an update. AES-256 encryption prevents data leakage, and SHA-256 checksums ensure integrity. This effectively addresses the common problem of user configuration data loss when a router enters upgrade mode to update firmware after a crash.

[0055] Furthermore, in another embodiment, after the router firmware is updated, it may frequently restart due to abnormalities such as power outages and network interruptions that result in incomplete firmware writing, resulting in a "semi-corrupted" state. Therefore, a method for updating a router after a crash also includes:

[0056] Step S301: Create a rollback partition, and the control unit backs up the firmware to the rollback partition.

[0057] It should be noted that the fallback partition uses a ring buffer structure to store the three most recent old firmware version images.

[0058] Step S302: The control unit executes the update process corresponding to the real-time firmware and generates a restart instruction and an abnormality detection timer.

[0059] It should be noted that the restart instruction is used to cause the router module to restart according to the real-time firmware update, and the abnormality detection timer is used to monitor the number of abnormal restarts of the router module.

[0060] Step S303: Record the number of restarts and the restart interval within a preset time window through the abnormality detection timer. If the number of restarts is greater than the rated threshold and the restart interval is less than the rated interval, output abnormal restart cycle information.

[0061] It should be noted that the rated threshold is generally 5 times, and the restart interval is generally 2 minutes. By monitoring the number of restarts and the restart interval, it is possible to accurately determine whether the router module has an abnormal restart cycle.

[0062] Step S304: triggering an automatic rollback mechanism based on the abnormal restart cycle information. The automatic rollback mechanism includes: loading firmware from the rollback partition, outputting a firmware image, clearing residual configurations of the real-time firmware, running the firmware image, and outputting a diagnostic report of the restart log.

[0063] It's important to note that to prevent the router module from entering a vicious reboot loop, an automatic fallback mechanism is triggered after an abnormal reboot loop message is generated. Specifically, the bootloader modifies the boot parameters to load the old firmware image from the fallback partition and cleans up any remaining configurations in the real-time firmware. This ensures the router module operates normally and prevents damage from frequent reboots. Finally, users can analyze key error log snippets based on the reboot log diagnostic report to identify any compatibility issues with the real-time firmware.

[0064] This method prevents repeated read and write operations on the firmware partition caused by frequent reboots. This is because flash memory has a limited number of erase and write cycles. The error recovery mechanism during an abnormal reboot will cause additional write operations, accelerating the aging of the storage chips. This can ultimately lead to an increase in bad blocks in the flash memory and prevent the firmware from being properly read. Furthermore, it can address the issue of memory overload and heating caused by repeated router reboots.

[0065] Corresponding to the aforementioned embodiment of the method for implementing application functions, the present application also provides an update device after a router crashes, an electronic device, and corresponding embodiments.

[0066] Figure 4 This is a functional module diagram of an update device after a router crashes, shown in an embodiment of the present application.

[0067] See also Figure 4 A device for updating a router after a crash includes: a reading module 100, an initialization module 200, and an update module 300, for reading environment variables, calculating and processing the environment variables, and outputting count values; the initialization module 200 is used to guide the initialization of the router module. If the router module starts abnormally, the count values ​​are superimposed and output as a real-time count value; the update module 300 is used to trigger an upgrade mode based on the real-time count value being greater than a preset extreme value, so that the router module obtains a firmware upgrade.

[0068] In a real-time mode, the initialization module 200 is further configured to clear the count value and output a zero value if the router module starts normally.

[0069] In a real-time mode, a writing module is also included, and the writing module is used to create environmental variables, perform calculation processing on the environmental variables, and output pre-processing count values.

[0070] In a real-time mode, a switching module is further included, and the switching module is used to exit the upgrade mode if the router module fails to obtain the firmware within a preset time threshold.

[0071] Regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated again here.

[0072] Figure 5 It is a structural diagram of an electronic device shown in an embodiment of the present application.

[0073] See also Figure 5 , the electronic device 1000 includes a memory 1010 and a processor 1020.

[0074] The processor 1020 may be a central processing unit (CPU), or an integrated circuit composed of other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor may be any conventional processor that can run the Linux kernel.

[0075] The memory 1010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage. ROM may store static data or instructions required by the processor 1020 or other modules of the computer. The permanent storage may be a readable and writable storage device. The permanent storage may be a non-volatile storage device that retains stored instructions and data even when the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (e.g., a magnetic or optical disk, flash memory) as the permanent storage device. In other embodiments, the permanent storage device may be a removable storage device (e.g., a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as dynamic random access memory. The system memory may store some or all instructions and data required by the processor during operation. In addition, the memory 1010 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and magnetic disks and / or optical disks may also be used. In some embodiments, the memory 1010 may include a readable and / or writable removable storage device, such as a compact disc (CD), a read-only digital versatile disc (e.g., DVD-ROM, double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not include carrier waves and transient electronic signals transmitted wirelessly or wired.

[0076] The memory 1010 stores executable codes. When the executable codes are processed by the processor 1020 , the processor 1020 may execute part or all of the above-mentioned methods.

[0077] In addition, the method according to the present application may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present application.

[0078] Alternatively, the present application can also be implemented as a computer-readable storage medium (or non-transitory machine-readable storage medium or machine-readable storage medium) on which executable code (or computer program or computer instruction code) is stored. When the executable code (or computer program or computer instruction code) is executed by a processor of an electronic device (or server, etc.), the processor executes part or all of the steps of the above-mentioned method according to the present application.

[0079] The scheme of the present application has been described in detail above with reference to the accompanying drawings. In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. Those skilled in the art should also be aware that the actions and modules involved in the description are not necessarily required for this application. In addition, it is understood that the steps in the method of the embodiment of the present application can be adjusted in sequence, merged and deleted according to actual needs, and the modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.

[0080] The embodiments of the present application have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or improvements to the technology in the market, or to enable other persons skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for updating a router after a crash, characterized in that: include: Reading environment variables, performing calculations on the environment variables, and outputting count values; Initiate the router module initialization process. If the router module fails to start normally, perform superposition processing on the count value and output a real-time count value. According to the real-time count value being greater than a preset extreme value, an upgrade mode is triggered to enable the router module to obtain a firmware upgrade.

2. The update method after a router crash according to claim 1, characterized in that: The method further comprises: If the router module starts normally, the count value is cleared and a zero value is output.

3. The update method after a router crash according to claim 1, characterized in that: The method further comprises: The environment variable is created, the environment variable is calculated and processed, and a preprocessing count value is output.

4. The update method after a router crash according to claim 1, characterized in that: The method further comprises: If the router module fails to obtain the firmware within a preset time threshold, the upgrade mode is exited.

5. A device for updating after a router crashes, characterized in that: include: A reading module is used to read environmental variables, perform calculations on the environmental variables, and output count values; An initialization module is used to guide the initialization process of the router module. If the router module is abnormally started, the count value is superimposed and a real-time count value is output; The update module is used to trigger an upgrade mode according to the real-time count value being greater than a preset extreme value, so that the router module obtains a firmware upgrade.

6. The update device after a router crash according to claim 5, characterized in that: The initialization module is further configured to clear the count value and output a zero value if the router module starts normally.

7. The updating device after a router crash according to claim 5, characterized in that: It also includes a writing module, which is used to create the environment variables, perform calculation processing on the environment variables, and output a preprocessing count value.

8. The update device after a router crash according to claim 5, characterized in that: It also includes a switching module, which is used to exit the upgrade mode if the router module fails to obtain the firmware within a preset time threshold.

9. An electronic device, characterized in that: include: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 4.

10. A computer-readable storage medium having executable code stored thereon, wherein when the executable code is executed by a processor of an electronic device, the processor is caused to execute the method according to any one of claims 1 to 4.