System starting control method and device based on real-time clock
By writing system startup information into the alarm clock register of the real-time clock and reading and processing this information by the boot loader, the problem of adding hardware equipment and storage space in the prior art is solved, flexible system startup control is realized, reducing system costs and improving stability and maintainability.
Patent Information
- Application Number
- CN202311174557.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-03-14
AI Technical Summary
The prior art requires additional hardware equipment and system storage space when retaining system startup information, and the lack of correlation between software and hardware, resulting in high system cost, poor stability and difficult maintenance.
By writing system startup information to the alarm clock register of the real-time clock, and reading this information by the boot loader at the time of the system startup, the startup type is judged to control the operation of the system software.
It realizes the unified, flexible and scalable setting of restart reasons and mode without increasing hardware equipment and system storage space, reducing system costs and improving stability and maintainability.
Smart Images

Figure CN119620823A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded devices, and in particular to a system startup control method and device based on a real-time clock. Background Art
[0002] In existing computer systems, there are two ways to set the restart reason and mode, including special hardware design and reserving a portion of RAM or ROM space for software to read and write the restart reason code.
[0003] However, these two methods have the following shortcomings. First, the existing technology relies on the design of the chip or hardware system. If the existing hardware design does not have the ability to support the setting of the restart reason and mode, additional hardware will need to be added later to support it, which increases the cost and complexity of the system. Secondly, the existing technology will take up additional system storage space, such as RAM or ROM. This will increase the demand for hardware resources and may cause power-off volatility and the risk of being overwritten. In addition, there are certain limitations on the number of times the ROM can be erased and written. In addition, due to the lack of a unified solution, the existing technology makes the software and hardware tightly coupled and cannot be decoupled. This leads to a lack of uniformity and reusability in software design, which increases the difficulty of development and maintenance. Summary of the invention
[0004] The object of the present invention is to provide a system startup control method and device based on a real-time clock to solve the problems in the prior art that retaining system startup information requires additional hardware equipment, system storage space, and lack of correlation between software and hardware.
[0005] To achieve one of the above-mentioned purposes, an embodiment of the present invention provides a system startup control method based on a real-time clock, comprising:
[0006] Write the system startup information to the alarm register;
[0007] When the system starts, the boot loader is run to read the alarm register;
[0008] Determine the type of the system startup information in the register and control the operation of the system software.
[0009] As a further improvement of an embodiment of the present invention, the method further includes: the “writing the system startup information into the alarm register” includes,
[0010] By configuring the alarm register, the function of retaining the system startup information is realized;
[0011] During the operation of the system, the system startup information is written into the register through system software.
[0012] As a further improvement of an embodiment of the present invention, the method further includes: the “running the boot loader to read the alarm register when the system starts” includes,
[0013] When the system starts normally, the boot loader reads the system startup information in the alarm register and makes a judgment;
[0014] Perform system-specific recovery scenarios when the system fails to boot properly.
[0015] As a further improvement of an embodiment of the present invention, the method further includes: the “controlling the system software operation by determining the type of system startup information in the register” includes:
[0016] The startup type of the system startup information includes startup after normal system shutdown, restart after system abnormality, and system restart required by software;
[0017] After the system software is started and runs, the alarm register is read again, the corresponding system software is processed according to the system startup information in the register, and the data is rewritten to the alarm register after the processing is completed.
[0018] As a further improvement of an embodiment of the present invention, the method further includes: when the system startup information is the startup after the system is normally shut down, the boot loader controls the system software to operate normally.
[0019] As a further improvement of an embodiment of the present invention, the method further includes: when the system startup information is a restart after a system abnormality, a judgment is made after the system restarts, including:
[0020] During the operation of the system software, if a restart event is received, causing the system to be in an unavailable state, the system software writes the captured exception information into the alarm register and then triggers a restart operation;
[0021] When the system is restarted, the boot loader reads the alarm register, and when it is determined that the system startup information is abnormal information, no processing is performed, and the system software continues to run;
[0022] After the system software is started and runs normally, the alarm register is read to obtain the abnormal information of the previous startup, and the abnormal information is recorded in the system log for subsequent investigation.
[0023] As a further improvement of an embodiment of the present invention, the method further includes: when the system startup information is a system restart required by the software, loading and controlling the backup software, including:
[0024] In the case where software needs to control the behavior of the boot loader, the system software writes a specific code to the alarm register and then triggers a restart;
[0025] After the boot loader is started, it reads the alarm register and loads and controls the backup software according to the startup information set by the software;
[0026] After the backup software is completed, the boot loader controls the operation of the system software according to the startup information set by the software.
[0027] To achieve one of the above-mentioned purposes of the invention, an embodiment of the present invention provides a system startup control device based on a real-time clock, comprising an information writing module, a system startup module and an information judgment module;
[0028] The information writing module is used to write the system startup information into the alarm register;
[0029] The system startup module is used to run the boot loader to read the alarm register when the system starts;
[0030] The information determination module is used to determine the type of the system startup information in the register and control the operation of the system software.
[0031] To achieve one of the above-mentioned purposes of the invention, one embodiment of the present invention provides an electronic device, comprising a memory and a processor, characterized in that the memory stores a computer program that can be run on the processor, and when the program is executed on the processor, the steps in the system startup control method based on the real-time clock as described above are implemented.
[0032] To achieve one of the above-mentioned purposes of the invention, an embodiment of the present invention provides a storage medium, wherein the storage medium stores a computer program, and is characterized in that when the computer program is executed by a processor, the steps in the system startup control method based on a real-time clock are implemented as described above.
[0033] Compared with the prior art, the system startup control method and device based on real-time clock provided by the present invention realizes a unified, flexible and scalable method for setting the restart reason and mode by utilizing the existing real-time clock hardware resources, making full use of the storage space and non-volatile characteristics, and seamlessly integrating with the existing software system. This will reduce system costs, improve system stability and maintainability, and provide better software design uniformity and reusability. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is an overall flow chart of a system startup control method based on a real-time clock in one embodiment of the present invention.
[0035] Figure 2It is a schematic diagram of the relationship between the real-time clock and the system software in the system startup control method based on the real-time clock in one embodiment of the present invention.
[0036] Figure 3 4 is a schematic diagram of a system startup control device based on a real-time clock in one embodiment of the present invention. DETAILED DESCRIPTION
[0037] The present invention will be described in detail below in conjunction with the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present invention, and any structural, methodological, or functional changes made by a person skilled in the art based on these embodiments are all within the scope of protection of the present invention.
[0038] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0039] A real-time clock (RTC) is an electronic device that provides a timing function for the current time and date. It is usually composed of a crystal oscillator, a counter, and some registers. The real-time clock can run independently of the main processor and can continue to record time after the system is shut down or powered off. The main function of a real-time clock is to track time and date and provide a clock signal so that other system components can operate and time according to time. It is commonly found in computer systems, embedded systems, electronic devices, and various consumer electronic products. The alarm register is a register in a real-time clock that is used to store settings and information related to the alarm. By setting the alarm register, a specific time point can be pre-specified to trigger the alarm function, such as sounding an alarm or performing a specific task at a specific time. When the real-time clock reaches the preset alarm time, it triggers the corresponding operation or event. The present invention configures the alarm register of the real-time clock so that it achieves the technical effect required by the present invention.
[0040] In the first embodiment of the present invention, the present invention provides a system startup control method based on a real-time clock, such as Figure 1 , 2 As shown, the method includes,
[0041] S1: Write the system startup information to the alarm register;
[0042] S2: When the system starts, the boot loader is run to read the alarm register;
[0043] S3: Determine the type of the system startup information in the register and control the operation of the system software.
[0044] In a specific implementation of the present invention, the system startup information is written into the alarm register, specifically,
[0045] During the operation of the system, the system software writes the system startup information into the configured alarm register by setting the bit width and address of the register. By writing the corresponding software code, the startup information is converted into the appropriate data format and written into the corresponding position of the register.
[0046] It should be noted that in the prior art, the computer does not fully use all real-time clock alarm registers during operation, so there are idle registers. Therefore, the present invention configures these idle registers to achieve the function of retaining system startup information.
[0047] In a specific embodiment of the present invention, when the system starts, the boot loader is run to read the alarm register, specifically,
[0048] When the system starts normally, the boot loader first reads the system startup information in the alarm register. This information includes the location of the operating system, startup options or other necessary configuration parameters. The boot loader makes a judgment based on this information to determine how to continue the startup process.
[0049] When the system fails to boot properly, perform system-specific recovery scenarios to diagnose and resolve boot issues so that the system can resume normal operation.
[0050] Before executing a specific playback scenario, an alarm is first triggered, such as sounding or flashing a light, to attract the user's attention. This helps indicate that there is a problem with the system and prompts the user to take further action. At the same time, relevant prompt information is displayed on the screen to provide users with detailed information about the startup problem. This information may include error codes, fault descriptions, or recommended solutions. Users can take appropriate measures based on these prompts. Specific recovery scenarios in the system include automatically repairing file system errors, restoring backed-up configuration files, or reinstalling key components of the operating system. These tasks are designed to resolve known startup problems and restore the normal operation of the system as much as possible. And run special startup mode options in the recovery scenario, such as safe mode or recovery mode. In these modes, the system will start with minimal drivers and configurations so that users can diagnose and solve startup problems. These modes usually provide more permissions and tools for users to troubleshoot and repair.
[0051] In a specific embodiment of the present invention, the system software is controlled by judging the type of system startup information in the register, specifically,
[0052] The system startup types include startup after normal system shutdown, restart after system abnormality, and system restart required by software.
[0053] When the system software starts and runs, the information in the alarm register is read again, and the system software performs corresponding processing according to the startup information in the alarm register. For example, if the startup type is a startup after a normal system shutdown, the system software can perform some initialization operations to ensure that the system is in the correct state. If the startup type is a restart after a system abnormality, the system software can try to repair the abnormality and resume normal operation. If the startup type is a system restart required by the software, the system software can perform the necessary restart operations to meet the software's requirements.
[0054] After the processing is completed, the system software will rewrite the data to the alarm register and update the startup information in the register so that it can be processed correctly the next time the system starts.
[0055] In a specific embodiment of the present invention, when the system startup information is the startup after the system is normally shut down, the boot loader controls the system software to operate normally, specifically,
[0056] The boot loader is a key component when the system starts up. It is located on the system's boot medium (such as a hard disk or solid-state drive) and is responsible for loading the operating system and other necessary software components. The main function of the boot loader is to initialize the system when it starts up and ensure that the operating system can be loaded and run correctly. The system is started by reading the boot sector or boot record on the boot medium. The boot loader checks the information in the boot record, determines the operating system to be loaded, and transfers control to the operating system's boot program. When the boot loader transfers control to the operating system, the system software will begin to run normally, including loading and initializing device drivers, starting system services and applications, and providing a user interface for user operation.
[0057] Preferably, the boot loader also includes self-checking and error handling at startup, by detecting hardware failures or software configuration errors, and taking appropriate measures to solve these problems. When an error occurs, the boot loader displays an error message or provides a repair option to help the user solve the problem.
[0058] In a specific embodiment of the present invention, when the system startup information is a restart after a system abnormality, a judgment is made after the system restarts, specifically,
[0059] During the operation of the system software, abnormal situations that may be encountered include memory overflow, CPU overload, hardware failure or software error, which may cause the system to be unavailable. At this time, the system software will respond to these abnormal events, capture and write the abnormal information to the alarm register. The abnormal information written to the alarm register may include the type of abnormality, the time of occurrence, and possible causes. After the abnormal information is written to the alarm register, the system software will trigger a restart operation. This restart operation may be a soft restart or a hard restart, depending on the severity of the abnormality and the configuration of the system.
[0060] When the system restarts, the boot loader will start working. During this process, the boot loader will read the alarm register to check whether there is any abnormal information. If the system startup information is judged to be abnormal information, the boot loader will not perform any special processing, but continue to control the operation of the system software. It should be noted that for most abnormalities, restarting can restore the normal operation of the system.
[0061] After the system software is started and runs normally, the system software will read the alarm register again to obtain the abnormal information of the previous startup. By recording the abnormal information in the system log, the system administrator can check the system log during subsequent troubleshooting to find out the cause of the abnormality and possible solutions.
[0062] Preferably, during the normal operation of the system, the system software can also obtain the system startup information by reading the alarm register and save it in the system log to facilitate the system administrator to perform normal maintenance work on the system.
[0063] In a specific embodiment of the present invention, when the system startup information is a system restart required by the software, the backup software is loaded and controlled, specifically,
[0064] In situations where software needs to control the behavior of the bootloader, including software updates and system upgrades that require a system reboot, the software will write a specific code to the alarm register and trigger a system reboot. This specific code is used to instruct the bootloader to take special actions after the system reboots.
[0065] Specifically, during the software upgrade process, some software updates may need to take effect after the system is restarted. To achieve this goal, the system software will write a specific code into the alarm register to notify the boot loader to take corresponding actions after the system is restarted.
[0066] After the boot loader is started, it reads the contents in the alarm register and loads and controls the backup software according to the startup information set by the software. According to the instructions of the specific code, the boot loader will load the backup software instead of the default system software.
[0067] Specifically, after the software backup is completed, the boot loader determines whether the backup software needs to be loaded according to the startup information set by the software. If the specific code indicates that the backup software needs to be loaded, the boot loader will load the backup software accordingly to ensure that the system can run correctly during the upgrade or update process.
[0068] After the backup software is loaded, the boot loader controls the operation of the system software according to the startup information set by the software. According to the instructions of the specific code, the boot loader will start the appropriate system software version according to the requirements of the software setting to ensure normal operation after the upgrade.
[0069] Specifically, during the operation of the control system software, the boot loader determines which system software version should be started based on the startup information set by the software, ensures that the system can run normally after the upgrade or update process is completed according to the instructions of the specific code, and switches to the corresponding system software version.
[0070] In the second embodiment of the present invention, the present invention provides a system startup control device based on a real-time clock, such as Figure 3 As shown, the device includes an information writing module, a system startup module and an information judgment module, and is characterized in that:
[0071] Information writing module 1, used for writing system startup information into the alarm register;
[0072] A system startup module 2, used for running a boot loader to read the alarm register when the system starts;
[0073] The information determination module 3 is used to determine the type of the system startup information in the register and control the operation of the system software.
[0074] In the third embodiment of the present invention, the present invention provides an electronic device, including a memory and a processor, characterized in that the memory stores a computer program that can be run on the processor, and when the program is executed on the processor, the steps of the system startup control method based on the real-time clock as described above are implemented.
[0075] In a fourth embodiment of the present invention, the present invention provides a storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the system startup control method based on a real-time clock as described above.
[0076] In summary, the system startup control method and device based on real-time clock provided by the present invention solves the problems in the prior art that additional hardware equipment and system storage space are required to retain system startup information, and there is a lack of correlation between software and hardware. By utilizing existing real-time clock hardware resources, making full use of storage space and non-volatile characteristics, and seamlessly integrating with existing software systems, a unified, flexible and scalable method for setting restart reasons and modes is realized. This will reduce system costs, improve system stability and maintainability, and provide better software design uniformity and reusability.
[0077] It should be understood that although this specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each implementation mode may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
[0078] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the modules described above can refer to the corresponding process in the aforementioned method implementation, and will not be repeated here.
[0079] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present implementation scheme.
[0080] In addition, each functional module in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0081] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for a computer system (which can be a personal computer, a server, or a network system, etc.) or a processor (processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0082] Finally, it should be noted that the above implementation modes are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned implementation modes, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned implementation modes, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various implementation modes of the present application.
Claims
1. A system startup control method based on a real-time clock, characterized in that: include, Write the system startup information to the alarm register; When the system starts, the boot loader is run to read the alarm register; Determine the type of the system startup information in the register and control the running of the system software.
2. The system startup control method based on real-time clock according to claim 1, characterized in that: The "writing system startup information into the alarm register" includes: By configuring the alarm register, the function of retaining the system startup information is realized; During the operation of the system, the system startup information is written into the register through system software.
3. The system startup control method based on real-time clock according to claim 2, characterized in that: The "when the system starts, running the boot loader to read the alarm register" includes: When the system starts normally, the boot loader reads the system startup information in the alarm register and makes a judgment; Perform system-specific recovery scenarios when the system fails to boot properly.
4. The system startup control method based on real-time clock according to claim 3, characterized in that: The “controlling the system software operation by determining the system startup information type in the register” includes: The startup type of the system startup information includes startup after normal system shutdown, restart after system abnormality, and system restart required by software; After the system software is started and runs, the alarm register is read again, the corresponding system software is processed according to the system startup information in the register, and the data is rewritten to the alarm register after the processing is completed.
5. The system startup control method based on real-time clock according to claim 4, characterized in that: When the system startup information is the startup after the system is normally shut down, the boot loader controls the system software to operate normally.
6. The system startup control method based on real-time clock according to claim 5, characterized in that: When the system startup information is a restart after a system abnormality, a judgment is made after the system restarts, including: During the operation of the system software, if a restart event is received, causing the system to be in an unavailable state, the system software writes the captured exception information into the alarm register and then triggers a restart operation; When the system is restarted, the boot loader reads the alarm register, and when it is determined that the system startup information is abnormal information, no processing is performed, and the system software continues to run; After the system software is started and runs normally, the alarm register is read to obtain the abnormal information of the previous startup, and the abnormal information is recorded in the system log for subsequent investigation.
7. The system startup control method based on real-time clock according to claim 6, characterized in that: When the system startup information is a system restart required by the software, loading and controlling the backup software includes: In the case where software needs to control the behavior of the boot loader, the system software writes a specific code to the alarm register and then triggers a restart; After the boot loader is started, it reads the alarm register and loads and controls the backup software according to the startup information set by the software; After the backup software is completed, the boot loader controls the operation of the system software according to the startup information set by the software.
8. A system startup control device based on a real-time clock, comprising an information writing module, a system startup module and an information judgment module, characterized in that: The information writing module is used to write the system startup information into the alarm register; The system startup module is used to run the boot loader to read the alarm register when the system starts; The information determination module is used to determine the type of the system startup information in the register and control the operation of the system software.
9. An electronic device, comprising a memory and a processor, characterized in that: The memory stores a computer program that can be run on the processor, and when the program is executed on the processor, the steps in the system startup control method based on the real-time clock as described in any one of claims 1 to 7 are implemented.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, the steps of the system startup control method based on the real-time clock according to any one of claims 1 to 7 are implemented.