Hex program file compiling and rewriting method based on Intel mode

By adopting the Hex program file compilation and rewriting method based on Intel mode in vehicle control software development, and using technologies such as python and MFC, the problem of low compilation and rewriting efficiency in the existing technology is solved, and rapid program compilation and rewriting hex program file are realized, which significantly improves the software development efficiency.

CN120066517APending Publication Date: 2025-05-30SHAANXI FAST AUTO DRIVE GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510074011.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the prior art, the compilation and rewriting methods of on-board control software are relatively inefficient. It takes about twenty minutes to compile a program, and about thirty minutes to rewrite a program.

Method used

The Hex program file compilation and rewriting method based on Intel mode is adopted, and the ASW generated by the simulink model is added, deleted, modified and checked using python scripts and bat files. The python scripts and bat files are called through the MFC software interface, and the makefile file is compiled to generate the hex program file, and the hex program file is rewriting based on the Excel program variable table and A2L file.

Benefits of technology

Hex program files can be compiled and rewrited within ten minutes, significantly shortening the program release cycle, improving software development efficiency, and being able to test multiple programs within one working day.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066517A_ABST
    Figure CN120066517A_ABST
Patent Text Reader

Abstract

The invention provides a hex program file compiling and rewriting method based on an Intel mode. The hex program file compiling and rewriting method comprises the steps that firstly, a python script is used for adding, deleting, modifying and checking an ASW generated by a simulink model; 2, using a python script to complete file carrying work of the ASW, moving the file to a specified folder, and completing connection work with the BSW; step 3, designing an MFC software interface, checking options of hex generated by each module, calling a python script through the MFC to execute a bat file, executing the bat file, calling a makefile to compile and generate a hex program file required by each module; and 4, according to the Excel program variable table, the A2L file and the hex program file generated by compiling in the step 3, completing a rewriting process of the hex program file, and generating the hex program file required by the vehicle-mounted controller. According to the method, the hex program file can be compiled within ten minutes, the rewriting process of the hex program file can be completed, a computer program is used for replacing tedious adding, deleting, modifying and checking work in the process that programming software and a program rewriting tool CANape are used by people, the program release period is shortened, and the software development efficiency is improved. And a plurality of programs can be tested in one workday.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of vehicle control software, involving compilation and rewriting, and specifically relates to a method for compiling and rewriting hex program files based on the Intel mode. Background Art

[0002] In the field of vehicle control software development, since different vehicle manufacturers have different calibration parameters for a certain product. Therefore, it is necessary to rewrite the hex program file according to the vehicle parameters calibration variable table and the A2L file. The traditional rewriting method rewrites variables one by one through CANape CDM, which has problems such as the relatively high cost of CANape devices and low rewriting efficiency. In terms of program compilation, since many vehicle manufacturers adopt the Autosar hierarchical development method, the application layer software is developed using Simulink, and the underlying software is developed using C language. The Simulink is converted into C language, connected with the underlying software, and then compiled using compilation tools such as HighTec to generate hex; there are problems such as low efficiency in the entire program generation process, and before the C code generated by Simulink is connected with the underlying C code, it is often necessary to perform some additional work such as adding, deleting, modifying, and querying on the C code of Simulink. Summary of the Invention

[0003] Aiming at the deficiencies of the existing technology, the purpose of the present invention is to provide a method for compiling and rewriting hex program files based on the Intel mode, so as to solve the technical problem that the efficiency of the existing compilation and rewriting methods needs to be further improved.

[0004] To solve the above technical problems, the present invention is implemented by adopting the following technical solutions:

[0005] A method for compiling and rewriting hex program files based on the Intel mode, the method includes the following steps:

[0006] Step 1, use a python script to perform addition, deletion, modification, and query operations on the ASW generated by the Simulink model.

[0007] Step 2, use a python script to complete the file transfer work of the ASW, move it to the specified folder, and complete the connection work with the BSW.

[0008] Step 3, design an MFC software interface, check the options of the hex generated by each module, call the python script through MFC to execute the bat file, and execute the bat file to call the makefile file to compile and generate the hex program files required by each module.

[0009] Step 4: According to the Excel program variable table and the A2L file, and the hex program file compiled in Step 3, complete the rewriting process of the hex program file to generate the hex program file required for the vehicle-mounted controller.

[0010] Compared with the prior art, the present invention has the following technical effects:

[0011] (Ⅰ) For the situation in the prior art described in the background art, there are problems such as low software release efficiency in the process of program compilation and hex program file rewriting. It takes about twenty minutes to compile a program and about thirty minutes to rewrite a program. In response to the above development method, the present invention has invented a fast program compilation and hex program file rewriting technology. The present invention can compile the hex program file and complete its rewriting process within ten minutes, replacing the cumbersome addition, deletion, modification, and query work of people using programming software and the program rewriting tool CANape with computer programs, shortening the program release cycle and improving software development efficiency. Multiple programs can be tested within one working day.

[0012] (Ⅱ) In terms of program compilation and generation, the present invention uses one-key hex program compilation technology to quickly compile and generate the hex to be flashed for each controller, compressing the program release cycle from twenty minutes to within three minutes.

[0013] (Ⅲ) In terms of program rewriting, the present invention uses one-key hex rewriting technology to quickly rewrite the hex to be flashed for each controller, compressing the time spent in the program rewriting process from thirty minutes to within five minutes.

[0014] (Ⅳ) The technology used in the present invention can significantly shorten the time spent in the program release process and improve the release efficiency of the test program. And the technology included in this patent is easy to promote and deploy to other embedded projects using Autosar hierarchical development.

[0015] (Ⅴ) Python files, MFC files, bat files, and makefile files are used in the present invention. According to the mutual call relationship between the files, the computer can quickly generate the hex program during the execution of the program, liberating engineers from cumbersome addition, deletion, modification, query, file transfer, etc. And the probability of the computer making mistakes in processing such work is 0 compared with people. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is the process of compiling and generating the hex program file.

[0017] Figure 2 It is the hex program file.

[0018] Figure 3 It is the hex Record program file structure.

[0019] Figure 4 It is a method for dividing hex Block Items.

[0020] Figure 5 It is a parsing process for hex Block Items.

[0021] Figure 6 It is a process for rewriting hex values.

[0022] Figure 7 It is a schematic diagram of a two-dimensional lookup table structure.

[0023] Figure 8 It is a schematic diagram of the hex rewriting process.

[0024] Figure 9 It is a one-key hex program software release process.

[0025] The following further elaborates on the specific content of the present invention in conjunction with embodiments. Specific Embodiments

[0026] It should be noted that all models, software, files, and program files in the present invention, unless otherwise specified, all adopt the models, software, files, and program files known in the prior art. The A2L file adopts the A2L file known in the art. The hex program file adopts the hex program file known in the art.

[0027] The following provides specific embodiments of the present invention. It should be noted that the present invention is not limited to the following specific embodiments, and all equivalent transformations made on the basis of the technical solution of this application fall within the protection scope of the present invention.

[0028] Embodiment:

[0029] This embodiment provides a method for compiling and rewriting hex program files based on the Intel mode. As Figure 1 shown, this method includes the following steps:

[0030] Step 1, as Figure 1 shown, use a python script to quickly add, delete, modify, and query the ASW (Application Software) generated by the simulink model, and complete the generation process of the hex program file.

[0031] Step 2, as Figure 1 shown, use a python script to complete the file transfer work of the ASW, move it to the specified folder, and complete the connection work with the BSW (Basic Software) to prepare for subsequent compilation by hightec.

[0032] Step 3, as Figure 1 shown, for the case of multiple controllers, design the MFC (Microsoft Foundation Classes) software interface, check the options of the hex files generated by each module, and call the python script through MFC to execute the bat file. Executing the bat file calls the makefile to compile and generate the hex program files required for each module.

[0033] Specifically in this embodiment, the hex program files are as Figure 2 shown. The hex program files are arranged in the form of lines, and each line is regarded as a Record; 19 lines of Records of the program are shown in the figure.

[0034] Specifically in this embodiment, the structure of the hex Record program file is as Figure 3 shown. The symbols and data contained in each line of Record are defined as a field according to different functions or meanings. It includes Record Identifier, Record Length, Record Load Address, Record Type, Record Info or Data, and Record Checksum, a total of 6 fields.

[0035] Record Identifier, each Record starts with ":".

[0036] Record Length, here the length indicates how many bytes the fifth field of the Record consists of.

[0037] Record Load Address, here the address is the offset address, indicating the specific position in the MCU PROM where the content contained in this line of Record is located.

[0038] The type of Record, indicating that the content in the fifth field is a base address or data. When it is 0x00, it means the fifth field is data; when it is 0x02, it means this Record Type can be used for both 16-bit and 32-bit format MCUs, but is mainly used in 16-bit ones to represent the high 8 bits of a 16-bit address, and the low 8 bits are 0x00. The actual address is calculated by combining the offset address of the next Record with the base address of this line; when it is 0x03, it means it can be used for both 16-bit and 32-bit format MCUs, but is mainly used in 16-bit ones, representing the starting execution address of the content of this hex file. This type is specifically for MCUs of the 8086 and 80186 types, and the 4-byte data in the DATA byte represents the values in the CS and IP registers; when it is 0x05, this type is for 32-bit MCUs, representing the starting execution address of the content of the hex file.

[0039] Record checksum. The checksum calculation starts from the second field to the end of the fifth field, adding byte by byte without carry. By checking the checksum value, it can be known whether the current Record information has been modified.

[0040] Specifically in this embodiment, the method for dividing the Hex Block is as follows Figure 4 As shown, the first line of the hex file starts with 0x04 and the last line ends with 0x01. In the middle lines of the file, Record Type 0x04 is interspersed, which respectively records different linear addresses. When a new 0x04 Record Type is encountered, calculate the new segment base address, and at the same time record the absolute address of the previous line of Reocrd. Calculate the absolute address of the next line of Reord Type according to the offset address corresponding to the next line of Record Type 0x00. Compare whether the addresses are continuous. If the addresses are continuous, it is the same Block Item, otherwise it is a new Block Item.

[0041] In step three, on the basis of Figure 4 Furthermore, during the compilation process, as Figure 5 shown, the parsing process of the hex Block Item is as follows: The first occurrence of Record Type 0x04 is recorded as the first Block, and then record the starting address and ending address of each line of Record; when a new Record Type 0x04 appears, compare whether the addresses of the Record in this line and the adjacent upper and lower lines of Record are continuous. If they are not continuous, record it as a new Block; thus, this is the complete parsing process of the hex Block.

[0042] Step 4: Based on the Excel program variable table and the A2L file, and the hex program file generated by compilation in Step 3, complete the rewriting process of the hex program file to generate the hex program file required by the vehicle-mounted controller.

[0043] In Step 4, the process of completing the rewriting of the hex program file includes rewriting the hex value, rewriting the hex axis, rewriting the hex array, rewriting the hex one-dimensional lookup table, and rewriting the hex two-dimensional lookup table.

[0044] As Figure 6 shown, the process of rewriting the hex value is as follows:

[0045] Step 40101: Obtain the absolute address of the quantity to be rewritten from the A2L file.

[0046] Step 40102: Obtain the rewritten value of the quantity to be rewritten from the Excel program variable table.

[0047] In Step 40103, the parsing process of the hex Block Item in Step 1 has recorded the starting absolute address and the ending absolute address of each row of Record.

[0048] Step 40104: Determine the row number where the Record to be rewritten is located according to the address of the quantity to be rewritten being greater than or equal to the starting address of the Record and less than or equal to the absolute address of the Record.

[0049] In Step 40105, due to the Intel little-endian mode, the Record data field stores the high byte at the high address and the low byte at the low address. Calculate the position of the Record data field corresponding to the quantity to be rewritten in this row.

[0050] Step 40106: Convert the value to be rewritten into hexadecimal and complete the rewriting at the corresponding data field position of the corresponding Record.

[0051] Step 40107: Recalculate the checksum of this row of Record according to the addition of nonary and complete the rewriting of the checksum.

[0052] Step 40108: Generate the rewritten hex program file.

[0053] In this embodiment, the two-dimensional lookup table structure is as Figure 7 shown.

[0054] In this embodiment, the methods of rewriting the hex axis, rewriting the hex array, rewriting the hex one-dimensional lookup table, and rewriting the hex two-dimensional lookup table are the same, all as Figure 8As shown, it can be completed according to the steps of addressing, determining the rewritten data field, calculating the rewritten content, and calculating the checksum, so as to achieve one-key rewriting of hex.

[0055] In this embodiment, the process of rewriting the hex two-dimensional lookup table is as follows:

[0056] Step 40201: Obtain the absolute address of the quantity to be rewritten corresponding to the rewriting position (xi, yj) from the A2L file.

[0057] Step 40202: Obtain the rewritten value of the quantity to be rewritten corresponding to the rewriting position (xi, yj) from the Excel program variable table.

[0058] Step 40203: Convert the rewritten value to a hexadecimal number.

[0059] Step 40204: Address and locate the Record to be rewritten.

[0060] Step 40205: Calculate the offset by subtracting the starting address of the Record in this row from the absolute address corresponding to the rewriting position (xi, yj).

[0061] Step 40206: If the offset is n, start rewriting from the nth byte of the data field.

[0062] Specifically in this embodiment, taking the float type as an example, the float type occupies four bytes. After locating the data field by the difference value, rewrite the four bytes starting from the data rewriting position.

[0063] Step 40207: Due to the Intel little-endian mode, in the data field from left to right, it represents low address to high address.

[0064] Step 40208: Fill the high byte of the hexadecimal number into the high address and the low byte into the low address.

[0065] Step 40209: Complete the rewriting of the data field, recalculate the checksum, and complete the rewriting of the checksum.

[0066] Step 40210: Generate the rewritten hex program file.

[0067] Furthermore, in this embodiment, the one-key hex program software release process is as Figure 9As shown in the figure, the entire process is automatically completed by a computer, which is fast and efficient. Before using this technical solution, hex compilation was completed by manual and cumbersome repetition of adding, deleting, modifying, and checking the program. The cycle of compiling and generating a hex was relatively long, and errors occasionally occurred after long-term manual processing. Handing this process entirely to the computer can significantly shorten the cycle, and the error probability is 0. Since the compiled hex cannot be directly used and requires manual operation of the CANape CDM software to rewrite it according to the Excel table, there is also the problem of low rewriting efficiency. This process can also be handed over to the computer to provide an Excel variable rewriting table, and the rewritten hex can be generated with one key from the compiled hex and A2L file, which can be quickly used for the test vehicle test.

[0068] In summary, after using this technology in the entire hex compilation and rewriting stage, all such work is converted to computer processing, which is simple, efficient, and saves working hours and labor costs. This technical solution is easy to promote, and this strategy can be used in many ways of hierarchical development at the bottom layer and application layer to shorten the program release cycle.

Claims

1. A method for compiling and rewriting a hex program file based on Intel mode, the method comprising the following steps: Step 1: Use Python scripts to add, delete, modify, and check the ASW generated by the Simulink model; Step 2: Use the python script to complete the file transfer of ASW, move it to the specified folder, and complete the connection with BSW; Features: Step 3: Design the MFC software interface, check the option of generating hex for each module, call the python script through MFC to execute the bat file, and execute the bat file to call the makefile file to compile and generate the hex program files required for each module; Step 4: According to the Excel program variable table and the A2L file, the hex program file generated by step 3 is compiled to complete the rewriting process of the hex program file and generate the hex program file required by the vehicle controller.

2. The method for compiling and rewriting a hex program file based on Intel mode as claimed in claim 1, characterized in that: In step 3, during the compilation process, the parsing process of the hex Block Item is as follows: the first occurrence of Record Type 0x04 is recorded as the first Block, and then the start address and end address of each row of Record are recorded; when a new Record Type 0x04 appears, compare the addresses of the two adjacent rows of Record above and below the row of Record to see if they are continuous. If not, record it as a new Block.

3. The method for compiling and rewriting a hex program file based on Intel mode as claimed in claim 1, characterized in that: In step 4, the rewriting process of the hex program file is completed, including rewriting the hex value, rewriting the hex axis, rewriting the hex array, rewriting the hex one-dimensional lookup table, and rewriting the hex two-dimensional lookup table.

4. The method for compiling and rewriting a hex program file based on Intel mode as claimed in claim 3, characterized in that: In step 4, the process of rewriting the hex value is: Step 40101, obtain the absolute address of the amount to be rewritten from the A2L file; Step 40102, obtaining the rewriting value of the amount to be rewritten from the Excel program variable table; Step 40103, the parsing process of the hex Block Item in step 1 has recorded the start absolute address and the end absolute address of each row of Record; Step 40104, according to the address of the amount to be rewritten being greater than or equal to the starting address of the Record and less than or equal to the absolute address of the Record, determine the row number of the rewritten Record; Step 40105, due to Intel little-endian mode, the Record data field adopts the mode of storing high addresses in high bytes and storing low addresses in low bytes, and calculates the position of the Record data field of the row corresponding to the amount to be rewritten; Step 40106, convert the value to be rewritten into hexadecimal and rewrite it in the corresponding data field of the corresponding Record; Step 40107, recalculate the checksum of the row of Records based on baseless addition, and complete the checksum rewrite; Step 40108, generate the rewritten hex program file.

5. The method for compiling and rewriting a hex program file based on Intel mode as claimed in claim 3, characterized in that: In step 4, the methods of rewriting the hex axis, rewriting the hex array, rewriting the hex one-dimensional lookup table, and rewriting the hex two-dimensional lookup table are the same.

6. The method for compiling and rewriting a hex program file based on Intel mode as claimed in claim 5, characterized in that: In step 4, the rewriting process of the hex two-dimensional lookup table is: Step 40201, obtain the absolute address of the rewrite position (xi, yj) corresponding to the amount to be rewritten from the A2L file; Step 40202, obtaining the rewrite value of the rewrite position (xi, yj) corresponding to the amount to be rewritten from the Excel program variable table; Step 40203, rewrite the value to convert it into a hexadecimal number; Step 40204, addressing and locating the Record to be rewritten; Step 40205, calculate the offset by subtracting the start address of the row Record from the absolute address corresponding to the rewrite position (xi, yj); Step 40206, if the offset is n, rewrite from the nth byte of the data field; Step 40207, due to Intel little-endian mode, the data field is from left to right, representing low address to high address; Step 40208, the high byte of the hexadecimal number is filled into the high address, and the low byte is filled into the low address; Step 40209, complete the data field rewriting, recalculate the checksum, and complete the checksum rewriting; Step 40210, generate the rewritten hex program file.