Real-time clock storage data recovery method and electronic device

By having the BIOS detect and save real-time clock data after the server powers on, and then clearing and restoring the time and date upon shutdown and restart, the problem of time loss after clearing the storage chip is solved, enabling automatic backup and fast recovery, and ensuring the accuracy and continuity of system time and configuration.

CN121050948BActive Publication Date: 2026-04-17INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2025-10-31
Publication Date
2026-04-17

Smart Images

  • Figure CN121050948B_ABST
    Figure CN121050948B_ABST
Patent Text Reader

Abstract

This application discloses a method and electronic device for recovering real-time clock stored data, relating to the field of computer technology. This application involves the Basic Input / Output System (PIS) detecting whether a real-time clock clearing action is being performed after the server is powered on. When this action is detected, the time and date data stored in the real-time clock are first read and temporarily stored in the processor. During the clearing action, the server is powered off, and the real-time clock data is cleared using a jump cap method. Subsequently, the server is restarted, and the updated current time and date obtained from the processor are restored to the real-time clock storage area, thus rewriting the current time and date. This solution effectively prevents the permanent loss of time and date data stored in the real-time clock due to hardware operations or jump cap clearing, thereby ensuring the continuity and accuracy of time information, hardware configuration data, and operation logs after system startup, and improving system maintenance and recovery efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method and electronic device for recovering real-time clock stored data. Background Technology

[0002] CMOS (Complementary Metal-Oxide-Semiconductor) is a memory chip on a computer motherboard used to store critical information such as system time and hardware configuration. With the development of computer technology, the memory chip on the motherboard, primarily used to store critical information such as system time and hardware configuration, has become a crucial component of the computer system. Normally, when a user performs a CMOS clear operation, the time and date information stored in the memory chip is restored to its factory default value. Because clearing the memory chip results in the loss of real-time clock data such as system time, date, and hardware configuration, users need to manually reset the time and date, and the real-time clock data needs to be retrieved again. This imposes an additional operational burden on users, especially in servers and critical systems, where frequent time and date resets and retrieval of real-time clock data can disrupt normal system operation. Summary of the Invention

[0003] This application provides a real-time clock storage data recovery method and electronic device to at least solve the problem in related technologies where the system time, date, and hardware configuration information are lost after the user performs a clearing operation on the storage chip, restoring it to the factory default value. This results in inaccurate system time and date, requiring manual reset of the time and date, and re-acquiring the time and date data stored in the real-time clock. Frequent resets of the time and date and re-acquisition of the real-time clock storage information cause inconvenience to the normal operation of the system, and may lead to problems such as inconsistent timestamps in log information, synchronization problems, and loss of time and date data stored in the real-time clock.

[0004] This application provides a method for recovering real-time clock stored data, including:

[0005] After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed.

[0006] In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before executing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0007] When performing the real-time clock clearing action, the server is shut down, and the time and date data stored in the real-time clock are cleared.

[0008] After performing the real-time clock clearing action, in response to the server powering on, the updated current time and date are obtained from the processor and written into the real-time clock.

[0009] This application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described real-time clock storage data recovery methods.

[0010] After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed.

[0011] In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before executing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0012] When performing the real-time clock clearing action, the server is shut down, and the time and date data stored in the real-time clock are cleared.

[0013] After performing the real-time clock clearing action, in response to the server powering on, the updated current time and date are obtained from the processor and written into the real-time clock.

[0014] This application utilizes a novel approach where the Basic Input / Output System (BIOS) detects the presence of a Real-Time Clock (RTC) clearing action after the server powers on. Upon detection, the BIOS first reads and temporarily stores the time and date data from the RTC in the processor. During the clearing process, the server is powered off, and the RTC data is cleared. The server is then restarted, restoring the updated current time and date from the processor to the RTC storage area, effectively rewriting the current time and date. This solution automatically backs up critical RTC data before it is cleared and quickly restores it afterward, effectively preventing permanent loss of the RTC's time and date data due to hardware operations or cap clearing. This ensures the continuity and accuracy of system time information, hardware configuration data, and operational logs after system startup, improving system maintenance and recovery efficiency. Attached Figure Description

[0015] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A flowchart illustrating the process of manually adjusting the time and date of an existing real-time clock;

[0017] Figure 2 This is a diagram illustrating the application environment of a real-time clock storage data recovery method in one embodiment of this application.

[0018] Figure 3 This is a flowchart illustrating a real-time clock storage data recovery method in one embodiment of this application;

[0019] Figure 4 This is a flowchart illustrating the monitoring phase in one embodiment of this application;

[0020] Figure 5 This is a flowchart illustrating the automatic recovery of time and date stages in one embodiment of this application;

[0021] Figure 6 This is a flowchart illustrating the process of clearing the real-time clock in one embodiment of this application;

[0022] Figure 7 This is a structural block diagram of a real-time clock storage data recovery device in one embodiment of this application;

[0023] Figure 8 This is an internal structural diagram of a computer device in one embodiment of this application. Detailed Implementation

[0024] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0025] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0026] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0027] In electronic devices, the Real-Time Clock (RTC) refers to a hardware clock independent of the motherboard's system clock. The RTC supports both motherboard power and backup power, with the backup power typically using a coin cell battery. When the motherboard loses power, it automatically switches to battery power to continue operating the RTC. The RTC primarily provides hardware time and date, alarms, and custom fields, with a focus on the time and date functionality. Clearing the Real-Time Clock Action Commands (Clear CMOS) is a function that restores all data in the RTC to its hardware default values. In server shutdown scenarios, a jumper cap is used to clear the Real-Time Clock Action Commands.

[0028] like Figure 1 As shown, for example, the default RTC time and date is January 1, 2000, 00:00:00. During server production, the current time and date are set in the RTC. When the user receives the machine, they check that the time and date in the Basic Input / Output System (BIOS Setup) and Operating System (OS) are correct. The server also provides BIOS Setup and OS interfaces for modifying the RTC time and date. After performing the Clear CMOS function in certain user scenarios, the RTC time and date revert to the default value of January 1, 2000, 00:00:00. If the user finds that the default time is inconsistent with the current time and date, they need to change it to the correct time and date. Users can modify this by entering the BIOS Setup or by entering the OS.

[0029] The current solution requires users to manually modify the time and date again. The drawback of this existing technology is that it requires manual modification, which is prone to errors. The overall user experience is poor, reducing customer satisfaction.

[0030] The real-time clock storage data recovery method provided in this application can be applied to, for example... Figure 2 In the application environment shown, terminal 102 communicates with server 104 via a network. Terminal 102 is used to send operation commands to server 104 to modify the time and date in the real-time clock (RTC) or to execute operation commands to clear the real-time clock. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices, and server 104 can be implemented as a standalone server or a server cluster consisting of multiple servers.

[0031] like Figure 3As shown, an embodiment of this application provides a method for recovering real-time clock stored data, including the following steps:

[0032] Step S1: After the server is powered on, check whether the real-time clock clearing action is being performed through the basic input / output system.

[0033] Step S2: In response to the detection of a real-time clock clearing action, before the real-time clock clearing action is performed, the time and date data stored in the real-time clock are read through the basic input / output system, and the time and date data stored in the real-time clock are sent to the processor for storage, and the processor updates the time and date in real time.

[0034] Step S3: When performing the real-time clock clearing action, control the server to shut down and perform the operation to clear the time and date data stored in the real-time clock;

[0035] Step S4: After performing the real-time clock clearing action, in response to the server powering on, the updated current time and date are obtained from the processor and written into the real-time clock.

[0036] This application detects the presence of a Real-Time Clock (RTC) clearing action by the Basic Input / Output System (BIOS) after the server powers on. When this action is detected, the system first reads and temporarily stores the time and date data stored in the RTC in the processor. During the clearing action, the server is powered off, and the RTC data is cleared using a jump cap. The server is then restarted, and the updated current time and date retrieved from the processor are restored to the RTC storage area, effectively rewriting the current time and date. Furthermore, when the stored time and date data is sent to the processor for storage and the processor updates the time and date in real time, a checksum can be used to verify the accuracy of the stored time and date data.

[0037] This method utilizes a jump cap to clear the time and date data stored in the real-time clock. This approach automatically backs up critical stored data before the real-time clock is cleared and quickly restores it afterward. It effectively prevents the permanent loss of time and date data stored in the real-time clock due to hardware operations or jump cap clearing, thus ensuring the continuity and accuracy of system time information, hardware configuration data, and operation logs after system startup, and improving system maintenance and recovery efficiency.

[0038] To ensure that the time and date data stored in the processor are updated in real time, the processor is powered separately. Even when the server is powered off, the processor continues to update the time and date in real time.

[0039] In this embodiment, after the server is powered on, detecting whether a real-time clock clearing action has been performed via the basic input / output system includes:

[0040] After the server is powered on, it will detect in real time whether there is a server shutdown command or a real-time clock power-off command.

[0041] In response to the detection of a server shutdown command, it is determined that the real-time clock is being cleared due to the server shutdown.

[0042] In response to the detection of a real-time clock power-off command, it is determined that a real-time clock clearing action has been performed due to the real-time clock power-off.

[0043] This application enables early identification before the RTC (Real-Time Data) is potentially erased. The system can perform a backup process before the risk is triggered, preventing the loss of critical time data. By intelligently judging shutdown and power-off signals, the system can proactively take protective measures, thereby effectively reducing data corruption caused by human intervention and misoperation, and improving the security of time information and the overall reliability of the system.

[0044] In this embodiment, real-time detection of whether a server shutdown command or a real-time clock power-off command exists after the server is powered on includes:

[0045] After the server is powered on, a monitoring program is built using the Basic Input / Output System. The monitoring program is used to monitor the access data of the address register port and the data register port.

[0046] Upon detecting a modification to the time and date in the real-time clock via access data, the modified time and date are read from the real-time clock and sent to the processor.

[0047] If a server restart or shutdown is detected through access data, it is determined that a server shutdown command exists.

[0048] The address selection register port and data register port are I / O port 70 and I / O port 71, respectively. By utilizing the BIOS monitoring program to monitor changes in the real-time clock's time and date, it is possible to effectively detect whether the operating system (OS) or BIOS has modified the real-time clock's time and date, promptly identifying potential errors or malicious tampering. This function not only ensures time consistency during boot but also provides strong support for subsequent system diagnostics. If the time data is tampered with, the system will automatically trigger an alarm, helping system administrators quickly locate and repair the problem, thereby enhancing system security and reliability.

[0049] This application is divided into three stages according to the implementation process: preparation stage, monitoring stage, and automatic recovery time and date stage.

[0050] The first stage is the preparation phase. When the server starts up, the Basic Input / Output System Settings (BIOS) builds SMI program code to monitor I / O ports 70 and 71. Any operation that accesses I / O ports 70 and 71 will first run to the SMI program code, which is mainly used to monitor whether any user is using I / O ports 70 and 71 to modify the RTC time and date.

[0051] like Figure 4 As shown, the next step is the monitoring phase. Currently, the server provides two methods for modifying the RTC time and date: Basic Input / Output System Setup (BIOS Setup) and Operating System (OS). Both methods use I / O ports 70 and 71 to modify the RTC time and date. When the BIOS monitoring program code detects that the user is using I / O ports 70 and 71 and has modified the RTC time and date, the BIOS retrieves the modified time and date from the RTC again, constructs a checksum for the time and date, and packages this data together and sends it to the processor (BMC). After receiving the time, date, and checksum, the BMC first calculates the checksum for the time and date and compares it with the checksum sent by the BIOS. If they match, it means that the time and date data is correct. Using the time and date sent by the BIOS as the initial values, the BMC's crystal oscillator is used, and frequency division technology is used to divide the crystal oscillator to 1Hz, that is, one cycle represents 1 second. This method maintains the operation of the time and date, ensuring that the time and date are correct at all times. The main purpose of the BIOS monitoring I / O ports 70 and 71 is to synchronize the user's modifications to the BMC in a timely manner, ensuring that the time and date stored on the BMC are the last modifications made by the user.

[0052] like Figure 5As shown, the final stage is the automatic time and date recovery. The user shuts down the server and executes the Clear CMOS function using a jump cap. Then, the server powers on. During startup, the BIOS checks relevant registers to confirm whether the user executed the Clear CMOS action. If Clear CMOS was executed, a Platform Management Interface (IPMI) command is sent to the BMC to obtain the current system time and date. If obtaining the information fails, it attempts to poll a maximum of three times. After three attempts, it is considered a failure and the process jumps directly to the end. If the time and date are successfully obtained, an IPMI command is sent to the BMC to obtain the checksum of the current system time and date. Again, this involves a maximum of three polling attempts. If the checksum is successfully obtained, the obtained time and date checksum is calculated and compared with the system time and date checksum obtained from the BMC to ensure data accuracy. If they match, the obtained current system time and date are valid and are written to the RTC. If they do not match, it indicates that an error occurred during the data transmission of the obtained time and date, or the checksum, and the process jumps back to the step of re-obtaining the time and date and executes it again.

[0053] This application adds a logging function. When the BIOS detects that the user has executed the Clear CMOS action command, it records the Clear CMOS log. When the user modifies the time and date, it records the log of the user's modified time and date, and also records the source of the modification, such as from the BIOS Setup or the OS. When the time is automatically restored, it also records the time recovery log. When the checksum comparison fails, it also records the checksum comparison failure log.

[0054] like Figure 6 As shown, this application adds an automatic recovery function for other data. In addition to providing time and date, the RTC also has other custom areas for implementing OEM functions. While monitoring user modifications to time and date, it also monitors changes in other areas and synchronizes them to the BMC EEPROM. After clearing the CMOS, the data in the custom areas is automatically recovered.

[0055] This application adds a modification restriction function. For example, if a user only wants to modify the time and date under the OS, that is, to close all other ways of modifying the time and date, the user can send the corresponding command. Then, when the BIOS monitors IO port 70 and IO port 71, it will only allow the OS way to modify the time and date, thus solving the problem of asynchronous modification through multiple channels. For example, after modifying the time and date under BIOS Setup, if the OS does not actively obtain the new time and date from the RTC again, the OS will use the old time and date.

[0056] The methods also include:

[0057] The cleanup operation can be triggered by specific basic input / output system commands or hardware ports, and its status can be monitored to determine the operation. At the same time, an event log is generated and the operation source and timestamp are recorded when the cleanup operation is performed.

[0058] After the real-time clock clearing action is completed, the recovery time point is determined by verifying the timestamp information, and the recovery time point is compared with the current time. If the difference between the two exceeds the set threshold, the time synchronization operation is triggered.

[0059] By triggering and monitoring the cleanup operation through specific BIOS commands or hardware ports, the traceability and security of the cleanup process are effectively ensured. Generating an event log and recording the operation source and timestamp allows for clear tracking of the cleanup process, providing detailed audit logs and improving system transparency and security. After the cleanup operation is complete, the timestamp information is verified and compared with the current time. If the time difference exceeds a set threshold, a time synchronization operation is automatically triggered to ensure the accuracy and consistency of the system clock. This process effectively prevents time errors or inconsistencies caused by the cleanup operation and ensures the system returns to the correct time state, improving system reliability and stability.

[0060] In this embodiment, in response to detecting a modification to the time and date in the real-time clock via access data, reading the modified time and date from the real-time clock and sending the modified time and date to the processor includes:

[0061] When the access data detects that the time and date in the real-time clock have been modified by the operating system or basic input / output system, the modified time and date are read from the real-time clock and the checksum is calculated.

[0062] Send the modified time, date, and verification code to the processor;

[0063] After the processor receives the modified time, date, and checksum, it calculates the checksum of the local time and date and compares it with the received checksum.

[0064] If the two match, the modified time and date are deemed valid, and the modified time and date are sent to the processor.

[0065] If the two are inconsistent, a time synchronization request is sent to the time server, and the time and date are obtained from the time server. The time and date obtained from the time server are then sent to the processor.

[0066] The checksum can employ algorithms such as CRC checksum and SHA256. By verifying the data read from the RTC using the checksum, the integrity and accuracy of the time data retrieved from the RTC can be ensured. The use of the checksum significantly reduces the risk of time data being tampered with or transmitted incorrectly, guaranteeing the reliability of time information transmission between multiple system modules. If data inconsistency occurs, the system can promptly detect and take measures. This verification mechanism effectively prevents system failures or data inconsistency problems caused by erroneous time.

[0067] This verification and time synchronization mechanism effectively prevents inconsistencies or erroneous transmission of time data. By comparing the modified time with the local time, it confirms the validity of the modified time. If verification fails, it obtains the accurate time from an external time source via NTP (Network Time Protocol), ensuring that the server system does not experience operational problems due to internal time errors or deviations. Furthermore, this solution can automatically restore the time to an accurate state, ensuring long-term time consistency and stability, especially in multi-node systems, avoiding distributed task execution errors caused by time differences.

[0068] This scheme improves the accuracy and tamper resistance of time synchronization through a double-ended verification mechanism. If a mismatch is detected in the checksum, the system automatically retrieves the standard time from the time server, thus ensuring that the system time is not affected by erroneous data or malicious tampering. This method enhances the security and reliability of time data during transmission and storage, guaranteeing the accuracy of the entire system's operational logic and log traceability.

[0069] In this embodiment, the real-time updating of time and date by the processor includes:

[0070] Use the time and date data stored in the real-time clock sent by the basic input / output system as the initial value;

[0071] The time and date are updated in real time using the processor's internal crystal oscillator based on the initial values.

[0072] In this embodiment, when updating the time and date in real time using the processor's internal crystal oscillator based on the initial value, the method further includes:

[0073] Periodically triggers synchronization of the processor with the time and date in the real-time clock;

[0074] When synchronizing the processor with the time and date in the real-time clock, the time deviation between the processor and the real-time clock is compared, and an alarm is triggered or a log is recorded when the time deviation exceeds a predetermined threshold.

[0075] The system features periodic synchronization, which can be triggered every ten minutes or whenever a time deviation is detected after the server boots up. This ensures the real-time clock proactively acquires and synchronizes to the latest time and date. The deviation threshold can be adjusted based on system requirements and device performance. The log entry can include the deviation magnitude, trigger time, and possible causes, facilitating subsequent analysis by system administrators. This solution provides a mechanism for proactively monitoring and correcting time deviations, effectively preventing clock drift caused by prolonged operation through periodic calibration. Deviation warnings and logging enable administrators to promptly detect and address time anomalies, ensuring the consistency of system event sequences and the effectiveness of security verification, thereby improving the long-term stability and accuracy of the system.

[0076] By periodically synchronizing the BMC and RTC times, the system can continuously monitor time drift and prevent problems caused by the accumulation of small time deviations over long-term operation. This feature is particularly important for systems requiring strict time management, especially in distributed environments or industries such as finance and healthcare, where time synchronization is crucial. If a time deviation exceeds a predetermined threshold during synchronization, the system will promptly issue an alert or log it, reminding administrators to take action to reduce potential system risks and failures, ensuring the efficiency and timeliness of time synchronization.

[0077] In this embodiment, obtaining the real-time updated current time and date from the processor includes:

[0078] After executing the real-time clock clearing action, read the updated current time and date from the processor, determine whether the updated current time and date are read from the processor, and if so, verify whether the current time and date are accurate; otherwise, retry reading the updated current time and date from the processor.

[0079] If the current time and date are accurate, then write the current time and date to the storage area within the real-time clock;

[0080] If multiple retries to read the updated current time and date from the processor fail, a failure log is recorded. The failure log includes the failure time and reason, marks the hardware configuration information recovery failure, and indicates the hardware configuration information synchronization failure.

[0081] If multiple retries fail, an alarm notification is sent to the system administrator or a system diagnostic program is triggered for handling. The alarm notification includes detailed information such as the failure log, the reason for the failure, and the number of attempts. The system diagnostic program is triggered to check for hardware or network problems that may be causing time synchronization failure. Multiple retries and data verification mechanisms ensure the integrity and correctness of RTC data recovery. Even in cases of read failure or incorrect configuration information, the system can provide precise error sources through log recording, providing a basis for subsequent maintenance. This design enhances the system's self-healing capabilities in complex environments and reduces the system risks associated with RTC recovery failures.

[0082] By designing a retry mechanism, the system will attempt to acquire time data multiple times if the first attempt fails, thereby increasing the probability of successfully obtaining accurate time. This mechanism significantly improves the system's robustness, avoiding interruptions or errors in recovery operations caused by a single failure. It is particularly suitable for scenarios where data transmission between the BMC and RTC experiences network fluctuations or temporary errors. By recording failure logs, administrators can track the causes of failures, conduct further troubleshooting, and ensure the stability and success rate of time recovery operations.

[0083] By providing timely feedback on time synchronization failures, system administrators can quickly become aware of the failure and take appropriate action. Especially in mission-critical and high-availability environments, timely error notifications can significantly reduce security vulnerabilities or system failures caused by time-related issues. This mechanism enhances the system's fault tolerance and fault response capabilities, ensuring the transparency and operability of the time recovery process.

[0084] In this embodiment, verifying the accuracy of the current time and date includes:

[0085] The current time and date are obtained from the time server. The current time and date obtained from the time server are compared with the current time and date read from the processor in real time to determine whether the current time and date read from the processor in real time is accurate.

[0086] In this embodiment, the method further includes:

[0087] An automatic verification program is executed every time the server restarts to check whether the time and date of the real-time clock have been tampered with or restored. If the verification result shows that the time and date of the real-time clock are abnormal, a recovery operation is initiated.

[0088] Before performing the recovery operation, the system diagnostic program checks the processor's performance indicators, temperature, and voltage parameters to determine the processor's health status, and determines whether to initiate the time recovery operation based on the check results; if a hardware failure is detected in the processor, a backup time synchronization source is used to obtain the time and date;

[0089] When performing a recovery operation, historical time records are retrieved from the processor's memory or log records. The real-time clock and the historical time records in the processor are compared. The difference between the current time and the historical time records is compared. If the difference between the current time and the historical time records is greater than the deviation threshold, the stability of the real-time clock and the processor is checked, and it is checked whether there are any factors that cause clock drift.

[0090] After the recovery process is completed, a consistency check is performed periodically to ensure that the recovered time is consistent with the network time or reference clock; if time drift is found to be outside the set range, the synchronization frequency is adjusted and the data is logged.

[0091] This solution employs automatic verification and recovery operations to ensure time consistency every time the server starts, preventing time deviations from impacting system stability. If anomalies in the real-time clock's time and date are detected, the system automatically initiates a recovery process. First, it checks the health status of the processor's Base Clock Management (BMC) to ensure synchronization using a backup time source in case of BMC failure. This not only guarantees high reliability of the system clock but also enhances the system's protection against time drift through multiple verification methods. If excessive deviations are detected during recovery, the system promptly verifies and adjusts to ensure all operations are time-based, reducing service interruptions or data errors caused by time issues and improving overall system stability and consistency. This solution establishes an automated time maintenance system integrating detection, recovery, diagnosis, and synchronization. By automatically verifying the RTC status and judging processor health during system restarts, and combining this with a backup synchronization source for fault-tolerant recovery, the server can maintain an accurate clock even in the event of hardware failure or time drift. This method strengthens the stability and security of time data, ensuring the reliability of event recording, data signatures, and communication verification during long-term system operation.

[0092] In the aforementioned real-time clock (RTC) data recovery method, the Basic Input / Output System (BIOS) detects the presence of a Real-Time Clock (RTC) clearing action after the server powers on. Upon detection, the system first reads and temporarily stores the RTC's time and date data in the processor. During the clearing process, the server is powered off, and the RTC data is cleared using a jump cap method. The server is then restarted, and the updated current time and date retrieved from the processor are restored to the RTC storage area, effectively rewriting the current time and date. This solution automatically backs up critical RTC data before it is cleared and quickly restores it afterward, effectively preventing the permanent loss of RTC's time and date data due to hardware operations or jump cap clearing. This ensures the continuity and accuracy of system time information, hardware configuration data, and operating logs after system startup, improving system maintenance and recovery efficiency.

[0093] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0094] In one embodiment, such as Figure 7 As shown, a real-time clock storage data recovery device 10 is provided, including: a status detection module 1, a data transfer module 2, a clearing operation module 3, and a data recovery module 4.

[0095] Status detection module 1 is used to detect whether the real-time clock clearing action is being performed through the basic input / output system after the server is powered on;

[0096] The data transfer module 2 is used to perform a real-time clock clearing action in response to the detection of the real-time clock. Before performing the real-time clock clearing action, it reads the time and date data stored in the real-time clock through the basic input / output system, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0097] The clearing operation module 3 is used to control the server to shut down when performing the clearing real-time clock action, and to perform the clearing of the time and date data stored in the real-time clock using the jump cap method;

[0098] Data recovery module 4 is used to retrieve the updated current time and date from the processor in response to the server power-on after performing the clear real-time clock action, and write the current time and date into the real-time clock.

[0099] In this embodiment, after the server is powered on, detecting whether a real-time clock clearing action has been performed via the basic input / output system includes:

[0100] After the server is powered on, it will detect in real time whether there is a server shutdown command or a real-time clock power-off command.

[0101] In response to the detection of a server shutdown command, it is determined that the real-time clock is being cleared due to the server shutdown.

[0102] In response to the detection of a real-time clock power-off command, it is determined that a real-time clock clearing action has been performed due to the real-time clock power-off.

[0103] In this embodiment, real-time detection of whether a server shutdown command or a real-time clock power-off command exists after the server is powered on includes:

[0104] After the server is powered on, a monitoring program is built using the Basic Input / Output System. The monitoring program is used to monitor the access data of the address register port and the data register port.

[0105] Upon detecting a modification to the time and date in the real-time clock via access data, the modified time and date are read from the real-time clock and sent to the processor.

[0106] If a server restart or shutdown is detected through access data, it is determined that a server shutdown command exists.

[0107] In this embodiment, in response to detecting a modification of the time and date in the real-time clock via access data, reading the modified time and date from the real-time clock and sending the modified time and date to the processor includes:

[0108] When the access data detects that the time and date in the real-time clock have been modified by the operating system or basic input / output system, the modified time and date are read from the storage area of ​​the real-time clock, and the checksum of the time and date is calculated.

[0109] Send the modified time, date, and verification code to the processor;

[0110] After the processor receives the modified time, date, and checksum, it calculates the checksum of the local time and date and compares it with the received checksum.

[0111] If the two match, the modified time and date are deemed valid, and the modified time and date are sent to the processor.

[0112] If the two are inconsistent, a time synchronization request is sent to the time server, and the time and date are obtained from the time server. The time and date obtained from the time server are then sent to the processor.

[0113] In this embodiment, the real-time updating of time and date by the processor includes:

[0114] Use the time and date data stored in the real-time clock sent by the basic input / output system as the initial value;

[0115] The time and date are updated in real time using the processor's internal crystal oscillator based on the initial values.

[0116] In this embodiment, when updating the time and date in real time using the processor's internal crystal oscillator based on the initial value, the method further includes:

[0117] Periodically triggers synchronization of the processor with the time and date in the real-time clock;

[0118] When synchronizing the processor with the time and date in the real-time clock, the time deviation between the processor and the real-time clock is compared, and an alarm is triggered or a log is recorded when the time deviation exceeds a predetermined threshold.

[0119] In this embodiment, obtaining the real-time updated current time and date from the processor includes:

[0120] After executing the real-time clock clearing action, read the updated current time and date from the processor, determine whether the updated current time and date are read from the processor, and if so, verify whether the current time and date are accurate; otherwise, retry reading the updated current time and date from the processor.

[0121] If the current time and date are accurate, then write the current time and date to the storage area within the real-time clock;

[0122] If multiple retries to read the updated current time and date from the processor fail, a failure log is recorded. The failure log includes the failure time and reason, marks the hardware configuration information recovery failure, and indicates the hardware configuration information synchronization failure.

[0123] In this embodiment, verifying the accuracy of the current time and date includes:

[0124] The current time and date are obtained from the time server. The current time and date obtained from the time server are compared with the current time and date read from the processor in real time to determine whether the current time and date read from the processor in real time is accurate.

[0125] like Figure 7 As shown, the real-time clock storage data recovery device 10 also includes a verification module 5, which is used for:

[0126] An automatic verification program is executed every time the server restarts to check whether the time and date of the real-time clock have been tampered with or restored. If the verification result shows that the time and date of the real-time clock are abnormal, a recovery operation is initiated.

[0127] Before performing the recovery operation, the system diagnostic program checks the processor's performance indicators, temperature, and voltage parameters to determine the processor's health status, and determines whether to initiate the time recovery operation based on the check results; if a hardware failure is detected in the processor, a backup time synchronization source is used to obtain the time and date;

[0128] When performing a recovery operation, historical time records are retrieved from the processor's memory or log records. The real-time clock and the historical time records in the processor are compared. The difference between the current time and the historical time records is compared. If the difference between the current time and the historical time records is greater than the deviation threshold, the stability of the real-time clock and the processor is checked, and it is checked whether there are any factors that cause clock drift.

[0129] After the recovery process is completed, a consistency check is performed periodically to ensure that the recovered time is consistent with the network time or reference clock; if time drift is found to be outside the set range, the synchronization frequency is adjusted and the data is logged.

[0130] In the aforementioned real-time clock (RTC) data recovery device, the Basic Input / Output System (BIOS) detects the presence of a real-time clock (RTC) clearing action after the server powers on. Upon detection, the device first reads and temporarily stores the time and date data stored in the RTC in the processor. During the clearing process, the server is powered off, and the RTC data is cleared using a jump cap method. The server is then restarted, and the updated current time and date retrieved from the processor are restored to the RTC storage area, effectively rewriting the current time and date. This solution automatically backs up critical stored data before the RTC is cleared and quickly restores it afterward, effectively preventing the permanent loss of time and date data due to hardware operations or jump cap clearing. This ensures the continuity and accuracy of system time information, hardware configuration data, and operating logs after system startup, improving system maintenance and recovery efficiency.

[0131] For a description of the features in the embodiment corresponding to the real-time clock data recovery device, please refer to the relevant description of the embodiment corresponding to the real-time clock data recovery method, which will not be repeated here.

[0132] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above embodiments of the real-time clock storage data recovery method.

[0133] In one embodiment, the electronic device may be a server, and its internal structure diagram may be as follows: Figure 8As shown, the electronic device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores real-time clock data recovery data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a real-time clock data recovery method.

[0134] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above embodiments of the real-time clock storage data recovery method when running:

[0135] After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed.

[0136] In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before executing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0137] When performing the real-time clock clearing action, the control server is shut down, and the time and date data stored in the real-time clock are cleared using the jump cap method;

[0138] After performing the real-time clock clearing action, in response to the server powering on, the system retrieves the updated current time and date from the processor and writes the current time and date into the real-time clock.

[0139] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0140] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the real-time clock storage data recovery method:

[0141] After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed.

[0142] In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before executing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0143] When performing the real-time clock clearing action, the control server is shut down, and the time and date data stored in the real-time clock are cleared using the jump cap method;

[0144] After performing the real-time clock clearing action, in response to the server powering on, the system retrieves the updated current time and date from the processor and writes the current time and date into the real-time clock.

[0145] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above embodiments of the real-time clock storage data recovery method:

[0146] After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed.

[0147] In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before performing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time.

[0148] When performing the real-time clock clearing action, the control server is shut down, and the time and date data stored in the real-time clock are cleared using the jump cap method;

[0149] After performing the real-time clock clearing action, in response to the server powering on, the updated current time and date are obtained from the processor and written into the real-time clock.

[0150] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0151] The above provides a detailed description of a real-time clock storage data recovery method and electronic device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for recovering data stored in a real-time clock, comprising: include: After the server is powered on, the basic input / output system is used to check whether the real-time clock clearing action has been performed. In response to the detection of a real-time clock clearing action, the system reads the time and date data stored in the real-time clock through the basic input / output system before executing the real-time clock clearing action, sends the time and date data stored in the real-time clock to the processor for storage, and the processor updates the time and date in real time. When performing the real-time clock clearing action, the server is shut down, and the time and date data stored in the real-time clock are cleared. After performing the real-time clock clearing action, in response to the server powering on, the real-time updated current time and date are obtained from the processor and written into the real-time clock; The processor is powered separately, and when the server is powered off, the processor keeps updating the time and date in real time to obtain the current time and date. The real-time time and date updates by the processor include: The time and date data stored in the real-time clock sent by the basic input / output system are used as initial values; The time and date are updated in real time using the crystal oscillator mode inside the processor based on the initial value; The step of updating the time and date in real time using the crystal oscillator mode inside the processor based on the initial value further includes: Periodically trigger the synchronization of the processor with the time and date in the real-time clock; When synchronizing the processor with the time and date in the real-time clock, the time deviation between the processor and the real-time clock is compared, and an alarm is triggered or a log is recorded when the time deviation exceeds a predetermined threshold; The method further includes: An automatic verification program is executed each time the server restarts to check whether the time and date of the real-time clock have been tampered with or restored. If the verification result shows that the time and date of the real-time clock are abnormal, a recovery operation is initiated. Before performing the recovery operation, the system diagnostic program checks the processor's performance indicators, temperature, and voltage parameters to determine the processor's health status, and determines whether to initiate the time recovery operation based on the check results; if a hardware failure is detected in the processor, a backup time synchronization source is used to obtain the time and date; During the recovery operation, historical time records are extracted from the processor's memory or log records. The real-time clock and the historical time records in the processor are compared. The difference between the current time and the historical time records is compared. If the difference between the current time and the historical time records is greater than the deviation threshold, the stability of the real-time clock and the processor is checked, and it is checked whether there are any factors that cause clock drift. After the recovery process is completed, a consistency check is performed periodically to ensure that the recovered time is consistent with the network time or reference clock; if time drift is found to be outside the set range, the synchronization frequency is adjusted and the data is logged. The cleanup operation is triggered by a basic input / output system command or hardware port, and its status is monitored for judgment. An event log is generated during the cleanup operation and the operation source and timestamp are recorded. After the real-time clock is cleared, the recovery time point is determined by verifying the timestamp information. The recovery time point is then compared with the current time. If the difference between the two exceeds the set threshold, a time synchronization operation is triggered.

2. The real-time clock storage data recovery method of claim 1, wherein, The step of detecting whether a real-time clock clearing action has been performed via the basic input / output system after the server is powered on includes: After the server is powered on, it will detect in real time whether there is a server shutdown command or a real-time clock power-off command. In response to the detection of a server shutdown command, it is determined that the real-time clock is being cleared due to the server shutdown. In response to the detection of a real-time clock power-off command, it is determined that a real-time clock clearing action has been performed due to the real-time clock power-off.

3. The real-time clock storage data recovery method according to claim 2, characterized in that, The step of detecting in real time whether there is a server shutdown command or a real-time clock power-off command after the server is powered on includes: After the server is powered on, a monitoring program is built using the basic input / output system. This monitoring program is used to monitor the access data of the address register port and the data register port. In response to detecting a modification of the time and date in the real-time clock via the access data, the modified time and date are read from the real-time clock and sent to the processor; If a server restart or shutdown is detected through the access data, it is determined that a server shutdown command exists.

4. The real-time clock storage data recovery method according to claim 3, characterized in that, The step of responding to the detection that the time and date in the real-time clock have been modified through the access data, reading the modified time and date from the real-time clock, and sending the modified time and date to the processor includes: When the access data detects that the time and date in the real-time clock have been modified by the operating system or basic input / output system, the modified time and date are read from the storage area of ​​the real-time clock, and the checksum of the time and date is calculated. Send the modified time, date, and verification code to the processor; After the processor receives the modified time, date, and checksum, it calculates the checksum of the local time and date and compares it with the received checksum. If the two match, the modified time and date are deemed valid, and the modified time and date are sent to the processor. If the two are inconsistent, a time synchronization request is sent to the time server, and the time and date are obtained from the time server. The time and date obtained from the time server are then sent to the processor.

5. The real-time clock storage data recovery method according to claim 1, characterized in that, The step of obtaining the real-time updated current time and date from the processor includes: After performing the real-time clock clearing action, the real-time updated current time and date are read from the processor. It is determined whether the real-time updated current time and date are read from the processor. If so, the accuracy of the current time and date is verified. Otherwise, the real-time updated current time and date are read from the processor again. If the current time and date are accurate, then the current time and date are written to the storage area within the real-time clock; If multiple retries to read the real-time updated current time and date from the processor fail, a failure log is recorded. The failure log includes the failure time and reason, a mark indicating that hardware configuration information recovery failed, and a hardware configuration information synchronization failure message.

6. The real-time clock storage data recovery method according to claim 5, characterized in that, The verification of whether the current time and date are accurate includes: The current time and date are obtained through a time server, and then compared with the current time and date updated in real time from the processor to determine whether the current time and date updated in real time from the processor is accurate.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the real-time clock storage data recovery method as described in any one of claims 1 to 6 when executing the computer program.

Citation Information

Patent Citations

  • Mobile terminal time and date information setting method and apparatus and mobile terminal

    CN104915269A

  • Time acquisition method and device of clock module based on processor

    CN120743039A