Equipment clock calibration method and device, storage medium, terminal and computer program product

By calibrating the clock of the terminal device in advance during the Uboot or LK stage, it ensures high clock accuracy before performing read/write tasks, solves the problem of device instability and crashes caused by clock frequency deviation, and achieves device operation stability and data accuracy. sexual enhancement.

CN118534973APending Publication Date: 2024-08-23SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410594746.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In the existing technology, the clock frequency deviation of electronic equipment is too large, resulting in unstable operation, and may even cause the terminal to crash, and the solution usually requires an increase in device cost.

Method used

In the Uboot or LK stage of the terminal, read and calibrate the clock calibration parameters of the target device in advance, ensure that the clock has been calibrated before performing read/write tasks, and reduce the data read/write rate in clock calibration mode to slow down the clock frequency deviation.

Benefits of technology

Without increasing the cost of the device, it effectively solves the problems of unstable device operation and terminal crashes caused by clock frequency deviation, and improves device stability and data accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118534973A
    Figure CN118534973A
Patent Text Reader

Abstract

A device clock calibration method and apparatus, a storage medium, a terminal, and a computer program product, the method comprising: determining that a terminal enters a Uboot stage or an LK stage, the terminal comprising at least one target device to be calibrated, each target device having a respective clock; and in the Uboot stage or the LK stage, for each to-be-calibrated target device, before executing a read task and / or a write task for the target device, reading a pre-stored clock calibration parameter of the target device, and calibrating a clock of the target device by using the clock calibration parameter. According to the scheme, under the condition that the device cost is not increased, the problems of unstable equipment operation and even terminal crash caused by overlarge equipment clock frequency offset can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for calibrating a device clock, a storage medium, a terminal, and a computer program product. Background Art

[0002] In computers, mobile phones, tablets and other terminals, the stable operation of various electronic devices (for example, embedded multimedia cards (EMMC), universal flash storage (UFS), etc.) requires accurate clock crystals to provide system clock signals. Crystal oscillators can be divided into two types: passive crystal oscillators and active crystal oscillators. Compared with active crystal oscillators, passive crystal oscillators (for example, temperature sensing crystals (TSX)) are cheaper, but their accuracy is also lower.

[0003] On the one hand, when the terminal is in the clock calibration stage (or called the clock calibration mode), the clock calibration parameters of each device need to be determined and stored. In the process of setting the clock calibration parameters (for example, the frequency deviation parameters) (for example, the clock calibration parameters of the device are determined by using a frequency deviation algorithm, which is usually the production line stage before the terminal leaves the factory), the stability of the crystal oscillator (especially the passive crystal oscillator) will be worse, resulting in an increase in the clock frequency deviation of the electronic device. In severe cases, it will affect the clock signal of the entire electronic device and may even cause the system to freeze and restart.

[0004] On the other hand, when the terminal is in the booting stage (or booting mode, which is usually the stage when the terminal is actually used by the user after leaving the factory), it is necessary to read the previously set and pre-stored clock calibration parameters, and use the read parameters to complete the clock calibration of each device. Since the booting process requires the execution of a large number of device read / write tasks, the stable execution of these tasks depends on a high-precision clock signal. Therefore, if these read / write tasks occur before the device clock calibration is completed, the probability of device operation errors will increase, and even the terminal will freeze.

[0005] The current solutions to the crystal oscillator stability problem on the market are mainly through adding peripheral circuits, or using more precise machining and assembly processes, or selecting higher-precision crystal oscillators, but these methods will incur additional costs. Summary of the invention

[0006] One of the purposes of the embodiments of the present invention is to solve the problem of unstable operation of equipment or even terminal crash caused by excessive clock frequency deviation of the equipment without increasing the cost of the device.

[0007] To achieve the above-mentioned purpose, an embodiment of the present invention provides a method for calibrating a device clock, comprising the following steps: confirming that a terminal enters a Uboot stage or an LK stage, wherein the terminal includes at least one target device to be calibrated, and each target device has its own clock; in the Uboot stage or the LK stage, for each target device to be calibrated, before executing a read task and / or a write task on the target device, reading a pre-stored clock calibration parameter of the target device, and using the clock calibration parameter to calibrate the clock of the target device.

[0008] Optionally, before executing the read task and / or write task on the target device, read the pre-stored clock calibration parameters of the target device, and use the clock calibration parameters to calibrate the clock of the target device, including: determining the timing of executing the read task on the target device for the first time in the Uboot stage or the LK stage, recorded as the first timing; determining the timing of executing the write task on the target device for the first time in the Uboot stage or the LK stage, recorded as the second timing; before the earlier of the first timing and the second timing, read the pre-stored clock calibration parameters of the target device, and use the clock calibration parameters to calibrate the clock of the target device.

[0009] Optionally, before confirming that the terminal enters the Uboot stage or the LK stage, the method also includes: in response to the terminal entering the clock calibration mode, determining the at least one target device to be calibrated; for each target device, reducing the data reading rate and / or data writing rate of the target device in the clock calibration mode, and then executing a clock calibration parameter setting program, wherein the clock calibration parameter setting program is used to determine and store the clock calibration parameters of the target device.

[0010] Optionally, the target device has a preset tolerable frequency deviation range and multiple data reading rates, and each data reading rate of the target device has a corresponding maximum clock frequency deviation; reducing the data reading rate of the target device includes: obtaining the currently set data reading rate of the target device, and determining the maximum clock frequency deviation corresponding to the data reading rate; if the maximum clock frequency deviation is greater than or equal to the maximum frequency deviation value of the tolerable frequency deviation range, then determining, from the multiple data reading rates, a data reading rate whose maximum clock frequency deviation falls within the tolerable frequency deviation range, and recording it as the target reading rate; switching the currently set data reading rate of the target device to the target reading rate.

[0011] Optionally, the maximum clock frequency deviation corresponding to each data reading rate of the target device is determined by the following method: determine a sample device; in the process of executing the clock calibration parameter setting procedure on the sample device at each data reading rate, determine a first frequency difference between the actual highest clock frequency of the sample device and a preset target frequency, and a second frequency difference between the actual lowest clock frequency and the preset target frequency; determine the frequency difference with a larger absolute value between the first frequency difference and the second frequency difference as the maximum sample clock frequency deviation of the sample device at that data reading rate; and use the maximum sample clock frequency deviation at each data reading rate as the maximum clock frequency deviation corresponding to that data reading rate.

[0012] Optionally, the clock calibration parameters for each target device are stored in the Raw partition of the disk.

[0013] Optionally, for a target device having a dependency relationship, the order of calibrating the clock of the dependent target device is before the order of calibrating the clock of the dependent target device; wherein the dependency relationship is used to indicate that part or all of the output data of the dependent target device serves as input data of the dependent target device.

[0014] Optionally, before executing the step of calibrating the clock of the target device for the first time, the method further includes: setting the thread processing mode of the Uboot stage or the LK stage to a single thread mode.

[0015] An embodiment of the present invention also provides a device clock calibration apparatus, comprising: a power-on phase determination module, used to confirm that a terminal enters a Uboot phase or an LK phase, wherein the terminal includes at least one target device to be calibrated, and each target device has a corresponding clock; a clock calibration module, used to read pre-stored clock calibration parameters of each target device to be calibrated in the Uboot phase or the LK phase before executing a read task and / or a write task on the target device, and use the clock calibration parameters to calibrate the clock of the target device.

[0016] An embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned device clock calibration method are executed.

[0017] An embodiment of the present invention also provides a terminal, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the steps of the above-mentioned device clock calibration method when running the computer program. The terminal also includes the above-mentioned target device to be calibrated.

[0018] An embodiment of the present invention further provides a computer program product, including a computer program, which executes the steps of the above-mentioned device clock calibration method when executed by a processor.

[0019] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0020] Since the stable and reliable operation of the device (mainly referring to the stable execution of the reading and / or writing tasks of the device) needs to rely on providing a high-precision system clock signal for the device, therefore, in the embodiment of the present invention, the clock calibration timing of each target device to be calibrated in the terminal is advanced to the timing of executing the reading and / or writing tasks of the target device, so as to ensure that the clock signal in the process of executing the reading and / or writing tasks of the target device is a calibrated clock signal with high precision. Therefore, by adopting this implementation scheme, the problem of unstable operation of the device or even terminal crash caused by excessive clock frequency deviation of the device can be effectively solved without increasing the cost of the device (especially for passive crystal oscillators with low clock precision, without improving the process or adding peripheral circuits).

[0021] Furthermore, compared with performing device clock calibration in other stages of terminal startup (for example, the Kernel stage which is later in the sequence), since the Uboot stage is an earlier stage in the startup process, this stage has relatively fewer read / write tasks for the target device, and is therefore more conducive to conveniently controlling the timing of clock calibration for each target device.

[0022] Furthermore, the embodiment of the present invention sets the timing of clock calibration for each target device before the first time of reading data from the target device and the first time of writing data to the target device, whichever is earlier, to ensure that there will be no data read and write operations on the target device before the clock of the target device is calibrated. In other words, it can ensure that all data read and write operations on the target device occur after the clock calibration of the target device is completed. In this way, the problem of data read and / or write task execution errors caused by the failure to complete the calibration of the device clock can be avoided, thereby improving the stability of device operation and data accuracy.

[0023] Furthermore, before the step of calibrating the clock of the target device is performed for the first time, the method further includes: setting the thread processing mode of the Uboot stage or the LK stage to a single thread mode. Thus, it is not only ensured that the read and write operations of all target devices occur after the target device has completed the clock calibration, but also that the read and write tasks and clock calibration operations of each target device are performed in an orderly and stable manner, thereby improving the stability of the entire system.

[0024] Furthermore, in an embodiment of the present invention, considering that in the clock calibration mode, the data reading rate and / or data writing rate requirements for the target device are lower than those in the device power-on mode, the data reading rate and / or data writing rate of the target device are reduced before executing the clock calibration parameter setting program to reduce the target device's requirements for clock accuracy and thereby improve the device operation stability in the clock calibration mode.

[0025] Furthermore, in an embodiment of the present invention, the reduction of the data reading rate (and / or data writing rate) of the target device is not arbitrary, but by determining the maximum clock frequency deviations corresponding to different data reading rates (and / or data writing rates) in the process of executing the clock calibration parameter setting program, the data reading rate and / or data writing rate of the target device is accurately reduced to a rate that meets the tolerable frequency deviation range requirements, thereby improving the operating stability of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a flow chart of a method for calibrating a device clock in an embodiment of the present invention;

[0027] Figure 2 is a flow chart of another device clock calibration method in an embodiment of the present invention;

[0028] Figure 3 The present invention is a schematic diagram of the structure of a device clock calibration apparatus according to an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and understandable, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0030] Reference Figure 1 , Figure 1 The present invention is a flowchart of a device clock calibration method in an embodiment of the present invention. The method can be applied to terminals with clock calibration function, including but not limited to mobile phones, tablet computers, computers, smart wearable terminals (such as smart watches, etc.), and vehicle-mounted terminals.

[0031] The method may include steps S11 to S12:

[0032] Step S11: confirming that the terminal enters the Uboot phase or the LK phase, the terminal includes at least one target device to be calibrated, each target device having its own clock;

[0033] Step S12: In the Uboot stage or the LK stage, for each target device to be calibrated, before executing a read task and / or a write task on the target device, read the pre-stored clock calibration parameters of the target device, and use the clock calibration parameters to calibrate the clock of the target device.

[0034] The following is an explanation of the relevant concepts and expressions in this application.

[0035] Uboot is the abbreviation of Universal Boot Loader, and its full name in English is Universal Boot Loader. It is mainly used in the startup process of embedded operating systems. It can initialize the hardware devices of the terminal to a suitable state and load and execute the operating system from storage media (for example, flash memory, SD card, network, etc.). The Uboot stage can also be called the Uboot startup stage, that is, the stage experienced by the execution of the Uboot during the terminal startup process, which may include multiple sub-stages.

[0036] LK, whose function is similar to Uboot, is also a boot loader mainly used to start embedded operating systems. Its full English name is Little Kernel, which is mainly used to start Android systems. The LK stage can also be called the LK startup stage, that is, the stage experienced by the execution of the LK during the terminal startup process, which stage can also include multiple sub-stages.

[0037] Taking the Uboot stage as an example, the sub-stages of the Uboot stage can be selected from but not limited to: (1) Initializing hardware: When the terminal is turned on, the processor jumps to the entry address of the Uboot program to perform initialization configuration of the processor, memory, peripherals, etc.; then the startup image file can be loaded through a predefined boot device (e.g., flash memory, SD card, etc.). (2) Configuring environment variables: Configure hardware information, such as processor type, clock frequency, etc., and also configure environment variables, which can be used to store and transmit configuration information. (3) Loading the startup image file: The image file is usually the kernel image of the operating system, and the startup image file can be loaded from the terminal's own storage medium (e.g., flash memory, SD card, etc.) or through the network (e.g., TFTP protocol). (4) Starting the kernel. After stage (3) ends, it can jump to the kernel's entry address to start the kernel and execute the operating system.

[0038] The device clock may specifically refer to the system clock signal provided by the crystal oscillator during the operation of the device. Crystal oscillators are commonly used frequency standard components in electronic circuits, mainly including passive crystal oscillators and active crystal oscillators. In actual use, the frequency of the crystal oscillator is not completely accurate due to a variety of possible factors (for example, voltage changes, temperature changes, mechanical stress, manufacturing deviations, etc.), and there is often a certain deviation (i.e., frequency deviation). When the frequency deviation exceeds a certain range, the accuracy of the device's clock signal is reduced accordingly, which may affect the performance and stability of the device. Therefore, during the production and use stages of mobile terminals such as mobile phones and tablets, or terminals such as computers and desktop computers, it is necessary to set frequency deviation calibration parameters for the crystal oscillator frequency or clock frequency of each electronic device inside and perform calibration.

[0039] Passive crystal oscillator: short for crystal resonator (Crystals), is a resonant device based on quartz crystal. In essence, it is a quartz crystal element, a quartz crystal piece that has been cut and processed into a specific shape and size. When it is excited by current, it will use the natural electromechanical effect of the quartz crystal to generate a precise frequency. The quartz crystal will oscillate under the action of the electric field. The frequency range of commonly used passive crystal oscillators is between a few kHz and tens of MHz.

[0040] Active crystal oscillator: short for crystal oscillator, is a crystal oscillator device with an integrated oscillator circuit that can directly output a stable square wave signal. Its basic working principle is to use the piezoelectric effect of the quartz crystal and the feedback mechanism of the oscillator circuit. When the quartz crystal is subjected to external pressure, it will generate voltage, and then the oscillator circuit will feedback and increase the voltage to maintain the oscillation of the crystal. It should be pointed out that the active crystal oscillator is better than the passive crystal oscillator in stability and more accurate than the passive crystal oscillator, but the price is higher. The stability of the passive crystal oscillator will be worse when setting the frequency deviation parameters while working, and the accuracy deviation will be large, which will seriously affect the clock signal of the entire device and even cause the system to freeze and restart.

[0041] Crystal oscillator frequency and clock frequency: The frequency of a crystal oscillator is its characteristic parameter, specifically the frequency of the crystal vibration inside the crystal oscillator. For example, common crystal oscillator frequencies are 4MHz, 8MHz, etc.; the clock frequency is usually obtained by counting the stable signal provided by the crystal oscillator, which can be understood as a measurement result of the crystal oscillator frequency. Generally speaking, the clock frequency can be a multiple of the crystal oscillator frequency, and the crystal oscillator frequency determines the maximum clock frequency capability of the computer.

[0042] In the specific implementation of step S11, the terminal may be a terminal running an embedded operating system, and the target device to be calibrated may be selected from but not limited to EMMC, UFS, etc. In some embodiments, the clock of the target device may be a system clock signal provided by a passive crystal oscillator. The passive crystal oscillator may be, for example, a temperature sensing crystal oscillator (TSX).

[0043] In the specific implementation of step S12, in the Uboot stage or the LK stage, for each target device to be calibrated, before executing the read task and / or write task on the target device, the pre-stored clock calibration parameters of the target device are read, and the clock of the target device is calibrated using the clock calibration parameters.

[0044] The clock calibration parameters may be used to calibrate the clock signal of the target device, and may include, for example, a frequency deviation parameter (ie, clock frequency deviation), a clock period deviation, and the like.

[0045] The read task of the target device specifically refers to: a task or operation executed in the Uboot stage or the LK stage to read data from the target device; the write task of the target device specifically refers to: a task or operation executed in the Uboot stage or the LK stage to write data to the target device. In a specific implementation, in the Uboot stage or the LK stage, there may be one or more read task operations and / or one or more write task operations for the same target device.

[0046] In a specific implementation, the step S12 may include: determining the timing of executing the read task of the target device for the first time in the Uboot stage or the LK stage (i.e., the timing of reading data from the target device for the first time), recorded as the first timing; determining the timing of executing the write task of the target device for the first time in the Uboot stage or the LK stage (i.e., the timing of writing data to the target device for the first time), recorded as the second timing; before the earlier of the first timing and the second timing, reading the pre-stored clock calibration parameters of the target device, and using the clock calibration parameters to calibrate the clock of the target device.

[0047] Since the stable and reliable operation of the device (mainly referring to the stable execution of the reading and / or writing tasks of the device) needs to rely on providing a high-precision system clock signal for the device, the embodiment of the present invention advances the clock calibration timing of each target device to be calibrated in the terminal to before the timing of executing the reading and / or writing tasks of the target device (specifically, it can be achieved by adjusting the clock calibration operations of each target device in the Uboot stage or the LK stage, and the order of execution of the data reading and writing operations of each target device) to ensure that the clock signal in the process of executing the reading and / or writing tasks of the target device is a calibrated clock signal with high precision. Therefore, by adopting this implementation scheme, the problem of unstable operation of the device or even terminal crash caused by excessive clock frequency deviation of the device can be effectively solved without increasing the cost of the device (especially for passive crystal oscillators with low clock precision, without improving the process or adding peripheral circuits).

[0048] Furthermore, compared with performing device clock calibration in other stages of the terminal startup process (for example, the Kernel stage), the embodiment of the present invention selects the Uboot stage or LK stage with an earlier timing and a smaller task volume, especially the reading and / or writing task volume of the target device, to perform clock calibration, which can more conveniently control the timing of clock calibration for each target device.

[0049] Furthermore, the embodiment of the present invention sets the timing of clock calibration for each target device before the timing of first reading data from the target device and the timing of first writing data to the target device, whichever is earlier, to ensure that there will be no data read and write operations on the target device before the clock of the target device is calibrated. In other words, it can ensure that all data read and write operations on the target device occur after the clock calibration of the target device is completed. Therefore, compared with setting the timing of device clock calibration before a randomly selected timing of reading data from the target device (or writing data to the target device), the problem of data read and / or write task execution errors caused by the failure of the device clock to complete calibration can be avoided, thereby improving the device operation stability and data accuracy. Furthermore, before executing the step of calibrating the clock of the target device for the first time, the method also includes: setting the thread processing mode of the Uboot stage or the LK stage to single-thread mode.

[0050] Specifically, single-threaded mode means that a program has only one thread, that is, tasks can only be executed in a fixed order, and a new task can only be started after the previous task is completed, and multiple tasks cannot be processed at the same time. Multi-threaded mode means that a program has multiple threads, that is, multiple tasks can be executed at the same time, or multiple subtasks can be processed in parallel in one task. Compared with multi-threaded mode, single-threaded mode does not need to consider communication and competition issues between threads, and the system operation is more stable and orderly.

[0051] It is understandable that, in the case where the terminal has multiple target devices to be calibrated, each target device has its own clock calibration timing (i.e., the timing of executing the step of calibrating the clock of the target device). The timing of the first execution of the step of calibrating the clock of the target device specifically refers to the earliest calibration timing among the clock calibration timings of each target device, that is, before the earliest calibration timing, the thread processing mode of the Uboot stage or the LK stage is set to single-thread mode. In this way, not only can it be ensured that the read and write operations of all target devices occur after the target device has completed the clock calibration, but also the read and write tasks and clock calibration operations of each target device can be executed in an orderly and stable manner, thereby improving the stability of the entire system.

[0052] It should be pointed out that since the calibration operation of the device clock is performed in the Uboot stage or the LK stage, and the amount of tasks performed in this stage is less than the amount of tasks in other subsequent boot stages, the embodiment of the present invention combines the characteristics of the stage and the stability advantage of the single thread, and chooses to use the single thread mode to execute each task or operation, so as to achieve a balance between system operation efficiency and stability as much as possible.

[0053] Furthermore, the number of target devices to be calibrated is greater than or equal to two, and includes target devices with dependency relationships; for target devices with dependency relationships, the order of calibrating the clock of the dependent target device is before the order of calibrating the clock of the dependent target device; wherein the dependency relationship is used to indicate part or all of the output data of the dependent target device as input data of the dependent target device.

[0054] Specifically, taking two target devices with a dependency relationship (respectively denoted as the first target device and the second target device) as an example, part or all of the output data of the first target device is used as input data of the second target device. In this case, the first target device and the second target device are target devices with a dependency relationship (or called a "data transfer relationship" or a "data flow relationship"); wherein the first target device can be called a "dependent target device" and the second target device can be called a "dependent target device".

[0055] In the embodiment of the present invention, for the clock calibration timing of each target device, the order of calibration timing is determined based on the dependency relationship or data transmission relationship between the target devices, which can further improve the operating stability of the target device and reduce the error probability.

[0056] Reference Figure 2 , Figure 2 is a flow chart of another device clock calibration method in an embodiment of the present invention. The another device clock calibration method may include: Figure 1 The steps S11 to S12 shown in the figure may further include the following steps S21 to S24. Among them, step S23 and Figure 1 The same as step S11 in step S24. Figure 1 The following is consistent with step S12 in Figure 1 The different contents in are explained.

[0057] In step S21, in response to the terminal entering a clock calibration mode, the at least one target device to be calibrated is determined.

[0058] In a specific implementation, one or more devices pre-specified in some or all devices included in the terminal can be used as the at least one target device to be calibrated in combination with actual application scenario requirements. For example, the clock accuracy level can be set for some or all devices included in the terminal, and the device with a clock accuracy level higher than a preset level threshold is selected as the target device to be calibrated.

[0059] Alternatively, at least part of the devices of the terminal have their own preset frequency deviation range; in the process of executing the clock calibration parameter setting procedure for at least part of the devices of the terminal, the actual maximum frequency deviation of the device is determined; and each device whose actual maximum frequency deviation does not fall within the frequency deviation range of the device is selected as the target device to be calibrated.

[0060] In step S22, for each target device, the data reading rate and / or data writing rate of the target device is reduced in the clock calibration mode, and then a clock calibration parameter setting program is executed, wherein the clock calibration parameter setting program is used to determine and store the clock calibration parameters of the target device.

[0061] The clock calibration parameter setting program may be an existing program for calculating clock calibration parameters (eg, frequency deviation parameters) of a computing device.

[0062] Furthermore, the clock calibration parameters of each target device may be stored in a Raw partition of a disk. By storing the clock calibration parameters in an unformatted partition, the efficiency and accuracy of reading the clock calibration parameters may be improved.

[0063] The Raw partition may also be called an original file system or a Raw file system, which is a disk partition that is not formatted by a New Technology File System (NT file system) or a File Allocation Table (FAT) file system.

[0064] Further, in a specific embodiment, the target device has a preset tolerable frequency deviation range and multiple data reading rates, and each data reading rate of the target device has a corresponding maximum clock frequency deviation; reducing the data reading rate of the target device includes: obtaining the currently set data reading rate of the target device, and determining the maximum clock frequency deviation corresponding to the data reading rate; if the maximum clock frequency deviation is greater than or equal to the maximum frequency deviation value of the tolerable frequency deviation range, then determining, from the multiple data reading rates, the data reading rate with the maximum clock frequency deviation falling within the tolerable frequency deviation range, and recording it as the target reading rate; switching the currently set data reading rate of the target device to the target reading rate.

[0065] The sample device may directly adopt the target device, or may be a device of the same type or function as the target device and of the same production batch. The tolerable frequency deviation interval of the target device may be obtained from the target device description document provided by the manufacturer. The maximum frequency deviation value of the tolerable frequency deviation interval may be the right endpoint value of the tolerable frequency deviation interval.

[0066] It can be understood that, in some embodiments, the target device may have two or more data reading rates corresponding to maximum clock frequency deviations that fall within the tolerable frequency deviation range of the target device, that is, there may be multiple target reading rates. In this case, in order to improve the clock stability of the target device while maintaining the data reading efficiency of the target device, the data reading rate currently set for the target device can be switched to the maximum rate value among the target reading rates.

[0067] Furthermore, the maximum clock frequency deviation corresponding to each data reading rate of the target device is determined by the following method: determine a sample device; in the process of executing the clock calibration parameter setting procedure on the sample device at each data reading rate, determine a first frequency difference between the actual highest clock frequency of the sample device and a preset target frequency, and a second frequency difference between the actual lowest clock frequency and the preset target frequency; determine the frequency difference with the larger absolute value between the first frequency difference and the second frequency difference as the maximum sample clock frequency deviation of the sample device at that data reading rate; and use the maximum sample clock frequency deviation at each data reading rate as the maximum clock frequency deviation corresponding to that data reading rate.

[0068] In some embodiments, the actual maximum clock frequency and the actual minimum clock frequency of the sample device may be the highest frequency value and the lowest frequency value of multiple sampled clock frequencies for sampling the clock frequency of the sample device, respectively. The preset target frequency may be the ideal frequency of the sample device determined based on historical experiments, which may be obtained from the instruction document of the sample device.

[0069] Specifically, the detailed implementation method of reducing the data writing rate of the target device is performed with reference to the above-mentioned method of reducing the data reading rate, which will not be described in detail here.

[0070] Generally speaking, on the one hand, the higher the data reading rate and / or data writing rate of the device, the higher the clock accuracy requirement for the device is, and the greater the fluctuation of the clock frequency of the device may be. On the contrary, the lower the data reading rate and / or data writing rate of the device, the lower the clock accuracy requirement for the device, and the smaller the fluctuation of the clock frequency of the device may be. On the other hand, in the clock calibration mode, during the execution of the clock calibration parameter setting program, the clock frequency fluctuation of the device will increase, and the clock accuracy will be further reduced. Therefore, in the embodiment of the present invention, considering that the data reading rate and / or data writing rate requirements for the target device in the clock calibration mode are lower than those in the device power-on mode, the data reading rate and / or data writing rate of the target device are reduced before the clock calibration parameter setting program is executed to reduce the clock accuracy requirement of the target device, thereby improving the operation stability of the device in the clock calibration mode.

[0071] Furthermore, in an embodiment of the present invention, the reduction of the data reading rate (and / or data writing rate) of the target device is not arbitrary, but by determining the maximum clock frequency deviations corresponding to different data reading rates (and / or data writing rates) in the process of executing the clock calibration parameter setting program, the data reading rate and / or data writing rate of the target device is accurately reduced to a rate that meets the tolerable frequency deviation range requirements, thereby improving the operating stability of the device.

[0072] Reference Figure 3 , Figure 3 1 is a schematic diagram of a device clock calibration apparatus according to an embodiment of the present invention. The device clock calibration apparatus may include:

[0073] A boot phase determination module 31, used to confirm that the terminal enters the Uboot phase or the LK phase, wherein the terminal includes at least one target device to be calibrated, and each target device has its own clock;

[0074] The clock calibration module 32 is used to read the pre-stored clock calibration parameters of each target device to be calibrated in the Uboot stage or the LK stage before executing the read task and / or write task on the target device, and use the clock calibration parameters to calibrate the clock of the target device.

[0075] For the principle, specific implementation and beneficial effects of the calibration device for the device clock, please refer to the previous article and Figure 1 to Figure 2 The relevant description of the device clock calibration method shown in any embodiment will not be repeated here.

[0076] The embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to execute the above Figure 1 to Figure 2 The steps of the device clock calibration method shown in any embodiment. The computer-readable storage medium may include a non-volatile memory or a non-transitory memory, and may also include an optical disk, a mechanical hard disk, a solid-state hard disk, etc.

[0077] Specifically, in the embodiment of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0078] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct rambus RAM (DR RAM).

[0079] The embodiment of the present invention further provides a terminal, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the above-mentioned Figure 1 to Figure 2 The steps of the method for calibrating a device clock shown in any embodiment.

[0080] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship.

[0081] The "plurality" appearing in the embodiments of the present application refers to two or more.

[0082] The first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects. There is no order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.

[0083] It should be pointed out that the serial numbers of the steps in this embodiment do not limit the execution order of the steps.

[0084] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

Claims

1. A method for calibrating a device clock, characterized in that: include: Confirming that the terminal enters the Uboot phase or the LK phase, the terminal includes at least one target device to be calibrated, each target device having its own clock; In the Uboot stage or the LK stage, for each target device to be calibrated, before executing a read task and / or a write task on the target device, a pre-stored clock calibration parameter of the target device is read, and the clock of the target device is calibrated using the clock calibration parameter.

2. The method according to claim 1, characterized in that Before executing a read task and / or a write task on the target device, reading a pre-stored clock calibration parameter of the target device and using the clock calibration parameter to calibrate the clock of the target device includes: Determine the time when the read task of the target device is first executed in the Uboot stage or the LK stage, which is recorded as the first time; Determine the timing of executing the write task to the target device for the first time in the Uboot phase or the LK phase, which is recorded as the second timing; Before the earlier one of the first timing and the second timing, the pre-stored clock calibration parameters of the target device are read, and the clock of the target device is calibrated using the clock calibration parameters.

3. The method according to claim 1, characterized in that Before confirming that the terminal enters the Uboot stage or the LK stage, the method further includes: In response to the terminal entering a clock calibration mode, at least one target device to be calibrated is determined; for each target device, a data reading rate and / or a data writing rate of the target device is reduced in the clock calibration mode, and then a clock calibration parameter setting program is executed, wherein the clock calibration parameter setting program is used to determine and store the clock calibration parameters of the target device.

4. The method according to claim 3, characterized in that: The target device has a preset tolerable frequency deviation range and multiple data reading rates, and each data reading rate of the target device has a corresponding maximum clock frequency deviation; Reduce the data read rate of the target device, including: Obtaining a currently set data reading rate of the target device, and determining a maximum clock frequency deviation corresponding to the data reading rate; If the maximum clock frequency deviation is greater than or equal to the maximum frequency deviation value of the tolerable frequency deviation interval, then determining, from the multiple data reading rates, a data reading rate whose maximum clock frequency deviation falls within the tolerable frequency deviation interval, and recording it as a target reading rate; The data reading rate currently set for the target device is switched to the target reading rate.

5. The method according to claim 4, characterized in that The maximum clock frequency deviation corresponding to each data reading rate of the target device is determined by the following method: Identify sample equipment; In the process of executing the clock calibration parameter setting procedure on the sample device at each data reading rate, determining a first frequency difference between an actual maximum clock frequency of the sample device and a preset target frequency, and a second frequency difference between an actual minimum clock frequency and the preset target frequency; Determine a frequency difference having a larger absolute value between the first frequency difference and the second frequency difference as a maximum sample clock frequency deviation of the sample device at the data reading rate; The maximum sample clock frequency deviation at each data reading rate is used as the maximum clock frequency deviation corresponding to the data reading rate.

6. The method according to claim 1, characterized in that The clock calibration parameters for each target device are stored in the Raw partition of the disk.

7. The method according to claim 1, characterized in that For a target device having a dependency relationship, the order of calibrating the clock of the dependent target device is before the order of calibrating the clock of the dependent target device; The dependency relationship is used to indicate that part or all of the output data of the dependent target device is used as the input data of the dependent target device.

8. The method according to claim 1, characterized in that Before performing the step of calibrating the clock of the target device for the first time, the method further includes: The thread processing mode of the Uboot stage or the LK stage is set to a single thread mode.

9. A device for calibrating a device clock, characterized in that: include: A boot phase determination module, used to confirm that the terminal enters the Uboot phase or the LK phase, wherein the terminal includes at least one target device to be calibrated, and each target device has a corresponding clock; The clock calibration module is used to read the pre-stored clock calibration parameters of each target device to be calibrated in the Uboot stage or the LK stage before executing the read task and / or write task on the target device, and use the clock calibration parameters to calibrate the clock of the target device.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the device clock calibration method according to any one of claims 1 to 8 are executed.

11. A terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the processor performs the steps of the device clock calibration method according to any one of claims 1 to 8; The terminal further comprises the target device to be calibrated as claimed in any one of claims 1 to 8.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the device clock calibration method according to any one of claims 1 to 8 are executed.