A calibration updating method, device, apparatus and storage medium
By parsing the address field of the machine code file, the calibration data of the ECU is directly updated, which solves the problems of cumbersome and inefficient calibration updates in the existing technology and achieves efficient and accurate calibration updates.
Patent Information
- Application Number
- CN202310922629.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-07-26
AI Technical Summary
Existing methods for updating vehicle calibration are cumbersome and inefficient, requiring manual input and recompilation of all ECU calibration data, resulting in low update efficiency.
By parsing the address field of the machine code file, the storage location of the data to be calibrated in the machine code file is determined, and the data at the storage location is updated directly, avoiding the process of obtaining and recompiling all calibration data of the ECU.
It improves the efficiency of calibration updates, enables real-time updates, saves manpower and time costs, reduces hardware costs, and improves data accuracy.
Smart Images

Figure CN116991857B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automotive technology, and in particular to a calibration update method, apparatus, device, and storage medium. Background Technology
[0002] In the process of automobile design and manufacturing, in order to optimize various performance aspects of the vehicle (such as power, control, and economy), technicians adjust the calibration data of the Electronic Control Unit (ECU), then encapsulate the obtained calibration data into a machine code file that can be recognized by the ECU, and download the machine code file to the ECU to optimize the operation and parameters of the ECU.
[0003] In the traditional calibration process, in order to generate machine code files, technicians need to first save all the calibration data of the ECU in an Excel spreadsheet, then import it into the Simulink model file to regenerate the code, and finally compile it to obtain the machine code file.
[0004] If the calibration data needs to be updated, it is necessary to modify all the previous calibration data first, and then re-execute the aforementioned traditional calibration process to obtain the new machine code file. It is evident that the existing calibration update method is cumbersome and complex, resulting in low efficiency. Summary of the Invention
[0005] Based on this, this application provides a calibration update method, apparatus, device, and storage medium, which can improve the problem of low efficiency in calibration updates in the prior art.
[0006] In a first aspect, this application provides a calibration update method, which includes: parsing the address field of each data line in the machine code file according to the data format of the machine code file, wherein the address field is used to record the starting address of the data in the data field of the data line; determining the storage location of the data to be calibrated in the machine code file according to the address field; and updating the data at the storage location using the data to be calibrated.
[0007] In conjunction with the first aspect, in a first possible implementation of the first aspect, the aforementioned step of determining the storage location of the data to be calibrated in the machine code file based on the address field includes: reading the address field of each data line to determine the target data line to which the data to be calibrated belongs; calculating the difference between the physical starting address of the data to be calibrated and the address field of the target data line to obtain the address offset of the data to be calibrated in the data field of the target data line; and determining the storage location of the data to be calibrated in the data field according to the address offset.
[0008] In conjunction with the first possible implementation of the first aspect, in the second possible implementation of the first aspect, the aforementioned step of reading the address field of each data row to determine the target data row to which the data to be calibrated belongs includes: starting from the first data row, sequentially reading the address field of each data row, and determining the size relationship between the address field of the current data row and the physical starting address of the data to be calibrated; if the address field of the current data row is equal to the physical starting address of the data to be calibrated, then determining that the current data row is the target data row to which the data to be calibrated belongs; if the address field of the current data row is greater than the physical starting address of the data to be calibrated, then determining that the previously read data row is the target data row; if the address field of the current data row is less than the physical starting address of the data to be calibrated, then reading the next data row, and performing the step of determining the size relationship between the address field of the current data row and the physical starting address of the data to be calibrated.
[0009] In conjunction with the first possible implementation of the first aspect, in the third possible implementation of the first aspect, the aforementioned step of reading the address field of each data row to determine the target data row to which the data to be calibrated belongs includes: starting from any data row, sequentially reading the address field and length field of each data row; calculating the address range of the data recorded in the data field of the current data row based on the address field and length field, and determining whether the physical starting address of the data to be calibrated is within the address range; if so, determining that the current data row is the target data row to which the data to be calibrated belongs; if not, reading another data row and performing the step of calculating the address range of the data recorded in the data field of the current data row based on the address field and length field.
[0010] In conjunction with the first aspect, in the fourth possible implementation of the first aspect, the aforementioned step of updating the data at the storage location using the data to be calibrated includes: obtaining the data dimension and data type of the data to be calibrated, and obtaining the unit length corresponding to the data type, wherein the data dimension represents the data length in units of the data type; calculating twice the product of the data dimension and the unit length to obtain the target character length; and replacing the data at the storage location with the data to be calibrated.
[0011] In conjunction with the first aspect, in the fifth possible implementation of the first aspect, after updating the data at the storage location using the data to be calibrated, the method further includes: calculating the checksum of the target data row where the data to be calibrated is located; and replacing the data recorded in the checksum field of the target data row with the checksum.
[0012] In conjunction with the first aspect, in the sixth possible implementation of the first aspect, before determining the storage location of the data to be calibrated in the machine code file based on the address field, the method further includes: parsing the DCM file to obtain the data to be calibrated and the data name of the data to be calibrated; and parsing the A2L file to obtain the physical starting address, data type, and data dimension corresponding to the data name.
[0013] Secondly, this application also provides a calibration update device, which includes: a parsing unit, used to parse the address field of each data line in the machine code file according to the data format of the machine code file, wherein the address field is used to record the starting address of the data in the data field of the data line; a positioning unit, used to determine the storage location of the data to be calibrated in the machine code file according to the address field; and an update unit, used to update the data at the storage location using the data to be calibrated.
[0014] In conjunction with the second aspect, in the first possible implementation of the second aspect, the aforementioned positioning unit is specifically used for: reading the address field of each data row to determine the target data row to which the data to be calibrated belongs; calculating the difference between the physical starting address of the data to be calibrated and the address field of the target data row to obtain the address offset of the data to be calibrated in the data field of the target data row; and determining the storage location of the data to be calibrated in the data field according to the address offset.
[0015] In conjunction with the first possible implementation of the second aspect, in the second possible implementation of the second aspect, the aforementioned positioning unit is specifically used for: starting from the first data row, sequentially reading the address field of each data row, and determining the size relationship between the address field of the current data row and the physical starting address of the data to be calibrated; if the address field of the current data row is equal to the physical starting address of the data to be calibrated, then determining that the current data row is the target data row to which the data to be calibrated belongs; if the address field of the current data row is greater than the physical starting address of the data to be calibrated, then determining that the previously read data row is the target data row; if the address field of the current data row is less than the physical starting address of the data to be calibrated, then reading the next data row, and performing the step of determining the size relationship between the address field of the current data row and the physical starting address of the data to be calibrated.
[0016] In conjunction with the first possible implementation of the second aspect, in the third possible implementation of the second aspect, the aforementioned positioning unit is specifically used for: starting from any data row, sequentially reading the address field and length field of each data row; calculating the address range of the data recorded in the data field of the current data row based on the address field and length field, and determining whether the physical starting address of the data to be calibrated is within the address range; if so, determining that the current data row is the target data row to which the data to be calibrated belongs; if not, reading another data row and performing the step of calculating the address range of the data recorded in the data field of the current data row based on the address field and length field.
[0017] In conjunction with the second aspect, in the fourth possible implementation of the second aspect, the aforementioned update unit is specifically used to: obtain the data dimension and data type of the data to be calibrated, and obtain the unit length corresponding to the data type, wherein the data dimension represents the data length in units of the data type; calculate twice the product of the data dimension and the unit length to obtain the target character length; and replace the data of the target character length at the storage location with the data to be calibrated.
[0018] In conjunction with the second aspect, in the fifth possible implementation of the second aspect, the aforementioned update unit is further configured to: calculate the checksum of the target data row where the data to be calibrated is located; and replace the data recorded in the check field of the target data row with the checksum.
[0019] In conjunction with the second aspect, in the sixth possible implementation of the second aspect, the aforementioned parsing unit is further configured to: parse the DCM file to obtain the data to be calibrated and the data name of the data to be calibrated; and parse the A2L file to obtain the physical starting address, data type, and data dimension corresponding to the data name.
[0020] Thirdly, this application also provides a calibration update device, which includes a processor and a memory connected via a bus; the processor is used to execute multiple instructions; the memory is used to store multiple instructions, which are adapted to be loaded by the processor and executed as a calibration update method as described in the first aspect or any embodiment of the first aspect.
[0021] Fourthly, this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor and executing a calibration update method as described in the first aspect or any embodiment of the first aspect.
[0022] In summary, this application provides a calibration update method, apparatus, device, and storage medium. The calibration update apparatus / device first parses the address field of each data line. Since the address field records the starting address of the data in the data field, and the data in the data field is stored sequentially according to its physical address in the ECU, after parsing the address field of the data line, the storage location of the data to be calibrated in the machine code file can be determined based on the data field. Then, the data at the corresponding storage location is updated using the data to be calibrated, resulting in the updated machine code file. Therefore, this application can directly update the machine code file without obtaining all the calibration data from the ECU or re-executing the traditional calibration process, thus greatly improving the efficiency of calibration updates. Attached Figure Description
[0023] Figure 1 This is an embodiment of the present application that specifies the SREC file before the update;
[0024] Figure 2 This is a schematic flowchart of a calibration update method in one embodiment of this application;
[0025] Figure 3 This is a schematic flowchart illustrating the steps for determining a target data row in one embodiment of this application;
[0026] Figure 4 This is a schematic flowchart illustrating the steps for determining the target data row in another embodiment of this application;
[0027] Figure 5 This is a schematic flowchart illustrating the calibration update method in another embodiment of this application;
[0028] Figure 6 This is a schematic block diagram of a calibration update device in one embodiment of this application;
[0029] Figure 7 This is a structural block diagram of a calibration update device in one embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0031] In the existing calibration update method, technicians need to manually fill all the calibration data of the ECU into an Excel spreadsheet in a fixed format, then modify the calibration data in the Excel spreadsheet, import the calibration data in the Excel spreadsheet into the Simulink model file to regenerate the code, and finally compile it to obtain the machine code file to realize the calibration update of the machine code file.
[0032] To improve the efficiency of calibration updates, expensive calibration systems can be used to memorize previously calibrated data, or the calibration system can be used to parse the machine code file in the ECU to obtain all the calibration data of the ECU. It can be seen that those skilled in the art tend to use tools such as calibration systems and compilation software when updating calibrations, rather than directly modifying the machine code file. This is because, in traditional technical concepts, machine code is considered to have very poor readability and is intended solely for machine use.
[0033] While calibration systems and compilation software can lower the barrier to entry for calibration and make it easier to learn, they still suffer from low efficiency during calibration updates. To address this, the inventors of this application, abandoning technical bias, compared and analyzed the differences between machine code files before and after the update, and analyzed the data format of the machine code files. They discovered the update pattern of the machine code files during calibration updates, namely the relationship between the data to be calibrated and the changed parts of the machine code file, thus proposing a calibration update method. Specifically, the calibration update device / equipment parses the address field of each data line in the machine code file according to the data format of the machine code file. The address field records the starting address of the data in the data field of the data line. Based on the address field, the storage location of the data to be calibrated in the machine code file is determined. The data at the storage location is then updated using the data to be calibrated.
[0034] For example, taking SREC documents as an example, such as Figure 1 As shown, the machine code file contains multiple data lines. Before the calibration update, the second data line includes: S32580040040323130383130302D524B3031000000003832353200000000000000000000000BE. The address field from the 5th to the 12th character contains "80040040," representing the starting address of the "data field" from the 13th to the 76th character. This indicates that the data field records calibration data within the ECU's physical address range of 0x80040040 to 0x8004005F. Therefore, the storage location of any calibration data within this range can be determined based on the address field of the data line. Furthermore, since the data in the machine code file is represented in hexadecimal, two characters represent one byte.
[0035] It should be noted that machine code files can be S-record files (including SREC files, S19, S28, and S37, etc.) or binary files such as HEX files. Machine code files consist of multiple ASCII text lines separated by newline characters, carriage returns, or both. Each text line is called a record, and each text line contains hexadecimal characters encoding multiple binary numbers. The data lines described in this application refer to the text lines in the machine code file used to store identification data, such as text lines of record type S1, S2, or S3 in an SREC file, or text lines of record type 00 in a HEX file. Furthermore, since each text line in a HEX file and an S-record file includes a record type field, the record type recorded in the type field can be used to determine whether a text line is of type S1, S2, S3, or 00, thus determining whether it is a data line. If not, it is skipped; if it is, it is parsed. This will not be elaborated further in this application.
[0036] It should also be noted that, according to the data format of machine code files, each data line in HEX and S-record files includes a length field (Byte count), an address field (Address), a type field (Record type), a data field (Data), and a checksum field (Checksum). The difference is that the length field of a HEX file records the byte length of the data field; while the length field of an S-record file records the sum of the byte lengths of the address, data, and checksum fields. However, since the byte lengths of the data in the address and checksum fields are known, the byte length of the data field can be deduced from the length field. This is because, in an S-record file, the checksum field has a fixed byte length of 1 byte, and the address field's byte length corresponds to the type field. For example, when the type field is S1, the address field's byte length is 2 bytes; when the type field is S2, the address field's byte length is 3 bytes; and when the type field is S3, the address field's byte length is 4 bytes. After determining the byte length of the address field based on the type field, the byte length of the data field can be obtained by subtracting the byte length of the address field and the byte length of the check field from the data in the length field.
[0037] To better understand the calibration update method of this application, such as Figure 2 As shown, this application proposes an embodiment of a calibration update method. Next, this application uses a calibration update device as the execution entity to... Figure 2 The calibration update method shown is explained in detail. Specifically:
[0038] 100: Parse the address fields of each data line in the machine code file according to the data format of the machine code file.
[0039] Each data line in the machine code file includes an address field, which records the starting address of the data in the data field of the data line. It should be noted that this application does not restrict the parsing order of the data lines. Parsing can begin sequentially from the first data line of the machine code file; or in reverse order from the last data line of the machine code file; or in a random order from any data line of the machine code file.
[0040] For example, taking SREC documents as an example, such as Figure 1 According to the data format of the machine code file, the data rows shown can be parsed to show that the field with a length of 8 characters, starting from the 5th character of the data row, is the address field.
[0041] 200: Determine the storage location of the data to be calibrated in the machine code file based on the address field.
[0042] Each data line in the machine code file also includes a data field. The data field is used to store at least one calibration data of the ECU. The at least one calibration data is stored in the data field in the order of storage in the ECU. The address field records the starting address of the data in the data field. Therefore, the storage location of the data to be calibrated in the machine code file can be deduced based on the address field of the data line.
[0043] It should be noted that the character / byte length of the data fields in each data line of the machine code is variable; that is, the character / byte length of the data characters in different data lines may not be equal, making it impossible for the calibration update device to directly locate the storage location of the data to be calibrated in the machine code file. To address this, we can first determine the target data line to which the data to be calibrated belongs, and then confirm the specific storage location of the data to be calibrated within the target data line. Specifically: read the address field of each data line to determine the target data line to which the data to be calibrated belongs; calculate the difference between the physical starting address of the data to be calibrated and the address field of the target data line to obtain the address offset of the data to be calibrated within the data field of the target data line; and determine the storage location of the data to be calibrated within the data field according to the address offset.
[0044] For example, taking the SREC file as an example, assume the physical address of the data to be calibrated in the ECU is 0x80040052. The calibration update device reads the data sequentially as follows: Figure 1The address fields of each data line shown, when reading the address field 0x80040040 of the second data line, determine the byte length of the data field to be 32 bytes based on the length field 0x25. This indicates that the data field of this data line is used to record calibration data in the ECU with a physical address range from 0x80040040 to 0x8004005F. The physical starting address of the data to be calibrated is exactly within this address range, indicating that the second data line is the target data line to which the data to be calibrated belongs. Then, calculate the difference (i.e., 0x12) between the physical starting address of the data to be calibrated (0x80040052) and the address field of the target data line (0x80040040), resulting in an address offset of 18 bytes (i.e., 36 characters). The address field (0x80040040) of the target data line records the starting address of the data in the data field, that is, the physical address of the 13th and 14th characters of the target data line (the 1st and 2nd characters in the data field). Based on the address offset of 36 characters, the physical starting address 0x80040052 of the data to be calibrated corresponds to the 49th and 50th characters in the target data line (the 37th and 38th characters in the data field). The 49th and 50th characters of the target data line are also the storage locations of the data to be calibrated in the machine code file.
[0045] 300: Update the data at the storage location using the data to be calibrated.
[0046] In this process, after determining the storage location of the data to be calibrated in the machine code file, if the character length of the data to be calibrated is 2 characters, which is exactly the same as the character length of the storage location determined in the previous step, the data to be calibrated can be directly replaced in the storage location; if the character length of the calibration data is more than the target character length of 2 characters, then the data of the target character length at the storage location needs to be replaced with the data to be calibrated.
[0047] It should be noted that before calibration and updating, if the data to be calibrated is not in hexadecimal, it needs to be converted to hexadecimal before updating the data at that storage location. Additionally, for cases where the character length of the data to be calibrated may exceed two characters, this application also provides a calibration and updating method for data of any data type, satisfying the update and calibration requirements of multiple vehicle models and multiple ECUs. Specifically: The method involves obtaining the data dimension and data type of the data to be calibrated, and obtaining the unit length corresponding to the data type, where the data dimension represents the data length in units of the data type; calculating twice the product of the data dimension and the unit length to obtain the target character length; and replacing the data of the target character length at the storage location with the data to be calibrated.
[0048] For example, the data types for calibration data include short, UBYTE, int, and float. The unit length for short is 2 bytes, for UBYTE it's 1 byte, for int it's 4 bytes, and for float it's 4 bytes. Assuming the data to be calibrated is 1, the data type is UBYTE, and the data dimension is 1, then according to the calculation formula: target character length of the data to be calibrated = 2 (unit length corresponding to the data type × data dimension), the target character length of the data to be calibrated is 2 characters, that is, 2 characters starting from the storage location (i.e., the 49th and 50th characters of the target data line). After the calibration update device converts the data to be calibrated into hexadecimal 0x01, it replaces 0x35 in the 49th and 50th characters of the target data line with 0x01 to achieve the calibration update of the machine code file.
[0049] It should be noted that after calibration update, to maintain the correctness of the calibration data, a verification update can also be performed. This involves calculating the checksum of the target data row containing the data to be calibrated, and replacing the data in the checksum field of that target data row with the calculated checksum. The verification update process specifically includes: after updating the data at the storage location using the data to be calibrated, calculating the checksum of the target data row containing the data to be calibrated; and replacing the data recorded in the checksum field of the target data row with the checksum. Specifically, during verification update, taking an SREC file as an example, the calibration update device can first calculate the sum of the data recorded in the address field and the data field, then retain the lowest two bytes of the sum, and finally calculate the complement of the lowest two bytes to obtain the checksum.
[0050] For example, in the case of Figure 1 After replacing 0x35 with 0x01 in the 49th and 50th characters (i.e., the 37th and 38th characters in the data field) of the second data line, the calibration update device calculates the checksum 0x0E of the calibrated and updated target data line, and replaces the data 0xBE in the last two characters (i.e., the check field) of the target data line with the checksum 0x0E. After the calibration update and checksum update, the target data line is represented as: S32580040040323130383130302D524B3031000000003832013200000000000000000000000000E.
[0051] It should also be noted that the physical address, data type, and data dimension of the data to be calibrated can be obtained from the A2L file based on the data name, which in turn can be obtained from the DCM. Specifically: before determining the storage location of the data to be calibrated in the machine code file based on the address field, the DCM file is parsed to obtain the data to be calibrated and its data name; the A2L file is parsed to obtain the physical address, data type, and data dimension corresponding to the data name. The A2L file is obtained from the most recent software release and records the data name, physical address, data type, and data dimension of all calibration data. These pieces of information are interrelated; a unique corresponding information can be found through the data name. The DCM file is the output file after the ECU is calibrated by the calibration tool. The DCM records multiple data sets to be calibrated and their corresponding data names. For example:
[0052] First, the calibration update device parses the data to be calibrated and the data names of the data to be calibrated from the DCM file to form Table 1 as shown below:
[0053] Data Name Data to be calibrated C_Name 1
[0054] Then, the calibration update device parses the corresponding physical address, data type, and data dimension in A2L based on the data name, and merges the parsed data into Table 1, resulting in Table 2 as shown below:
[0055] Data Name Data to be calibrated Physical address Data types Data Dimensions C_Name 1 0x80040052 UBYTE 1
[0056] In summary, since the calibration update method of this application can directly update the machine code file, it improves the efficiency of calibration update by eliminating the need to obtain all calibration data of the ECU and re-execute the traditional calibration process. It also enables real-time updates by only updating certain values in the machine code file, thus accelerating software release. Furthermore, it saves labor and time costs and improves data accuracy by eliminating the need for manual input and verification of all ECU calibration data, preventing errors or omissions due to human error. Finally, it saves on hardware costs by not requiring the use of an expensive professional calibration system.
[0057] Furthermore, regarding step 200 described in the previous embodiment, where the calibration update device determines the target data row to which the data to be calibrated belongs before determining the specific storage location of the data to be calibrated in the machine code file, this application provides two methods: "sequential reading" and "random reading." "Sequential reading" has the advantage of being simple and fast in finding the target data row, while "random reading" is universal and does not restrict the reading order. For these two methods, this application proposes two implementations to illustrate how to determine the target data row to which the data to be calibrated belongs.
[0058] First embodiment: In the "sequential reading" method, the calibration update device sequentially reads the address fields of each data line of the machine code file, and quickly determines the target data line to which the data to be calibrated belongs based on the relationship between the address fields and the physical starting address of the data to be calibrated. Specifically:
[0059] 211: Starting from the first data row, read the address field of each data row sequentially.
[0060] 212: Determine the relationship between the address field of the current data row and the physical starting address of the data to be calibrated.
[0061] 213: If the address field of the current data row is equal to the physical starting address of the data to be calibrated, then the current data row is determined to be the target data row.
[0062] 214: If the address field of the current data row is greater than the physical starting address of the data to be calibrated, then the data row read previously is determined to be the target data row.
[0063] 215: If the address field of the current data row is less than the physical starting address of the data to be calibrated, then read the address field of the next data row.
[0064] The calibration update device starts from the first data line of the machine code file, sequentially reads the address field of each data line, and determines the relationship between the address field of the current data line and the physical starting address of the data to be calibrated. If the address field of the current data line is equal to the physical starting address of the data to be calibrated, it means that the current data line is the target data line to which the data to be calibrated belongs, and the starting position of the data field of the current data line is the storage location of the data to be calibrated. If the address field of the current data line is less than the physical starting address of the data to be calibrated, it means that the previously read data lines were not the target data lines, but the current data line may be the target data line to which the data to be calibrated belongs. To determine this, the address field of the next data line needs to be read, so the next data line is read. If the address field of the current data line is greater than the physical starting address of the data to be calibrated, it means that the current data line and the data lines following it are not the target data lines, and the previous data line is the only choice for the target data line. Therefore, the target data line to which the data to be calibrated belongs is the data line preceding the current data line.
[0065] For example, taking the SREC file as an example, assuming the physical starting address of the data to be calibrated is 0x80040052, multiple data lines in the SREC file are as follows: Figure 1 As shown, the calibration update device starts reading from the address field of the first data line. Since the address field of the first data line, 0x80040020, is less than the physical starting address of the data to be calibrated, 0x80040052, the address field of the second data line, 0x80040040, is read. Since 0x80040040 is less than 0x80040052, the address field of the third data line, 0x80040060, is read. Since 0x80040060 is greater than 0x80040052, the previously read data line (i.e., the second data line) is the target data line of the data to be calibrated.
[0066] It should be noted that the embodiment in this application is an example of sequentially reading each data row. Next, this application will describe other possible implementation methods:
[0067] Alternatively, the calibration update device can read the address fields of each data line in reverse order, starting from the last data line of the machine code file. Specifically: the calibration update device reads the address fields of each data line in reverse order, starting from the last data line of the machine code file, and determines the relationship between the address field of the current data line and the physical starting address of the data to be calibrated; if the address field of the current data line is equal to the physical starting address of the data to be calibrated, then the current data line is determined to be the target data line to which the data to be calibrated belongs; if the address field of the current data line is greater than the physical starting address of the data to be calibrated, then the previous data line is read, and the step of determining the relationship between the address field of the current data line and the physical starting address of the data to be calibrated is performed; if the address field of the current data line is less than the physical starting address of the data to be calibrated, then the current data line is determined to be the target data line.
[0068] In another approach, the calibration update device can sequentially read the address fields of each data line starting from any data line in the middle of the machine code file. Specifically: starting from any data line in the middle of the machine code file, the calibration update device determines the relationship between the address field of the current data line and the physical starting address of the data to be calibrated; if the address field of the current data line is equal to the physical starting address of the data to be calibrated, the current data line is determined to be the target data line to which the data to be calibrated belongs; if the address field of the current data line is greater than the physical starting address of the data to be calibrated, the method of reading the address fields of each data line in reverse order as described in the other approach is implemented to determine the target data line to which the data to be calibrated belongs is executed; if the address field of the current data line is less than the physical starting address of the data to be calibrated, the method of sequentially reading the address fields of each data line as described in this embodiment is executed to determine the target data line to which the data to be calibrated belongs.
[0069] In summary, in the embodiments of this application, the calibration update device improves the search speed of the target data line by "sequential reading", thereby improving the speed of determining the storage location of the data to be calibrated in the machine code file, thus further improving the problem of low efficiency of calibration update in the prior art.
[0070] The second embodiment: In the "sequential reading" method, the calibration update device randomly reads the address field of each data line of the machine code file and calculates whether the current data line is the target data line to which the data to be calibrated belongs. Specifically:
[0071] 221: Starting from any data row, read the address field and length field of each data row in sequence.
[0072] 222: Calculate the address range of the data recorded in the data fields of the current data row based on the address field and the length field.
[0073] 223: Determine whether the physical starting address of the data to be calibrated is within the aforementioned address range.
[0074] 224: If the physical starting address of the data to be calibrated is within the aforementioned address range, then the current data row is determined to be the target data row to which the data to be calibrated belongs.
[0075] 225: If the physical starting address of the data to be calibrated is not within the aforementioned address range, then read another data line.
[0076] The calibration update device does not restrict the order in which it reads each data line. It can start reading from any line in the middle of the machine code file. Whenever the address field and length field of a data line are read, the address range of the data stored in the data line is calculated based on the address field and length field. If the physical starting address of the data to be calibrated is within the address range, then the data line is determined to be the target data line to which the data to be calibrated belongs; if the physical starting address of the data to be calibrated is not within the address range, another data line is read.
[0077] For example, taking an SREC file as an example, multiple data rows in an SREC file, such as... Figure 1 As shown, assuming the calibration update device reads the address field 0x80040020 and the length field 0x25 of the second data line, subtracting the address field's byte length (4 bytes) and the check field's byte length (1 byte) from 0x25, the data field's byte length is 32 bytes. This means the address range of the data recorded in the current data line's data field is 0x80040040 to 0x8004005F. Assuming the physical starting address of the data to be calibrated is 0x80040052, which falls within the aforementioned address range, the second data line is determined to be the target data line to which the data to be calibrated belongs. Assuming the physical starting address of the data to be calibrated is 0x80040066, which is outside the aforementioned address range, the second data line is determined not to be the target data line to which the data to be calibrated belongs. Another unread data line is then randomly read, and the previous address range calculation process is repeated until the target data line to which the data to be calibrated belongs is found.
[0078] In another possible implementation, in order to further improve the efficiency of finding the target data row based on "random reading", in step 225, when performing the step of reading another data row, the calibration update device may further: compare the size relationship between the address field of the current data row and the physical starting address of the data to be calibrated; if the address field of the current data row is greater than the physical starting address of the data to be calibrated, then set the current data row and the data rows after the current data row as unselectable, and randomly read another selectable data row forward; if the address field of the current data row is less than the physical starting address of the data to be calibrated, then set the current data row and the data rows before the current data row as unselectable, and randomly read another selectable data row backward.
[0079] In this embodiment, while the calibration update device reads data randomly, it also imposes certain restrictions on the order in which it reads subsequent data rows, thereby improving the speed at which the target data row can be found quickly. Specifically, before reading another data row, the calibration update device determines whether the target data row is before or after the current data row by comparing the size relationship between the physical starting address of the data to be calibrated and the address field of the current data row. It should be noted that when initially reading data lines, all data lines in the machine code file are optional. If it is determined that the current data line is not the target data line, the current data line, as well as the data lines before and after it, need to be set to unoptional. This ensures that the calibration update device can only read from the remaining optional data lines during subsequent random reads. This is because: if it is determined that the current data line is not the target data line, and the address field of the current data line is greater than the physical starting address of the data to be calibrated, it can be determined that the address fields of the data lines after the current data line will also be greater than the physical starting address of the data to be calibrated. Therefore, the data lines after the current data line cannot be the target data line. Conversely, if it is determined that the current data line is not the target data line, and the address field of the current data line is less than the physical starting address of the data to be calibrated, since the current data line is not the target data line, the data lines before it are even less likely to be the target data line. The target data line can only be after the current data line. In summary, this feasible implementation avoids redundant calculations and wasted computing resources by narrowing the range of optional data lines, and greatly improves the speed of finding the target data line.
[0080] For example, taking an SREC file as an example, multiple data rows in an SREC file, such as... Figure 1As shown, assuming the physical starting address of the data to be calibrated is 0x80040052, when initially reading the data rows, rows one through six are all selectable. The calibration update device initially randomly reads the address field of the fourth data row and, after determining that the fourth data row is not the target data row to which the data to be calibrated belongs, compares the address field of the fourth data row (0x80040080) with the physical starting address of the data to be calibrated (0x80040052). Then, the calibration update device sets the fourth, fifth, and sixth data rows to be unselectable and randomly reads the address field of the first data row (0x80040020). Following the same calculation method, it can be determined that the first data row is also not the target data row. Next, the address field of the first data line, 0x80040020, is compared to the physical starting address of the data to be calibrated, 0x80040052. Therefore, the first data line is set to be unselectable, and another data line is randomly read backward. It should be noted that only one data line can be randomly read between the second and third data lines, because only the second and third data lines are selectable after the first data line.
[0081] In summary, in the embodiments of this application, the calibration update device not only improves the problem of low efficiency in calibration update in the prior art, but also adopts a "random reading" method, which improves the universality of the calibration update method.
[0082] In addition, based on the first embodiment, this application also provides another embodiment of the calibration update method, which more completely describes the implementation process of calibration update. Next, this application will use a calibration update device as the execution subject to... Figure 5 The calibration update method shown will be explained in detail below:
[0083] 510: Parse the DCM file to obtain the data to be calibrated and the data name of the data to be calibrated, and parse the A2L file to obtain the physical starting address, data type and data dimension corresponding to the data name.
[0084] 520: Parse the address fields of each data line in the machine code file according to the data format of the machine code file.
[0085] 530: Determine the storage location of the data to be calibrated in the machine code file based on the address field.
[0086] 540: Update the data at the aforementioned storage location using the data to be calibrated.
[0087] 550: Calculate the checksum of the target data row containing the data to be calibrated, and use the checksum to replace the data recorded in the check field of the target data row.
[0088] In summary, this application first parses the data to be calibrated and related information in the DCM and A2L files. Then, according to the data format of the machine code file, it parses the address fields of each data line of the machine code to determine the target data line to which the data to be calibrated belongs in the machine code file. Further, it determines the storage location of the data to be calibrated in the target data line. Finally, after updating the data at the aforementioned storage location using the data to be calibrated, it also verifies and updates the target data line to maintain its security and correctness. In general, this application provides a more detailed implementation process for the calibration update method, improving the low efficiency of calibration updates in the prior art.
[0089] This application also provides a calibration update device, such as Figure 6 As shown. This application embodiment can divide the device into functional modules based on the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods. Specifically, as... Figure 6 As shown, the calibration update device includes: a parsing unit 610, used to parse the address field of each data line in the machine code file according to the data format of the machine code file, wherein the address field is used to record the starting address of the data in the data field of the data line; a positioning unit 620, used to determine the storage location of the data to be calibrated in the machine code file according to the address field; and an update unit 630, used to update the data at the storage location using the data to be calibrated.
[0090] In another possible implementation, the aforementioned positioning unit 620 is specifically used to: read the address field of each data row to determine the target data row to which the data to be calibrated belongs; calculate the difference between the physical starting address of the data to be calibrated and the address field of the target data row to obtain the address offset of the data to be calibrated in the data field of the target data row; and determine the storage location of the data to be calibrated in the data field according to the address offset.
[0091] In another possible implementation, the aforementioned positioning unit 620 is specifically used to: starting from the first data line, sequentially read the address field of each data line, and determine the size relationship between the address field of the current data line and the physical starting address of the data to be calibrated; if the address field of the current data line is equal to the physical starting address of the data to be calibrated, then determine that the current data line is the target data line to which the data to be calibrated belongs; if the address field of the current data line is greater than the physical starting address of the data to be calibrated, then determine that the previously read data line is the target data line; if the address field of the current data line is less than the physical starting address of the data to be calibrated, then read the next data line and perform the step of determining the size relationship between the address field of the current data line and the physical starting address of the data to be calibrated.
[0092] In another possible implementation, the aforementioned positioning unit 620 is specifically used to: starting from any data row, sequentially read the address field and length field of each data row; calculate the address range of the data recorded in the data field of the current data row based on the address field and length field, and determine whether the physical starting address of the data to be calibrated is within the address range; if so, determine that the current data row is the target data row to which the data to be calibrated belongs; if not, read another data row and perform the step of calculating the address range of the data recorded in the data field of the current data row based on the address field and length field.
[0093] In another possible implementation, the aforementioned update unit 630 is specifically used to: obtain the data dimension and data type of the data to be calibrated, and obtain the unit length corresponding to the data type, wherein the data dimension represents the data length in units of the data type; calculate twice the product of the data dimension and the unit length to obtain the target character length; and replace the data of the target character length at the storage location with the data to be calibrated.
[0094] In another possible implementation, the aforementioned update unit 630 is further configured to: calculate the checksum of the target data row containing the data to be calibrated; and replace the data recorded in the check field of the target data row with the checksum.
[0095] In another possible implementation, the aforementioned parsing unit 610 is also used to: parse the DCM file to obtain the data to be calibrated and the data name of the data to be calibrated; and parse the A2L file to obtain the physical starting address, data type, and data dimension corresponding to the data name.
[0096] This application also provides a calibration update device, see [link to relevant documentation] Figure 7The calibration update device in this embodiment, as shown in the figure, may include a processor 710 and a memory 720. The processor 710 and the memory 720 are connected via a bus 730. The processor 710 is used to execute multiple instructions; the memory 720 is used to store multiple instructions adapted to be loaded by the processor 710 and executed as in the calibration update method described in the above embodiment.
[0097] The processor 710 can be an Electronic Control Unit (ECU), a Central Processing Unit (CPU), a general-purpose processor, a coprocessor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The processor 710 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a 5SP and a microprocessor, etc. In this embodiment, the processor 710 can be a microcontroller. By programming the microcontroller, various control functions can be implemented. The processor has the advantages of powerful computing capabilities and fast processing speed. Specifically, the processor 710 is used to: execute the function of the parsing unit 610, which is used to parse the address field of each data line in the machine code file according to the data format of the machine code file, wherein the address field is used to record the starting address of the data in the data field of the data line; execute the function of the positioning unit 620, which is used to determine the storage location of the data to be calibrated in the machine code file according to the address field; and execute the function of the updating unit 630, which is used to update the data at the storage location using the data to be calibrated.
[0098] In another possible implementation, the processor 710 is specifically used to: read the address field of each data row to determine the target data row to which the data to be calibrated belongs; calculate the difference between the physical starting address of the data to be calibrated and the address field of the target data row to obtain the address offset of the data to be calibrated in the data field of the target data row; and determine the storage location of the data to be calibrated in the data field according to the address offset.
[0099] In another possible implementation, the processor 710 is specifically used to: starting from the first data line, sequentially read the address field of each data line, and determine the size relationship between the address field of the current data line and the physical starting address of the data to be calibrated; if the address field of the current data line is equal to the physical starting address of the data to be calibrated, then determine that the current data line is the target data line to which the data to be calibrated belongs; if the address field of the current data line is greater than the physical starting address of the data to be calibrated, then determine that the previously read data line is the target data line; if the address field of the current data line is less than the physical starting address of the data to be calibrated, then read the next data line and execute the step of determining the size relationship between the address field of the current data line and the physical starting address of the data to be calibrated.
[0100] In another possible implementation, the processor 710 is specifically used to: starting from any data line, sequentially read the address field and length field of each data line; calculate the address range of the data recorded in the data field of the current data line based on the address field and length field, and determine whether the physical starting address of the data to be calibrated is within the address range; if so, determine that the current data line is the target data line to which the data to be calibrated belongs; if not, read another data line and execute the step of calculating the address range of the data recorded in the data field of the current data line based on the address field and length field.
[0101] In another possible implementation, the processor 710 is specifically used to: obtain the data dimension and data type of the data to be calibrated, and obtain the unit length corresponding to the data type, wherein the data dimension represents the data length in units of the data type; calculate twice the product of the data dimension and the unit length to obtain the target character length; and replace the data of the target character length at the storage location with the data to be calibrated.
[0102] In another possible implementation, the processor 710 is also used to: calculate the checksum of the target data row containing the data to be calibrated; and replace the data recorded in the check field of the target data row with the checksum.
[0103] In another possible implementation, the processor 710 is also used to: parse the DCM file to obtain the data to be calibrated and the data name of the data to be calibrated; and parse the A2L file to obtain the physical starting address, data type, and data dimension corresponding to the data name.
[0104] In one embodiment, this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor and executing the methods in any of the foregoing embodiments. A processor is provided for executing the plurality of instructions; a memory is provided for storing the plurality of instructions, which are loaded by the processor and executed as the calibration update method in the above embodiments.
[0105] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0106] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A calibration update method characterized by, The method comprises the following steps: According to the data format of the machine code file, the address field of each data line in the machine code file is parsed, wherein the address field is used to record the starting address of the data in the data field of the data line; The address field of each data line is read to determine the target data line to which the to-be-calibrated data belongs; The difference between the physical first address of the to-be-calibrated data and the address field of the target data line is calculated to obtain the address offset of the to-be-calibrated data in the data field of the target data line; The storage position of the to-be-calibrated data in the data field is determined according to the address offset; The data dimension and data type of the to-be-calibrated data are obtained, and the unit length corresponding to the data type is obtained, wherein the data dimension represents the data length in the unit of the data type; The product of the data dimension and the unit length is calculated twice to obtain the target character length; The target character length of data at the storage position is replaced by the to-be-calibrated data.
2. The method of claim 1, wherein, The step of reading the address field of each data line to determine the target data line to which the to-be-calibrated data belongs comprises: Starting from the first data line, the address fields of the data lines are sequentially read, and the size relationship between the address field of the current data line and the physical first address of the to-be-calibrated data is judged; If the address field of the current data line is equal to the physical first address of the to-be-calibrated data, it is determined that the current data line is the target data line to which the to-be-calibrated data belongs; If the address field of the current data line is greater than the physical first address of the to-be-calibrated data, it is determined that the data line read last time is the target data line; If the address field of the current data line is less than the physical first address of the to-be-calibrated data, the next data line is read, and the step of judging the size relationship between the address field of the current data line and the physical first address of the to-be-calibrated data is executed.
3. The method of claim 1, wherein, The step of reading the address field of each data line to determine the target data line to which the to-be-calibrated data belongs comprises: Starting from any data line, the address field and the length field of each data line are sequentially read; According to the address field and the length field, the address range of the data recorded in the data field of the current data line is calculated, and it is judged whether the physical first address of the to-be-calibrated data is within the address range; If yes, it is determined that the current data line is the target data line to which the to-be-calibrated data belongs; If no, another data line is read, and the step of calculating the address range of the data recorded in the data field of the current data line according to the address field and the length field is executed.
4. The method of claim 1, wherein, After the target character length of data at the storage position is replaced by the to-be-calibrated data, the following steps are further included: The checksum of the target data line where the to-be-calibrated data is located is calculated; The data recorded in the checksum field of the target data line is replaced by the checksum.
5. The method of claim 1, wherein, Before the step of reading the address field of each data line to determine the target data line to which the to-be-calibrated data belongs, the following steps are further included: The DCM file is parsed to obtain the to-be-calibrated data and a data name of the to-be-calibrated data; The A2L file is parsed to obtain the physical first address, the data type and the data dimension corresponding to the data name.
6. A calibration update device, characterized by The calibration updating device comprises: The parsing unit is configured to parse an address field of each data row in the machine code file according to a data format of the machine code file, wherein the address field is used to record a start address of data in a data field of the data row; The positioning unit is configured to read the address field of each data row to determine a target data row to which the to-be-calibrated data belongs; calculate a difference between the physical first address of the to-be-calibrated data and the address field of the target data row to obtain an address offset of the to-be-calibrated data in the data field of the target data row; and determine a storage position of the to-be-calibrated data in the data field according to the address offset; The updating unit is configured to obtain a data dimension and a data type of the to-be-calibrated data, and obtain a unit length corresponding to the data type, wherein the data dimension represents a data length in the data type; calculate a product of the data dimension and the unit length multiplied by two to obtain a target character length; and replace data of the target character length at the storage position with the to-be-calibrated data.
7. A calibration update device, characterized by The calibration updating device comprises a processor and a memory connected through a bus; the processor is configured to execute a plurality of instructions; and the memory is configured to store the plurality of instructions, the instructions being adapted to be loaded and executed by the processor to implement the calibration updating method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a plurality of instructions, the instructions being adapted to be loaded and executed by the processor to implement the calibration updating method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Analysis method and system for flash file of controller and computer readable medium
CN116069360A
System to detect, assess and counter disinformation
US20220164643A1