Software program flow monitoring method, electronic device and storage medium
Through the method of heterogeneous computing and random number encoding, the problems of high computational complexity and poor real-time performance of program flow monitoring in the existing technology are solved, accurate monitoring and fault detection of program flow sequence are realized, and the requirements of high functional safety level are met. Require.
Patent Information
- Application Number
- CN202410394675.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-02
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-04-02
AI Technical Summary
When existing software program flow monitoring methods meet high functional safety requirements, they have high computational complexity and poor real-time performance. They cannot effectively identify the reversal and disorder of the program flow sequence, and cannot detect failures of data storage units and logical computing units in a real-time operating environment. .
Heterogeneous computing methods are used to calculate the execution results and monitoring results of the program flow respectively through random numbers and software element encoding, and use asymmetric computing priorities and sequences to detect faults in the chip's logical computing unit and data storage unit, and pass D1 and D2 Position switching detects data storage unit failures to meet high functional safety levels.
It achieves accurate monitoring of the program flow sequence, can identify the reversal and disorder of the program flow sequence, detect failures in the chip's logical computing unit and data storage unit, reduces the system monitoring load, and improves the practicality and functional safety level of program flow monitoring. .
Smart Images

Figure CN118277200B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of vehicle control technology, and in particular to a software program flow monitoring method, an electronic device and a storage medium. Background Art
[0002] As the controllers in automobiles are gradually integrated or domain controlled, the controller software is becoming more and more complex, and the functional safety requirements are also getting higher. Program flow monitoring, as a software execution timing monitoring method that must be met to meet high functional safety requirements, has received more and more attention. Based on this, a method for software program flow monitoring is proposed here to cope with the high complexity and high reliability requirements of software execution.
[0003] According to the AUTOSAR standard, software program flow monitoring is mainly divided into three aspects, as follows:
[0004] Alive Supervision: Provides general dog-feeding services for periodically checking the execution reliability of one or more program flows, that is, monitoring whether periodic programs can be executed normally and requiring that the program be executed within the defined cycle range.
[0005] Deadline Supervision: It is used to monitor the running time of a program between two points, requiring that the time taken by the program from the start of execution to the end of execution is within the designed time range.
[0006] Logical Supervision: Provides the correctness of the execution order of the monitoring software, requiring that the program execution sequence is executed in the expected order, without repeating or missing a program, and without the reversed or disordered order of program execution.
[0007] Although there are methods for monitoring the above-mentioned software program flow in the prior art, they all have their shortcomings. For example, the MD5 algorithm is complex to calculate, has poor real-time performance, and is not practical. For example, some use the XOR method, which can only identify the loss of program flow or multiple executions but cannot identify the inversion of the program flow order. For example, some algorithms are single, and due to the failure of the data storage unit and the logic calculation unit, the results of the program flow element execution and the program flow monitoring execution are the same, which cannot identify the real-time operating environment failure and cannot meet the requirements of higher functional safety diagnostic coverage. Summary of the invention
[0008] Embodiments of the present invention provide a software program flow monitoring method, an electronic device, and a storage medium, which can meet the requirements of higher functional safety diagnostic coverage.
[0009] A first aspect of an embodiment of the present invention provides a software program flow monitoring method, comprising:
[0010] Before each program flow is executed, a random number is randomly generated;
[0011] Based on the random number, the software element codes corresponding to each program flow and the first algorithm, the program flow execution results of the software elements of each program flow are calculated in sequence according to the order in which the program flows are executed, until the program flow execution result of the software element of the last program flow is obtained, which is recorded as the first result;
[0012] Based on the first result, the software element codes corresponding to each program flow, and the second algorithm, the monitoring results of the program flow execution of the software elements of each program flow are calculated in sequence according to the order of program flow execution from back to front, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result;
[0013] The second result is compared with the random number. If the second result and the random number are the same, the program flow monitoring is correct.
[0014] In an embodiment of the present invention, the first result and the second result are obtained by heterogeneous computing (asymmetric computing), that is, the operation priority and order of calculating the first result and the second result are different, so that the fault of the logical computing unit of the chip (Logical Supervision requirement) and the fault of the data storage unit can be detected to ensure a higher functional safety level.
[0015] The random number is generated by the true / pseudo-random number generator of the MCU. Each time the program flow is executed, the generated random number is different, thereby ensuring that the first result and the second result obtained by each program flow monitoring are different. Of course, the random number can also be generated by an external device and then sent to the MCU.
[0016] As an optional implementation, in the first aspect of the embodiment of the present invention, based on the random number, the software element code corresponding to each program flow and the first algorithm, the software element program flow execution result of each program flow is calculated in sequence according to the order of program flow execution, until the software element program flow execution result of the last program flow is obtained, which is recorded as the first result, including:
[0017] According to the random number and the software element code of the first program flow, the software element program flow execution result of the first program flow is calculated:
[0018] A1=[(C+B1)*D1]%NUM
[0019] Wherein, A1 is the execution result of the software element program flow of the first program flow, B1 is the software element code of the first program flow; C is the random number, D1 is the first calculation parameter, and NUM is the second calculation parameter;
[0020] According to the software element program flow execution result of the (i-1)th program flow and the software element code of the i-th program flow, the software element program flow execution result of the i-th program flow is calculated:
[0021] A i =[(A i-1 +B i )*D1]%NUM
[0022] Among them, A i is the execution result of the software element program flow of the i-th program flow, B i Encode the software element of the i-th program flow; A i-1 is the software element program flow execution result of the (i-1)th program flow, 1<i≤n, n is the total number of program flows executed in the loop, then the first result A n for:
[0023] A n =[(A n-1 +B n )*D1]%NUM
[0024] Among them, A n-1 is the software element program flow execution result of the (n-1)th program flow, B n Encode the software element for the nth program flow.
[0025] When obtaining the execution result of the program flow, the execution is carried out in the order of the program flow execution, and the program flow execution result is obtained by the above formula. Compared with the existing program flow monitoring, it has the advantages of simple calculation, reduced system monitoring load, and improved practicality of program flow monitoring.
[0026] As an optional implementation, in the first aspect of the embodiment of the present invention, based on the first result, the software element codes corresponding to each program flow and the second algorithm, the monitoring results of the program flow execution of the software elements of each program flow are calculated in sequence according to the order of program flow execution from back to front, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result, including:
[0027] After the program flow execution is completed, the program flow monitoring check is performed;
[0028] According to the first result and the software element code of the last program flow, the monitoring result of the execution of the software element program flow of the last program flow is calculated:
[0029] E n =(A n *D2-B n )%NUM
[0030] Among them, E n is the monitoring result of the execution of the software element program flow of the last program flow, D2 is the third calculation parameter, and D1, D2 and NUM satisfy the following conditions:
[0031] D1*D2-NUM=1
[0032] According to the monitoring result of the software element program flow execution of the (j+1)th program flow and the software element coding of the jth program flow, the monitoring result of the software element program flow execution of the jth program flow is calculated:
[0033] E j =(E j+1 *D2-B j )%NUM
[0034] Among them, E j is the monitoring result of the software element program flow execution of the jth program flow, B j Encode the software element of the jth program flow; E j+1 is the monitoring result of the execution of the software element program flow of the (j+1)th program flow, 1≤j<n, then the second result E1 is:
[0035] E1=(E2*D2-B1)%NUM
[0036] Among them, E2 is the monitoring result of the execution of the software element program flow of the second program flow.
[0037] After completing a program flow monitoring operation, the positions of D1 and D2 can be switched to perform the program flow monitoring operation again. Since the data obtained in the intermediate process of the two monitoring operations are different, the failure of the data storage unit can be detected accordingly. Therefore, this asymmetric program flow verification method can ensure a higher functional safety level.
[0038] As an optional implementation, in the first aspect of the embodiment of the present invention, the software element is the earliest executed software element corresponding to each program flow.
[0039] Each program flow will contain multiple related software elements with an execution order. When monitoring the program flow, you can select any software element from each program flow to calculate its corresponding execution result and monitoring result. That is, as long as the software element selected for each program flow is the same when calculating the execution result and monitoring result, in order to avoid confusion in the process, the earliest executed software element in each program flow can be selected to calculate the execution result and monitoring result.
[0040] As an optional implementation manner, in the first aspect of the embodiment of the present invention, the method further includes:
[0041] According to the target time of the target software element execution function in the current execution cycle, the target time of the previous execution cycle is subtracted to obtain the function function execution cycle of the target software element, and the function function execution cycle is compared with the preset cycle to check whether the function function is executed within the preset cycle; the target time is the start time or the end time;
[0042] If the function is executed within the preset period, and the second result is equal to the random number, the program flow monitoring is correct; otherwise, if the function is not executed within the preset period, and / or the second result is not equal to the random number, the program flow monitoring fails.
[0043] By calculating the execution cycle of each software element's execution function, we ensure that each function runs within the preset cycle (in compliance with Alive Supervision requirements) to monitor whether periodic programs can be executed normally.
[0044] As an optional implementation manner, in the first aspect of the embodiment of the present invention, the method further includes:
[0045] According to the obtained execution end time of the target software element execution function in the current execution cycle, the execution start time of the target software element is subtracted to obtain the function execution time of the target software element, and the function execution time is compared with the preset time range to check whether the function execution time is within the preset time range;
[0046] If the function execution time is within the preset time range and the second result is equal to the random number, the program flow monitoring is correct. Otherwise, if the function execution time is not within the preset time range, and / or the second result is not equal to the random number, the program flow monitoring fails.
[0047] By calculating the execution time of the execution function, we ensure that the function execution time of each execution function is within the preset time range, and ensure that the time required for the program to be executed from the beginning to the end of the program execution is within the designed time range (in line with the Deadline Supervision requirements).
[0048] As an optional implementation, in the first aspect of the embodiment of the present invention, the execution start time and the execution end time of the target software element execution function are obtained through a timer, and the timer is STM or GTM or watchdog.
[0049] As an optional implementation manner, in the first aspect of the embodiment of the present invention, the method further includes:
[0050] Create three OS-Applications, ASIL D, ASIL B, and QM, according to the functional safety level, where the functional safety levels of ASIL D, ASIL B, and QM decrease in sequence;
[0051] According to the functional safety level of the functional module or the software element of the functional module, the execution function of the software element is allocated to the task function or interrupt function of the corresponding OS-Application;
[0052] The execution functions in the OS-Application assigned to the QM do not participate in the software program flow monitoring.
[0053] Based on the requirement of freedom from interference, three OS-Applications are created, namely ASIL D, ASIL B, and QM. Alarm, schedule, isr, and task are created in each OS-Application as needed. According to the functional safety level requirements of the functional module or the software elements of the functional module, the execution functions of each software element are assigned to the task and isr functions of the OS-Application of the corresponding functional safety level. This avoids mutual interference during the operation of software program flows of different functional safety levels. In addition, this partitioning method can also make the complexity of program flow monitoring parameters D1, D2, and NUM with higher functional levels higher than that of program flow monitoring parameters D1, D2, and NUM with higher functional levels, so as to better meet the requirements of high functional safety levels. Among them, the function functions in the OS-Application assigned to QM are not subject to program flow monitoring.
[0054] In a second aspect of an embodiment of the present invention, a software program flow monitoring system is provided, which includes:
[0055] A generation unit is used to randomly generate a random number before each program flow is executed;
[0056] a first calculation unit, configured to calculate the execution results of the software elements of each program flow in sequence according to the order in which the program flows are executed, based on the random number, the software element codes corresponding to each program flow, and the first algorithm, until the execution result of the software element program flow of the last program flow is obtained, which is recorded as the first result;
[0057] a second calculation unit, configured to calculate the monitoring results of the program flow execution of the software elements of each program flow in sequence according to the order of program flow execution from back to front, based on the first result, the software element codes corresponding to each program flow, and the second algorithm, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result;
[0058] The comparison unit is used to compare the second result with the random number. If the second result and the random number are the same, the program flow monitoring is correct.
[0059] In an embodiment of the present invention, the first result and the second result are obtained by heterogeneous computing (asymmetric computing), that is, the operation priority and order of calculating the first result and the second result are different, so that the fault of the logical computing unit of the chip (Logical Supervision requirement) and the fault of the data storage unit can be detected to ensure a higher functional safety level.
[0060] The random number is generated by the random number generator of the MCU. Each time the program flow is executed, the generated random number is different, thereby ensuring that the first result and the second result obtained by each program flow monitoring are different.
[0061] A third aspect of an embodiment of the present invention discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the steps of the software program flow monitoring method disclosed in the first aspect of the embodiment of the present invention are implemented.
[0062] A fourth aspect of an embodiment of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the steps of the software program flow monitoring method disclosed in the first aspect of the embodiment of the present invention.
[0063] A fifth aspect of an embodiment of the present invention discloses a computer program product. When the computer program product runs on a computer, the computer executes the steps of the software program flow monitoring method disclosed in the first aspect of the embodiment of the present invention.
[0064] A sixth aspect of an embodiment of the present invention discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the steps of the software program flow monitoring method disclosed in the first aspect of the embodiment of the present invention.
[0065] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0066] 1. When the embodiment of the present invention monitors the program flow, based on the random number and the software element code, the execution result of the program flow and the monitoring result of the program flow execution are respectively performed with the first algorithm and the second algorithm to obtain the second result, and then the second result and the random number are compared to determine whether there is a program flow monitoring fault. This heterogeneous calculation method (the calculation formula and calculation order of the execution result and the monitoring result are different) can detect the fault of the logic calculation unit of the chip (not only can it be identified that a certain software element is executed less or more, but also whether the execution order of each software element in the program flow is disordered), and the calculation process is relatively simple, which can reduce the load of system monitoring, obtain the monitoring results in time, and is more conducive to the gradual integration or domain control of automobile controllers;
[0067] 2. During the program flow monitoring process, the positions of D1 and D2 (D1 and D2 are not equal) can be swapped to perform two comparisons. Since the intermediate data obtained twice during the execution process and the intermediate data obtained during the monitoring process are not the same, this can also detect faults in the data storage unit and ensure a higher functional safety level.
[0068] 3. Partition the execution functions of software elements according to the functional safety level to meet the requirements of functional safety freedom from interference and avoid timing interference of program flow monitoring.
[0069] 4. This program flow monitoring method can meet the requirements of Alive Supervision, Deadline Supervision and Logical Supervision of AUTOSAR and the interference-free requirements of Part 6 Appendix D of the functional safety standard ISO26262. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 It is a flowchart of a software program flow monitoring method provided by an embodiment of the present invention;
[0071] Figure 2 It is a schematic diagram of execution function partitioning provided by an embodiment of the present invention;
[0072] Figure 3 is a structural diagram of a software program flow monitoring system provided by an embodiment of the present invention;
[0073] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical scheme and advantages of the present invention clearer, the specific embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. It should be noted that, under the premise of no conflict, the various embodiments described below or the various technical features can be arbitrarily combined to form a new embodiment. Except for special instructions, the materials and equipment used in this embodiment can be purchased from the market. Examples of embodiments are shown in the accompanying drawings, in which the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and the limitations of the present application cannot be understood.
[0075] In the description of the present application, it should be understood that the terms "upper", "lower", "front", "back", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as a limitation on the present application. In the description of the present application, "plurality" means two or more, unless otherwise precisely and specifically specified.
[0076] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "connected", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, or it can be connected through an intermediary medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0077] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0078] Embodiment 1
[0079] See also Figure 1, Figure 1 FIG. 1 is a flow chart of a software program flow monitoring method disclosed in an embodiment of the present invention. Figure 1 As shown, the software program flow monitoring method includes:
[0080] S110, before each program flow is executed, a random number is randomly generated.
[0081] Before program flow monitoring is performed, the execution functions of the software elements need to be partitioned to meet the requirements of Part 6 Appendix D of the functional safety standard ISO26262 for freedom from interference. Figure 2 As shown, create three OS-Applications for ASIL D, ASIL B, and QM respectively, and create alarm, schedule, isr, and task in each OS-Application as needed. According to the functional safety level requirements of the software elements of each functional module, assign the execution function of each software element to the task and isr functions of the OS-Application of the corresponding functional safety level. This avoids mutual interference between the running of software of different functional safety levels. The OS-Application function assigned to QM does not perform program flow monitoring.
[0082] In a preferred embodiment of the present invention, each functional module can constitute a program flow. Of course, multiple functional modules can jointly constitute a program flow. There can be multiple related software elements with a sequential execution order in a program flow (the later software element may require the execution result of the previous software element. The execution result here refers to the execution result calculated by the execution function based on the specific monitoring value, which is different from the execution result involved in step 120). That is, software elements with time dependencies (if divided by function, they can be called functional software elements, and their corresponding execution functions can also be called functional functions) are organized into a sequence for program flow monitoring.
[0083] Exemplarily, the three-phase motor control module uses the software elements 1. calculating the motor phase line current, 2. calculating the motor rotor position, 3. motor FOC control, 4. calculating SVPWM, and 5. generating six PWM signals as a complete execution of the motor control program flow monitoring sequence, wherein the serial number in front of the software element represents its execution order in the program flow, and calculating the motor phase line current is the first software element of the motor control program flow.
[0084] For another example, the solenoid valve driving module will 1. set the target current, 2. collect and calculate the actual current, 3. PI regulation, and 4. calculate the output duty cycle as a complete execution of the solenoid valve program flow monitoring sequence.
[0085] The DC brush motor control module uses the software elements 1. setting the target current, 2. collecting and calculating the phase current, 3. collecting and calculating the motor terminal voltage, 4. PI adjustment, and 5. outputting the control duty cycle as a complete execution of the DC brush motor program flow monitoring sequence.
[0086] It can be seen from the above two examples that the software element PI adjustment is the third software element executed in the solenoid valve program flow, and is the fourth software element executed in the DC brushed motor program flow monitoring. At the same time, due to their different dependencies, the corresponding execution functions of the two may not be the same.
[0087] For example, the peripheral chip on the circuit board uses the software elements 1. peripheral chip working condition check, 2. read and clear faults, 3. initialization configuration of the peripheral chip, 4. configuration check, 5. peripheral chip driver, and 6. peripheral chip fault monitoring as a complete execution of the peripheral chip program flow monitoring sequence.
[0088] In a preferred embodiment of the present invention, each software element functional function will be scheduled in each task or isr function for program flow monitoring. Therefore, a unique scheduling number can be set for each functional module software element. The unique scheduling number is recorded as the software element code. The subsequent steps S120 and S130 will be performed around the software element code.
[0089] Random numbers can be generated by the true / pseudo-random number generator of the MCU. Of course, random numbers can also be generated by external devices and sent to the MCU. Each time the program flow is executed, the corresponding random numbers are different, thereby ensuring that the first result and the second result obtained by each program flow monitoring are different.
[0090] The program flow execution here refers to multiple program flows in an ECU software, which are executed one at a time according to the order of each program flow. For the sake of distinction, the program flow here can also be recorded as a program flow group, or an ECU software program flow.
[0091] S120. Based on the random number, the software element code corresponding to each program flow and the first algorithm, the program flow execution results of the software elements of each program flow are calculated in sequence according to the order of program flow execution, until the program flow execution result of the software element of the last program flow is obtained, which is recorded as the first result.
[0092] During the calculation process of the execution result, the first algorithm is adopted, and the software element program flow execution result of each program flow is calculated in sequence according to the order of execution of each program flow until the software element program flow execution result of the last program flow is obtained. Except that the software element program flow execution result of the last program flow is recorded as the first result, the software element program flow execution results of other program flows can be recorded as execution intermediate data.
[0093] In a preferred embodiment of the present invention, the software element used in the process of calculating the execution results and the monitoring results can be the first software element executed in each program flow. Of course, in other embodiments, any software element can be selected from each program flow to calculate its corresponding execution results and monitoring results, as long as the software element selected for each program flow is the same when calculating the execution results and the monitoring results.
[0094] Specifically, it may include the following steps:
[0095] First, according to the random number and the software element code of the first program flow, the software element program flow execution result of the first program flow is calculated:
[0096] A1=[(C+B1)*D1]%NUM
[0097] Among them, A1 is the execution result of the software element program flow of the first program flow, B1 is the software element code of the first program flow; C is the random number, D1 is the first calculation parameter, NUM is the second calculation parameter, and % is the remainder operation.
[0098] Secondly, according to the software element program flow execution result of the (i-1)th program flow and the software element code of the i-th program flow, the software element program flow execution result of the i-th program flow is calculated:
[0099] A i =[(A i-1 +B i )*D1]%NUM
[0100] Among them, A i is the execution result of the software element program flow of the i-th program flow, B i Encode the software element of the i-th program flow; A i-1 It is the software element program flow execution result of the (i-1)th program flow, 1<i≤n, and n is the total number of program flows executed in the loop.
[0101] When i=n, the software element program flow execution result of the last program flow is obtained, that is, the first result A n for:
[0102] An =[(A n-1 +B n )*D1]%NUM
[0103] Among them, A n-1 is the software element program flow execution result of the (n-1)th program flow, B n Encode the software element for the nth program flow.
[0104] Only focusing on the calculation process of the execution result, when obtaining the execution result of the program flow, it is carried out in the order of the program flow execution, and the program flow execution result is obtained by the above formula. Compared with the existing program flow monitoring, it has the advantages of simple calculation, reduced system monitoring load, and improved practicality of program flow monitoring.
[0105] S130. Based on the first result, the software element codes corresponding to each program flow and the second algorithm, the monitoring results of the program flow execution of the software elements of each program flow are calculated in sequence from the back to the front of the program flow execution, until the monitoring results of the program flow execution of the software elements of the first program flow are obtained, which are recorded as the second result.
[0106] The monitoring result calculation process is realized when the program flow monitoring check is performed after the program flow execution is completed.
[0107] The process is as follows:
[0108] First, according to the first result and the software element code of the last program flow, the monitoring result of the execution of the software element program flow of the last program flow is calculated:
[0109] E n =(A n *D2-B n )%NUM
[0110] Among them, E n It is the monitoring result of the execution of the software element program flow of the last program flow, and D2 is the third calculation parameter.
[0111] Secondly, according to the monitoring result of the software element program flow execution of the (j+1)th program flow and the software element code of the jth program flow, the monitoring result of the software element program flow execution of the jth program flow is calculated:
[0112] E j =(E j+1 *D2-B j )%NUM
[0113] Among them, E j is the monitoring result of the software element program flow execution of the jth program flow, B jEncode the software element of the jth program flow; E j+1 is the monitoring result of the software element program flow execution of the (j+1)th program flow, 1≤j<n,
[0114] When j=1, the monitoring result of the execution of the software element program flow of the first program flow is obtained, that is, the second result E1 is:
[0115] E1=(E2*D2-B1)%NUM
[0116] Among them, E2 is the monitoring result of the execution of the software element program flow of the second program flow.
[0117] From the above, it can be seen that the first result and the second result are obtained by heterogeneous computing (asymmetric computing), that is, the operation priority and order of calculating the first result and the second result are different, so that the failure of the logical computing unit of the chip can be detected (Logical Supervision requirement), which can ensure a higher functional safety level.
[0118] The first calculation parameter D1, the third calculation parameter D2 and the second calculation parameter NUM satisfy the following conditions:
[0119] D1*D2-NUM=1
[0120] It can be seen from this that when there is no program flow monitoring fault, that is, when the second result is equal to the random number, the replacement of the positions of D1 and D2 does not affect the specific value of the second result. Therefore, when D1 and D2 have different values, the execution result and the monitoring result can be calculated twice by swapping the positions of D1 and D2 to obtain the intermediate data of the two calculations, so as to detect the fault of the data storage unit and further ensure a higher functional safety level.
[0121] In addition, in specific operations, when setting the specific values of the first calculation parameter D1, the third calculation parameter D2 and the second calculation parameter NUM, these parameters with high functional safety levels can be set more complex than those with low functional safety levels, so as to better meet the requirements of high functional safety levels.
[0122] There are many combinations of values that satisfy the relationship formula of the first calculation parameter D1, the third calculation parameter D2 and the second calculation parameter NUM. Considering the load and practicality of actual program flow monitoring, the simplest sets of data are selected here, as shown in Table 1:
[0123] Table 1. Examples of numerical values of D1, D2 and NUM
[0124]
[0125]
[0126] S140, comparing the second result and the random number. If the second result and the random number are the same, the program flow monitoring is correct.
[0127] If the second result is the same as the random number, it means that the program flow monitoring is correct and the program flow monitoring meets the Logical Supervision requirements. If the second result is different from the random number, it means that the program flow monitoring fails and the program flow monitoring failure is reported.
[0128] During the above operation process, the calculation formulas for the monitoring results and the execution results are obviously different, which is mainly manifested in the difference in operation priority. Compared with the existing program flow monitoring, it has the advantages of simple calculation, reduced system monitoring load, and improved practicality of program flow monitoring. At the same time, due to the use of asymmetric calculation methods, it can detect faults in the chip's logical computing units.
[0129] Afterwards, a new random number can be generated and a new round of program flow monitoring can be performed.
[0130] In other embodiments, one or more of the Alive Supervision requirement and the DeadlineSupervision requirement may be combined with the Logical Supervision requirement to ensure that program flow monitoring complies with the AUTOSAR standard.
[0131] For the Alive Supervision requirements, the operation can be performed while Logical Supervision monitoring is being performed. For example, the execution start time (or end time, recorded as the target time) of the execution function of the current software element (recorded as the target software element) can be obtained, and the start time (or end time) of the previous execution cycle can be subtracted to obtain the execution cycle of the function function, and check whether the function function runs within the specified cycle. If the function function runs within the preset cycle, that is, the function function execution cycle is less than or equal to the preset cycle, then the Alive Supervision requirements are met. Conversely, if the function function execution cycle is greater than the preset cycle, it does not meet the Alive Supervision requirements.
[0132] For the Deadline Supervision requirements, the operation can be performed while Logical Supervision monitoring is being performed. For example, the execution end time value of the execution function of the current software element (target software element) can be subtracted from its execution start time value to obtain the function execution time of the current software element, and check whether this function execution time is within the time range required for function execution. If the function execution time is within the preset time range, it meets the DeadlineSupervision requirements. Conversely, if the function execution time is not within the preset time range, it does not meet the DeadlineSupervision requirements.
[0133] When the three are monitored in combination, if Logical Supervision, Alive Supervision and DeadlineSupervision all meet the requirements, it indicates that the program flow monitoring is correct. Otherwise, as long as one of them does not meet the requirements, it indicates that the program flow monitoring is faulty.
[0134] The execution start time and execution end time of the target software element execution function can be realized by a timer, and the timer can be any one of STM, GTM, and watchdog. Before the execution of each functional module software element execution function starts, the time value before the execution starts is obtained through the STM, GTM, or watchdog timer, i.e., the execution start time. Similarly, at the end of each task execution, the time value of the task end at this time is obtained through the STM, GTM, or watchdog timer, i.e., the execution end time.
[0135] Embodiment 2
[0136] See also Figure 3 , Figure 3 Schematic diagram of the structure of a software program flow monitoring system disclosed in an embodiment of the present invention. Figure 3 As shown, the software program flow monitoring system includes:
[0137] A generating unit 210, used for randomly generating a random number before each program flow is executed;
[0138] A first calculation unit 220 is used to calculate the execution results of the software elements of each program flow in sequence according to the order of program flow execution based on the random number, the software element codes corresponding to each program flow and the first algorithm, until the execution result of the software element program flow of the last program flow is obtained, which is recorded as the first result;
[0139] A second calculation unit 230 is used to calculate the monitoring results of the program flow execution of the software elements of each program flow in sequence according to the order of program flow execution from back to front based on the first result, the software element codes corresponding to each program flow and the second algorithm, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result;
[0140] The comparison unit 240 is used to compare the second result with the random number. If the second result and the random number are the same, the program flow monitoring is correct.
[0141] Preferably, the first calculation unit 220 may include:
[0142] According to the random number and the software element code of the first program flow, the software element program flow execution result of the first program flow is calculated:
[0143] A1=[(C+B1)*D1]%NUM
[0144] Wherein, A1 is the execution result of the software element program flow of the first program flow, B1 is the software element code of the first program flow; C is the random number, D1 is the first calculation parameter, and NUM is the second calculation parameter;
[0145] According to the software element program flow execution result of the (i-1)th program flow and the software element code of the i-th program flow, the software element program flow execution result of the i-th program flow is calculated:
[0146] A i =[(A i-1 +B i )*D1]%NUM
[0147] Among them, A i is the execution result of the software element program flow of the i-th program flow, B i Encode the software element of the i-th program flow; A i-1 is the software element program flow execution result of the (i-1)th program flow, 1<i≤n, n is the total number of program flows executed in the loop, then the first result A n for:
[0148] A n =[(A n-1 +B n )*D1]%NUM,
[0149] Among them, A n-1 is the software element program flow execution result of the (n-1)th program flow, B n Encode the software element for the nth program flow.
[0150] Preferably, the second calculation unit 230 may include:
[0151] After the program flow execution is completed, the program flow monitoring check is performed;
[0152] According to the first result and the software element code of the last program flow, the monitoring result of the execution of the software element program flow of the last program flow is calculated:
[0153] E n =(A n *D2-B n )%NUM
[0154] Among them, E n is the monitoring result of the execution of the software element program flow of the last program flow, D2 is the third calculation parameter, and D1, D2 and NUM satisfy the following conditions:
[0155] D1*D2-NUM=1
[0156] According to the monitoring result of the software element program flow execution of the (j+1)th program flow and the software element coding of the jth program flow, the monitoring result of the software element program flow execution of the jth program flow is calculated:
[0157] E j =(E j+1 *D2-B j )%NUM
[0158] Among them, E j is the monitoring result of the software element program flow execution of the jth program flow, B j Encode the software element of the jth program flow; E j+1 is the monitoring result of the execution of the software element program flow of the (j+1)th program flow, 1≤j<n, then the second result E1 is:
[0159] E1=(E2*D2-B1)%NUM
[0160] Among them, E2 is the monitoring result of the execution of the software element program flow of the second program flow.
[0161] Preferably, the software element is the earliest executed software element corresponding to each program flow.
[0162] Preferably, the system may further include an Alive Supervision requirement monitoring unit, configured to:
[0163] According to the target time of the target software element execution function in the current execution cycle, the target time of the previous execution cycle is subtracted to obtain the function function execution cycle of the target software element, and the function function execution cycle is compared with the preset cycle to check whether the function function is executed within the preset cycle; the target time is the start time or the end time;
[0164] If the function is executed within the preset period, and the second result is equal to the random number, the program flow monitoring is correct; otherwise, if the function is not executed within the preset period, and / or the second result is not equal to the random number, the program flow monitoring fails.
[0165] Preferably, the system may further include a Deadline Supervision requirement monitoring unit, configured to:
[0166] According to the obtained execution end time of the target software element execution function in the current execution cycle, the execution start time of the target software element is subtracted to obtain the function execution time of the target software element, and the function execution time is compared with the preset time range to check whether the function execution time is within the preset time range;
[0167] If the function execution time is within the preset time range and the second result is equal to the random number, the program flow monitoring is correct. Otherwise, if the function execution time is not within the preset time range, and / or the second result is not equal to the random number, the program flow monitoring fails.
[0168] Preferably, the execution start time and the execution end time of the target software element execution function can be obtained through a timer, and the timer is STM or GTM or watchdog.
[0169] Preferably, the system may further include a partitioning unit, configured to:
[0170] Create three OS-Applications, ASIL D, ASIL B, and QM, according to the functional safety level, where the functional safety levels of ASIL D, ASIL B, and QM decrease in sequence;
[0171] According to the functional safety level of the functional module or the software element of the functional module, the execution function of the software element is allocated to the task function or interrupt function of the corresponding OS-Application to avoid mutual interference between two independent (unrelated) program flows. At the same time, the parameters D1, D2 and NUM monitored by the program flow with a high functional safety level are more complex than the parameters D1, D2 and NUM monitored by the program flow with a low functional safety level, meeting the higher functional safety level;
[0172] The execution functions in the OS-Application assigned to the QM do not participate in the software program flow monitoring.
[0173] Embodiment 3
[0174] See also Figure 4 , Figure 4 The schematic diagram of the structure of the electronic device that can be used to implement the embodiment of the present invention is shown. In a preferred embodiment of the present invention, the electronic device mainly includes an ECU (Electronic Control Unit), and of course, in other embodiments, it can also be other devices with processing and storage functions, such as a single-chip microcomputer.
[0175] like Figure 4 As shown, the electronic device includes at least one processor 310, and a memory connected to the at least one processor 310, such as a ROM (read-only memory) 320, a RAM (random access memory) 330, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 310 can perform various appropriate actions and processes according to the computer program stored in the ROM 320 or the computer program loaded from the storage unit 380 to the random access memory RAM 330. In the RAM 330, various programs and data required for the operation of the electronic device can also be stored. The processor 310, the ROM 320, and the RAM 330 are connected to each other via a bus 340. An I / O (input / output) interface 350 is also connected to the bus 340.
[0176] A number of components in the electronic device are connected to the I / O interface 350, including: an input unit 360, such as a keyboard, a mouse, etc.; an output unit 370, such as various types of displays, speakers, etc.; a storage unit 380, such as a disk, an optical disk, etc.; and a communication unit 390, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 390 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet or / and various telecommunication networks.
[0177] The processor 310 may be a variety of general or / and special processing components with processing and computing capabilities. Some examples of the processor 310 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 310 executes one or more steps of a software program flow monitoring method described in the first embodiment above.
[0178] In some embodiments, a software program flow monitoring method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 380. In some embodiments, part or all of the computer program may be loaded into or / and installed on an electronic device via a ROM 320 or / and a communication unit 390. When the computer program is loaded into the RAM 330 and executed by the processor 310, one or more steps of a software program flow monitoring method described in the first embodiment above may be performed. Alternatively, in other embodiments, the processor 310 may be configured to perform a software program flow monitoring method in any other appropriate manner (e.g., by means of firmware).
[0179] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, or / and combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed or / and interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0180] The computer programs for implementing the methods of the embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart or / and the block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0181] In the context of an embodiment of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0182] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0183] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0184] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0185] The above is a detailed introduction to a software program flow monitoring method, electronic device and storage medium disclosed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A software program flow monitoring method, characterized in that: It includes the following steps: Before each program flow is executed, a random number is randomly generated; Based on the random number, the software element codes corresponding to each program flow and the first algorithm, the program flow execution results of the software elements of each program flow are calculated in sequence according to the order in which the program flows are executed, until the program flow execution result of the software element of the last program flow is obtained, which is recorded as the first result; Based on the first result, the software element codes corresponding to each program flow, and the second algorithm, the monitoring results of the program flow execution of the software elements of each program flow are calculated in sequence according to the order of program flow execution from back to front, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result; comparing the second result with the random number, if the second result and the random number are the same, the program flow monitoring is correct; Based on the random number, the software element codes corresponding to each program flow, and the first algorithm, the software element program flow execution results of each program flow are calculated in sequence according to the order in which the program flow is executed, until the software element program flow execution result of the last program flow is obtained, which is recorded as the first result, including: According to the random number and the software element code of the first program flow, the software element program flow execution result of the first program flow is calculated: in, The software element program flow execution result of the first program flow, is the software element code of the first program flow; C is the random number, D1 is the first calculation parameter, and NUM is the second calculation parameter; According to the software element program flow execution result of the (i-1)th program flow and the software element coding of the i-th program flow, the software element program flow execution result of the i-th program flow is calculated: in, is the software element program flow execution result of the i-th program flow, Encode the software element of the ith program flow; is the software element program flow execution result of the (i-1)th program flow, 1<i≤n, n is the total number of program flows executed in the loop, then the first result for: in, The software element program flow execution result of the (n-1)th program flow, Encode the software element of the nth program flow; Based on the first result, the software element codes corresponding to each program flow, and the second algorithm, the monitoring results of the program flow execution of the software elements of each program flow are calculated in sequence according to the order of program flow execution from back to front, until the monitoring result of the program flow execution of the software element of the first program flow is obtained, which is recorded as the second result, including: After the program flow execution is completed, the program flow monitoring check is performed; According to the first result and the software element code of the last program flow, the monitoring result of the execution of the software element program flow of the last program flow is calculated: in, is the monitoring result of the execution of the software element program flow of the last program flow, D2 is the third calculation parameter, and D1, D2 and NUM satisfy the following conditions: According to the monitoring result of the software element program flow execution of the (j+1)th program flow and the software element encoding of the jth program flow, the monitoring result of the software element program flow execution of the jth program flow is calculated: in, The monitoring result of the software element program flow execution of the jth program flow, Encode the software element of the jth program flow; is the monitoring result of the execution of the software element program flow of the (j+1)th program flow, 1≤j<n, then the second result for: in, The monitoring result of the software element program flow execution for the second program flow.
2. The software program flow monitoring method according to claim 1, characterized in that: The software element is the earliest executed software element corresponding to each program flow.
3. The software program flow monitoring method according to claim 1, characterized in that: The method further comprises: According to the acquired target time of the target software element execution function in the current execution cycle, the target time of the previous execution cycle is subtracted to obtain the function function execution cycle of the target software element, and the function function execution cycle is compared with the preset cycle to check whether the function function is executed within the preset cycle; the target time is the start time or the end time; If the function is executed within the preset period and the second result is equal to the random number, the program flow monitoring is correct. Otherwise, if the function is not executed within the preset period, and / or the second result is not equal to the random number, the program flow monitoring fails.
4. The software program flow monitoring method according to claim 1, characterized in that: The method further comprises: According to the obtained execution end time of the target software element execution function in the current execution cycle, the execution start time of the target software element is subtracted to obtain the function execution time of the target software element, and the function execution time is compared with the preset time range to check whether the function execution time is within the preset time range; If the function execution time is within the preset time range and the second result is equal to the random number, the program flow monitoring is correct. Otherwise, if the function execution time is not within the preset time range, and / or the second result is not equal to the random number, the program flow monitoring fails.
5. The software program flow monitoring method according to claim 3 or 4, characterized in that: The execution start time and the execution end time of the target software element execution function are obtained through a timer, and the timer is STM or GTM or watchdog.
6. The software program flow monitoring method according to any one of claims 1 to 4, characterized in that: The method further comprises: Create three OS-Applications, ASIL D, ASIL B, and QM, according to the functional safety level, where the functional safety levels of ASIL D, ASIL B, and QM decrease in sequence; According to the functional safety level of the functional module or the software element of the functional module, the execution function of the software element is allocated to the task function or interrupt function of the corresponding OS-Application; The execution functions in the OS-Application assigned to the QM do not participate in the software program flow monitoring.
7. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the software program flow monitoring method as described in any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that: It stores a computer program, wherein the computer program enables a computer to execute the software program flow monitoring method described in any one of claims 1-5.
