HEX file generation method and device, electronic equipment and storage medium
Through the method of automatically extracting and generating HEX files, the problem of inefficient segmentation of HEX files is solved, and the efficiency and accuracy of software flashing is improved. It is suitable for frequently updated vehicle systems.
Patent Information
- Application Number
- CN202411917702.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-24
AI Technical Summary
In the prior art, the inefficiency of manually segmenting HEX files is caused by complex software flashing and error-prone, affecting the normal operation of the vehicle.
By obtaining the complete HEX file and target memory section of the ECU to be upgraded, the target data set is automatically extracted and the target HEX file is generated to achieve automatic segmentation of the complete HEX file.
It improves the efficiency of HEX file generation, reduces manual operations, ensures the accuracy and efficiency of software flashing, and is suitable for frequently updated vehicle systems.
Smart Images

Figure CN119829094A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software upgrade, and in particular to a HEX file generation method, device, electronic device and storage medium. Background Art
[0002] As automotive electronic systems become increasingly complex and intelligent, the number and complexity of electronic control units (ECUs) are also increasing. Each control unit runs a specific software program to manage the various functions of the vehicle. And as functional requirements increase, the frequency of vehicle software updates is increasing. At present, most vehicles have adopted Over-the-Air (OTA) technology to update the vehicle system, and the vehicle system needs to be regularly upgraded for firmware and security updates.
[0003] During the process of flashing the vehicle software, HEX files are used as carriers of software codes to transfer programs and data to the ECU. Before flashing the software, developers need to extract the code in the specific memory segment that the ECU needs to flash from the complete HEX file corresponding to the ECU. This method of manually specifying the address range and splitting the file is complex and inefficient. It is also prone to errors, especially when frequent updates are required, which may cause the software flashing to fail and affect the normal operation of the vehicle. Summary of the invention
[0004] The embodiments of the present application provide a HEX file generation method, device, electronic device and storage medium to solve the problem of low efficiency in manually splitting HEX files in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a HEX file, the method comprising:
[0006] Obtain a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded;
[0007] Extracting a target data set corresponding to the target memory segment from the complete HEX file;
[0008] A target HEX file for flashing the software of the ECU to be upgraded is generated according to the target data set.
[0009] In a second aspect, an embodiment of the present application further provides a HEX file generating device, the device comprising:
[0010] An acquisition module is used to acquire a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded;
[0011] An extraction module, used for extracting a target data set corresponding to the target memory segment from the complete HEX file;
[0012] A generating module is used to generate a target HEX file for flashing the software of the ECU to be upgraded according to the target data set.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned HEX file generation method when executed by the processor.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned HEX file generation method is implemented.
[0015] The embodiments of the present application include at least the following technical effects:
[0016] The technical solution of the embodiment of the present application, by obtaining the complete HEX file corresponding to the ECU to be upgraded and the target memory segment corresponding to the function to be upgraded in the ECU to be upgraded, can extract the target data set corresponding to the target memory segment from the complete HEX file, and generate a target HEX file for software flashing of the ECU to be upgraded based on the target data set. The present application can flexibly generate different HEX files according to the different flashing requirements of the ECU, realizes the automatic segmentation of the complete HEX file, reduces manual operations, improves the generation efficiency of the HEX file, and thereby improves the software flashing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0018] Figure 1 This is one of the flow charts of the HEX file generation method provided in the embodiment of the present application;
[0019] Figure 2 This is the second flow chart of the HEX file generation method provided in the embodiment of the present application;
[0020] Figure 3 It is a structural schematic diagram of a HEX file generating device provided in an embodiment of the present application;
[0021] Figure 4 A block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0023] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0024] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0025] In the prior art, before software flashing, developers need to extract the code in the specific memory segment that the ECU needs to flash from the complete HEX (Intel Hexadecimal Object File Format, a file format created by Intel Corporation) file corresponding to the ECU (Electronic Control Unit). This method of manually specifying the address range and splitting the file is complicated and inefficient, especially when frequent updates are required. It is also prone to errors, which may cause software flashing failure and affect the normal operation of the vehicle.
[0026] To solve this problem, the embodiments of the present application provide a HEX file generation method, device, electronic device and storage medium, which can flexibly generate different HEX files according to the different flashing requirements of the ECU, realize automatic segmentation of complete HEX files, reduce manual operations, improve the generation efficiency of HEX files, and thereby improve the software flashing efficiency.
[0027] like Figure 1 As shown, the embodiment of the present application provides a HEX file generation method, the method comprising:
[0028] Step 101: Obtain a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded.
[0029] Specifically, first, the ECU to be upgraded and the function to be upgraded in the ECU to be upgraded are determined, where the function to be upgraded is at least one function included in the ECU to be upgraded.
[0030] Then, obtain the complete HEX file corresponding to the ECU to be upgraded. The complete HEX file is usually provided by the automobile manufacturer or software supplier, which contains the program code and data information of all functional modules of the ECU to be upgraded, presented in hexadecimal text format, covering the entire software system from basic hardware drivers to complex application logic codes. For example, in the complete HEX file of the automobile engine control ECU, there will be code for engine sensor data collection and processing, fuel injection control algorithm code, ignition timing control code and other content.
[0031] At the same time, it is also necessary to determine the target memory segment corresponding to the function to be upgraded. Specifically, the ECU includes multiple functions, and different functions correspond to different memory segments, that is, the code for implementing each function has a specific storage location in the memory of the ECU. Optionally, these storage locations are planned during the design and development process of the ECU. For example, in the transmission control ECU of a car, if you want to upgrade the shift control function, you need to clearly define the memory segment that stores the shift control code.
[0032] Step 102: extract a target data set corresponding to the target memory segment from the complete HEX file.
[0033] Since the complete HEX file contains a large amount of information, when performing software flashing on a certain function or several functions of the ECU, only the required part can be extracted from it, that is, the target data set corresponding to the target memory segment can be extracted from the complete HEX file.
[0034] Step 103: Generate a target HEX file for flashing the software of the ECU to be upgraded according to the target data set.
[0035] Specifically, the target HEX file contains data related to the function to be upgraded, which is more streamlined than the complete HEX file. It can realize the separate upgrade of specific functional modules in the ECU. Due to the continuous development and updating of automotive electronic systems, the upgrade requirements of different functional modules may not be synchronized. Some functions may need to be upgraded frequently, while some functions are relatively stable. In this way, the target HEX file can be independently generated for upgrade according to the needs of different functional modules, without the need for unified and large-scale upgrade operations on the entire ECU, which improves the flexibility and pertinence of ECU software upgrades.
[0036] In addition, during the generation process, the data will be reorganized according to the standard format of the HEX file so that the generated target HEX file can be correctly recognized and used by the flashing tool.
[0037] In this embodiment, by obtaining the complete HEX file corresponding to the ECU to be upgraded and the target memory segment corresponding to the function to be upgraded in the ECU to be upgraded, the target data set corresponding to the target memory segment can be extracted from the complete HEX file, and based on the target data set, a target HEX file for software flashing of the ECU to be upgraded is generated. This application can flexibly generate different HEX files according to the different flashing requirements of the ECU, realizes automatic segmentation of the complete HEX file, reduces manual operations, improves the generation efficiency of the HEX file, and thereby improves the software flashing efficiency.
[0038] In an optional embodiment of the present application, obtaining a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded includes:
[0039] Obtaining HEX file generation request information corresponding to the ECU to be upgraded; wherein the HEX file generation request information carries a storage path of a complete HEX file corresponding to the ECU to be upgraded and an identifier corresponding to a function to be upgraded in the ECU to be upgraded;
[0040] According to the storage path, obtain the complete HEX file;
[0041] Acquire a mapping relationship between a function identifier of the ECU to be upgraded and a memory segment;
[0042] According to the mapping relationship and the identifier corresponding to the function to be upgraded, a target memory segment corresponding to the function to be upgraded is obtained.
[0043] In the specific implementation process, it is necessary to first obtain the HEX file generation request information corresponding to the electronic control unit to be upgraded. The HEX file generation request information carries the storage path of the complete HEX file corresponding to the ECU to be upgraded and the identifier of the function to be upgraded in the ECU to be upgraded. Specifically, the storage path can be a server path. In the ECU, different functions correspond to different identifiers. For example, in an automotive electronic system, if a certain function of the engine control ECU is to be upgraded, then this HEX file generation request information will include the specific storage path of the complete HEX file of the engine control ECU and the identifier of the specific function to be upgraded.
[0044] By obtaining the HEX file generation request information, clear guidance can be provided for subsequent operations, allowing the system to accurately find the required complete HEX file and determine the specific functions to be upgraded, thereby preparing for targeted software flashing.
[0045] After obtaining the HEX file generation request information, you can search and read the file on the corresponding storage medium (such as server hard disk, local storage device, etc.) according to the storage path to obtain the complete HEX file corresponding to the ECU to be upgraded. For example, if the storage path points to a folder on an internal server, the system will connect to the server through the network and use the corresponding file reading protocol to obtain the complete HEX file. This complete HEX file contains all the program code and data information of the ECU to be upgraded, presented in hexadecimal text format, and is the basis for the subsequent extraction of the target data set for software flashing.
[0046] At the same time, the mapping relationship between the function identification of the ECU to be upgraded and the memory segment is obtained. The mapping relationship can be determined during the design and development process of the ECU, and the specific storage location of each function module in the ECU memory is recorded in detail.
[0047] Then, according to the obtained mapping relationship and the identifier corresponding to the function to be upgraded, the target memory segment corresponding to the function to be upgraded can be obtained. This target memory segment is the basis for extracting the target data set from the complete HEX file later.
[0048] The above implementation scheme of the present application can accurately obtain the required complete HEX file and target memory segment by obtaining HEX file request information, thereby improving the efficiency of the entire software upgrade process. The target memory segment is determined based on the mapping relationship between the function identifier and the memory segment, ensuring the pertinence and accuracy of the software upgrade.
[0049] In an optional embodiment of the present application, extracting a target data set corresponding to the target memory segment from the complete HEX file includes:
[0050] Determine the address information corresponding to each line of data included in the complete HEX file;
[0051] Determine whether the address information corresponding to each row of data belongs to the target memory segment;
[0052] Each row of data whose address information belongs to the target memory segment in the complete HEX file is determined as the target data set.
[0053] Specifically, the target memory segment corresponds to a starting address and an ending address, which defines the storage area of the data of the function to be upgraded in the ECU memory. First, it is necessary to parse the complete HEX file line by line according to the format specification of the HEX file to obtain the address information corresponding to each line of data. At the same time, it is necessary to judge line by line to determine whether the address information corresponding to the line of data belongs to the target memory segment, that is, compare the address value parsed from each line of data with the starting address and ending address of the target memory segment. If the address value of a line of data is greater than or equal to the starting address of the target memory segment, and less than or equal to the ending address of the target memory segment, then it can be considered that the address information corresponding to the line of data belongs to the target memory segment.
[0054] Finally, the rows of data in the complete HEX file whose address information belongs to the target memory segment are determined as the target data set. The target data set is used to generate the target HEX file and is the data source for software flashing. It only contains data content in the target memory segment that has a substantial impact on the upgrade function.
[0055] It should be noted that when it is determined that the address information of a row of data belongs to the target memory segment, the address information of the row needs to be reconverted into an address offset and combined with the RECTYP (Record Type) field information, data field information, and Checksum field information of the row to generate complete data for the row.
[0056] The above implementation scheme of the present application can achieve the accuracy of extracting the target data set from the complete HEX file by judging and filtering according to the address information, avoiding the mixing of irrelevant data. Compared with directly flashing the complete HEX file, the target data set only contains the necessary data related to the function to be upgraded, and the amount of data is relatively small. During the software flashing process, the smaller the amount of data processed, the shorter the time required for flashing, thereby improving the efficiency of the upgrade and reducing the waiting time during vehicle offline or maintenance.
[0057] In an optional embodiment of the present application, before extracting the target data set corresponding to the target memory segment from the complete HEX file, the method further includes:
[0058] Create cache area and HEX entity;
[0059] Loading the complete HEX file into the cache area;
[0060] Determine the address information corresponding to each line of data included in the complete HEX file, including:
[0061] Reading each line of data included in the complete HEX file from the cache area in sequence, and determining address information corresponding to each line of data;
[0062] Determining each row of data whose address information in the complete HEX file belongs to the target memory segment as the target data set includes:
[0063] Storing the data whose address information belongs to the target memory segment in the HEX entity;
[0064] The data stored in the HEX entity is extracted to obtain the target data set.
[0065] Specifically, before extracting the target data set from the complete HEX file, you must first create a cache area, which is a temporary storage space in the computer's memory for temporarily storing the contents of the complete HEX file. At the same time, you also need to create a HEX entity. The HEX entity is an area that can be distinguished from the cache area and is used to store data related to the target memory segment after screening and processing, that is, the target data set.
[0066] Load the complete HEX file into the created cache area to ensure that there is a temporary copy of the complete HEX file in the memory so that data can be quickly obtained from the cache area for processing later.
[0067] Read each line of data in the complete HEX file from the cache area in turn, and determine the address information corresponding to each line of data. Since the complete HEX file has been loaded into the cache area, each line of data can be quickly obtained directly from the cache area without having to read it from the external storage device again. When reading each line of data, parse it according to the format specification of the HEX file, where each line of the HEX file usually contains information such as record type, data length, address offset, etc. By interpreting this information and applying related algorithms, the address offset and other content are converted into actual memory address values, thereby determining the address information corresponding to each line of data, so as to subsequently determine whether the line of data belongs to the target memory segment.
[0068] After determining the address information corresponding to each row of data, the address information of which rows of data belongs to the target memory segment is compared with the starting address and the ending address of the target memory segment. Then, these qualified data rows are stored row by row into the previously created HEX entity, so that the HEX entity gradually accumulates all the data contents related to the target memory segment.
[0069] The HEX entity stores all the filtered data related to the target memory segment. Through specific extraction operations, the data in the HEX entity is completely extracted to obtain the target data set that is ultimately used for subsequent software flashing and other operations.
[0070] The above implementation scheme of the present application greatly improves the efficiency of data reading and processing by creating a cache area and loading a complete HEX file into it. Reading data from the cache area is much faster than reading directly from an external storage device, which enables faster determination of the address information corresponding to each row of data and subsequent various data screening and processing operations. Creating a HEX entity and storing data related to the target memory segment therein facilitates data management and operation. The target data set can be directly extracted from the HEX entity for flashing without the need for complex screening and extraction operations from the complete HEX file again, which simplifies the software flashing process and improves the convenience of operation.
[0071] In an optional embodiment of the present application, determining the address information corresponding to each row of data includes:
[0072] Obtaining a start address corresponding to the data segment to which each row of data belongs and an address offset corresponding to each row of data;
[0073] For each row of data, the start address and the address offset are integrated to obtain address information corresponding to each row of data.
[0074] For each line of data in a complete HEX file, you first need to get the start address of the data segment to which it belongs. In the organizational structure of a HEX file, data is usually divided into different data segments, each of which has a specific function or is associated with a specific module. These data segments have their own clear starting position in the memory, that is, the start address.
[0075] At the same time, the address offset corresponding to each row of data must also be obtained. The address offset is a parameter in the HEX file format used to indicate the offset of the row of data relative to the start address of the data segment to which it belongs.
[0076] For each row of data, the acquired start address and address offset are integrated to obtain the address information corresponding to the row of data. The specific integration method is to add the start address and the address offset. For example, if the start address of the data segment to which a row of data belongs is 0x1000, and the address offset corresponding to the row of data is 0x020, then by adding these two values, the 0x1020 obtained is the address information corresponding to the row of data, that is, the actual location of the row of data in the entire memory space.
[0077] The above implementation scheme of the present application can accurately determine the location of each row of data in the memory by obtaining the starting address of the data segment to which each row of data belongs and integrating it with its corresponding address offset, that is, obtaining accurate address information. Only by accurately knowing the location of each row of data can we accurately determine whether it belongs to the target memory segment, thereby avoiding misselection or omission of data, ensuring the accuracy of data processing, so as to filter out the data located in the memory segment corresponding to the function, and ensuring the pertinence and correctness of the upgrade operation.
[0078] In an optional embodiment of the present application, obtaining the start address corresponding to the data segment to which each row of data belongs includes:
[0079] Parsing each row of data in turn to obtain a data type, wherein the data type includes a storage type, a start type, and an end type, wherein the start type is used to indicate a start row of a data segment, the end type is used to indicate an end row of a data segment, and the storage type is used to indicate an intermediate row of a data segment;
[0080] When the parsed data is of the start type, the segment address carried in the data is obtained, and is determined as the start address corresponding to the current data segment;
[0081] When the parsed data is of the end type, the start address corresponding to the current data segment is initialized;
[0082] When the data type obtained by parsing is data of a storage type, the start address corresponding to the current data segment is determined as the start address corresponding to the data segment to which the data belongs.
[0083] In order to obtain the starting address of the data segment to which each line of data belongs, you first need to parse each line of data in the complete HEX file in turn. HEX files have specific format specifications, and each line of data contains a series of information. By interpreting it according to this format specification, you can get the data type of the line of data. For example, the data type is located in the 8th byte of the data, so by parsing the data of the 8th byte, you can get the data type corresponding to the line of data.
[0084] Specifically, the data type includes storage type (0x03), start type (0x01) and end type (0x02). The start type is used to indicate the start line of the data segment, which marks the start position of a new data segment in the HEX file; the end type is used to indicate the end line of the data segment, which marks the end of a data segment; the storage type is used to indicate the middle line of the data segment, that is, the line data between the start line and the end line of the data segment, which mainly stores the actual data content and other related information.
[0085] When the parsed data type is the start type, it marks the beginning of a new data segment. At this time, it is necessary to obtain the segment address carried by this line of data. This segment address is the starting address of the data segment to be started in the memory.
[0086] The segment address obtained from the start type data is determined as the start address corresponding to the current data segment. Once this start address is determined, the specific locations of other rows of data belonging to this data segment in the memory can be further determined based on this start address.
[0087] When the data type obtained by parsing is the end type of data, it indicates that the data segment currently being processed has ended. At this time, it is necessary to initialize the start address corresponding to the current data segment. The purpose of initialization is to prepare for processing the next possible data segment and reset the start address to an initial state so that when encountering the next start type of data row, the start address of the new data segment can be accurately obtained and determined again.
[0088] When the data type obtained by parsing is storage type data, it indicates that this row of data is in the middle of the data segment and is responsible for storing the actual data content. For these storage type data rows, the start address corresponding to the current data segment is determined as the start address corresponding to the data segment to which the data belongs. Since the start address of the current data segment has been determined when the start type data was parsed before, the storage type data row belongs to this data segment with a determined start address. In addition, the storage type data includes address offset, RECTYP field information, data field information, and Checksum field information.
[0089] The above implementation scheme of the present application can accurately locate the starting position of each data segment in the HEX file and the data segment to which each line of data belongs and its specific position in the memory by parsing each line of data and determining the starting address according to different data types. This facilitates the subsequent extraction of data related to the target memory segment from the complete HEX file. It is possible to accurately know whether each line of data belongs to the target memory segment, thereby avoiding problems such as erroneous extraction or missed extraction due to inaccurate judgment of data segments and data positions, thereby ensuring the accuracy of data processing.
[0090] In an optional embodiment of the present application, the HEX file generation request information also carries a target address path. After generating a target HEX file for software flashing the ECU to be upgraded according to the target data set, the method further includes:
[0091] The target HEX file is stored in the target address path.
[0092] Specifically, the HEX file generation request information also carries a target address path, which explicitly specifies the location where the target HEX file generated for software flashing of the ECU to be upgraded is to be stored later.
[0093] After generating a target HEX file for flashing the software of the ECU to be upgraded, the target HEX file is stored in the target address path.
[0094] The above implementation scheme of the present application can realize efficient management and organization of software flashing related files by storing the target HEX file to the target address path. The target HEX files corresponding to different vehicles, different ECUs and different upgrade functions can be classified and stored according to the pre-set path, so that when these files need to be found, used or maintained in the future, the required files can be located very conveniently, thereby improving work efficiency and reducing the time spent on finding files.
[0095] The overall implementation process of the embodiment of the present application is introduced below. Figure 2 As shown, including:
[0096] Step 201 : Obtain HEX file generation request information, which carries the storage path of the complete HEX file corresponding to the ECU to be upgraded, the identifier corresponding to the function to be upgraded in the ECU to be upgraded, and the target address path.
[0097] Step 202: Obtain a target memory segment corresponding to the function to be upgraded according to the mapping relationship between the function identifier of the ECU to be upgraded and the memory segment and the identifier corresponding to the function to be upgraded.
[0098] Step 203: Based on the storage path, check whether the complete HEX file exists. If yes, execute step 205; otherwise, execute step 204.
[0099] Step 204: output error prompt information.
[0100] Step 205: Obtain the complete HEX file and load it into the cache area.
[0101] Step 206: read the Nth line of data of the complete HEX file from the cache area, parse it, and obtain the data type, where N is an integer greater than or equal to 1.
[0102] Step 207: When the data type is the end type, initialize the start address of the data segment.
[0103] Step 208: When the data type is a storage type, extract the address offset.
[0104] Step 209: When the data type is a start type, extract the start address of the data segment.
[0105] Step 210: Integrate the start address and the address offset to obtain address information corresponding to the Nth row of data.
[0106] Step 211, determine whether the address information belongs to the target memory segment. If yes, execute step 212, otherwise execute step 213.
[0107] Step 212: Store the Nth row of data into the HEX entity.
[0108] Step 213: Determine whether the Nth line is the last line of the complete HEX file. If yes, execute step 215; otherwise, execute step 214.
[0109] Step 214, N+1.
[0110] Step 215: extract the data stored in the HEX entity to obtain the target data set.
[0111] Step 216: Generate a target HEX file for flashing the software of the ECU to be upgraded according to the target data set, and store it in the target address path.
[0112] The above implementation scheme reduces the tedious steps of manual segmentation and greatly reduces the error rate by automatically identifying the memory address range of the ECU. It improves the efficiency of vehicle software flashing, which is especially suitable for large-scale vehicle system updates, saving time and labor costs. Through a strict verification mechanism, the generated HEX file data is ensured to be complete and accurate to avoid software flashing failures. It supports a variety of vehicle system configurations and can flexibly generate HEX files according to the needs of the ECU to adapt to the application scenarios of various vehicle systems. This algorithm is not only suitable for the vehicle manufacturer's factory flashing system, but also for later OTA (Over-the-Air) updates, which improves the convenience of vehicle system maintenance.
[0113] The above introduces the HEX file generation method provided in the embodiment of the present application. The following will introduce the HEX file generation device provided in the embodiment of the present application in conjunction with the accompanying drawings.
[0114] like Figure 3 As shown, an embodiment of the present invention further provides a HEX file generating device, the device comprising:
[0115] An acquisition module 301 is used to acquire a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded;
[0116] An extraction module 302 is used to extract a target data set corresponding to the target memory segment from the complete HEX file;
[0117] The generating module 303 is used to generate a target HEX file for flashing the software of the ECU to be upgraded according to the target data set.
[0118] Optionally, the acquisition module includes:
[0119] A first acquisition submodule is used to acquire HEX file generation request information corresponding to the ECU to be upgraded; wherein the HEX file generation request information carries a storage path of a complete HEX file corresponding to the ECU to be upgraded and an identifier corresponding to a function to be upgraded in the ECU to be upgraded;
[0120] A second acquisition submodule is used to acquire the complete HEX file according to the storage path;
[0121] A third acquisition submodule is used to acquire a mapping relationship between the function identifier of the ECU to be upgraded and the memory segment;
[0122] The fourth acquisition submodule is used to obtain the target memory segment corresponding to the function to be upgraded according to the mapping relationship and the identifier corresponding to the function to be upgraded.
[0123] Optionally, the extraction module includes:
[0124] A first determination submodule is used to determine the address information corresponding to each line of data included in the complete HEX file;
[0125] A judging submodule, used for judging whether the address information corresponding to each row of data belongs to the target memory segment;
[0126] The second determination submodule is used to determine each row of data whose address information in the complete HEX file belongs to the target memory segment as the target data set.
[0127] Optionally, before extracting the target data set corresponding to the target memory segment from the complete HEX file, the device further includes:
[0128] Create a module to create a cache area and HEX entity;
[0129] A loading module, used for loading the complete HEX file into the cache area;
[0130] The first determination submodule is further used for:
[0131] Reading each line of data included in the complete HEX file from the cache area in sequence, and determining address information corresponding to each line of data;
[0132] The second determination submodule includes:
[0133] A storage unit, used for storing the data whose address information belongs to the target memory segment into the HEX entity;
[0134] The extraction unit is used to extract the data stored in the HEX entity to obtain the target data set.
[0135] Optionally, the first determining submodule includes:
[0136] An acquisition unit, used for acquiring a start address corresponding to a data segment to which each row of data belongs and an address offset corresponding to each row of data;
[0137] The address integration unit is used to integrate the start address and the address offset for each row of data to obtain address information corresponding to each row of data.
[0138] Optionally, the acquisition unit includes:
[0139] A parsing subunit, used to parse each row of data in turn to obtain a data type, wherein the data type includes a storage type, a start type, and an end type, wherein the start type is used to indicate a start row of a data segment, the end type is used to indicate an end row of a data segment, and the storage type is used to indicate an intermediate row of a data segment;
[0140] A first determining subunit is used to obtain a segment address carried in the data when parsing the data whose data type is a start type, and determine it as a start address corresponding to the current data segment;
[0141] An initialization subunit, used for initializing a start address corresponding to the current data segment when the data type obtained by parsing is the end type of data;
[0142] The second determining subunit is used to determine the starting address corresponding to the current data segment as the starting address corresponding to the data segment to which the data belongs when parsing to obtain data of a storage type.
[0143] Optionally, the HEX file generation request information also carries a target address path. After generating a target HEX file for software flashing the ECU to be upgraded according to the target data set, the device further includes:
[0144] A storage module is used to store the target HEX file to the target address path.
[0145] The HEX file generating device provided by the present application obtains the complete HEX file corresponding to the ECU to be upgraded and the target memory segment corresponding to the function to be upgraded in the ECU to be upgraded, so as to extract the target data set corresponding to the target memory segment from the complete HEX file, and generate the target HEX file for software flashing of the ECU to be upgraded according to the target data set. The present application can flexibly generate different HEX files according to the different flashing requirements of the ECU, realizes the automatic segmentation of the complete HEX file, reduces manual operations, improves the generation efficiency of the HEX file, and thus improves the software flashing efficiency.
[0146] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0147] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned HEX file generation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0148] For example, Figure 4 FIG. 1 shows a schematic diagram of the physical structure of an electronic device. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call the logic instructions in the memory 430, and the processor 410 is used to perform the following steps: obtain the complete HEX file corresponding to the ECU to be upgraded and the target memory segment corresponding to the function to be upgraded in the ECU to be upgraded; extract the target data set corresponding to the target memory segment from the complete HEX file; and generate a target HEX file for software flashing the ECU to be upgraded according to the target data set. The processor 410 can also execute other schemes in the embodiments of the present application, which will not be further elaborated here.
[0149] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0150] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned HEX file generation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0151] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0152] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0153] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0154] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0156] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0157] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0159] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0160] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A HEX file generation method, characterized in that: The method comprises: Obtain a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded; Extracting a target data set corresponding to the target memory segment from the complete HEX file; A target HEX file for flashing the software of the ECU to be upgraded is generated according to the target data set.
2. The HEX file generation method according to claim 1, characterized in that: Obtain the complete HEX file corresponding to the ECU to be upgraded and the target memory segment corresponding to the function to be upgraded in the ECU to be upgraded, including: Obtaining HEX file generation request information corresponding to the ECU to be upgraded; wherein the HEX file generation request information carries a storage path of a complete HEX file corresponding to the ECU to be upgraded and an identifier corresponding to a function to be upgraded in the ECU to be upgraded; According to the storage path, obtain the complete HEX file; Acquire a mapping relationship between a function identifier of the ECU to be upgraded and a memory segment; According to the mapping relationship and the identifier corresponding to the function to be upgraded, a target memory segment corresponding to the function to be upgraded is obtained.
3. The HEX file generation method according to claim 1, characterized in that: Extracting a target data set corresponding to the target memory segment from the complete HEX file includes: Determine the address information corresponding to each line of data included in the complete HEX file; Determine whether the address information corresponding to each row of data belongs to the target memory segment; Each row of data whose address information belongs to the target memory segment in the complete HEX file is determined as the target data set.
4. The HEX file generation method according to claim 1, characterized in that: Before extracting the target data set corresponding to the target memory segment from the complete HEX file, the method further includes: Create cache area and HEX entity; Loading the complete HEX file into the cache area; Determine the address information corresponding to each line of data included in the complete HEX file, including: Reading each line of data included in the complete HEX file from the cache area in sequence, and determining address information corresponding to each line of data; Determining each row of data whose address information in the complete HEX file belongs to the target memory segment as the target data set includes: Storing the data whose address information belongs to the target memory segment in the HEX entity; The data stored in the HEX entity is extracted to obtain the target data set.
5. The HEX file generation method according to claim 3, characterized in that: Determining the address information corresponding to each row of data includes: Obtaining a start address corresponding to the data segment to which each row of data belongs and an address offset corresponding to each row of data; For each row of data, the start address and the address offset are integrated to obtain address information corresponding to each row of data.
6. The HEX file generation method according to claim 5, characterized in that: Obtaining the start address corresponding to the data segment to which each row of data belongs, including: Parsing each row of data in turn to obtain a data type, wherein the data type includes a storage type, a start type, and an end type, wherein the start type is used to indicate a start row of a data segment, the end type is used to indicate an end row of a data segment, and the storage type is used to indicate an intermediate row of a data segment; When the parsed data is of the start type, the segment address carried in the data is obtained, and is determined as the start address corresponding to the current data segment; When the parsed data is of the end type, the start address corresponding to the current data segment is initialized; When the data type obtained by parsing is data of a storage type, the start address corresponding to the current data segment is determined as the start address corresponding to the data segment to which the data belongs.
7. The HEX file generation method according to claim 2, characterized in that: The HEX file generation request information also carries a target address path. After generating a target HEX file for flashing the software of the ECU to be upgraded according to the target data set, the method further includes: The target HEX file is stored in the target address path.
8. A HEX file generating device, characterized in that: include: An acquisition module is used to acquire a complete HEX file corresponding to the ECU to be upgraded and a target memory segment corresponding to the function to be upgraded in the ECU to be upgraded; An extraction module, used for extracting a target data set corresponding to the target memory segment from the complete HEX file; A generating module is used to generate a target HEX file for flashing the software of the ECU to be upgraded according to the target data set.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method for generating a HEX file according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the HEX file generation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Information safety equipment and its file memory and access method
CN101196922A
Update data conversion method for vehicle updating
CN104572153A
Vehicle built-in software update method and system
CN108491224A
Electronic control system scrapping method and apparatus and computer medium
CN109324813A
Method and apparatus for updating software, and intelligent device
WO2024087234A1