Time calibration method, device and computer readable storage medium for firmware emulation
Patent Information
- Application Number
- CN202211392832.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-11-08
AI Technical Summary
[0006]本发明的主要目的在于提供一种固件仿真的时间校准方法,旨在解决如何避免固件仿真过程中由于记录到的进程时刻提前或滞后而影响到固件仿真结果的准确性的问题
[0039] This invention provides a firmware emulation time calibration method, device, and computer-readable storage medium. The method includes: upon receiving an activity event of a process, determining the event type of the activity event; if the event type is a start event, acquiring a first start time recorded by the process on a runtime timeline and acquiring a second start time recorded by the process on a background timeline, wherein the background timeline is associated with a reference clock source; determining whether the runtime timeline meets preset timeline calibration conditions based on the first and second start times; if so, updating the start time recorded on the runtime timeline when the start event is received, based on the time on the background timeline. By using a background timeline associated with a reference clock source, the runtime timeline is calibrated each time a start event is received during firmware emulation, thereby avoiding inaccurate firmware emulation results caused by accumulated recording time errors during long-term firmware emulation operation.
Smart Images

Figure CN115826681B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of firmware emulation technology, and in particular to a firmware emulation time calibration method, device, and computer-readable storage medium. Background Technology
[0002] Solid-state drives (SSDs) are hard drives made using arrays of solid-state electronic storage chips. Due to their high read and write speeds, they are widely used in various electronic fields. In SSD testing technologies, firmware emulation is a common method, which uses software to simulate the firmware environment for convenient and efficient firmware analysis and vulnerability checking.
[0003] In the firmware emulation process, in order to avoid misjudging the end of the entire firmware emulation process when a certain process ends, a virtual running timeline is usually set in the software. When each process ends, a firmware emulation end judgment is made on the running timeline. The firmware emulation process ends only when all processes are judged to have ended.
[0004] However, since the runtime timeline is obtained through software simulation, the time error on the runtime timeline will continue to accumulate during the long firmware simulation process. This will cause the error between the timing on the runtime timeline and the actual timing to become larger and larger. As a result, the time of the process recorded during the firmware simulation will be earlier or later than the actual time, which will ultimately affect the accuracy of the firmware simulation results.
[0005] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The main objective of this invention is to provide a time calibration method for firmware simulation, which aims to solve the problem of how to avoid the accuracy of firmware simulation results being affected by the recorded process time being too early or too late during firmware simulation.
[0007] To achieve the above objectives, the present invention provides a firmware emulation time calibration method, the method comprising:
[0008] Upon receiving an activity event from a process, determine the event type of the activity event;
[0009] If the event type is a start event, obtain the first start time recorded by the process on the running timeline, and obtain the second start time recorded by the process on the background timeline, wherein the background timeline is associated with a reference clock source;
[0010] Based on the first start time and the second start time, determine whether the running time axis meets the preset time axis calibration conditions;
[0011] If satisfied, based on the time on the background timeline, update the start time recorded on the running timeline when the start event is received.
[0012] Optionally, the time scale of the running time axis is different from the time scale of the background time axis, and the step of determining whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time includes:
[0013] Obtain the time scale mapping between the running timeline and the background timeline;
[0014] Based on the time scale mapping, determine whether there is a time difference between the first start time and the second start time;
[0015] If a time difference exists, it is determined that the running time axis meets the time axis calibration conditions;
[0016] If there is no time difference, it is determined that the running time axis does not meet the time axis calibration conditions.
[0017] Optionally, the step of determining whether there is a time difference between the first start time and the second start time based on the time scale mapping includes:
[0018] Based on the time scale mapping, the time corresponding to the second start time in the time scale of the first start time is determined, and this time is used as the mapped second start time.
[0019] Determine whether there is a time difference between the first start time and the mapped second start time.
[0020] Optionally, the time scale of the running time axis is the same as the time scale of the background time axis, and the step of determining whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time includes:
[0021] Determine whether there is a time elapsed difference between the running timeline and the background timeline;
[0022] If the time elapsed difference does not exist, perform a difference operation on the parameter values corresponding to the first start time and the second start time. If the result of the difference operation is zero, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met; or...
[0023] If the time elapsed difference does not exist, perform a difference operation on the first start time and the second start time. If the absolute value of the result after the difference operation is less than or equal to a preset first threshold, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met.
[0024] Optionally, after determining whether there is a time elapsed difference between the running timeline and the background timeline, the method further includes:
[0025] If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, and compare the result of the product operation with the second start time. If the comparison result is the same, determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met; or...
[0026] If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, determine the absolute value of the difference between the result of the product operation and the second start time, if the absolute value of the difference is less than or equal to a preset second threshold, then determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met.
[0027] Optionally, obtaining the second start time recorded by the process on the background timeline includes:
[0028] Obtain the current time on the reference clock source, and obtain the transmission delay between the firmware emulation device and the reference clock source;
[0029] The transmission delay and the current time are summed, and the result of the summation is determined as the second start time.
[0030] Optionally, the step of updating the start time recorded on the running timeline when the start event is received, based on the time on the background timeline, includes:
[0031] If the time scale of the running time axis is different from that of the background time axis, obtain the time mapping relationship between the times of the running time axis and the background time axis, and based on the time mapping relationship, determine the mapping time corresponding to the current time of the background time axis on the running time axis, and determine the mapping time as the current time on the running time axis;
[0032] If the time scale of the running timeline is the same as the time scale of the background timeline, the current time on the background timeline is taken as the corresponding current time on the running timeline.
[0033] Optionally, after determining the event type of the activity event upon receiving an activity event of the process, the method further includes:
[0034] If the event type is an end event, determine whether there is a parallel process of the process in the resource space associated with the process;
[0035] If the parallel processes exist, determine the last end time among the preset end times of each of the parallel processes;
[0036] Based on the final end time, the end time of the running time axis is determined, and the firmware simulation ends when the end time is reached.
[0037] In addition, to achieve the above objectives, the present invention also provides a firmware emulation device, the firmware emulation device comprising: a memory, a processor, and a firmware emulation time calibration program stored in the memory and executable on the processor, wherein when the firmware emulation time calibration program is executed by the processor, it implements the steps of the firmware emulation time calibration method as described above.
[0038] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a firmware emulation time calibration program, which, when executed by a processor, implements the steps of the firmware emulation time calibration method as described above.
[0039] This invention provides a firmware emulation time calibration method, device, and computer-readable storage medium. The method includes: upon receiving an activity event of a process, determining the event type of the activity event; if the event type is a start event, acquiring a first start time recorded by the process on a runtime timeline and acquiring a second start time recorded by the process on a background timeline, wherein the background timeline is associated with a reference clock source; determining whether the runtime timeline meets preset timeline calibration conditions based on the first and second start times; if so, updating the start time recorded on the runtime timeline when the start event is received, based on the time on the background timeline. By using a background timeline associated with a reference clock source, the runtime timeline is calibrated each time a start event is received during firmware emulation, thereby avoiding inaccurate firmware emulation results caused by accumulated recording time errors during long-term firmware emulation operation. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the hardware architecture of the firmware emulation device involved in an embodiment of the present invention;
[0041] Figure 2 This is a flowchart illustrating the first embodiment of the firmware simulation time calibration method of the present invention;
[0042] Figure 3 This is a flowchart illustrating a second embodiment of the firmware simulation time calibration method of the present invention;
[0043] Figure 4 This is a flowchart illustrating the third embodiment of the firmware simulation time calibration method of the present invention;
[0044] Figure 5 This is a flowchart illustrating the fourth embodiment of the firmware simulation time calibration method of the present invention;
[0045] Figure 6 This is a flowchart illustrating the fifth embodiment of the firmware simulation time calibration method of the present invention.
[0046] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0047] This application uses a background timeline associated with a reference clock source to calibrate the running timeline every time a start event is received during firmware simulation, thereby avoiding inaccurate firmware simulation results caused by accumulated recording time errors during long firmware simulation runs.
[0048] To better understand the above technical solutions, exemplary embodiments of this disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of this disclosure to those skilled in the art.
[0049] As one implementation method, firmware emulation devices can be like... Figure 1 As shown.
[0050] The embodiments of the present invention relate to a firmware emulation device, which includes: a processor 101, such as a CPU, a memory 102, and a communication bus 103. The communication bus 103 is used to enable communication between these components.
[0051] Memory 102 can be high-speed RAM or stable memory (non-volatile memory), such as disk storage. Figure 1 As shown, the memory 102, which is a computer-readable storage medium, may include a firmware emulation time calibration program; and the processor 101 can be used to call the firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0052] Upon receiving an activity event from a process, determine the event type of the activity event;
[0053] If the event type is a start event, obtain the first start time recorded by the process on the running timeline, and obtain the second start time recorded by the process on the background timeline, wherein the background timeline is associated with a reference clock source;
[0054] Based on the first start time and the second start time, determine whether the running time axis meets the preset time axis calibration conditions;
[0055] If satisfied, based on the time on the background timeline, update the start time recorded on the running timeline when the start event is received.
[0056] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0057] Obtain the time scale mapping between the running timeline and the background timeline;
[0058] Based on the time scale mapping, determine whether there is a time difference between the first start time and the second start time;
[0059] If a time difference exists, it is determined that the running time axis meets the time axis calibration conditions;
[0060] If there is no time difference, it is determined that the running time axis does not meet the time axis calibration conditions.
[0061] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0062] Based on the time scale mapping, the time corresponding to the second start time in the time scale of the first start time is determined, and this time is used as the mapped second start time.
[0063] Determine whether there is a time difference between the first start time and the mapped second start time.
[0064] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0065] Determine whether there is a time elapsed difference between the running timeline and the background timeline;
[0066] If the time elapsed difference does not exist, perform a difference operation on the parameter values corresponding to the first start time and the second start time. If the result of the difference operation is zero, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met; or...
[0067] If the time elapsed difference does not exist, perform a difference operation on the first start time and the second start time. If the absolute value of the result after the difference operation is less than or equal to a preset first threshold, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met.
[0068] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0069] If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, and compare the result of the product operation with the second start time. If the comparison result is the same, determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met; or...
[0070] If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, determine the absolute value of the difference between the result of the product operation and the second start time, if the absolute value of the difference is less than or equal to a preset second threshold, then determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met.
[0071] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0072] Obtain the current time on the reference clock source, and obtain the transmission delay between the firmware emulation device and the reference clock source;
[0073] The transmission delay and the current time are summed, and the result of the summation is determined as the second start time.
[0074] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0075] If the time scale of the running time axis is different from that of the background time axis, obtain the time mapping relationship between the times of the running time axis and the background time axis, and based on the time mapping relationship, determine the mapping time corresponding to the current time of the background time axis on the running time axis, and determine the mapping time as the current time on the running time axis;
[0076] If the time scale of the running timeline is the same as the time scale of the background timeline, the current time on the background timeline is taken as the corresponding current time on the running timeline.
[0077] In one embodiment, the processor 101 can be used to invoke a firmware emulation time calibration program stored in the memory 102 and perform the following operations:
[0078] If the event type is an end event, determine whether there is a parallel process of the process in the resource space associated with the process;
[0079] If the parallel processes exist, determine the last end time among the preset end times of each of the parallel processes;
[0080] Based on the final end time, the end time of the running time axis is determined, and the firmware simulation ends when the end time is reached.
[0081] Based on the hardware architecture of the firmware simulation device based on firmware simulation technology described above, an embodiment of the firmware simulation time calibration method of the present invention is proposed.
[0082] Reference Figure 2 In the first embodiment, the firmware emulation time calibration method includes the following steps:
[0083] Step S10: Upon receiving an activity event of a process, determine the event type of the activity event;
[0084] In this embodiment, when the firmware emulation device (hereinafter referred to as the device) receives an activity event of a process during firmware emulation, it determines the event type of the activity event. An activity event is an operation log recorded during firmware emulation when the process reaches certain key nodes. The activity event includes a timestamp and relevant identification information of the process. Upon receiving an activity event, the device can determine the corresponding time point on the running timeline set during firmware emulation based on the timestamp.
[0085] In this embodiment, the event type mainly involves start events, which are activity events triggered at the beginning of a process's execution. It should be noted that since activity events include timestamps, the timestamp corresponding to a start event is the start time of the process recorded by the device. Therefore, by obtaining the start event of a process, the start time of that process can be determined.
[0086] Step S20: If the event type is a start event, obtain the first start time recorded by the process on the running timeline and obtain the second start time recorded by the process on the background timeline, wherein the background timeline is associated with a reference clock source;
[0087] In this embodiment, when the event type of the activity event is determined to be a start event, the timestamp of the start event of the process is obtained, and this timestamp is recorded on the running timeline as the first start time. The start time recorded on the background timeline is also obtained as the second start time. The background timeline represents an external timeline in the firmware emulation process, and it is associated with a reference clock source, meaning that the timing on the background timeline is highly synchronized with the timing of the reference clock source. The clock source for the running timeline is the clock source built into the firmware emulation device.
[0088] Specifically, the method for determining the second start time is to record the time on the background timeline when the running timeline detects that the first start time has been recorded, and use this time as the second start time. For example, if the first start time is recorded as 15:22:03:0157 milliseconds, the time on the background timeline is obtained at the same time as the first start time is recorded, and this time is used as the second start time.
[0089] It should be noted that in some implementations, the time scales of the background timeline and the runtime timeline are the same. For example, if the runtime timeline is set to correspond to a clock in daily life and is in the format of year, month, day, hour, minute, second, and millisecond, then the time scales of the background timeline and the runtime timeline are the same, both in the format of year, month, day, hour, minute, second, and millisecond. In other implementations, the time scales of the two are different. For example, if the runtime timeline records data with the start time of the firmware simulation process as its origin, then the runtime timeline's time scale is in a format similar to a timer, and the time recorded on the runtime timeline is the entire runtime of the firmware simulation, while the background timeline's time scale is in the format of year, month, day, hour, minute, second, and millisecond, in this implementation, the time on the background timeline needs to be converted to correspond with the time on the runtime timeline through a certain time mapping relationship in order to complete the calibration of the runtime timeline.
[0090] Optionally, in some implementations, the reference clock source can be a cesium atomic clock array. Specifically, it can be a National Reference Clock (PRC) containing cesium atomic clocks. The PRC is a national reference clock containing cesium atomic clocks that conforms to the G.811 standard. The timing reference signal it generates is sent to various regions through a timing reference transmission link, and the background timeline can communicate with the reference clock source through the reference transmission link, thereby achieving association with the reference clock source.
[0091] Step S30: Determine whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time;
[0092] Step S40: If satisfied, calibrate the running time axis based on the time on the background time axis, and update the start time recorded on the running time axis when the start event is received.
[0093] In this embodiment, after obtaining the first start time and the second start time, it is determined whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time. When it is determined that the running time axis meets the preset time calibration conditions, it is judged that there is a large error between the running time axis and the background time axis. Then, the start time recorded when updating the activity event of the process on the background time axis is used.
[0094] For example, assuming the first start time was originally recorded as 15:47:38 on the running timeline, and the second start time corresponding to the first start time on the background timeline is determined to be 15:47:37, then the first start time is updated to 15:47:37.
[0095] In the technical solution provided in this embodiment, a background timeline associated with a reference clock source is used to calibrate the running timeline every time a start event is received during firmware simulation, thereby avoiding the phenomenon that the accumulated recording time error during long firmware simulation operation causes inaccurate firmware simulation results.
[0096] Reference Figure 3 In the second embodiment, based on the first embodiment, step S30 includes:
[0097] Step S31: Obtain the time scale mapping between the running time axis and the background time axis;
[0098] Step S32: Based on the time scale mapping, determine whether there is a time difference between the first start time and the second start time;
[0099] Step S33: If a time difference exists, determine that the running time axis meets the time axis calibration conditions;
[0100] Step S34: If there is no time difference, it is determined that the running time axis does not meet the time axis calibration conditions.
[0101] Optionally, in this embodiment, the time scale of the running time axis is different from that of the background time axis. Therefore, before determining whether the time axis calibration conditions are met based on the first start time and the second start time, it is necessary to obtain the time scale mapping between the running time axis and the background time axis, and convert the second start time into the same time format as the first start time through the time scale mapping.
[0102] Specifically, by mapping the time scale, the time corresponding to the second start time in the time scale of the first start time can be determined as the mapped second start time. Then, it can be determined whether there is a time difference between the first start time and the mapped second start time.
[0103] For example, suppose the first start time is 0:53:49, which means that when the process triggers the start event, the recorded time is 53 minutes and 49 seconds after the firmware simulation has been running. The second start time is 17:31:37, which means that the second start time on the background timeline is 17:31:37. At this time, based on the time scale mapping, it can be seen that the second start time corresponds to 0:53:47 on the running timeline. This means that there is a time difference between the first start time and the second start time, and it is determined that the running timeline meets the timeline calibration condition.
[0104] In the technical solution provided in this embodiment, since the time scale of the running time axis is different from that of the background time axis, the two start times are converted into the same time through time scale mapping, thereby providing a prerequisite for subsequent time calibration.
[0105] Reference Figure 4 In the third embodiment, based on any embodiment, step S30 includes:
[0106] Step S35: Determine whether there is a time elapsed difference between the running time axis and the background time axis;
[0107] Step S36: If the time elapsed difference does not exist, perform a difference operation on the parameter values corresponding to the first start time and the second start time. If the result of the difference operation is zero, determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met; or...
[0108] Step S37: If there is no time elapsed difference, perform a difference operation on the first start time and the second start time. If the absolute value of the result after the difference operation is less than or equal to a preset first threshold, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met.
[0109] Optionally, in this embodiment, the time scale of the running timeline is the same as that of the background timeline, and there is no time difference between the running timeline and the background timeline; that is, the ratio of time elapsed on the running timeline to that in the real world can be equal to 1:1. After determining that there is no time difference between the running timeline and the background timeline, the difference between the corresponding time values of the running timeline and the background timeline with the same time scale is directly calculated.
[0110] Specifically, this embodiment provides two different timeline calibration conditions. One timeline calibration condition requires high accuracy of the running timeline during firmware simulation. Specifically, if the difference between the corresponding time values of the running timeline and the background timeline is 0, it is determined that the timeline calibration condition is not met. In other words, if there is no time difference between the running timeline and the background timeline, it is determined that the running timeline does not need timeline calibration; however, if there is a time difference, it is directly determined that timeline calibration is required. This timeline calibration condition is suitable for scenarios where the firmware simulation process is relatively short.
[0111] Optionally, this time axis calibration condition can be used when the firmware simulation time is less than 36 hours.
[0112] In another timeline calibration condition, the accuracy requirement for the running timeline during firmware simulation is lower. If the difference between the corresponding time values on the running timeline and the background timeline is less than or equal to a preset time threshold (the first threshold), then the running timeline does not require calibration; otherwise, calibration is necessary. This timeline calibration condition is suitable for scenarios with long firmware simulation times. Because in such scenarios, the running timeline is more prone to accumulating time errors, setting a threshold for judgment can provide a certain degree of error tolerance to the firmware simulation process while avoiding a decrease in the accuracy of the results.
[0113] Optionally, the first threshold can be 3 seconds.
[0114] Optionally, this time axis calibration condition can be used when the firmware emulation time is greater than or equal to 36 hours.
[0115] In the technical solution provided in this embodiment, the time scale of the running time axis is the same as that of the background time axis, and there is no time difference between the running time axis and the background time axis. The running time axis is calibrated by calculating the difference between the two different time axis calibration conditions, which provides a prerequisite for subsequent time calibration.
[0116] Reference Figure 5 In the fourth embodiment, based on any embodiment, after step S35, the method further includes:
[0117] Step S38: If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, and compare the result of the product operation with the second start time. If the comparison result is the same, determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met; or...
[0118] Step S39: If the time elapsed difference exists, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, determine the absolute value of the difference between the result of the product operation and the second start time, if the absolute value of the difference is less than or equal to a preset first threshold, then determine that the running time axis does not meet the time axis calibration condition; otherwise, determine that the time axis calibration condition is met.
[0119] Optionally, in this embodiment, the time scale of the running time axis is the same as that of the background time axis, and there is a time elapsed difference between the running time axis and the background time axis, that is, the ratio of the running time axis to the time elapsed in the real world is not equal to 1:1. Since firmware simulation simulates the running aging of firmware over a long period of time in a short period of time, a time elapsed ratio can also be set for the running time axis in this embodiment compared to the actual running time of the firmware on the actual device.
[0120] Optionally, the time elapsed ratio can be 60:1. That is, one second on the background timeline is equal to one minute of the firmware emulation process.
[0121] Furthermore, if a time elapsed difference exists, the time elapsed ratio corresponding to the time elapsed difference is obtained, and the time elapsed ratio and the first start time are multiplied. The result of the multiplication operation is compared with the second start time, and the time axis calibration condition is determined based on the comparison result.
[0122] Specifically, this embodiment provides two different timeline calibration conditions. One timeline calibration condition requires high accuracy of the running timeline during firmware simulation. Specifically, after multiplying the running timeline and the time elapsed ratio, the result is compared to the second starting time. If the comparison result is the same, it is determined that the timeline calibration condition is not met. In other words, if there is no time difference between the running timeline and the background timeline, it is determined that the running timeline does not need timeline calibration; however, if there is a time difference between the two, it is directly determined that timeline calibration is required. This timeline calibration condition is suitable for scenarios where the firmware simulation process is relatively short.
[0123] Optionally, this time axis calibration condition can be used when the firmware simulation time is less than 36 hours.
[0124] For example, assuming the time elapsed ratio is 60:1, when the first start time is determined to be 0 minutes and 53 seconds on the running time axis and the second start time is 0 minutes and 54 seconds, after multiplying the time elapsed ratio and the running time axis, the calibrated first start time is determined to be 1 minute and 53 seconds.
[0125] In another timeline calibration condition, the accuracy requirement for the running timeline during firmware simulation is lower. If the product of the corresponding time values between the running timeline and the background timeline is less than or equal to a preset time threshold (a second threshold), then the running timeline does not require calibration; otherwise, calibration is necessary. This timeline calibration condition is suitable for scenarios with long firmware simulation times. Because in such scenarios, the running timeline is more prone to accumulating time errors, setting a threshold for judgment can provide a certain degree of error tolerance to the firmware simulation process while avoiding a decrease in the accuracy of the results.
[0126] Optionally, the second threshold can be 2 seconds.
[0127] Optionally, this time axis calibration condition can be used when the firmware emulation time is greater than or equal to 36 hours.
[0128] In the technical solution provided in this embodiment, the time scale of the running time axis is the same as that of the background time axis, and there is a time elapsed difference between the running time axis and the background time axis. The running time axis is calibrated by multiplying the two different time axis calibration conditions, which provides a prerequisite for subsequent time calibration.
[0129] Reference Figure 6 In the fifth embodiment, based on any embodiment, after step S10, the method further includes:
[0130] Step S50: If the event type is an end event, determine whether there is a parallel process of the process in the resource space associated with the process;
[0131] Step S60: If the parallel processes exist, determine the last end time among the preset end times of each of the parallel processes.
[0132] Step S70: Determine the end time of the running time axis based on the last end time, and terminate the firmware simulation when the end time is reached.
[0133] Optionally, after determining the event type of the active event, if the event type corresponding to the active event of the process is determined to be a termination event, then it is determined whether there are parallel processes associated with the process other than the process itself within the resource space associated with the process. Resource space is the memory space allocated by the device for the entire firmware emulation program during firmware emulation runtime. For parallel processes, due to limited memory resources, the more parallel processes there are, the smaller the resource subspace allocated to each process. When one of the multiple parallel processes terminates, the resource subspace of the other processes will relatively increase. That is, the size of the resource subspace is negatively correlated with the number of parallel processes. In most cases, the sum of the resource subspaces corresponding to each parallel process should be less than the resource space occupied by the entire firmware emulation. It should be noted that in this embodiment, parallel processes represent processes running simultaneously. However, the start and end times of different parallel processes may be the same or different, and the execution times of different parallel processes may be the same or different. This embodiment does not impose any limitations.
[0134] Furthermore, after determining whether parallel processes exist, if parallel processes are found to exist during firmware simulation, a preset end time for each parallel process is determined, and then the latest ending time is determined from these preset end times. In this embodiment, since firmware simulation simulates the actual operation of firmware in software, a large number of processes are executed rapidly and frequently during the simulation process to simulate the hardware aging of firmware under long-term operation. In this embodiment, each simulated process is assigned a preset end time at the beginning of execution, which is theoretically the shortest running time for that process. It should be noted that the preset end time is a theoretical value. During the actual operation of the process, the actual running time may be greater or less than the preset end time due to resource space occupancy. Therefore, the determined final end time is also a theoretical value.
[0135] Furthermore, in this embodiment, after determining the final end time, the end time of the firmware simulation's runtime timeline is determined based on the final end time, so that the entire firmware simulation process ends when the device reaches this end time. The runtime timeline is a horizontally scrolling timeline program simulated by the device during firmware simulation, which can simulate the passage of time in the real world.
[0136] In the technical solution provided in this embodiment, when an activity event of a process is received, the event type of the activity event is determined. When the event type is an end event, it is determined whether there are parallel processes other than the process in the resource space associated with the process. If there are parallel processes, the last end time among the preset end times of each parallel process is determined. Finally, based on the last end time, the end time of the firmware simulation's running time axis is determined so that the firmware simulation ends when the end time is reached.
[0137] Furthermore, those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the firmware emulation device to implement the process steps of the embodiments of the above methods.
[0138] Therefore, the present invention also provides a computer-readable storage medium storing a firmware emulation time calibration program, which, when executed by a processor, implements the various steps of the firmware emulation time calibration method as described in the above embodiments.
[0139] The computer-readable storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0140] It should be noted that, since the storage medium provided in the embodiments of this application is the storage medium used to implement the methods of the embodiments of this application, those skilled in the art can understand the specific structure and variations of the storage medium based on the methods described in the embodiments of this application, and therefore will not be repeated here. All storage media used in the methods of the embodiments of this application fall within the scope of protection of this application.
[0141] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0142] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0143] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0144] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0145] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0146] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0147] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A firmware emulation time calibration method, characterized in that, Applied to firmware emulation devices, the method includes: Upon receiving an activity event from a process, determine the event type of the activity event; If the event type is a start event, obtain the first start time recorded by the process on the running timeline, and obtain the second start time recorded by the process on the background timeline, wherein the background timeline is associated with a reference clock source; Based on the first start time and the second start time, determine whether the running time axis meets the preset time axis calibration conditions; If satisfied, update the start time recorded on the running timeline when the start event is received, based on the time on the background timeline; Wherein, the time scale of the running time axis is different from the time scale of the background time axis, and the step of determining whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time includes: Obtain the time scale mapping between the running timeline and the background timeline; Based on the time scale mapping, the time corresponding to the second start time in the time scale of the first start time is determined, and this time is used as the mapped second start time. Determine whether the time difference exists between the first start time and the mapped second start time; If a time difference exists, it is determined that the running time axis meets the time axis calibration conditions; If there is no time difference, it is determined that the running time axis does not meet the time axis calibration conditions; Wherein, the time scale of the running time axis is the same as the time scale of the background time axis, and the step of determining whether the running time axis meets the preset time axis calibration conditions based on the first start time and the second start time includes: Determine whether there is a time elapsed difference between the running timeline and the background timeline; If the time elapsed difference does not exist, when the firmware simulation time is less than 36 hours, the parameter values corresponding to the first start time and the second start time are subtracted. If the result of the subtraction operation is zero, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met. If the time elapsed difference does not exist, when the firmware simulation time is greater than or equal to 36 hours, the difference between the first start time and the second start time is calculated. If the absolute value of the result after the difference calculation is less than or equal to a preset first threshold, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met. If the time elapsed difference exists, when the firmware simulation time is less than 36 hours, obtain the time elapsed ratio corresponding to the time elapsed difference, perform a product operation on the time elapsed ratio and the first start time, and compare the result of the product operation with the second start time. If the comparison result is the same, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met; or... If the time elapsed difference exists, when the firmware simulation time is greater than or equal to 36 hours, the time elapsed ratio corresponding to the time elapsed difference is obtained, the time elapsed ratio and the first start time are multiplied, and the absolute value of the difference between the result of the multiplication operation and the second start time is determined. If the absolute value of the difference is less than or equal to a preset second threshold, it is determined that the running time axis does not meet the time axis calibration condition; otherwise, it is determined that the time axis calibration condition is met. The step of updating the start time recorded on the running timeline when the start event is received, based on the time on the background timeline, includes: If the time scale of the running time axis is different from that of the background time axis, obtain the time mapping relationship between the times of the running time axis and the background time axis, and based on the time mapping relationship, determine the mapping time corresponding to the current time of the background time axis on the running time axis, and determine the mapping time as the current time on the running time axis.
2. The method as described in claim 1, characterized in that, The step of obtaining the second start time recorded by the process on the background timeline includes: Obtain the current time on the reference clock source, and obtain the transmission delay between the firmware emulation device and the reference clock source; The transmission delay and the current time are summed, and the result of the summation is determined as the second start time.
3. The method as described in claim 1, characterized in that, The step of updating the start time recorded on the running timeline when the start event is received, based on the time on the background timeline, includes: If the time scale of the running timeline is the same as the time scale of the background timeline, the current time on the background timeline is taken as the corresponding current time on the running timeline.
4. The method as described in claim 1, characterized in that, After determining the event type of the activity event upon receiving an activity event of the process, the method further includes: If the event type is an end event, determine whether there is a parallel process of the process in the resource space associated with the process; If the parallel processes exist, determine the last end time among the preset end times of each of the parallel processes; Based on the final end time, the end time of the running time axis is determined, and the firmware simulation ends when the end time is reached.
5. A firmware emulation device, characterized in that, The firmware emulation device includes: a memory, a processor, and a firmware emulation time calibration program stored in the memory and executable on the processor. When the firmware emulation time calibration program is executed by the processor, it implements the steps of the firmware emulation time calibration method as described in any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a firmware emulation time calibration program, which, when executed by a processor, implements the steps of the firmware emulation time calibration method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Simulation time correction method and device, electronic equipment and autonomous vehicle
CN114329947A