Hex file generation method and apparatus, electronic device, and storage medium
By obtaining the complete HEX file of the ECU and the target memory segment, the target dataset is automatically extracted to generate a HEX file, which solves the problem of complex and inefficient HEX file segmentation in the existing technology and improves the efficiency and accuracy of software flashing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, the splitting of HEX files is complex, inefficient, and prone to errors, leading to vehicle software flashing failures and affecting normal operation.
By obtaining the complete HEX file and target memory segment of the ECU to be upgraded, the target dataset is automatically extracted and a target HEX file for software flashing is generated, reducing manual operations and improving generation efficiency.
It enables automatic segmentation of HEX files, improves software flashing efficiency, ensures the accuracy and flexibility of upgrades, and is suitable for flexible upgrade needs of different ECUs.
Smart Images

Figure CN119829094B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software upgrade technology, and in particular to a method, apparatus, electronic device and storage medium for generating HEX files. Background Technology
[0002] As automotive electronic systems become increasingly complex and intelligent, the number and complexity of Electronic Control Units (ECUs) are also constantly increasing. Each ECU runs specific software programs to manage various vehicle functions. Furthermore, with increasing functional requirements, the frequency of onboard software updates is rising. Currently, most vehicles employ Over-the-Air (OTA) technology for onboard system updates, requiring regular firmware and security upgrades.
[0003] During the vehicle software flashing process, the HEX file serves as the carrier of software code, used to transfer programs and data to the ECU. Before flashing the software, developers need to extract the code from 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, especially when frequent updates are required. It is also prone to errors, which may lead to software flashing failure and affect the normal operation of the vehicle. Summary of the Invention
[0004] This application provides a method, apparatus, electronic device, and storage medium for generating HEX files, in order to solve the problem of low efficiency in manually splitting HEX files in the prior art.
[0005] In a first aspect, embodiments of this application provide a method for generating HEX files, the method comprising:
[0006] 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;
[0007] Extract the target dataset corresponding to the target memory segment from the complete HEX file;
[0008] Based on the target dataset, a target HEX file is generated for software flashing of the ECU to be upgraded.
[0009] Secondly, embodiments of this application also provide a HEX file generation apparatus, the apparatus comprising:
[0010] The acquisition module is used to acquire 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;
[0011] The extraction module is used to extract the target dataset corresponding to the target memory segment from the complete HEX file;
[0012] The generation module is used to generate a target HEX file for software flashing of the ECU to be upgraded, based on the target dataset.
[0013] Thirdly, embodiments of this application also provide an electronic device, which includes 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, it implements the HEX file generation method described above.
[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described HEX file generation method.
[0015] The embodiments of this application include at least the following technical effects:
[0016] The technical solution of this application embodiment 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. Thus, the target dataset corresponding to the target memory segment can be extracted from the complete HEX file, and a target HEX file for software flashing of the ECU to be upgraded can be generated based on the target dataset. This application can flexibly generate different HEX files according to different flashing requirements of the ECU, realize automatic segmentation of the complete HEX file, reduce manual operation, improve the generation efficiency of HEX file, and thus improve the software flashing efficiency. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0018] Figure 1 This is one of the flowcharts illustrating the HEX file generation method provided in the embodiments of this application;
[0019] Figure 2 This is a second schematic flowchart of the HEX file generation method provided in the embodiments of this application;
[0020] Figure 3 This is a schematic diagram of the structure of the HEX file generation device provided in the embodiments of this application;
[0021] Figure 4 A block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0023] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0024] In the various embodiments of this application, it should be understood that the sequence number of each process described below does not imply 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 this application.
[0025] In existing technologies, 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) file corresponding to the ECU (Electronic Control Unit). This method of manually specifying the address range and splitting the file is complex and inefficient. Especially when frequent updates are required, it is also prone to errors, which may lead to software flashing failure and affect the normal operation of the vehicle.
[0026] To address this issue, embodiments of this application provide a HEX file generation method, apparatus, electronic device, and storage medium. These can flexibly generate different HEX files according to the different flashing requirements of the ECU, achieving automatic segmentation of the complete HEX file, reducing manual operations, improving HEX file generation efficiency, and thus improving software flashing efficiency.
[0027] like Figure 1 As shown in the figure, this application provides a method for generating HEX files, the method including:
[0028] Step 101: 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.
[0029] Specifically, first, identify the ECU to be upgraded and the function to be upgraded within the ECU. The function to be upgraded here refers to at least one function included in the ECU to be upgraded.
[0030] Next, obtain the complete HEX file corresponding to the ECU to be upgraded. This complete HEX file is usually provided by the car manufacturer or software supplier and 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 code. For example, the complete HEX file of a car engine control ECU will contain code for engine sensor data acquisition and processing, fuel injection control algorithm code, ignition timing control code, and many other aspects.
[0031] Simultaneously, it is necessary to determine the target memory segment corresponding to the function to be upgraded. Specifically, an ECU includes multiple functions, each corresponding to a different memory segment. That is, the code implementing each function has a specific storage location in the ECU's memory. Optionally, these storage locations are planned during the ECU's design and development process. For example, in a car's transmission control ECU, if the shift control function needs to be upgraded, then the memory segment storing the shift control code needs to be clearly defined.
[0032] Step 102: Extract the target dataset corresponding to the target memory segment from the complete HEX file.
[0033] Because a complete HEX file contains a large amount of information, when flashing the software for one or more functions of an ECU, only the necessary parts can be extracted from it, that is, the target dataset corresponding to the target memory segment can be extracted from the complete HEX file.
[0034] Step 103: Based on the target dataset, generate a target HEX file for software flashing of the ECU to be upgraded.
[0035] Specifically, the target HEX file contains data related to the function to be upgraded, making it more concise than a full HEX file. It enables individual upgrades of specific functional modules within the ECU. As automotive electronic systems continuously evolve and update, the upgrade requirements for different functional modules may differ. Some functions may require frequent upgrades, while others are relatively stable. This approach allows for the independent generation of target HEX files for upgrades tailored to the needs of different functional modules, eliminating the need for a unified, large-scale upgrade of the entire ECU, thus improving the flexibility and specificity of ECU software upgrades.
[0036] In addition, during the generation process, the data will be reorganized according to the standard format of HEX files 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 dataset corresponding to the target memory segment can be extracted from the complete HEX file. Based on the target dataset, 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 different flashing requirements of the ECU, realize automatic segmentation of the complete HEX file, reduce manual operation, improve the generation efficiency of HEX files, and thus improve the software flashing efficiency.
[0038] In an optional embodiment of this application, 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 includes:
[0039] Obtain the HEX file generation request information corresponding to the ECU to be upgraded; wherein, 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 corresponding to the function to be upgraded in the ECU to be upgraded;
[0040] Based on the storage path, obtain the complete HEX file;
[0041] Obtain the mapping relationship between the function identifier of the ECU to be upgraded and the memory segment;
[0042] Based on the mapping relationship and the identifier corresponding to the function to be upgraded, the target memory segment corresponding to the function to be upgraded is obtained.
[0043] In the specific implementation process, the first step is to obtain the HEX file generation request information corresponding to the electronic control unit (ECU) to be upgraded. This HEX file generation request information carries the storage path of the complete HEX file for the ECU to be upgraded, as well as the identifier of the function to be upgraded within the ECU. Specifically, this storage path can be a server path, and different functions within the ECU correspond to different identifiers. For example, in an automotive electronic system, if a certain function of the engine control ECU needs 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 HEX file generation request information, clear guidance can be provided for subsequent operations, enabling the system to accurately locate the required complete HEX file and determine the specific functions to be upgraded, thereby preparing for targeted software flashing.
[0045] After receiving the HEX file generation request information, the system can locate and read the file from the corresponding storage medium (such as a server hard drive or local storage device) based on 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 that server via the network and use the appropriate 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 serves as the basis for subsequent extraction of the target dataset for software flashing.
[0046] Simultaneously, the mapping relationship between the function identifiers of the ECU to be upgraded and memory segments is obtained. This mapping relationship can be determined during the design and development process of the ECU, and details the specific storage location of each functional module in the ECU's memory.
[0047] Then, based on the obtained mapping relationship and the identifier corresponding to the feature to be upgraded, the target memory segment corresponding to the feature to be upgraded can be obtained. This target memory segment is the basis for subsequently extracting the target dataset from the complete HEX file.
[0048] The above-described implementation scheme of this application, by obtaining HEX file request information, can accurately obtain the required complete HEX file and target memory segment, improving the efficiency of the entire software upgrade process. Determining the target memory segment based on the mapping relationship between function identifiers and memory segments ensures the targeted and accurate nature of the software upgrade.
[0049] In an optional embodiment of this application, extracting the target dataset 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] The rows of data in the complete HEX file whose address information belongs to the target memory segment are identified as the target dataset.
[0053] Specifically, the target memory segment corresponds to a start address and an end address, defining the storage area in the ECU memory for the data of the function to be upgraded. First, the complete HEX file needs to be parsed line by line according to the HEX file format specifications to obtain the address information corresponding to each line of data. Simultaneously, each line is evaluated to determine whether the address information corresponding to that line of data belongs to the target memory segment; that is, the address value parsed from each line of data is compared with the start and end addresses of the target memory segment. If the address value of a line of data is greater than or equal to the start address of the target memory segment and less than or equal to the end address of the target memory segment, then the address information corresponding to that line of data can be considered to belong 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 identified as the target dataset. This target dataset is used to generate the target HEX file and is the data source for software flashing. It only contains data content within the target memory segment that has a substantial impact on the upgrade functionality.
[0055] It should be noted that when it is determined that the address information of a certain row of data belongs to the target memory segment, the address information of that row needs to be converted back into an address offset, and then combined with the RECTYP (Record Type) field information, data field information, and Checksum field information of this row to generate the complete data of this row.
[0056] The above-described implementation scheme of this application, by judging and filtering according to address information, can achieve the accuracy of extracting the target dataset from the complete HEX file and avoid the mixing of irrelevant data. Compared with directly flashing the complete HEX file, the target dataset only contains the necessary data related to the function to be upgraded, and the data volume is relatively small. During the software flashing process, the smaller the amount of data processed, the shorter the flashing time required, thereby improving the upgrade efficiency and reducing the waiting time during vehicle decommissioning or maintenance.
[0057] In an optional embodiment of this application, before extracting the target dataset corresponding to the target memory segment from the complete HEX file, the method further includes:
[0058] Create a cache region and a HEX entity;
[0059] Load the complete HEX file into the cache area;
[0060] Determining the address information corresponding to each line of data included in the complete HEX file includes:
[0061] Read each line of data in the complete HEX file sequentially from the cache area and determine the address information corresponding to each line of data;
[0062] The target dataset is defined as the rows of data in the complete HEX file whose address information belongs to the target memory segment, including:
[0063] The address information belonging to the target memory segment is stored in the HEX entity;
[0064] Extract the data stored in the HEX entity to obtain the target dataset.
[0065] Specifically, before extracting the target dataset from the complete HEX file, a cache region must first be created. This cache region is a temporary storage space allocated in the computer's memory to temporarily store the contents of the complete HEX file. Simultaneously, a HEX entity needs to be created. The HEX entity is a region distinct from the cache region, used to store the filtered and processed data related to the target memory segment—that is, the target dataset.
[0066] The complete HEX file is loaded into the created cache area to ensure that there is a temporary copy of the complete HEX file in memory so that data can be quickly retrieved from the cache area for processing later.
[0067] The process reads each line of data from the complete HEX file sequentially from the cache area and determines the address information corresponding to each line. Since the complete HEX file is already loaded into the cache area, each line of data can be quickly retrieved directly from the cache area without needing to read it from external storage devices again. When reading each line of data, it is parsed according to the HEX file format specification. Each record in a HEX file typically contains information such as record type, data length, and address offset. By interpreting this information and applying relevant algorithms, the address offset and other information 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 system compares it with the start and end addresses of the target memory segment to identify which rows of data belong to the target memory segment. Then, these matching rows are stored row by row into the previously created HEX entity, allowing the HEX entity to gradually accumulate all data related to the target memory segment.
[0069] The HEX entity stores all filtered data related to the target memory segment. By performing specific extraction operations, the data in the HEX entity can be completely extracted to obtain the final target dataset used for subsequent software flashing and other operations.
[0070] The above-described implementation scheme in this application significantly improves the efficiency of data reading and processing by creating a cache area and loading the complete HEX file into it. Reading data from the cache area is much faster than reading directly from external storage devices, enabling faster determination of the address information corresponding to each row of data and subsequent data filtering and processing operations. Creating a HEX entity and storing data related to the target memory segment within it facilitates data management and operation. The target dataset can be directly extracted from the HEX entity for flashing without needing to perform complex filtering and extraction operations from the complete HEX file again, simplifying the software flashing process and improving operational convenience.
[0071] In an optional embodiment of this application, determining the address information corresponding to each row of data includes:
[0072] Obtain the starting address of the data segment to which each row of data belongs and the address offset of each row of data;
[0073] For each row of data, the starting address and the address offset are integrated to obtain the address information corresponding to each row of data.
[0074] For each line of data in a complete HEX file, the first step is to obtain the starting address of its corresponding data segment. In the organization of a HEX file, data is typically divided into different data segments, each with its specific function or associated with a specific module. These data segments each have their own clearly defined starting location in memory, which is their starting address.
[0075] At the same time, it is also necessary to obtain the address offset corresponding to each line of data. The address offset is a parameter in the HEX file format used to represent the offset of that line of data relative to the start address of its corresponding data segment.
[0076] For each row of data, the obtained start address and address offset are combined to obtain the address information corresponding to that row of data. Specifically, the start address and address offset are added together. For example, if the start address of a data segment to which a row of data belongs is 0x1000, and the address offset of that row of data is 0x020, then by adding these two values, the resulting 0x1020 is the address information corresponding to that row of data, which is the actual location of that row of data in the entire memory space.
[0077] The above-described implementation scheme of this application, by obtaining the start address of the data segment to which each row of data belongs and integrating it with its corresponding address offset, can accurately determine the location of each row of data in memory, thus obtaining accurate address information. Only by accurately knowing the location of each row of data can it be accurately determined whether it belongs to the target memory segment, thereby avoiding misselection or omission of data, ensuring the accuracy of data processing, and filtering out data located in the memory segment corresponding to the function, ensuring the targeting and correctness of the upgrade operation.
[0078] In an optional embodiment of this application, obtaining the start address of the data segment to which each row of data belongs includes:
[0079] Each row of data is parsed sequentially to obtain a data type, which includes a storage type, a start type, and an end type. The start type indicates the beginning row of the data segment, the end type indicates the end row of the data segment, and the storage type indicates the middle row of the data segment.
[0080] When parsing data of type "start", the segment address carried in the data is obtained and determined as the start address corresponding to the current data segment;
[0081] When parsing data of type "end", the start address corresponding to the current data segment is initialized;
[0082] When parsing data of type storage, the starting address of the current data segment is determined as the starting address of the data segment to which the data belongs.
[0083] To obtain the starting address of the data segment to which each line of data belongs, we first need to parse each line of data in the complete HEX file sequentially. HEX files have specific format specifications, and each line of data contains a series of information. By interpreting it according to these format specifications, we can obtain the data type of that line of data. For example, if the data type is located in the 8th byte of the data, then by parsing the 8th byte, we can obtain the data type corresponding to that line of data.
[0084] Specifically, data types include storage type (0x03), start type (0x01), and end type (0x02). The start type indicates the first line of a data segment, marking the beginning of a new data segment in the HEX file; the end type indicates the last line of a data segment, signifying the end of the segment; and the storage type indicates the middle lines of a data segment, namely the lines between the start and end lines, which primarily store the actual data content and related information.
[0085] When the parsed data is of type `start`, it marks the beginning of a new data segment. At this point, it's necessary to retrieve the segment address carried by this data. This segment address is the starting address of the data segment to be started in memory.
[0086] The segment address obtained from the initial data type is used to determine the starting address of the current data segment. Once this starting address is determined, the specific memory location of other rows of data belonging to this segment can be further determined based on this starting address.
[0087] When the parsed data type is "End of Terminate", it indicates that the currently processed data segment has ended. At this point, it's 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 by resetting the start address to an initial state, so that when encountering the next data line with the "Start of Terminate" type, the start address of the new data segment can be accurately obtained and determined again.
[0088] When the parsed data type is storage type, it indicates that this data row is located in the middle of a data segment and serves to store the actual data content. For these storage type data rows, the start address of the current data segment is determined as the start address of the data segment to which this data belongs. Since the start address of the current data segment was already determined when the start type data was parsed previously, and the storage type data row belongs to this data segment with a determined start address, the storage type data includes address offset, RECTYP field information, data field information, and Checksum field information.
[0089] The above-described implementation scheme of this application, by parsing each line of data and determining the starting address according to different data types, can accurately locate the starting position of each data segment in the HEX file, as well as the data segment to which each line of data belongs and its specific location in memory. This facilitates the subsequent extraction of data related to the target memory segment from the complete HEX file, ensuring that each line of data accurately belongs to the target memory segment. This avoids problems such as incorrect extraction or omission due to inaccurate judgment of data segments and data locations, thus ensuring the accuracy of data processing.
[0090] In an optional embodiment of this application, the HEX file generation request information further carries a target address path. After generating a target HEX file for software flashing the ECU to be upgraded based on the target dataset, the method further includes:
[0091] Store the target HEX file at the target address path.
[0092] Specifically, the HEX file generation request information also includes the target address path. This target address path explicitly specifies the location where the generated target HEX file, used for software flashing the ECU to be upgraded, will be stored.
[0093] After generating the target HEX file for software flashing of the ECU to be upgraded, store this target HEX file in the target address path.
[0094] The above-described implementation scheme of this application enables efficient management and organization of software flashing-related files by storing the target HEX file in the target address path. Target HEX files corresponding to different vehicles, different ECUs, and different upgrade functions can be categorized and stored according to pre-defined paths. This allows for convenient location of the required file when it is needed for subsequent searching, use, or maintenance, thereby improving work efficiency and reducing the time spent searching for files.
[0095] The overall implementation process of the embodiments of this application is described below, such as... Figure 2 As shown, it includes:
[0096] Step 201: Obtain HEX file generation request information. This HEX file generation request information carries the storage path of the complete HEX file corresponding to the ECU to be upgraded, the identifier of the function to be upgraded in the ECU to be upgraded, and the target address path.
[0097] Step 202: Based on 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, obtain the target memory segment corresponding to the function to be upgraded.
[0098] Step 203: Based on the storage path, check if the complete HEX file exists. If yes, proceed to step 205; otherwise, proceed to step 204.
[0099] Step 204: Output error message.
[0100] Step 205: Obtain the complete HEX file and load it into the cache area.
[0101] Step 206: Read the Nth line of data from the cache area of the complete HEX file and parse it to obtain the data type, where N is an integer greater than or equal to 1.
[0102] Step 207: When the data type is an end type, initialize the start address of the data segment.
[0103] Step 208: When the data type is storage type, extract the address offset.
[0104] Step 209: When the data type is start type, extract the start address of the data segment.
[0105] Step 210: Integrate the starting address and address offset to obtain the 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, proceed to step 212; otherwise, proceed to step 213.
[0107] Step 212: Store the Nth row of data into the HEX entity.
[0108] Step 213: Determine if line N is the last line of the complete HEX file. If yes, proceed to step 215; otherwise, proceed to step 214.
[0109] Step 214, N+1.
[0110] Step 215: Extract the data stored in the HEX entity to obtain the target dataset.
[0111] Step 216: Based on the target dataset, generate the target HEX file for software flashing of the ECU to be upgraded, and store it in the target address path.
[0112] The above implementation scheme, by automatically identifying the ECU's memory address range, reduces the tedious steps of manual segmentation and significantly lowers the error rate. It improves the efficiency of vehicle software flashing, especially suitable for large-scale vehicle system updates, saving time and labor costs. A rigorous verification mechanism ensures the integrity and accuracy of the generated HEX file data, preventing software flashing failures. It supports multiple vehicle system configurations and can flexibly generate HEX files according to the ECU's needs, adapting to various vehicle system application scenarios. This algorithm is not only applicable to vehicle manufacturers' in-plant flashing systems but also to subsequent OTA (Over-the-Air) updates, improving the convenience of vehicle system maintenance.
[0113] The above describes the HEX file generation method provided by the embodiments of this application. The HEX file generation apparatus provided by the embodiments of this application will be described below with reference to the accompanying drawings.
[0114] like Figure 3 As shown, this embodiment of the invention also provides a HEX file generation apparatus, the apparatus comprising:
[0115] The acquisition module 301 is used to acquire 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.
[0116] Extraction module 302 is used to extract the target dataset corresponding to the target memory segment from the complete HEX file;
[0117] The generation module 303 is used to generate a target HEX file for software flashing of the ECU to be upgraded, based on the target dataset.
[0118] Optionally, the acquisition module includes:
[0119] The first acquisition submodule is used to acquire the HEX file generation request information corresponding to the ECU to be upgraded; wherein, 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 corresponding to the function to be upgraded in the ECU to be upgraded.
[0120] The second acquisition submodule is used to acquire the complete HEX file according to the storage path;
[0121] The third acquisition submodule is used to acquire the 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 based on the mapping relationship and the identifier corresponding to the function to be upgraded.
[0123] Optionally, the extraction module includes:
[0124] The first determining submodule is used to determine the address information corresponding to each line of data included in the complete HEX file;
[0125] The judgment submodule is used to determine whether the address information corresponding to each row of data belongs to the target memory segment;
[0126] The second determining submodule is used to determine the rows of data in the complete HEX file whose address information belongs to the target memory segment as the target dataset.
[0127] Optionally, before extracting the target dataset corresponding to the target memory segment from the complete HEX file, the apparatus further includes:
[0128] Create a module for creating cache regions and HEX entities;
[0129] A loading module is used to load the complete HEX file into the cache area;
[0130] The first determining submodule is further used for:
[0131] Read each line of data in the complete HEX file sequentially from the cache area and determine the address information corresponding to each line of data;
[0132] The second determination submodule includes:
[0133] A storage unit is used to store the address information belonging 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 dataset.
[0135] Optionally, the first determined submodule includes:
[0136] The acquisition unit is used to acquire the start address of the data segment to which each row of data belongs and the address offset of 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 the address information corresponding to each row of data.
[0138] Optionally, the acquisition unit includes:
[0139] The parsing subunit is used to parse each row of data sequentially to obtain the data type, which includes a storage type, a start type, and an end type. The start type is used to indicate the beginning row of the data segment, the end type is used to indicate the end row of the data segment, and the storage type is used to indicate the middle row of the data segment.
[0140] The first determining subunit is used to obtain the segment address carried in the data when parsing data of type start, and determine it as the start address corresponding to the current data segment;
[0141] An initialization subunit is used to initialize the start address corresponding to the current data segment when parsing data of type end.
[0142] The second determining subunit is used to determine the start address corresponding to the current data segment as the start address corresponding to the data segment to which the data belongs when parsing data of type storage.
[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 based on the target dataset, 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 generation device provided in this 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. It can then extract the target dataset corresponding to the target memory segment from the complete HEX file and generate a target HEX file for software flashing of the ECU based on the target dataset. This application can flexibly generate different HEX files according to different flashing requirements of the ECU, realize automatic segmentation of the complete HEX file, reduce manual operation, improve the efficiency of HEX file generation, and thus improve the efficiency of software flashing.
[0146] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0147] This 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, it implements the various processes of the above-described HEX file generation method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here.
[0148] For example, Figure 4 A schematic diagram of the physical structure of an electronic device is shown. (For example...) Figure 4 As shown, the electronic device may include a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, communications interface 420, and memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to perform the following steps: 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; extracting the target dataset corresponding to the target memory segment from the complete HEX file; and generating a target HEX file for software flashing the ECU based on the target dataset. The processor 410 can also execute other schemes in the embodiments of this application, which will not be further described here.
[0149] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0150] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described HEX file generation method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be 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 document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0152] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0153] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0154] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0155] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0156] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0157] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0158] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0159] If the aforementioned functions are implemented as 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 this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0160] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method of generating a HEX file, characterized by, The method comprises: 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; extracting a target data set corresponding to the target memory segment from the complete HEX file; generating a target HEX file for software flashing of the ECU to be upgraded according to the target data set; 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, comprising: obtaining a HEX file generation request information corresponding to the ECU to be upgraded; wherein the HEX file generation request information carries a storage path of the complete HEX file corresponding to the ECU to be upgraded and an identifier corresponding to the function to be upgraded in the ECU to be upgraded; obtaining the complete HEX file according to the storage path; obtaining a mapping relationship between the function identifier of the ECU to be upgraded and the memory segment; obtaining 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; extracting a target data set corresponding to the target memory segment from the complete HEX file, comprising: determining address information corresponding to each line of data included in the complete HEX file; respectively judging whether the address information corresponding to each line of data belongs to the target memory segment; determining each line of data in the complete HEX file whose address information belongs to the target memory segment as the target data set.
2. The method of claim 1, wherein, Before extracting a target data set corresponding to the target memory segment from the complete HEX file, the method further comprises: creating a cache area and a HEX entity; loading the complete HEX file into the cache area; determining address information corresponding to each line of data included in the complete HEX file, comprising: reading each line of data included in the complete HEX file from the cache area in sequence and determining the address information corresponding to each line of data; determining each line of data in the complete HEX file whose address information belongs to the target memory segment as the target data set, comprising: storing data whose address information belongs to the target memory segment in the HEX entity; extracting the data stored in the HEX entity to obtain the target data set.
3. The method of claim 1, wherein, determining the address information corresponding to each line of data, comprising: obtaining a start address corresponding to a data segment to which each line of data belongs and an address offset corresponding to each line of data; integrating the start address and the address offset for each line of data to obtain the address information corresponding to each line of data.
4. The method of claim 3, wherein, obtaining a start address corresponding to a data segment to which each line of data belongs, comprising: sequentially parsing each line of data to obtain a data type, the data type comprising a storage type, a start type and an end type, wherein the start type is used to indicate a start line of a data segment, the end type is used to indicate an end line of a data segment, and the storage type is used to indicate an intermediate line of a data segment; When the data of the start type is parsed, the segment address carried in the data is obtained, and a start address corresponding to the current data segment is determined; When the data of the end type is parsed, a start address corresponding to the current data segment is initialized; When the data of the storage type is parsed, a start address corresponding to the current data segment is determined as a start address corresponding to a data segment to which the data belongs.
5. The method of claim 1, wherein, The HEX file generation request information further carries a target address path, and after the target HEX file used for software flashing of the ECU to be upgraded is generated according to the target data set, the method further includes: storing the target HEX file to the target address path.
6. A HEX file generating apparatus characterized by comprising: The method comprises: an obtaining module, configured to obtain a complete HEX file corresponding to an ECU to be upgraded and a target memory segment corresponding to a function to be upgraded in the ECU to be upgraded; an extracting module, configured to extract a target data set corresponding to the target memory segment from the complete HEX file; a generating module, configured to generate a target HEX file used for software flashing of the ECU to be upgraded according to the target data set; the obtaining module comprises: a first obtaining sub-module, configured to obtain 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; a second obtaining sub-module, configured to obtain the complete HEX file according to the storage path; a third obtaining sub-module, configured to obtain a mapping relationship between a function identifier and a memory segment of the ECU to be upgraded; a fourth obtaining sub-module, configured 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; the extracting module comprises: a first determining sub-module, configured to determine address information corresponding to each line of data included in the complete HEX file; a judging sub-module, configured to judge whether the address information corresponding to each line of data belongs to the target memory segment respectively; a second determining sub-module, configured to determine each line of data in the complete HEX file, of which the address information belongs to the target memory segment, as the target data set.
7. An electronic device, comprising: The computer program is stored on the computer readable storage medium and is executed by the processor to implement the HEX file generation method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium and is executed by the processor to implement the HEX file generation method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Vehicle built-in software update method and system
CN108491224A
Electronic control system scrapping method and apparatus and computer medium
CN109324813A